Skip to content

Instantly share code, notes, and snippets.

@erikcorry
Created November 26, 2025 12:04
Show Gist options
  • Select an option

  • Save erikcorry/6159504e30cbb1ef3e23f2aec85284fa to your computer and use it in GitHub Desktop.

Select an option

Save erikcorry/6159504e30cbb1ef3e23f2aec85284fa to your computer and use it in GitHub Desktop.
The LdaSmi bytecode in the V8 interpreter (it also checks if the next bytecode is store-a-on-stack and does that).
1958cc0: 43 0f be 5c 0c 01 movsbl 0x1(%r12,%r9,1),%ebx // ebx = load small int
1958cc6: 49 8d 51 02 lea 0x2(%r9),%rdx // rdx = next bytecode addr
1958cca: 43 0f b6 74 0c 02 movzbl 0x2(%r12,%r9,1),%esi // esi = peek at next bytecode
1958cd0: 8d 04 1b lea (%rbx,%rbx,1),%eax // eax = rbx * 2 (tag smi)
1958cd3: 40 80 fe c1 cmp $0xc1,%sil // is next bc star? (Store accumulator in 'register'.
1958cd7: 73 09 jae 1958ce2 <Builtins_LdaSmiHandler+0x22> // jmp if star
1958cd9: 49 8b 0c f7 mov (%r15,%rsi,8),%rcx // add bytecode to r15, load next bytecode handler.
1958cdd: 4c 8b ca mov %rdx,%r9 // Update bytecode program counter
1958ce0: ff e1 jmp *%rcx // Dispatch to next handler
1958ce2: 48 8b dd mov %rbp,%rbx // rbx = frame pointer
1958ce5: 48 89 84 f3 48 f9 ff mov %rax,-0x6b8(%rbx,%rsi,8) // store accumulator on stack (why not use rbp?)
1958cec: ff
1958ced: 48 8d 5a 01 lea 0x1(%rdx),%rbx // rbx = next bytecode addr
1958cf1: 43 0f b6 54 0c 03 movzbl 0x3(%r12,%r9,1),%edx // load next bytecode to ecx
1958cf7: 49 8b 0c d7 mov (%r15,%rdx,8),%rcx // add bytecode to r15, load next bytecode handler
1958cfb: 4c 8b cb mov %rbx,%r9 // update bytecode program counter
1958cfe: ff e1 jmp *%rcx // Dispatch to next handler
1958d00: 90 nop
1958d01: 0f 1f 00 nopl (%rax)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment