Skip to content

Commit a9301a3

Browse files
authored
[Profile] Fix CFG BB weight calculation (#17)
I might be missing something, but the first argument to reduce is the accumulator which should be a number, not an CFGInstruction. This silently failed because .weight on a number is undefined, which just got subsistuted for 0.
1 parent fa31c47 commit a9301a3

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

lnt/server/ui/static/lnt_profile.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,8 @@ function CFGBasicBlock (instructions, fallThruInstruction, cfg) {
1919
this.targets = gjt[1];
2020
this.noFallThru = gjt[0];
2121
this.weight = this.instructions
22-
.reduce(function (a,b) {
23-
var weight_a = (a.weight === undefined)?0:a.weight;
24-
var weight_b = (b.weight === undefined)?0:b.weight;
25-
return weight_a+weight_b;
22+
.reduce(function (acc,inst) {
23+
return acc + ((inst.weight === undefined)?0:inst.weight);
2624
}, 0);
2725
};
2826

0 commit comments

Comments
 (0)