-
Notifications
You must be signed in to change notification settings - Fork 14
Open
Description
For the specific function https://goo.gl/EYwhBF, with the baseline JIT option enabled, it appears to me as if the asm listing is cut before the blocks for a br_table has been printed. I don't see any mov instructions that would correspond to the get_global and i32.load instructions in the blocks.
This C code...
#define CASE break;case
extern int A, B, C, D;
int f(int x) {
int r = 0;
switch (x) {
CASE(0): r = A;
CASE(1): r = B;
CASE(2): r = C;
CASE(3): r = D;
}
return r;
}
...generates this wast...
(module
(type $type0 (func (param i32) (result i32)))
(import $global0 "env" "A" (global i32))
(import $global1 "env" "B" (global i32))
(import $global2 "env" "C" (global i32))
(import $global3 "env" "D" (global i32))
(table 0 anyfunc)
(memory 1)
(export "memory" memory)
(export "_Z1fi" $func0)
(func $func0 (param $var0 i32) (result i32)
block $label4 block $label3 block $label2 block $label0
get_local $var0
i32.const 3
i32.gt_u
br_if $label0
block $label1
get_local $var0
br_table $label1 $label2 $label3 $label4 $label1
end $label1
get_global $global0
i32.load
return
end $label0
i32.const 0
return
end $label2
get_global $global1
i32.load
return
end $label3
get_global $global2
i32.load
return
end $label4
get_global $global3
i32.load
)
)
which generates this asm:
wasm-function[0]:
sub rsp, 0x18 ; 0x000000 48 83 ec 18
mov qword ptr [rsp + 8], r14 ; 0x000004 4c 89 74 24 08
mov rax, rsp ; 0x000009 48 8b c4
add rax, 0 ; 0x00000c 48 05 00 00 00 00
cmp qword ptr [r14 + 0x28], rax ; 0x000012 49 39 46 28
jae 0xd1 ; 0x000016 0f 83 b5 00 00 00
0x00001c:
mov dword ptr [rsp + 4], edi ; 0x00001c 89 7c 24 04
mov eax, dword ptr [rsp + 4] ; 0x000020 8b 44 24 04
cmp eax, 3 ; 0x000024 83 f8 03
ja 0x93 ; 0x000027 0f 87 66 00 00 00
0x00002d:
mov eax, dword ptr [rsp + 4] ; 0x00002d 8b 44 24 04
cmp eax, 4 ; 0x000031 83 f8 04
jb 0x73 ; 0x000034 0f 82 39 00 00 00
0x00003a:
jmp 0x81 ; 0x00003a e9 42 00 00 00
0x00003f:
jmp 0x81 ; 0x00003f e9 3d 00 00 00
0x000044:
jmp 0x9a ; 0x000044 e9 51 00 00 00
0x000049:
jmp 0xac ; 0x000049 e9 5e 00 00 00
0x00004e:
jmp 0xbe ; 0x00004e e9 6b 00 00 00
If I unselect the baseline jit option, I get this output instead (notice the four labels with 2 mov instructions each that are missing in the output above):
wasm-function[0]:
sub rsp, 8 ; 0x000000 48 83 ec 08
cmp edi, 3 ; 0x000004 83 ff 03
ja 0x32 ; 0x000007 0f 87 25 00 00 00
0x00000d:
mov eax, edi ; 0x00000d 8b c7
cmp eax, 4 ; 0x00000f 83 f8 04
jae 0x25 ; 0x000012 0f 83 0d 00 00 00
0x000018:
movabs rcx, 0 ; 0x000018 48 b9 00 00 00 00 00 00 00 00
jmp qword ptr [rcx + rax*8] ; 0x000022 ff 24 c1
0x000025:
mov eax, dword ptr [r14 + 0x40] ; 0x000025 41 8b 46 40
mov eax, dword ptr [r15 + rax] ; 0x000029 41 8b 04 07
jmp 0x5b ; 0x00002d e9 29 00 00 00
0x000032:
xor eax, eax ; 0x000032 33 c0
jmp 0x5b ; 0x000034 e9 22 00 00 00
0x000039:
mov eax, dword ptr [r14 + 0x44] ; 0x000039 41 8b 46 44
mov eax, dword ptr [r15 + rax] ; 0x00003d 41 8b 04 07
jmp 0x5b ; 0x000041 e9 15 00 00 00
0x000046:
mov eax, dword ptr [r14 + 0x48] ; 0x000046 41 8b 46 48
mov eax, dword ptr [r15 + rax] ; 0x00004a 41 8b 04 07
jmp 0x5b ; 0x00004e e9 08 00 00 00
0x000053:
mov eax, dword ptr [r14 + 0x4c] ; 0x000053 41 8b 46 4c
mov eax, dword ptr [r15 + rax] ; 0x000057 41 8b 04 07
0x00005b: ; 0x00005b from: [0x00002d, 0x000034, 0x000041, 0x00004e]
nop ; 0x00005b 66 90
add rsp, 8 ; 0x00005d 48 83 c4 08
ret ; 0x000061 c3
Thank you for a super useful tool. So much easier than using IONFLAGS=codegen with the spidermonkey shell!
Metadata
Metadata
Assignees
Labels
No labels