Open Bug 812980 Opened 12 years ago Updated 2 years ago

IonMonkey: Prevent double type to flow into loop counters.

Categories

(Core :: JavaScript Engine, defect)

defect

Tracking

()

People

(Reporter: nbp, Unassigned)

References

(Depends on 1 open bug, Blocks 1 open bug)

Details

Attachments

(2 files, 1 obsolete file)

The following test case is a minimal test case of one case which appear in PdfJS octane benchmark which mask Bug 812446 and provide an effective ~30% win of v8 points (as of today, knowing that Bug 812446 is estimated at ~19% of the time, ~23% of v8 points).


function f () {
  var d = 0;
  var i = 0;
  var x = 0;
  while (i < 4000000) {
    if (d == (d | 0)) {
       // uncomment to see the expected perf.
       x = d // | 0;
       i += x - 1 + x - 1 + x - 1 + x - 1 + x - 1 + x - 1 + x - 1 + x;
       d = 0.5;
    } else {
       i++;
       d = 1;
    }
  }
}

f();



This test case provide the following results:

$ ./js -b --no-jm double-flow.js
runtime = 37.826 ms (Ion issue)
$ ./js -b --no-jm double-flow.js
runtime = 20.318 ms (Ion expectation)
$ ./js -b --no-ion double-flow.js
runtime = 91.329 ms (JM issue)
$ ./js -b --no-ion double-flow.js
runtime = 70.382 ms (JM expectation)

To fix this bug, one must use the pushedType of the addition which is monitored by the Type inference and the popedType of the argument and notice that the expected result is an int and that one of the expected input is also an int.  Once this observation is made, the other operand should be converted to an Int and bail otherwise, such as the addition can be specialized as an Int addition.

This modification should be easy to add to IonMonkey, inside the infer function used by MAdd / MSub.  Use a fallible MToInt32 to the unexpected Double operand.

Note: such assumption need to be relaxed in the unlikely case where it causes frequent bailout (see Bug 803710) such as when we subtract from a truncated double too big to fit on an Int32 with a Int32 which makes it fit on an Int32 value, such as

var i = 0;
var s = -1 >>> 0;
var d = s + 1;
while (i < 10000000) {
  i += (d + i) - i - s;
}
Assignee: general → nicolas.b.pierron
Status: NEW → ASSIGNED
This patch:
1/ Make Add and Sub optimistic, meaning that if the Typeset contains both Int and Double it will compile it as an Int operation.
2/ Favor the innermost type inside a loop, meaning if the variable is seen as a double out-side the loop and as an int inside the loop, the Phi would be typed as an Int.

This patch only give a 12% boost on PdfJS, and still has a 5ms slowdown (25ms) compared the truncated double of the test case reported in comment 0.

(1) is likely to cause some identical recompilation on test case which are using doubles, case which might happen in PdfJS, because running PdfJs with --no-jm show a slowdown.  I still have to investigate what is the best “heuristic” to make this optimistic change.
Attachment #690898 - Flags: feedback?(jdemooij)
The previous test case is extremely hard to improve without hacking deeply into TI to distinguish between infered doubles and seen double as we got rid of the local inference.  Bug 804676 promess to simplify this case as the local inference will move back to Ion.  The problem is the bub 804676 will land with the baseline compiler which is still months away.

In the mean time, I will reorient this issue to focus more on the problem seen in PdfJS with this new benchmark.

The current performance (without Bug 812446 patch) are:

$ ./js -b --no-jm bug812980-perf.js
runtime = 404.508 ms (mainly Bug 812446)
$ ./js -b --no-jm bug812980-perf.js
runtime = 264.852 ms (Ion with Double conversion at every loop iteration)
$ ./js -b --no-jm bug812980-perf.js
runtime = 245.264 ms (Ion expectation)

The goal/idea is to add the '| 0' precisely at the location commented by in the benchmark by propagating the type convertion backward from "str[i]".

With patch for Bug 812446, str[i] will use MCharCodeAt, which should remove a big chunk of the perf issue noticed here, but we can remove all Double->Int conversion by propagating backward the MToInt32 guard as long as we can specialize the output.
This patch improves the current reduced benchmark, even if it does not improves PdfJS yet.  This patch improves v8 benchmarks by ~ 3.6%.  This patch does not improves PdfJS yet because PdfJS case is even worse than the reduce benchmark as the "i" variable is aliased, which means that the type of "i" does not flow through a Phi, but through an aliased var.

The goal of this patch is to propagate Int32 guards (ToInt32) closer to their definitions, to all branches which can unconditionally flow into the guard with the exception of loop condition(*) which is considered to flow ""frequently"" into the loop body.

This patch push the guard type into a few operations such as Phi/Add/Sub and re-specialize Add/Sub and Compare operations based on these new observed types.
The re-specialization of Add/Sub let us optimize the case where "int x double -> int" can let us do a Int operation by guarding that the double is an Int.  The re-specialization of Compare is used to update information filled by IonBuilder to prevent the coercion of all operands to double, even if both are Int operands

(*) We propagate the guard across the loop condition even if the condition of the loop might change the flow of the returned value.  This has only one exception where the double vs. int type is observable with a “|0” comparison.
Attachment #690898 - Attachment is obsolete: true
Attachment #690898 - Flags: feedback?(jdemooij)
Attachment #692959 - Flags: review?(dvander)
Marty, I adding you as CC to this bug as you mentioned that a similar approach might help on kraken's crypto benchmarks.
So I noticed a while back that the kraken crypto benchmarks do a whole bunch of unnecessary double math.  I decided to see the exact extent of these atrocoties.  Here are a bunch of bash scripts along with their output.  The line numbers that I have for the -data files will likely be a bit off because I pretified them first.
~/bench/kraken-pretty; cat aes.log ccm.log pbkdf2.log  sha256.log | sed -n -e "/Analyzing/,/Done/p" | grep -E "MathD|Scripts|cvt"
[Scripts] Analyzing script ./tests/kraken-1.1/stanford-crypto-aes-data.js:30 (0x7f6a0a610640) (usecount=10340) (maxloopcount=81)
[Codegen] cvtsi2sd   0(%r13,%r12,3), %xmm0
[Codegen] cvttsd2si  %xmm0, %rdx
[Codegen] cvtsi2sd   %r8, %xmm0
[Codegen] cvtsi2sd   0(%r13,%rax,3), %xmm1
[Codegen] cvttsd2si  %xmm1, %rdx
[Codegen] cvttsd2si  %xmm0, %rbp
[Codegen] cvtsi2sd   0(%rbp,%rdx,3), %xmm0
[Codegen] cvttsd2si  %xmm0, %rbp
[Codegen] cvtsi2sd   %rsi, %xmm1
[Codegen] cvttsd2si  %xmm1, %rdx
[Codegen] cvtsi2sd   %rdx, %xmm15
[Codegen] cvttsd2si  %xmm2, %rdx
[Codegen] cvtsi2sd   %rdx, %xmm15
[Codegen] cvttsd2si  %xmm1, %rbp
[Codegen] cvtsi2sd   %rbp, %xmm15
[Codegen] cvttsd2si  %xmm1, %rbp
[Codegen] cvtsi2sd   %rbp, %xmm15
[Scripts] Done compiling (./tests/kraken-1.1/stanford-crypto-aes-data.js:30)
[Scripts] Analyzing script ./tests/kraken-1.1/stanford-crypto-aes-data.js:104 (0x7f6a0a610940) (usecount=10240) (maxloopcount=13)
[Codegen] cvtsi2sd   0x0(%rax), %xmm0
[Codegen] cvtsi2sd   0x0(%rdi), %xmm1
[Codegen] cvttsd2si  %xmm0, %r8
[Codegen] cvttsd2si  %xmm1, %r9
[Codegen] cvtsi2sd   0(%rax,%r9,3), %xmm0
[Codegen] cvtsi2sd   0x8(%rdi), %xmm1
[Codegen] cvttsd2si  %xmm0, %r10
[Codegen] cvttsd2si  %xmm1, %r12
[Codegen] cvtsi2sd   0x10(%rax), %xmm0
[Codegen] cvtsi2sd   0x10(%rdi), %xmm1
[Codegen] cvttsd2si  %xmm0, %r12
[Codegen] cvttsd2si  %xmm1, %r13
[Codegen] cvtsi2sd   0(%rax,%r9,3), %xmm0
[Codegen] cvtsi2sd   0x18(%rdi), %xmm1
[Codegen] cvttsd2si  %xmm0, %rax
[Codegen] cvttsd2si  %xmm1, %rdx
[Codegen] cvtsi2sd   0(%rsi,%rax,3), %xmm0
[Codegen] cvttsd2si  %xmm0, %r14
[Codegen] cvtsi2sd   0(%rsi,%rcx,3), %xmm0
[Codegen] cvttsd2si  %xmm0, %rbp
[Codegen] cvtsi2sd   0(%rsi,%rbp,3), %xmm0
[Codegen] cvttsd2si  %xmm0, %r14
[Codegen] cvtsi2sd   0(%rsi,%rcx,3), %xmm0
[Codegen] cvttsd2si  %xmm0, %r14
[Codegen] cvtsi2sd   %r9, %xmm0
[Codegen] cvttsd2si  %xmm0, %rcx
[Codegen] cvtsi2sd   0(%r8,%rax,3), %xmm0
[Codegen] cvttsd2si  %xmm0, %r14
[Codegen] cvttsd2si  %xmm2, %r8
[Codegen] cvtsi2sd   %r8, %xmm15
[Codegen] cvttsd2si  %xmm0, %r9
[Codegen] cvtsi2sd   %r9, %xmm15
[Codegen] cvttsd2si  %xmm2, %r10
[Codegen] cvtsi2sd   %r10, %xmm15
[Codegen] cvttsd2si  %xmm0, %r12
[Codegen] cvtsi2sd   %r12, %xmm15
[Codegen] cvttsd2si  %xmm2, %r12
[Codegen] cvtsi2sd   %r12, %xmm15
[Codegen] cvttsd2si  %xmm0, %r13
[Codegen] cvtsi2sd   %r13, %xmm15
[Codegen] cvttsd2si  %xmm2, %rax
[Codegen] cvtsi2sd   %rax, %xmm15
[Codegen] cvttsd2si  %xmm0, %rdx
[Codegen] cvtsi2sd   %rdx, %xmm15
[Codegen] cvttsd2si  %xmm1, %r14
[Codegen] cvtsi2sd   %r14, %xmm15
[Codegen] cvttsd2si  %xmm1, %rbp
[Codegen] cvtsi2sd   %rbp, %xmm15
[Codegen] cvttsd2si  %xmm1, %r14
[Codegen] cvtsi2sd   %r14, %xmm15
[Codegen] cvttsd2si  %xmm1, %r14
[Codegen] cvtsi2sd   %r14, %xmm15
[Codegen] cvttsd2si  %xmm1, %rcx
[Codegen] cvtsi2sd   %rcx, %xmm15
[Codegen] cvttsd2si  %xmm1, %r14
[Codegen] cvtsi2sd   %r14, %xmm15
[Scripts] Done compiling (./tests/kraken-1.1/stanford-crypto-aes-data.js:104)
[Scripts] Analyzing script ./tests/kraken-1.1/stanford-crypto-aes-data.js:172 (0x7f6a0a610e80) (usecount=10244) (maxloopcount=4)
[Codegen] cvtsi2sd   0(%r9,%rcx,3), %xmm0
[Codegen] cvttsd2si  %xmm0, %r10
[Codegen] cvtsi2sd   %rcx, %xmm0
[Codegen] cvtsi2sd   %rcx, %xmm0
[Codegen] cvttsd2si  %xmm1, %r10
[Codegen] cvtsi2sd   %r10, %xmm15
[Scripts] Done compiling (./tests/kraken-1.1/stanford-crypto-aes-data.js:172)
[Scripts] Analyzing script ./tests/kraken-1.1/stanford-crypto-aes-data.js:152 (0x7f6a0a610b80) (usecount=10241) (maxloopcount=0)
[Codegen] cvtsi2sd   0(%r8,%rdx,3), %xmm0
[Codegen] cvtsi2sd   %rax, %xmm1
[Codegen] instruction 35:MathD
[Codegen] cvtsi2sd   %rcx, %xmm0
[Scripts] Done compiling (./tests/kraken-1.1/stanford-crypto-aes-data.js:152)
[Scripts] Analyzing script ./tests/kraken-1.1/stanford-crypto-aes-data.js:169 (0x7f6a0a610dc0) (usecount=10241) (maxloopcount=0)
[Codegen] instruction 17:MathD
[Codegen] cvtsi2sd   %rdx, %xmm0
[Codegen] cvtsi2sd   %rcx, %xmm0
[Scripts] Done compiling (./tests/kraken-1.1/stanford-crypto-aes-data.js:169)
[Scripts] Analyzing script ./tests/kraken-1.1/stanford-crypto-aes-data.js:992 (0x7f6a0a6251c0) (usecount=10240) (maxloopcount=0)
[Scripts] Inlining script ./tests/kraken-1.1/stanford-crypto-aes-data.js:969 (0x7f6a0a624f40)
[Scripts] Done compiling (./tests/kraken-1.1/stanford-crypto-aes-data.js:992)
[Scripts] Analyzing script ./tests/kraken-1.1/stanford-crypto-aes-data.js:58 (0x7f6a0a6107c0) (usecount=10240) (maxloopcount=0)
[Scripts] Done compiling (./tests/kraken-1.1/stanford-crypto-aes-data.js:58)
[Scripts] Analyzing script ./tests/kraken-1.1/stanford-crypto-aes-data.js:55 (0x7f6a0a610700) (usecount=10240) (maxloopcount=0)
[Scripts] Done compiling (./tests/kraken-1.1/stanford-crypto-aes-data.js:55)
[Scripts] Analyzing script ./tests/kraken-1.1/stanford-crypto-aes.js:1 (0x7f6a0a625940) (usecount=10404) (maxloopcount=85)
[Scripts] Inlining script ./tests/kraken-1.1/stanford-crypto-aes-data.js:55 (0x7f6a0a610700)
[Scripts] Inlining script ./tests/kraken-1.1/stanford-crypto-aes-data.js:58 (0x7f6a0a6107c0)
[Scripts] Done compiling (./tests/kraken-1.1/stanford-crypto-aes.js:1)
[Scripts] Analyzing script ./tests/kraken-1.1/stanford-crypto-ccm-data.js:104 (0x7ffd6df10940) (usecount=10245) (maxloopcount=13)
[Codegen] cvttsd2si  %xmm0, %r10
[Codegen] cvttsd2si  %xmm0, %rax
[Codegen] cvtsi2sd   %r10, %xmm0
[Codegen] cvttsd2si  %xmm1, %r10
[Codegen] cvtsi2sd   %r10, %xmm15
[Codegen] cvtsi2sd   %rdx, %xmm0
[Codegen] cvttsd2si  %xmm1, %rax
[Codegen] cvtsi2sd   %rax, %xmm15
[Scripts] Done compiling (./tests/kraken-1.1/stanford-crypto-ccm-data.js:104)
[Scripts] Analyzing script ./tests/kraken-1.1/stanford-crypto-ccm-data.js:235 (0x7ffd6df1f340) (usecount=10263) (maxloopcount=33)
[Codegen] cvttsd2si  %xmm0, %rax
[Codegen] cvtsi2sd   %rcx, %xmm0
[Codegen] cvttsd2si  %xmm1, %rax
[Codegen] cvtsi2sd   %rax, %xmm15
[Scripts] Done compiling (./tests/kraken-1.1/stanford-crypto-ccm-data.js:235)
[Scripts] Analyzing script ./tests/kraken-1.1/stanford-crypto-ccm-data.js:179 (0x7ffd6df10f40) (usecount=10270) (maxloopcount=33)
[Codegen] instruction 67:MathD
[Codegen] cvttsd2si  %xmm1, %rdx
[Codegen] instruction 85:MathD
[Codegen] cvttsd2si  %xmm2, %rbx
[Codegen] cvttsd2si  %xmm3, %rdi
[Codegen] cvttsd2si  %xmm3, %rcx
[Codegen] cvttsd2si  %xmm0, %rcx
[Codegen] instruction 153:MathD
[Codegen] cvttsd2si  %xmm1, %rbx
[Codegen] cvtsi2sd   %rbp, %xmm0
[Codegen] cvtsi2sd   %rbp, %xmm0
[Codegen] cvttsd2si  %xmm2, %rdx
[Codegen] cvtsi2sd   %rdx, %xmm15
[Codegen] cvttsd2si  %xmm3, %rbx
[Codegen] cvtsi2sd   %rbx, %xmm15
[Codegen] cvtsi2sd   %r8, %xmm3
[Codegen] cvttsd2si  %xmm4, %rdi
[Codegen] cvtsi2sd   %rdi, %xmm15
[Codegen] cvtsi2sd   %rdx, %xmm0
[Codegen] cvttsd2si  %xmm1, %rcx
[Codegen] cvtsi2sd   %rcx, %xmm15
[Codegen] cvtsi2sd   %rbp, %xmm0
[Codegen] cvtsi2sd   %rcx, %xmm0
[Codegen] cvttsd2si  %xmm2, %rbx
[Codegen] cvtsi2sd   %rbx, %xmm15
[Codegen] cvtsi2sd   %rcx, %xmm0
[Scripts] Done compiling (./tests/kraken-1.1/stanford-crypto-ccm-data.js:179)
[Scripts] Analyzing script ./tests/kraken-1.1/stanford-crypto-ccm-data.js:30 (0x7ffd6df10640) (usecount=10277) (maxloopcount=81)
[Scripts] Done compiling (./tests/kraken-1.1/stanford-crypto-ccm-data.js:30)
[Scripts] Analyzing script ./tests/kraken-1.1/stanford-crypto-ccm-data.js:172 (0x7ffd6df10e80) (usecount=10240) (maxloopcount=32)
[Codegen] cvttsd2si  %xmm0, %r8
[Codegen] cvttsd2si  %xmm1, %r10
[Codegen] cvtsi2sd   %rcx, %xmm0
[Codegen] cvtsi2sd   %rcx, %xmm0
[Codegen] cvtsi2sd   %r8, %xmm0
[Codegen] cvtsi2sd   %r8, %xmm1
[Codegen] cvttsd2si  %xmm2, %r8
[Codegen] cvtsi2sd   %r8, %xmm15
[Codegen] cvttsd2si  %xmm0, %r10
[Codegen] cvtsi2sd   %r10, %xmm15
[Scripts] Done compiling (./tests/kraken-1.1/stanford-crypto-ccm-data.js:172)
[Scripts] Analyzing script ./tests/kraken-1.1/stanford-crypto-ccm-data.js:169 (0x7ffd6df10dc0) (usecount=10240) (maxloopcount=0)
[Codegen] instruction 17:MathD
[Codegen] cvtsi2sd   %rdx, %xmm0
[Codegen] cvtsi2sd   %rcx, %xmm0
[Scripts] Done compiling (./tests/kraken-1.1/stanford-crypto-ccm-data.js:169)
[Scripts] Analyzing script ./tests/kraken-1.1/stanford-crypto-ccm-data.js:55 (0x7ffd6df10700) (usecount=10240) (maxloopcount=0)
[Scripts] Done compiling (./tests/kraken-1.1/stanford-crypto-ccm-data.js:55)
[Scripts] Analyzing script ./tests/kraken-1.1/stanford-crypto-ccm-data.js:165 (0x7ffd6df10d00) (usecount=10246) (maxloopcount=0)
[Codegen] cvttsd2si  %xmm0, %rdx
[Codegen] cvttsd2si  %xmm0, %rbp
[Codegen] cvtsi2sd   %rbx, %xmm1
[Codegen] instruction 30:MathD
[Codegen] cvtsi2sd   %rdx, %xmm0
[Codegen] instruction 32:MathD
[Codegen] cvtsi2sd   %rbp, %xmm0
[Codegen] cvttsd2si  %xmm1, %rdx
[Codegen] cvtsi2sd   %rdx, %xmm15
[Codegen] cvttsd2si  %xmm1, %rbp
[Codegen] cvtsi2sd   %rbp, %xmm15
[Scripts] Done compiling (./tests/kraken-1.1/stanford-crypto-ccm-data.js:165)
[Scripts] Analyzing script ./tests/kraken-1.1/stanford-crypto-ccm-data.js:157 (0x7ffd6df10c40) (usecount=10245) (maxloopcount=0)
[Scripts] Inlining script ./tests/kraken-1.1/stanford-crypto-ccm-data.js:165 (0x7ffd6df10d00)
[Codegen] cvtsi2sd   %r8, %xmm1
[Codegen] instruction 29:MathD
[Codegen] cvttsd2si  %xmm0, %rbx
[Codegen] cvtsi2sd   %r10, %xmm0
[Codegen] cvtsi2sd   %rbx, %xmm1
[Codegen] instruction 85:MathD
[Codegen] cvtsi2sd   %r10, %xmm0
[Codegen] instruction 87:MathD
[Codegen] cvtsi2sd   %rbp, %xmm0
[Codegen] cvttsd2si  %xmm1, %rbx
[Codegen] cvtsi2sd   %rbx, %xmm15
[Scripts] Done compiling (./tests/kraken-1.1/stanford-crypto-ccm-data.js:157)
[Scripts] Analyzing script ./tests/kraken-1.1/stanford-crypto-ccm-data.js:152 (0x7ffd6df10b80) (usecount=10243) (maxloopcount=0)
[Codegen] cvtsi2sd   %rax, %xmm1
[Codegen] instruction 36:MathD
[Codegen] cvtsi2sd   %r9, %xmm0
[Codegen] cvtsi2sd   %rcx, %xmm0
[Scripts] Done compiling (./tests/kraken-1.1/stanford-crypto-ccm-data.js:152)
[Scripts] Analyzing script ./tests/kraken-1.1/stanford-crypto-ccm-data.js:418 (0x7ffd6df1fd00) (usecount=10248) (maxloopcount=20)
[Scripts] Inlining script ./tests/kraken-1.1/stanford-crypto-ccm-data.js:165 (0x7ffd6df10d00)
[Scripts] Inlining script ./tests/kraken-1.1/stanford-crypto-ccm-data.js:165 (0x7ffd6df10d00)
[Scripts] Inlining script ./tests/kraken-1.1/stanford-crypto-ccm-data.js:165 (0x7ffd6df10d00)
[Scripts] Inlining script ./tests/kraken-1.1/stanford-crypto-ccm-data.js:197 (0x7ffd6df1f040)
[Scripts] Inlining script ./tests/kraken-1.1/stanford-crypto-ccm-data.js:55 (0x7ffd6df10700)
[Scripts] Inlining script ./tests/kraken-1.1/stanford-crypto-ccm-data.js:197 (0x7ffd6df1f040)
[Scripts] Inlining script ./tests/kraken-1.1/stanford-crypto-ccm-data.js:55 (0x7ffd6df10700)
[Codegen] cvtsi2sd   %rcx, %xmm1
[Codegen] cvtsi2sd   %rdx, %xmm1
[Codegen] instruction 161:MathD
[Codegen] cvttsd2si  %xmm2, %rbx
[Codegen] cvtsi2sd   %rbp, %xmm1
[Codegen] cvtsi2sd   %rbp, %xmm2
[Codegen] instruction 179:MathD
[Codegen] instruction 206:MathD
[Codegen] cvttsd2si  %xmm2, %rdx
[Codegen] cvttsd2si  %xmm0, %rbx
[Codegen] instruction 236:MathD
[Codegen] cvttsd2si  %xmm0, %rdx
[Codegen] cvtsi2sd   %rdx, %xmm2
[Codegen] instruction 258:MathD
[Codegen] cvtsi2sd   %rcx, %xmm2
[Codegen] instruction 289:MathD
[Codegen] cvttsd2si  %xmm0, %rbp
[Codegen] cvttsd2si  %xmm0, %rbp
[Codegen] cvttsd2si  %xmm0, %rbp
[Codegen] cvttsd2si  %xmm0, %rbx
[Codegen] cvttsd2si  %xmm0, %rbp
[Codegen] cvttsd2si  %xmm0, %rbp
[Codegen] cvttsd2si  %xmm0, %rbp
[Codegen] cvttsd2si  %xmm0, %rbp
[Codegen] cvttsd2si  %xmm0, %rbx
[Codegen] cvttsd2si  %xmm0, %rbp
[Codegen] cvtsi2sd   %r14, %xmm0
[Codegen] cvttsd2si  %xmm1, %rbx
[Codegen] cvtsi2sd   %rbx, %xmm15
[Codegen] cvtsi2sd   %rcx, %xmm0
[Codegen] cvttsd2si  %xmm2, %rbx
[Codegen] cvtsi2sd   %rbx, %xmm15
[Codegen] cvtsi2sd   %rcx, %xmm0
[Codegen] cvttsd2si  %xmm1, %rdx
[Codegen] cvtsi2sd   %rdx, %xmm15
[Codegen] cvtsi2sd   %rsi, %xmm0
[Codegen] cvttsd2si  %xmm1, %rbp
[Codegen] cvtsi2sd   %rbp, %xmm15
[Codegen] cvtsi2sd   %rbp, %xmm0
[Codegen] cvttsd2si  %xmm1, %rbx
[Codegen] cvtsi2sd   %rbx, %xmm15
[Codegen] cvtsi2sd   %rsi, %xmm0
[Codegen] cvttsd2si  %xmm1, %rbp
[Codegen] cvtsi2sd   %rbp, %xmm15
[Codegen] cvtsi2sd   %rbp, %xmm0
[Codegen] cvttsd2si  %xmm1, %rbx
[Codegen] cvtsi2sd   %rbx, %xmm15
[Scripts] Done compiling (./tests/kraken-1.1/stanford-crypto-ccm-data.js:418)
[Scripts] Analyzing script ./tests/kraken-1.1/stanford-crypto-ccm-data.js:146 (0x7ffd6df10ac0) (usecount=10244) (maxloopcount=0)
[Codegen] cvttsd2si  %xmm1, %rbx
[Codegen] cvtsi2sd   %rbx, %xmm0
[Codegen] cvtsi2sd   %rcx, %xmm0
[Codegen] cvttsd2si  %xmm2, %rbx
[Codegen] cvtsi2sd   %rbx, %xmm15
[Scripts] Done compiling (./tests/kraken-1.1/stanford-crypto-ccm-data.js:146)
[Scripts] Analyzing script ./tests/kraken-1.1/stanford-crypto-ccm-data.js:439 (0x7ffd6df1fdc0) (usecount=10244) (maxloopcount=12)
[Scripts] Inlining script ./tests/kraken-1.1/stanford-crypto-ccm-data.js:165 (0x7ffd6df10d00)
[Scripts] Inlining script ./tests/kraken-1.1/stanford-crypto-ccm-data.js:55 (0x7ffd6df10700)
[Scripts] Inlining script ./tests/kraken-1.1/stanford-crypto-ccm-data.js:197 (0x7ffd6df1f040)
[Scripts] Inlining script ./tests/kraken-1.1/stanford-crypto-ccm-data.js:55 (0x7ffd6df10700)
[Codegen] instruction 37:MathD
[Codegen] cvttsd2si  %xmm2, %rcx
[Codegen] cvtsi2sd   %rcx, %xmm2
[Codegen] instruction 79:MathD
[Codegen] cvttsd2si  %xmm0, %rbp
[Codegen] cvttsd2si  %xmm0, %rbp
[Codegen] cvttsd2si  %xmm0, %rbp
[Codegen] cvttsd2si  %xmm0, %rbx
[Codegen] cvttsd2si  %xmm0, %rbp
[Codegen] instruction 238:MathD
[Codegen] cvttsd2si  %xmm0, %rdi
[Codegen] cvttsd2si  %xmm0, %rbx
[Codegen] cvttsd2si  %xmm0, %r8
[Codegen] cvttsd2si  %xmm0, %r8
[Codegen] cvtsi2sd   %r14, %xmm0
[Codegen] cvtsi2sd   %rcx, %xmm0
[Codegen] cvtsi2sd   %r12, %xmm0
[Codegen] cvttsd2si  %xmm1, %rcx
[Codegen] cvtsi2sd   %rcx, %xmm15
[Codegen] cvtsi2sd   %rsi, %xmm0
[Codegen] cvttsd2si  %xmm1, %rbp
[Codegen] cvtsi2sd   %rbp, %xmm15
[Codegen] cvtsi2sd   %rbp, %xmm0
[Codegen] cvttsd2si  %xmm1, %rbx
[Codegen] cvtsi2sd   %rbx, %xmm15
[Codegen] cvtsi2sd   %r10, %xmm2
[Codegen] cvtsi2sd   %rsi, %xmm0
[Codegen] cvttsd2si  %xmm1, %rdi
[Codegen] cvtsi2sd   %rdi, %xmm15
[Scripts] Done compiling (./tests/kraken-1.1/stanford-crypto-ccm-data.js:439)
[Scripts] Analyzing script ./tests/kraken-1.1/stanford-crypto-pbkdf2-data.js:343 (0x7f33c6a1fac0) (usecount=10265) (maxloopcount=43)
[Codegen] cvtsi2sd   0(%r15,%rbx,3), %xmm0
[Codegen] cvtsi2sd   0(%rdx,%r15,3), %xmm0
[Codegen] cvttsd2si  %xmm0, %r8
[Codegen] cvtsi2sd   %rbp, %xmm0
[Codegen] cvtsi2sd   %rsi, %xmm1
[Codegen] instruction 141:MathD
[Codegen] cvtsi2sd   0(%rdx,%rcx,3), %xmm1
[Codegen] instruction 144:MathD
[Codegen] cvtsi2sd   %rsi, %xmm1
[Codegen] instruction 151:MathD
[Codegen] cvttsd2si  %xmm0, %rbp
[Codegen] cvtsi2sd   %rbp, %xmm0
[Codegen] cvtsi2sd   %r14, %xmm1
[Codegen] instruction 159:MathD
[Codegen] cvtsi2sd   %rcx, %xmm1
[Codegen] instruction 172:MathD
[Codegen] cvtsi2sd   %rcx, %xmm1
[Codegen] instruction 177:MathD
[Codegen] cvtsi2sd   %rcx, %xmm1
[Codegen] instruction 180:MathD
[Codegen] cvtsi2sd   %r9, %xmm1
[Codegen] instruction 182:MathD
[Codegen] cvttsd2si  %xmm1, %rcx
[Codegen] cvtsi2sd   %rbp, %xmm1
[Codegen] instruction 189:MathD
[Codegen] cvtsi2sd   %rbp, %xmm1
[Codegen] instruction 202:MathD
[Codegen] cvttsd2si  %xmm0, %rbp
[Codegen] cvtsi2sd   %rdx, %xmm0
[Codegen] cvtsi2sd   %rdx, %xmm1
[Codegen] instruction 213:MathD
[Codegen] cvttsd2si  %xmm0, %rbp
[Codegen] cvtsi2sd   %rsi, %xmm0
[Codegen] cvtsi2sd   %rsi, %xmm1
[Codegen] instruction 219:MathD
[Codegen] cvttsd2si  %xmm0, %rdi
[Codegen] cvtsi2sd   %rbp, %xmm0
[Codegen] cvtsi2sd   %rbp, %xmm1
[Codegen] instruction 225:MathD
[Codegen] cvttsd2si  %xmm0, %r8
[Codegen] cvtsi2sd   %rdi, %xmm0
[Codegen] cvtsi2sd   %r9, %xmm1
[Codegen] instruction 231:MathD
[Codegen] cvttsd2si  %xmm0, %rdi
[Codegen] cvtsi2sd   %r8, %xmm0
[Codegen] cvtsi2sd   %r10, %xmm1
[Codegen] instruction 237:MathD
[Codegen] cvttsd2si  %xmm0, %r8
[Codegen] cvtsi2sd   %rdi, %xmm0
[Codegen] cvtsi2sd   %r12, %xmm1
[Codegen] instruction 243:MathD
[Codegen] cvttsd2si  %xmm0, %rdi
[Codegen] cvtsi2sd   %r8, %xmm0
[Codegen] cvtsi2sd   %r13, %xmm1
[Codegen] instruction 249:MathD
[Codegen] cvttsd2si  %xmm0, %r8
[Codegen] cvtsi2sd   %rdi, %xmm0
[Codegen] cvtsi2sd   %r14, %xmm1
[Codegen] instruction 255:MathD
[Codegen] cvttsd2si  %xmm0, %rdi
[Codegen] cvttsd2si  %xmm1, %r8
[Codegen] cvtsi2sd   %r8, %xmm15
[Codegen] cvttsd2si  %xmm1, %rbp
[Codegen] cvtsi2sd   %rbp, %xmm15
[Codegen] cvttsd2si  %xmm2, %rcx
[Codegen] cvtsi2sd   %rcx, %xmm15
[Codegen] cvttsd2si  %xmm1, %rbp
[Codegen] cvtsi2sd   %rbp, %xmm15
[Codegen] cvttsd2si  %xmm1, %rbp
[Codegen] cvtsi2sd   %rbp, %xmm15
[Codegen] cvttsd2si  %xmm1, %rdi
[Codegen] cvtsi2sd   %rdi, %xmm15
[Codegen] cvttsd2si  %xmm1, %r8
[Codegen] cvtsi2sd   %r8, %xmm15
[Codegen] cvttsd2si  %xmm1, %rdi
[Codegen] cvtsi2sd   %rdi, %xmm15
[Codegen] cvttsd2si  %xmm1, %r8
[Codegen] cvtsi2sd   %r8, %xmm15
[Codegen] cvttsd2si  %xmm1, %rdi
[Codegen] cvtsi2sd   %rdi, %xmm15
[Codegen] cvttsd2si  %xmm1, %r8
[Codegen] cvtsi2sd   %r8, %xmm15
[Codegen] cvttsd2si  %xmm1, %rdi
[Codegen] cvtsi2sd   %rdi, %xmm15
[Scripts] Done compiling (./tests/kraken-1.1/stanford-crypto-pbkdf2-data.js:343)
[Scripts] Analyzing script ./tests/kraken-1.1/stanford-crypto-pbkdf2-data.js:317 (0x7f33c6a1f880) (usecount=10243) (maxloopcount=11)
[Scripts] Inlining script ./tests/kraken-1.1/stanford-crypto-pbkdf2-data.js:165 (0x7f33c6a10d00)
[Scripts] Inlining script ./tests/kraken-1.1/stanford-crypto-pbkdf2-data.js:303 (0x7f33c6a1f700)
[Codegen] cvtsi2sd   %rbp, %xmm1
[Codegen] instruction 53:MathD
[Codegen] cvtsi2sd   0x30(%rbx), %xmm0
[Codegen] instruction 95:MathD
[Codegen] cvttsd2si  %xmm15, %rdi
[Codegen] cvtsi2sd   0x30(%rbx), %xmm0
[Codegen] cvttsd2si  %xmm0, %rdi
[Codegen] cvttsd2si  %xmm1, %rdi
[Codegen] cvtsi2sd   %rdi, %xmm15
[Scripts] Done compiling (./tests/kraken-1.1/stanford-crypto-pbkdf2-data.js:317)
[Scripts] Analyzing script ./tests/kraken-1.1/stanford-crypto-pbkdf2-data.js:562 (0x7f33c6a21340) (usecount=10447) (maxloopcount=85)
[Scripts] Done compiling (./tests/kraken-1.1/stanford-crypto-pbkdf2-data.js:562)
[Scripts] Analyzing script ./tests/kraken-1.1/stanford-crypto-pbkdf2-data.js:146 (0x7f33c6a10ac0) (usecount=10240) (maxloopcount=0)
[Codegen] cvtsi2sd   %rcx, %xmm0
[Scripts] Done compiling (./tests/kraken-1.1/stanford-crypto-pbkdf2-data.js:146)
[Scripts] Analyzing script ./tests/kraken-1.1/stanford-crypto-pbkdf2-data.js:169 (0x7f33c6a10dc0) (usecount=10242) (maxloopcount=0)
[Codegen] cvtsi2sd   %rbx, %xmm1
[Codegen] instruction 18:MathD
[Codegen] cvtsi2sd   %rcx, %xmm0
[Scripts] Done compiling (./tests/kraken-1.1/stanford-crypto-pbkdf2-data.js:169)
[Scripts] Analyzing script ./tests/kraken-1.1/stanford-crypto-pbkdf2-data.js:309 (0x7f33c6a1f7c0) (usecount=10241) (maxloopcount=1)
[Codegen] cvtsi2sd   0x30(%rdx), %xmm0
[Codegen] instruction 86:MathD
[Codegen] instruction 90:MathD
[Codegen] cvttsd2si  %xmm0, %rcx
[Codegen] cvtsi2sd   %rcx, %xmm0
[Codegen] cvtsi2sd   %rdx, %xmm0
[Codegen] cvtsi2sd   %rcx, %xmm0
[Codegen] cvttsd2si  %xmm2, %rcx
[Codegen] cvtsi2sd   %rcx, %xmm15
[Scripts] Done compiling (./tests/kraken-1.1/stanford-crypto-pbkdf2-data.js:309)
[Scripts] Analyzing script ./tests/kraken-1.1/stanford-crypto-pbkdf2-data.js:152 (0x7f33c6a10b80) (usecount=10245) (maxloopcount=0)
[Codegen] cvtsi2sd   %rax, %xmm1
[Codegen] instruction 35:MathD
[Codegen] cvtsi2sd   %rcx, %xmm0
[Scripts] Done compiling (./tests/kraken-1.1/stanford-crypto-pbkdf2-data.js:152)
[Scripts] Analyzing script ./tests/kraken-1.1/stanford-crypto-pbkdf2-data.js:562 (0x7f33c6a21340) (usecount=10445) (maxloopcount=85)
[Scripts] Done compiling (./tests/kraken-1.1/stanford-crypto-pbkdf2-data.js:562)
[Scripts] Analyzing script ./tests/kraken-1.1/stanford-crypto-pbkdf2-data.js:558 (0x7f33c6a21280) (usecount=10244) (maxloopcount=0)
[Scripts] Inlining script ./tests/kraken-1.1/stanford-crypto-pbkdf2-data.js:290 (0x7f33c6a1f580)
[Scripts] Inlining script ./tests/kraken-1.1/stanford-crypto-pbkdf2-data.js:303 (0x7f33c6a1f700)
[Scripts] Inlining script ./tests/kraken-1.1/stanford-crypto-pbkdf2-data.js:290 (0x7f33c6a1f580)
[Scripts] Inlining script ./tests/kraken-1.1/stanford-crypto-pbkdf2-data.js:303 (0x7f33c6a1f700)
[Codegen] cvtsi2sd   %rcx, %xmm0
[Codegen] cvtsi2sd   %rcx, %xmm0
[Scripts] Done compiling (./tests/kraken-1.1/stanford-crypto-pbkdf2-data.js:558)
[Scripts] Analyzing script ./tests/kraken-1.1/stanford-crypto-sha256-iterative-data.js:343 (0x7fc4c9a1fac0) (usecount=10278) (maxloopcount=86)
[Codegen] cvttsd2si  %xmm0, %r15
[Codegen] cvttsd2si  %xmm1, %rbp
[Codegen] cvtsi2sd   %r8, %xmm2
[Codegen] cvtsi2sd   %r15, %xmm3
[Codegen] instruction 144:MathD
[Codegen] instruction 148:MathD
[Codegen] instruction 154:MathD
[Codegen] cvttsd2si  %xmm2, %rbp
[Codegen] cvtsi2sd   %rbp, %xmm0
[Codegen] cvtsi2sd   %r14, %xmm1
[Codegen] instruction 162:MathD
[Codegen] cvtsi2sd   %rcx, %xmm1
[Codegen] instruction 175:MathD
[Codegen] cvtsi2sd   %rcx, %xmm1
[Codegen] instruction 180:MathD
[Codegen] cvtsi2sd   %rcx, %xmm1
[Codegen] instruction 183:MathD
[Codegen] cvtsi2sd   %r9, %xmm1
[Codegen] instruction 185:MathD
[Codegen] cvttsd2si  %xmm1, %rcx
[Codegen] cvtsi2sd   %rbp, %xmm1
[Codegen] instruction 192:MathD
[Codegen] cvtsi2sd   %rbp, %xmm1
[Codegen] instruction 205:MathD
[Codegen] cvttsd2si  %xmm0, %rbp
[Codegen] cvtsi2sd   %rdx, %xmm0
[Codegen] cvtsi2sd   %rdx, %xmm1
[Codegen] instruction 216:MathD
[Codegen] cvttsd2si  %xmm0, %rbp
[Codegen] cvtsi2sd   %rsi, %xmm0
[Codegen] cvtsi2sd   %rsi, %xmm1
[Codegen] instruction 222:MathD
[Codegen] cvttsd2si  %xmm0, %rdi
[Codegen] cvtsi2sd   %rbp, %xmm0
[Codegen] cvtsi2sd   %rbp, %xmm1
[Codegen] instruction 228:MathD
[Codegen] cvttsd2si  %xmm0, %r8
[Codegen] cvtsi2sd   %rdi, %xmm0
[Codegen] cvtsi2sd   %r9, %xmm1
[Codegen] instruction 234:MathD
[Codegen] cvttsd2si  %xmm0, %rdi
[Codegen] cvtsi2sd   %r8, %xmm0
[Codegen] cvtsi2sd   %r10, %xmm1
[Codegen] instruction 240:MathD
[Codegen] cvttsd2si  %xmm0, %r8
[Codegen] cvtsi2sd   %rdi, %xmm0
[Codegen] cvtsi2sd   %r12, %xmm1
[Codegen] instruction 246:MathD
[Codegen] cvttsd2si  %xmm0, %rdi
[Codegen] cvtsi2sd   %r8, %xmm0
[Codegen] cvtsi2sd   %r13, %xmm1
[Codegen] instruction 252:MathD
[Codegen] cvttsd2si  %xmm0, %r8
[Codegen] cvtsi2sd   %rdi, %xmm0
[Codegen] cvtsi2sd   %r14, %xmm1
[Codegen] instruction 258:MathD
[Codegen] cvttsd2si  %xmm0, %rdi
[Codegen] cvtsi2sd   %rcx, %xmm0
[Codegen] cvtsi2sd   %rcx, %xmm0
[Codegen] cvtsi2sd   %rcx, %xmm1
[Codegen] cvttsd2si  %xmm2, %r15
[Codegen] cvtsi2sd   %r15, %xmm15
[Codegen] cvttsd2si  %xmm2, %rbp
[Codegen] cvtsi2sd   %rbp, %xmm15
[Codegen] cvtsi2sd   %rbp, %xmm3
[Codegen] cvtsi2sd   %r8, %xmm3
[Codegen] cvttsd2si  %xmm3, %rbp
[Codegen] cvtsi2sd   %rbp, %xmm15
[Codegen] cvttsd2si  %xmm2, %rcx
[Codegen] cvtsi2sd   %rcx, %xmm15
[Codegen] cvttsd2si  %xmm1, %rbp
[Codegen] cvtsi2sd   %rbp, %xmm15
[Codegen] cvttsd2si  %xmm1, %rbp
[Codegen] cvtsi2sd   %rbp, %xmm15
[Codegen] cvttsd2si  %xmm1, %rdi
[Codegen] cvtsi2sd   %rdi, %xmm15
[Codegen] cvttsd2si  %xmm1, %r8
[Codegen] cvtsi2sd   %r8, %xmm15
[Codegen] cvttsd2si  %xmm1, %rdi
[Codegen] cvtsi2sd   %rdi, %xmm15
[Codegen] cvttsd2si  %xmm1, %r8
[Codegen] cvtsi2sd   %r8, %xmm15
[Codegen] cvttsd2si  %xmm1, %rdi
[Codegen] cvtsi2sd   %rdi, %xmm15
[Codegen] cvttsd2si  %xmm1, %r8
[Codegen] cvtsi2sd   %r8, %xmm15
[Codegen] cvttsd2si  %xmm1, %rdi
[Codegen] cvtsi2sd   %rdi, %xmm15
[Scripts] Done compiling (./tests/kraken-1.1/stanford-crypto-sha256-iterative-data.js:343)
[Scripts] Analyzing script ./tests/kraken-1.1/stanford-crypto-sha256-iterative-data.js:213 (0x7fc4c9a1f1c0) (usecount=10273) (maxloopcount=41)
[Scripts] Inlining script ./tests/kraken-1.1/stanford-crypto-sha256-iterative-data.js:165 (0x7fc4c9a10d00)
[Codegen] cvtsi2sd   %rbx, %xmm0
[Codegen] cvtsi2sd   %r8, %xmm1
[Codegen] instruction 112:MathD
[Codegen] cvtsi2sd   %rdi, %xmm0
[Codegen] instruction 114:MathD
[Scripts] Done compiling (./tests/kraken-1.1/stanford-crypto-sha256-iterative-data.js:213)
[Scripts] Analyzing script ./tests/kraken-1.1/stanford-crypto-sha256-iterative-data.js:317 (0x7fc4c9a1f880) (usecount=10242) (maxloopcount=14)
[Scripts] Inlining script ./tests/kraken-1.1/stanford-crypto-sha256-iterative-data.js:165 (0x7fc4c9a10d00)
[Scripts] Inlining script ./tests/kraken-1.1/stanford-crypto-sha256-iterative-data.js:303 (0x7fc4c9a1f700)
[Codegen] cvtsi2sd   %rbp, %xmm1
[Codegen] instruction 53:MathD
[Codegen] cvtsi2sd   0x30(%rbx), %xmm0
[Codegen] instruction 95:MathD
[Codegen] cvttsd2si  %xmm15, %rdi
[Codegen] cvtsi2sd   0x30(%rbx), %xmm0
[Codegen] cvttsd2si  %xmm0, %rdi
[Codegen] cvttsd2si  %xmm1, %rdi
[Codegen] cvtsi2sd   %rdi, %xmm15
[Scripts] Done compiling (./tests/kraken-1.1/stanford-crypto-sha256-iterative-data.js:317)
[Scripts] Analyzing script ./tests/kraken-1.1/stanford-crypto-sha256-iterative-data.js:309 (0x7fc4c9a1f7c0) (usecount=10244) (maxloopcount=1)
[Codegen] cvtsi2sd   0x30(%rdx), %xmm0
[Codegen] instruction 66:MathD
[Codegen] instruction 70:MathD
[Codegen] cvttsd2si  %xmm0, %rcx
[Codegen] cvtsi2sd   %rcx, %xmm0
[Codegen] cvtsi2sd   %rdx, %xmm0
[Codegen] cvtsi2sd   %rcx, %xmm0
[Codegen] cvttsd2si  %xmm2, %rcx
[Codegen] cvtsi2sd   %rcx, %xmm15
[Scripts] Done compiling (./tests/kraken-1.1/stanford-crypto-sha256-iterative-data.js:309)

and just to get a better feel for the worst offenders:
~/bench/kraken-pretty; join <(cat aes.log ccm.log pbkdf2.log  sha256.log | sed -n -e "/Analyzing/,/Done/p" | grep -E "MathD|Scripts|cvt" | grep -n Done | cut -d: -f1 | numinterval | cat -n) <(cat aes.log ccm.log pbkdf2.log  sha256.log | sed -n -e "/Analyzing/,/Done/p" | grep -E "MathD|Scripts|cvt" | grep Done | cat -n) | sed -e 's/^[^ ]* //' | sort -n
2 [Scripts] Done compiling (./tests/kraken-1.1/stanford-crypto-aes-data.js:58)
2 [Scripts] Done compiling (./tests/kraken-1.1/stanford-crypto-aes-data.js:992)
2 [Scripts] Done compiling (./tests/kraken-1.1/stanford-crypto-ccm-data.js:169)
2 [Scripts] Done compiling (./tests/kraken-1.1/stanford-crypto-ccm-data.js:179)
2 [Scripts] Done compiling (./tests/kraken-1.1/stanford-crypto-pbkdf2-data.js:152)
2 [Scripts] Done compiling (./tests/kraken-1.1/stanford-crypto-pbkdf2-data.js:317)
3 [Scripts] Done compiling (./tests/kraken-1.1/stanford-crypto-aes-data.js:169)
3 [Scripts] Done compiling (./tests/kraken-1.1/stanford-crypto-pbkdf2-data.js:562)
4 [Scripts] Done compiling (./tests/kraken-1.1/stanford-crypto-aes-data.js:55)
5 [Scripts] Done compiling (./tests/kraken-1.1/stanford-crypto-aes-data.js:152)
5 [Scripts] Done compiling (./tests/kraken-1.1/stanford-crypto-ccm-data.js:172)
5 [Scripts] Done compiling (./tests/kraken-1.1/stanford-crypto-pbkdf2-data.js:146)
5 [Scripts] Done compiling (./tests/kraken-1.1/stanford-crypto-pbkdf2-data.js:309)
6 [Scripts] Done compiling (./tests/kraken-1.1/stanford-crypto-aes-data.js:172)
6 [Scripts] Done compiling (./tests/kraken-1.1/stanford-crypto-ccm-data.js:104)
6 [Scripts] Done compiling (./tests/kraken-1.1/stanford-crypto-ccm-data.js:157)
7 [Scripts] Done compiling (./tests/kraken-1.1/stanford-crypto-ccm-data.js:418)
8 [Scripts] Done compiling (./tests/kraken-1.1/stanford-crypto-aes-data.js:104)
8 [Scripts] Done compiling (./tests/kraken-1.1/stanford-crypto-pbkdf2-data.js:562)
8 [Scripts] Done compiling (./tests/kraken-1.1/stanford-crypto-sha256-iterative-data.js:343)
10 [Scripts] Done compiling (./tests/kraken-1.1/stanford-crypto-aes.js:1)
11 [Scripts] Done compiling (./tests/kraken-1.1/stanford-crypto-pbkdf2-data.js:169)
11 [Scripts] Done compiling (./tests/kraken-1.1/stanford-crypto-sha256-iterative-data.js:317)
12 [Scripts] Done compiling (./tests/kraken-1.1/stanford-crypto-ccm-data.js:30)
13 [Scripts] Done compiling (./tests/kraken-1.1/stanford-crypto-ccm-data.js:55)
13 [Scripts] Done compiling (./tests/kraken-1.1/stanford-crypto-pbkdf2-data.js:343)
13 [Scripts] Done compiling (./tests/kraken-1.1/stanford-crypto-sha256-iterative-data.js:213)
14 [Scripts] Done compiling (./tests/kraken-1.1/stanford-crypto-ccm-data.js:165)
28 [Scripts] Done compiling (./tests/kraken-1.1/stanford-crypto-ccm-data.js:235)
35 [Scripts] Done compiling (./tests/kraken-1.1/stanford-crypto-ccm-data.js:146)
56 [Scripts] Done compiling (./tests/kraken-1.1/stanford-crypto-ccm-data.js:152)
58 [Scripts] Done compiling (./tests/kraken-1.1/stanford-crypto-aes-data.js:30)
86 [Scripts] Done compiling (./tests/kraken-1.1/stanford-crypto-ccm-data.js:439)
90 [Scripts] Done compiling (./tests/kraken-1.1/stanford-crypto-pbkdf2-data.js:558)

and a couple of the worst offenders (#1 inlined a couple of other functions):
stanford-crypto-aes-data.js:30:sjcl.cipher.aes = function(a) {
stanford-crypto-aes-data.js:31:    this.h[0][0][0] || this.w();
stanford-crypto-aes-data.js:32:    var b, c, d, e, f = this.h[0][4],
stanford-crypto-aes-data.js:33:        g = this.h[1];
stanford-crypto-aes-data.js:34:    b = a.length;
stanford-crypto-aes-data.js:35:    var h = 1;
stanford-crypto-aes-data.js:36:    if (b !== 4 && b !== 6 && b !== 8) throw new sjcl.exception.invalid("invalid aes key size");
stanford-crypto-aes-data.js:37:    this.a = [d = a.slice(0), e = []];
stanford-crypto-aes-data.js:38:    for (a = b; a < 4 * b + 28; a++) {
stanford-crypto-aes-data.js:39:        c = d[a - 1];
stanford-crypto-aes-data.js:40:        if (a % b === 0 || b === 8 && a % b === 4) {
stanford-crypto-aes-data.js:41:            c = f[c >>> 24] << 24 ^ f[c >> 16 & 255] << 16 ^ f[c >> 8 & 255] << 8 ^ f[c & 255];
stanford-crypto-aes-data.js:42:            if (a % b === 0) {
stanford-crypto-aes-data.js:43:                c = c << 8 ^ c >>> 24 ^ h << 24;
stanford-crypto-aes-data.js:44:                h = h << 1 ^ (h >> 7) * 283
stanford-crypto-aes-data.js:45:            }
stanford-crypto-aes-data.js:46:        }
stanford-crypto-aes-data.js:47:        d[a] = d[a - b] ^ c
stanford-crypto-aes-data.js:48:    }
stanford-crypto-aes-data.js:49:    for (b = 0; a; b++, a--) {
stanford-crypto-aes-data.js:50:        c = d[b & 3 ? a : a - 4];
stanford-crypto-aes-data.js:51:        e[b] = a <= 4 || b < 4 ? c : g[0][f[c >>> 24]] ^ g[1][f[c >> 16 & 255]] ^ g[2][f[c >> 8 & 255]] ^ g[3][f[c & 255]]
stanford-crypto-aes-data.js:52:    }
stanford-crypto-aes-data.js:53:};


stanford-crypto-ccm-data.js:439:    I: function(a, b, c, d, e, f) {
stanford-crypto-ccm-data.js:440:        var g, h = sjcl.bitArray;
stanford-crypto-ccm-data.js:441:        g = h.k;
stanford-crypto-ccm-data.js:442:        var i = b.length,
stanford-crypto-ccm-data.js:443:            k = h.bitLength(b);
stanford-crypto-ccm-data.js:444:        c = h.concat([h.partial(8, f - 1)], c).concat([0,
stanford-crypto-ccm-data.js:445:        0, 0]).slice(0, 4);
stanford-crypto-ccm-data.js:446:        d = h.bitSlice(g(d, a.encrypt(c)), 0, e);
stanford-crypto-ccm-data.js:447:        if (!i) return {
stanford-crypto-ccm-data.js:448:            tag: d,
stanford-crypto-ccm-data.js:449:            data: []
stanford-crypto-ccm-data.js:450:        };
stanford-crypto-ccm-data.js:451:        for (g = 0; g < i; g += 4) {
stanford-crypto-ccm-data.js:452:            c[3]++;
stanford-crypto-ccm-data.js:453:            e = a.encrypt(c);
stanford-crypto-ccm-data.js:454:            b[g] ^= e[0];
stanford-crypto-ccm-data.js:455:            b[g + 1] ^= e[1];
stanford-crypto-ccm-data.js:456:            b[g + 2] ^= e[2];
stanford-crypto-ccm-data.js:457:            b[g + 3] ^= e[3]
stanford-crypto-ccm-data.js:458:        }
stanford-crypto-ccm-data.js:459:        return {
stanford-crypto-ccm-data.js:460:            tag: d,
stanford-crypto-ccm-data.js:461:            data: h.clamp(b, k)
stanford-crypto-ccm-data.js:462:        }
stanford-crypto-ccm-data.js:463:    }

and a cursory look at these says that they should not be doing that much double math.
(In reply to Nicolas B. Pierron [:pierron] [:nbp] from comment #3)
> This
> patch does not improves PdfJS yet because PdfJS case is even worse than the
> reduce benchmark as the "i" variable is aliased, which means that the type
> of "i" does not flow through a Phi, but through an aliased var.

It appears that the function getToken is only used at the end of the processed stream, and the aliased var 'i' can be live on the stack until the first call to getToken.  Solving this would imply some escape analysis to determine which state is captured by a function.  This kind of optimization is unlikely to be critical for the moment.
Comment on attachment 692959 [details] [diff] [review]
Move guards closer to their point of definitions.

Cancel this review as this patch does not give any perf improvment to PdfJS.
Attachment #692959 - Flags: review?(dvander)
Unassigned my-self: I am not actively working on it right now.
Assignee: nicolas.b.pierron → general
Status: ASSIGNED → NEW
I don't know if this is still relevant. We're faster than the competition on the reduced pdf.js Octane benchmark:

SM: 202ms
d8: 264ms
jsc: 643ms

We're still slower than v8 on the test from comment 0 (with time measurements around the function invocation):

SM: 31ms
d8: 25ms
jsc: 45ms
OS: Linux → All
Hardware: x86_64 → All
Summary: JM & Ion: Prevent double type to flow into loop counters. → IonMonkey: Prevent double type to flow into loop counters.
Version: 19 Branch → Trunk
(In reply to Till Schneidereit [:till] from comment #9)
> I don't know if this is still relevant.

This is still relevant for pdf.js, but this is not the only reason.  In PdfJS the variable is captured by the scope chain and type propagation might think that a double flow into the loop counter.

In practice I think we could use the fact that baseline does not monitor any double math to guard against double math.  One of the problem, which might be worst and that I expect to solve with escape analysis is to move the loop counter out of the scope chain, into a register for most of the time.
Assignee: general → nobody
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: