Skip to content

Commit 2480f74

Browse files
committed
handle the possibility of elided fields in profile data
1 parent f3aed7a commit 2480f74

File tree

2 files changed

+48
-44
lines changed

2 files changed

+48
-44
lines changed

src/vm/moar/HLL/Backend.nqp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,11 @@ class HLL::Backend::MoarVM {
7676
}
7777

7878
sub post_process_call_graph_node($node) {
79-
for $node<allocations> -> %alloc_info {
80-
my $type := %alloc_info<type>;
81-
%alloc_info<type> := $type.HOW.name($type);
79+
if $node<allocations> {
80+
for $node<allocations> -> %alloc_info {
81+
my $type := %alloc_info<type>;
82+
%alloc_info<type> := $type.HOW.name($type);
83+
}
8284
}
8385
if $node<callees> {
8486
for $node<callees> {

src/vm/moar/profiler/template.html

Lines changed: 43 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -760,18 +760,18 @@ <h3>Global Deoptimization</h3>
760760
}
761761
});
762762
function walkCallGraphNode(node) {
763-
totalEntries += node.entries;
764-
inlineEntries += node.inlined_entries;
765-
speshEntries += node.spesh_entries;
766-
jitEntries += node.jit_entries;
767-
deoptOnes += node.deopt_one;
768-
deoptAlls += node.deopt_all;
769-
osrs += node.osr;
763+
totalEntries += node.entries || 0;
764+
inlineEntries += node.inlined_entries || 0;
765+
speshEntries += node.spesh_entries || 0;
766+
jitEntries += node.jit_entries || 0;
767+
deoptOnes += node.deopt_one || 0;
768+
deoptAlls += node.deopt_all || 0;
769+
osrs += node.osr || 0;
770770
if (node.callees)
771771
node.callees.map(walkCallGraphNode);
772772
}
773773
walkCallGraphNode(rawData[0].call_graph);
774-
774+
775775
// Time spent
776776
var overheadTime = speshTime + gcTime;
777777
var executingTime = totalTime - overheadTime;
@@ -833,11 +833,11 @@ <h3>Global Deoptimization</h3>
833833
idToOSR[node.id] = false;
834834
idRecDepth[node.id] = 0;
835835
}
836-
idToEntries[node.id] += node.entries;
837-
idToSpeshEntries[node.id] += node.spesh_entries;
838-
idToJITEntries[node.id] += node.jit_entries;
839-
idToExclusive[node.id] += node.exclusive_time;
840-
totalExclusive += node.exclusive_time;
836+
idToEntries[node.id] += node.entries || 0;
837+
idToSpeshEntries[node.id] += node.spesh_entries || 0;
838+
idToJITEntries[node.id] += node.jit_entries || 0;
839+
idToExclusive[node.id] += node.exclusive_time || 0;
840+
totalExclusive += node.exclusive_time || 0;
841841
if (node.osr > 0)
842842
idToOSR[node.id] = true;
843843
if (idRecDepth[node.id] == 0)
@@ -995,31 +995,33 @@ <h3>Global Deoptimization</h3>
995995
var typeIdToRoutineStats = {};
996996
var maxAllocations = 1;
997997
function walkCallGraphNode(node) {
998-
node.allocations.map(function (alloc) {
999-
if (!typeIdToName[alloc.id]) {
1000-
typeIdToName[alloc.id] = alloc.type == "" ? "<anon>" : alloc.type;
1001-
typeIdToAllocations[alloc.id] = 0;
1002-
typeIdToAllocationsByType[alloc.id] = [0, 0, 0];
1003-
typeIdToRoutineStats[alloc.id] = {};
1004-
}
1005-
typeIdToAllocations[alloc.id] += alloc.count;
1006-
typeIdToAllocationsByType[alloc.id][0] += alloc.count - alloc.spesh - alloc.jit;
1007-
typeIdToAllocationsByType[alloc.id][1] += alloc.spesh;
1008-
typeIdToAllocationsByType[alloc.id][2] += alloc.jit;
1009-
if (typeIdToAllocations[alloc.id] > maxAllocations)
1010-
maxAllocations = typeIdToAllocations[alloc.id];
1011-
if (typeIdToRoutineStats[alloc.id][node.id]) {
1012-
typeIdToRoutineStats[alloc.id][node.id]['count'] += alloc.count;
1013-
typeIdToRoutineStats[alloc.id][node.id]['spesh'] += alloc.spesh;
1014-
typeIdToRoutineStats[alloc.id][node.id]['jit'] += alloc.jit;
1015-
} else {
1016-
typeIdToRoutineStats[alloc.id][node.id] = {
1017-
count: alloc.count,
1018-
spesh: alloc.spesh,
1019-
jit: alloc.jit
1020-
};
1021-
}
1022-
});
998+
if (node.allocations) {
999+
node.allocations.map(function (alloc) {
1000+
if (!typeIdToName[alloc.id]) {
1001+
typeIdToName[alloc.id] = alloc.type == "" ? "<anon>" : alloc.type;
1002+
typeIdToAllocations[alloc.id] = 0;
1003+
typeIdToAllocationsByType[alloc.id] = [0, 0, 0];
1004+
typeIdToRoutineStats[alloc.id] = {};
1005+
}
1006+
typeIdToAllocations[alloc.id] += alloc.count;
1007+
typeIdToAllocationsByType[alloc.id][0] += alloc.count - (alloc.spesh || 0) - (alloc.jit || 0);
1008+
typeIdToAllocationsByType[alloc.id][1] += alloc.spesh || 0;
1009+
typeIdToAllocationsByType[alloc.id][2] += alloc.jit || 0;
1010+
if (typeIdToAllocations[alloc.id] > maxAllocations)
1011+
maxAllocations = typeIdToAllocations[alloc.id];
1012+
if (typeIdToRoutineStats[alloc.id][node.id]) {
1013+
typeIdToRoutineStats[alloc.id][node.id]['count'] += alloc.count || 0;
1014+
typeIdToRoutineStats[alloc.id][node.id]['spesh'] += alloc.spesh || 0;
1015+
typeIdToRoutineStats[alloc.id][node.id]['jit'] += alloc.jit || 0;
1016+
} else {
1017+
typeIdToRoutineStats[alloc.id][node.id] = {
1018+
count: alloc.count || 0,
1019+
spesh: alloc.spesh || 0,
1020+
jit: alloc.jit || 0
1021+
};
1022+
}
1023+
});
1024+
}
10231025
if (node.callees) {
10241026
node.callees.map(walkCallGraphNode);
10251027
}
@@ -1120,9 +1122,9 @@ <h3>Global Deoptimization</h3>
11201122
idToDeoptOne[node.id] = 0;
11211123
idToDeoptAll[node.id] = 0;
11221124
}
1123-
idToOSR[node.id] += node.osr;
1124-
idToDeoptOne[node.id] += node.deopt_one;
1125-
idToDeoptAll[node.id] += node.deopt_all;
1125+
idToOSR[node.id] += node.osr || 0;
1126+
idToDeoptOne[node.id] += node.deopt_one || 0;
1127+
idToDeoptAll[node.id] += node.deopt_all || 0;
11261128
if (idToOSR[node.id] > maxOSR)
11271129
maxOSR = idToOSR[node.id];
11281130
if (idToDeoptOne[node.id] > maxDeoptOne)

0 commit comments

Comments
 (0)