Skip to content

Instantly share code, notes, and snippets.

@zbjornson
Last active August 29, 2015 14:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zbjornson/af5298f089c420f94d5d to your computer and use it in GitHub Desktop.
Save zbjornson/af5298f089c420f94d5d to your computer and use it in GitHub Desktop.
function flip() {
var flipper = new Uint8Array(4 * 10000);
flipFloat(flipper, 10000, 4);
}
function flipFloat(flipper, iMax, eSize) {
for (var i = 0; i < iMax; i += eSize) {
var t = flipper[i];
// Toggle this line:
if (t === undefined) {}
flipper[i] = flipper[i + 3];
flipper[i + 3] = t;
var u = flipper[i + 1];
flipper[i + 1] = flipper[i + 2];
flipper[i + 2] = u;
}
}
flip();
flip();
%OptimizeFunctionOnNextCall(flip);
flip();
console.log(%GetOptimizationStatus(flip));
@zbjornson
Copy link
Author

With line 10 present:

> node --trace_opt --trace_deopt --allow-natives-syntax test_opt.js
[deoptimize context: e8f14679]
[optimizing: flip / e8fcaf19 - took 0.000, 0.000, 0.000 ms]
[marking IN 0xd600ab70 for recompilation, reason: hot and stable, ICs with typeinfo: 1/2 (50%)]
[disabled optimization for IN, reason: call to a JavaScript runtime function]

With line 10 commented-out:

> node --trace_opt --trace_deopt --allow-natives-syntax test_opt.js
[deoptimize context: 94f14679]
[optimizing: flip / 94fcaf19 - took 0.000, 0.000, 0.000 ms]
**** DEOPT: flip at bailout #8, address 0x0, frame size 24
[deoptimizing: begin 0x94fcaf19 flip @8]
  translating flip => node=34, height=16
    0x0029f6a8: [top + 48] <- 0xbbd06c91 ; [sp + 56] 00000000BBD06C91 <JS Global Object>
    0x0029f6a0: [top + 40] <- 0xffe67b26 ; caller's pc
    0x0029f698: [top + 32] <- 0x0029f6d8 ; caller's fp
    0x0029f690: [top + 24] <- 0x94fcaee1; context
    0x0029f688: [top + 16] <- 0x94fcaf19; function
    0x0029f680: [top + 8] <- 0x94fccfe1 ; rax 0000000094FCCFE1 <an Uint8Array>
    0x0029f678: [top + 0] <- 0x94fcaf61 ; rbx 0000000094FCAF61 <JS Function flipFloat>
  translating flipFloat => node=19, height=24
    0x0029f670: [top + 80] <- 0xbbd06c91 ; rdx 00000000BBD06C91 <JS Global Object>
    0x0029f668: [top + 72] <- 0x94fccfe1 ; rax 0000000094FCCFE1 <an Uint8Array>
    0x0029f660: [top + 64] <- 10000 ; literal
    0x0029f658: [top + 56] <- 4 ; literal
    0x0029f650: [top + 48] <- 0xffe67d8b ; caller's pc
    0x0029f648: [top + 40] <- 0x0029f698 ; caller's fp
    0x0029f640: [top + 32] <- 0x94fcaee1; context
    0x0029f638: [top + 24] <- 0x94fcaf61; function
    0x0029f630: [top + 16] <- 0 ; r8 (smi)
    0x0029f628: [top + 8] <- 00000000BBD04121 <undefined> ; literal
    0x0029f620: [top + 0] <- 00000000BBD04121 <undefined> ; literal
[deoptimizing: end 0x94fcaf61 flipFloat => node=19, pc=0xffe67e63, state=NO_REGISTERS, alignment=no padding, took 2.000
ms]
[removing optimized code for: flip]
[marking flipFloat 0x94fcaf60 for recompilation, reason: small function, ICs with typeinfo: 15/16 (93%)]
[marking IN 0xbbd0ab70 for recompilation, reason: hot and stable, ICs with typeinfo: 1/2 (50%)]
[disabled optimization for IN, reason: call to a JavaScript runtime function]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment