Skip to content
Create a gist now

Instantly share code, notes, and snippets.

Embed URL


Subversion checkout URL

You can clone with
Download ZIP
Boolean vs Int in Javascript
; JavaScript Code : "!a"
movabsq $0xfff9800000000000, %r11 ; type tag of boolean (SpiderMonkey uses a trait of NaN-boxing)
cmpq %r11, %r9 ; compare with type tag of a
jne ((165)) ; if not equal jump to stub
xorl 1, %r15d ; xor value of a with 1, true is value 1 so 1^1 = 0, false is 0 so 1^0 = 1
; JavaScript Code: "a - 1"
movabsq $0xfff8800000000000, %r11 ; type tag of int
cmpq %r11, %r15
jne ((73)) ; jump if not int
subl $0x1, %r9d ; subtract 1
jo ((83)) ; jump if overflow
; JavaScript Code: "if (a)"
movabsq $0xfff9800000000000, %r11
cmpq %r11, %r15
jne ((86)) ; jump if not boolean
testl %r9d, %r9d ; test
jne ((95)) ; jump false
jmp ((100)) ; jump true
; JavaScript Code: "if (a == 1)
movabsq $0xfff8800000000000, %r11
cmpq %r11, %r12
jne ((70))
cmpl $0x1, %r15d
jne ((80))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.