Skip to content

Instantly share code, notes, and snippets.

@mraleph
Last active December 20, 2015 16:09
Show Gist options
  • Save mraleph/6159778 to your computer and use it in GitHub Desktop.
Save mraleph/6159778 to your computer and use it in GitHub Desktop.
--- Optimized code ---
kind = OPTIMIZED_FUNCTION
name = foo
stack_slots = 1
Instructions (size = 90)
0x48634f60 0 55 push ebp
0x48634f61 1 89e5 mov ebp,esp
0x48634f63 3 56 push esi
0x48634f64 4 57 push edi
0x48634f65 5 6a00 push 0x0
;;; <@0,#0> -------------------- B0 --------------------
;;; <@2,#1> context
0x48634f67 7 8b75fc mov esi,[ebp+0xfc]
;;; <@10,#8> -------------------- B1 --------------------
;;; <@12,#10> stack-check
0x48634f6a 10 3b25c4062d01 cmp esp,[0x12d06c4]
0x48634f70 16 7305 jnc 23 (0x48634f77)
0x48634f72 18 e869abfdff call 0x4860fae0 ;; code: STUB, StackCheckStub, minor: 0
;;; <@13,#10> gap
0x48634f77 23 8b4508 mov eax,[ebp+0x8]
;;; <@14,#12> check-non-smi
0x48634f7a 26 a801 test al,0x1
0x48634f7c 28 0f8415000000 jz 55 (0x48634f97)
;;; --------------
;;; Here we are checking receiver's hidden class. Notice that hidden class of the prototype is not
;;; checked because the check is elided. This code will instead be deoptimized if somebody changes
;;; hidden class of the A.prototype.
;;; --------------
;;; <@16,#13> check-maps
0x48634f82 34 8178ff8904a152 cmp [eax+0xff],0x52a10489 ;; object: 0x52a10489 <Map(elements=3)>
0x48634f89 41 0f850d000000 jnz 60 (0x48634f9c)
;;; <@20,#21> -------------------- B2 --------------------
;;; <@22,#25> constant-t
0x48634f8f 47 33c0 xor eax,eax
;;; <@24,#23> return
0x48634f91 49 89ec mov esp,ebp
0x48634f93 51 5d pop ebp
0x48634f94 52 c20800 ret 0x8
;;; -------------------- Jump table --------------------
;;; jump table entry 0: deoptimization bailout 1.
0x48634f97 55 e86e507dfb call 0x43e0a00a ;; deoptimization bailout 1
;;; jump table entry 1: deoptimization bailout 2.
0x48634f9c 60 e873507dfb call 0x43e0a014 ;; deoptimization bailout 2
0x48634fa1 65 90 nop
0x48634fa2 66 90 nop
0x48634fa3 67 90 nop
0x48634fa4 68 90 nop
0x48634fa5 69 90 nop
0x48634fa6 70 66 nop
0x48634fa7 71 90 nop
function A() { }
A.prototype.foo = function () { return 0; };
function foo(a) { return a.foo(); }
foo(new A);
foo(new A);
foo(new A);
%OptimizeFunctionOnNextCall(foo);
foo(new A);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment