diff options
author | Mike Pall <mike> | 2010-02-11 16:21:18 +0100 |
---|---|---|
committer | Mike Pall <mike> | 2010-02-11 16:21:18 +0100 |
commit | b2067236c5e1f9bfddeb5232f78865f72faef494 (patch) | |
tree | 4ce7391dc45261ea438d08fc52db801c9cd15eb1 /src | |
parent | 565eb3957485bf7568bf6e8bba75e5f35f9bf3e9 (diff) | |
download | luajit-b2067236c5e1f9bfddeb5232f78865f72faef494.tar.gz luajit-b2067236c5e1f9bfddeb5232f78865f72faef494.tar.bz2 luajit-b2067236c5e1f9bfddeb5232f78865f72faef494.zip |
Move dispatch tables out of GG_State struct.
Diffstat (limited to 'src')
-rw-r--r-- | src/Makefile.dep | 24 | ||||
-rw-r--r-- | src/buildvm_x64.h | 4 | ||||
-rw-r--r-- | src/buildvm_x64win.h | 4 | ||||
-rw-r--r-- | src/buildvm_x86.dasc | 8 | ||||
-rw-r--r-- | src/buildvm_x86.h | 4 | ||||
-rw-r--r-- | src/lib_jit.c | 1 | ||||
-rw-r--r-- | src/lj_asm.c | 4 | ||||
-rw-r--r-- | src/lj_dispatch.c | 6 | ||||
-rw-r--r-- | src/lj_dispatch.h | 23 | ||||
-rw-r--r-- | src/lj_state.c | 10 |
10 files changed, 45 insertions, 43 deletions
diff --git a/src/Makefile.dep b/src/Makefile.dep index d1ed9094..ef64bd9a 100644 --- a/src/Makefile.dep +++ b/src/Makefile.dep | |||
@@ -22,11 +22,11 @@ lib_debug.o: lib_debug.c lua.h luaconf.h lauxlib.h lualib.h lj_obj.h \ | |||
22 | lib_init.o: lib_init.c lua.h luaconf.h lauxlib.h lualib.h | 22 | lib_init.o: lib_init.c lua.h luaconf.h lauxlib.h lualib.h |
23 | lib_io.o: lib_io.c lua.h luaconf.h lauxlib.h lualib.h lj_obj.h lj_def.h \ | 23 | lib_io.o: lib_io.c lua.h luaconf.h lauxlib.h lualib.h lj_obj.h lj_def.h \ |
24 | lj_arch.h lj_gc.h lj_err.h lj_errmsg.h lj_str.h lj_ff.h lj_ffdef.h \ | 24 | lj_arch.h lj_gc.h lj_err.h lj_errmsg.h lj_str.h lj_ff.h lj_ffdef.h \ |
25 | lj_trace.h lj_jit.h lj_ir.h lj_dispatch.h lj_bc.h lj_traceerr.h \ | 25 | lj_trace.h lj_jit.h lj_ir.h lj_dispatch.h lj_traceerr.h lj_lib.h \ |
26 | lj_lib.h lj_libdef.h | 26 | lj_libdef.h |
27 | lib_jit.o: lib_jit.c lua.h luaconf.h lauxlib.h lualib.h lj_arch.h \ | 27 | lib_jit.o: lib_jit.c lua.h luaconf.h lauxlib.h lualib.h lj_arch.h \ |
28 | lj_obj.h lj_def.h lj_err.h lj_errmsg.h lj_str.h lj_tab.h lj_ir.h \ | 28 | lj_obj.h lj_def.h lj_err.h lj_errmsg.h lj_str.h lj_tab.h lj_bc.h \ |
29 | lj_jit.h lj_iropt.h lj_dispatch.h lj_bc.h lj_vm.h lj_vmevent.h lj_lib.h \ | 29 | lj_ir.h lj_jit.h lj_iropt.h lj_dispatch.h lj_vm.h lj_vmevent.h lj_lib.h \ |
30 | luajit.h lj_libdef.h | 30 | luajit.h lj_libdef.h |
31 | lib_math.o: lib_math.c lua.h luaconf.h lauxlib.h lualib.h lj_obj.h \ | 31 | lib_math.o: lib_math.c lua.h luaconf.h lauxlib.h lualib.h lj_obj.h \ |
32 | lj_def.h lj_arch.h lj_lib.h lj_libdef.h | 32 | lj_def.h lj_arch.h lj_lib.h lj_libdef.h |
@@ -59,8 +59,8 @@ lj_err.o: lj_err.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h lj_err.h \ | |||
59 | lj_errmsg.h lj_str.h lj_tab.h lj_func.h lj_state.h lj_frame.h lj_bc.h \ | 59 | lj_errmsg.h lj_str.h lj_tab.h lj_func.h lj_state.h lj_frame.h lj_bc.h \ |
60 | lj_trace.h lj_jit.h lj_ir.h lj_dispatch.h lj_traceerr.h lj_vm.h | 60 | lj_trace.h lj_jit.h lj_ir.h lj_dispatch.h lj_traceerr.h lj_vm.h |
61 | lj_func.o: lj_func.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h lj_gc.h \ | 61 | lj_func.o: lj_func.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h lj_gc.h \ |
62 | lj_func.h lj_trace.h lj_jit.h lj_ir.h lj_dispatch.h lj_bc.h \ | 62 | lj_func.h lj_trace.h lj_jit.h lj_ir.h lj_dispatch.h lj_traceerr.h \ |
63 | lj_traceerr.h lj_vm.h | 63 | lj_vm.h |
64 | lj_gc.o: lj_gc.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h lj_gc.h \ | 64 | lj_gc.o: lj_gc.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h lj_gc.h \ |
65 | lj_err.h lj_errmsg.h lj_str.h lj_tab.h lj_func.h lj_udata.h lj_meta.h \ | 65 | lj_err.h lj_errmsg.h lj_str.h lj_tab.h lj_func.h lj_udata.h lj_meta.h \ |
66 | lj_state.h lj_frame.h lj_bc.h lj_trace.h lj_jit.h lj_ir.h lj_dispatch.h \ | 66 | lj_state.h lj_frame.h lj_bc.h lj_trace.h lj_jit.h lj_ir.h lj_dispatch.h \ |
@@ -70,14 +70,14 @@ lj_gdbjit.o: lj_gdbjit.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \ | |||
70 | lj_ir.h lj_dispatch.h | 70 | lj_ir.h lj_dispatch.h |
71 | lj_ir.o: lj_ir.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h lj_gc.h \ | 71 | lj_ir.o: lj_ir.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h lj_gc.h \ |
72 | lj_str.h lj_tab.h lj_ir.h lj_jit.h lj_iropt.h lj_trace.h lj_dispatch.h \ | 72 | lj_str.h lj_tab.h lj_ir.h lj_jit.h lj_iropt.h lj_trace.h lj_dispatch.h \ |
73 | lj_bc.h lj_traceerr.h lj_lib.h | 73 | lj_traceerr.h lj_lib.h |
74 | lj_lex.o: lj_lex.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h lj_gc.h \ | 74 | lj_lex.o: lj_lex.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h lj_gc.h \ |
75 | lj_err.h lj_errmsg.h lj_str.h lj_lex.h lj_parse.h lj_ctype.h | 75 | lj_err.h lj_errmsg.h lj_str.h lj_lex.h lj_parse.h lj_ctype.h |
76 | lj_lib.o: lj_lib.c lauxlib.h lua.h luaconf.h lj_obj.h lj_def.h lj_arch.h \ | 76 | lj_lib.o: lj_lib.c lauxlib.h lua.h luaconf.h lj_obj.h lj_def.h lj_arch.h \ |
77 | lj_gc.h lj_err.h lj_errmsg.h lj_str.h lj_tab.h lj_func.h lj_vm.h \ | 77 | lj_gc.h lj_err.h lj_errmsg.h lj_str.h lj_tab.h lj_func.h lj_vm.h \ |
78 | lj_lib.h | 78 | lj_lib.h |
79 | lj_mcode.o: lj_mcode.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \ | 79 | lj_mcode.o: lj_mcode.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \ |
80 | lj_gc.h lj_jit.h lj_ir.h lj_mcode.h lj_trace.h lj_dispatch.h lj_bc.h \ | 80 | lj_gc.h lj_jit.h lj_ir.h lj_mcode.h lj_trace.h lj_dispatch.h \ |
81 | lj_traceerr.h | 81 | lj_traceerr.h |
82 | lj_meta.o: lj_meta.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h lj_gc.h \ | 82 | lj_meta.o: lj_meta.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h lj_gc.h \ |
83 | lj_err.h lj_errmsg.h lj_str.h lj_tab.h lj_meta.h lj_bc.h lj_vm.h | 83 | lj_err.h lj_errmsg.h lj_str.h lj_tab.h lj_meta.h lj_bc.h lj_vm.h |
@@ -85,11 +85,11 @@ lj_obj.o: lj_obj.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h | |||
85 | lj_opt_dce.o: lj_opt_dce.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \ | 85 | lj_opt_dce.o: lj_opt_dce.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \ |
86 | lj_ir.h lj_jit.h lj_iropt.h | 86 | lj_ir.h lj_jit.h lj_iropt.h |
87 | lj_opt_fold.o: lj_opt_fold.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \ | 87 | lj_opt_fold.o: lj_opt_fold.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \ |
88 | lj_str.h lj_ir.h lj_jit.h lj_iropt.h lj_trace.h lj_dispatch.h lj_bc.h \ | 88 | lj_str.h lj_ir.h lj_jit.h lj_iropt.h lj_trace.h lj_dispatch.h \ |
89 | lj_traceerr.h lj_vm.h lj_folddef.h | 89 | lj_traceerr.h lj_vm.h lj_folddef.h |
90 | lj_opt_loop.o: lj_opt_loop.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \ | 90 | lj_opt_loop.o: lj_opt_loop.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \ |
91 | lj_err.h lj_errmsg.h lj_str.h lj_ir.h lj_jit.h lj_iropt.h lj_trace.h \ | 91 | lj_err.h lj_errmsg.h lj_str.h lj_ir.h lj_jit.h lj_iropt.h lj_trace.h \ |
92 | lj_dispatch.h lj_bc.h lj_traceerr.h lj_snap.h lj_vm.h | 92 | lj_dispatch.h lj_traceerr.h lj_snap.h lj_vm.h |
93 | lj_opt_mem.o: lj_opt_mem.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \ | 93 | lj_opt_mem.o: lj_opt_mem.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \ |
94 | lj_tab.h lj_ir.h lj_jit.h lj_iropt.h | 94 | lj_tab.h lj_ir.h lj_jit.h lj_iropt.h |
95 | lj_opt_narrow.o: lj_opt_narrow.c lj_obj.h lua.h luaconf.h lj_def.h \ | 95 | lj_opt_narrow.o: lj_opt_narrow.c lj_obj.h lua.h luaconf.h lj_def.h \ |
@@ -122,8 +122,8 @@ lj_trace.o: lj_trace.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \ | |||
122 | lj_udata.o: lj_udata.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \ | 122 | lj_udata.o: lj_udata.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \ |
123 | lj_gc.h lj_udata.h | 123 | lj_gc.h lj_udata.h |
124 | lj_vmevent.o: lj_vmevent.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \ | 124 | lj_vmevent.o: lj_vmevent.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \ |
125 | lj_str.h lj_tab.h lj_state.h lj_dispatch.h lj_bc.h lj_jit.h lj_ir.h \ | 125 | lj_str.h lj_tab.h lj_state.h lj_dispatch.h lj_jit.h lj_ir.h lj_vm.h \ |
126 | lj_vm.h lj_vmevent.h | 126 | lj_vmevent.h |
127 | ljamalg.o: ljamalg.c lua.h luaconf.h lauxlib.h lj_gc.c lj_obj.h lj_def.h \ | 127 | ljamalg.o: ljamalg.c lua.h luaconf.h lauxlib.h lj_gc.c lj_obj.h lj_def.h \ |
128 | lj_arch.h lj_gc.h lj_err.h lj_errmsg.h lj_str.h lj_tab.h lj_func.h \ | 128 | lj_arch.h lj_gc.h lj_err.h lj_errmsg.h lj_str.h lj_tab.h lj_func.h \ |
129 | lj_udata.h lj_meta.h lj_state.h lj_frame.h lj_bc.h lj_trace.h lj_jit.h \ | 129 | lj_udata.h lj_meta.h lj_state.h lj_frame.h lj_bc.h lj_trace.h lj_jit.h \ |
diff --git a/src/buildvm_x64.h b/src/buildvm_x64.h index ef507af1..95af6a6c 100644 --- a/src/buildvm_x64.h +++ b/src/buildvm_x64.h | |||
@@ -1063,7 +1063,7 @@ static void build_subroutines(BuildCtx *ctx, int cmov, int sse) | |||
1063 | dasm_put(Dst, 1461, Dt1(->base), Dt1(->base), Dt1(->top), FRAME_CONT, Dt7(->gate), Dt1(->base), Dt1(->base)); | 1063 | dasm_put(Dst, 1461, Dt1(->base), Dt1(->base), Dt1(->top), FRAME_CONT, Dt7(->gate), Dt1(->base), Dt1(->base)); |
1064 | dasm_put(Dst, 1656, -BCBIAS_J*4, LJ_TISTRUECOND, LJ_TISTRUECOND, Dt1(->base)); | 1064 | dasm_put(Dst, 1656, -BCBIAS_J*4, LJ_TISTRUECOND, LJ_TISTRUECOND, Dt1(->base)); |
1065 | dasm_put(Dst, 1764, Dt1(->base), Dt1(->base), FRAME_CONT, LJ_TFUNC); | 1065 | dasm_put(Dst, 1764, Dt1(->base), Dt1(->base), FRAME_CONT, LJ_TFUNC); |
1066 | dasm_put(Dst, 1887, Dt7(->gate), Dt1(->base), Dt1(->base), Dt1(->base), Dt1(->base), Dt7(->gate), Dt1(->base), Dt1(->base), GG_DISP_STATIC*8, 1+1); | 1066 | dasm_put(Dst, 1887, Dt7(->gate), Dt1(->base), Dt1(->base), Dt1(->base), Dt1(->base), Dt7(->gate), Dt1(->base), Dt1(->base), BC__MAX*8, 1+1); |
1067 | dasm_put(Dst, 2042, LJ_TISTRUECOND, 1+1, ~LJ_TNUMX); | 1067 | dasm_put(Dst, 2042, LJ_TISTRUECOND, 1+1, ~LJ_TNUMX); |
1068 | if (cmov) { | 1068 | if (cmov) { |
1069 | dasm_put(Dst, 2136); | 1069 | dasm_put(Dst, 2136); |
@@ -1346,7 +1346,7 @@ static void build_subroutines(BuildCtx *ctx, int cmov, int sse) | |||
1346 | dasm_put(Dst, 7442, DISPATCH_GL(hookmask), HOOK_VMEVENT, HOOK_ACTIVE, LUA_MASKLINE|LUA_MASKCOUNT, DISPATCH_GL(hookcount)); | 1346 | dasm_put(Dst, 7442, DISPATCH_GL(hookmask), HOOK_VMEVENT, HOOK_ACTIVE, LUA_MASKLINE|LUA_MASKCOUNT, DISPATCH_GL(hookcount)); |
1347 | #endif | 1347 | #endif |
1348 | dasm_put(Dst, 7475, DISPATCH_GL(hookmask), HOOK_ACTIVE, LUA_MASKLINE|LUA_MASKCOUNT, DISPATCH_GL(hookcount), LUA_MASKLINE, Dt1(->base), Dt1(->base)); | 1348 | dasm_put(Dst, 7475, DISPATCH_GL(hookmask), HOOK_ACTIVE, LUA_MASKLINE|LUA_MASKCOUNT, DISPATCH_GL(hookcount), LUA_MASKLINE, Dt1(->base), Dt1(->base)); |
1349 | dasm_put(Dst, 7542, GG_DISP_STATIC*8); | 1349 | dasm_put(Dst, 7542, BC__MAX*8); |
1350 | #if LJ_HASJIT | 1350 | #if LJ_HASJIT |
1351 | dasm_put(Dst, 7579); | 1351 | dasm_put(Dst, 7579); |
1352 | #endif | 1352 | #endif |
diff --git a/src/buildvm_x64win.h b/src/buildvm_x64win.h index d4db201c..94d0641f 100644 --- a/src/buildvm_x64win.h +++ b/src/buildvm_x64win.h | |||
@@ -1060,7 +1060,7 @@ static void build_subroutines(BuildCtx *ctx, int cmov, int sse) | |||
1060 | dasm_put(Dst, 1419, Dt1(->base), Dt1(->base), Dt1(->top), FRAME_CONT, Dt7(->gate), Dt1(->base), Dt1(->base)); | 1060 | dasm_put(Dst, 1419, Dt1(->base), Dt1(->base), Dt1(->top), FRAME_CONT, Dt7(->gate), Dt1(->base), Dt1(->base)); |
1061 | dasm_put(Dst, 1615, -BCBIAS_J*4, LJ_TISTRUECOND, LJ_TISTRUECOND, Dt1(->base)); | 1061 | dasm_put(Dst, 1615, -BCBIAS_J*4, LJ_TISTRUECOND, LJ_TISTRUECOND, Dt1(->base)); |
1062 | dasm_put(Dst, 1724, Dt1(->base), Dt1(->base), FRAME_CONT, LJ_TFUNC); | 1062 | dasm_put(Dst, 1724, Dt1(->base), Dt1(->base), FRAME_CONT, LJ_TFUNC); |
1063 | dasm_put(Dst, 1849, Dt7(->gate), Dt1(->base), Dt1(->base), Dt1(->base), Dt1(->base), Dt7(->gate), Dt1(->base), Dt1(->base), GG_DISP_STATIC*8, 1+1); | 1063 | dasm_put(Dst, 1849, Dt7(->gate), Dt1(->base), Dt1(->base), Dt1(->base), Dt1(->base), Dt7(->gate), Dt1(->base), Dt1(->base), BC__MAX*8, 1+1); |
1064 | dasm_put(Dst, 2005, LJ_TISTRUECOND, 1+1, ~LJ_TNUMX); | 1064 | dasm_put(Dst, 2005, LJ_TISTRUECOND, 1+1, ~LJ_TNUMX); |
1065 | if (cmov) { | 1065 | if (cmov) { |
1066 | dasm_put(Dst, 2101); | 1066 | dasm_put(Dst, 2101); |
@@ -1343,7 +1343,7 @@ static void build_subroutines(BuildCtx *ctx, int cmov, int sse) | |||
1343 | dasm_put(Dst, 7419, DISPATCH_GL(hookmask), HOOK_VMEVENT, HOOK_ACTIVE, LUA_MASKLINE|LUA_MASKCOUNT, DISPATCH_GL(hookcount)); | 1343 | dasm_put(Dst, 7419, DISPATCH_GL(hookmask), HOOK_VMEVENT, HOOK_ACTIVE, LUA_MASKLINE|LUA_MASKCOUNT, DISPATCH_GL(hookcount)); |
1344 | #endif | 1344 | #endif |
1345 | dasm_put(Dst, 7450, DISPATCH_GL(hookmask), HOOK_ACTIVE, LUA_MASKLINE|LUA_MASKCOUNT, DISPATCH_GL(hookcount), LUA_MASKLINE, Dt1(->base), Dt1(->base)); | 1345 | dasm_put(Dst, 7450, DISPATCH_GL(hookmask), HOOK_ACTIVE, LUA_MASKLINE|LUA_MASKCOUNT, DISPATCH_GL(hookcount), LUA_MASKLINE, Dt1(->base), Dt1(->base)); |
1346 | dasm_put(Dst, 7516, GG_DISP_STATIC*8); | 1346 | dasm_put(Dst, 7516, BC__MAX*8); |
1347 | #if LJ_HASJIT | 1347 | #if LJ_HASJIT |
1348 | dasm_put(Dst, 7552); | 1348 | dasm_put(Dst, 7552); |
1349 | #endif | 1349 | #endif |
diff --git a/src/buildvm_x86.dasc b/src/buildvm_x86.dasc index 10899e70..fdbefb83 100644 --- a/src/buildvm_x86.dasc +++ b/src/buildvm_x86.dasc | |||
@@ -1271,9 +1271,9 @@ static void build_subroutines(BuildCtx *ctx, int cmov, int sse) | |||
1271 | | movzx OP, RCL | 1271 | | movzx OP, RCL |
1272 | | shr RC, 16 | 1272 | | shr RC, 16 |
1273 | |.if X64 | 1273 | |.if X64 |
1274 | | jmp aword [DISPATCH+OP*8+GG_DISP_STATIC*8] // Retry FORI or JFORI. | 1274 | | jmp aword [DISPATCH+OP*8+BC__MAX*8] // Retry FORI or JFORI. |
1275 | |.else | 1275 | |.else |
1276 | | jmp aword [DISPATCH+OP*4+GG_DISP_STATIC*4] // Retry FORI or JFORI. | 1276 | | jmp aword [DISPATCH+OP*4+BC__MAX*4] // Retry FORI or JFORI. |
1277 | |.endif | 1277 | |.endif |
1278 | | | 1278 | | |
1279 | |//----------------------------------------------------------------------- | 1279 | |//----------------------------------------------------------------------- |
@@ -2629,9 +2629,9 @@ static void build_subroutines(BuildCtx *ctx, int cmov, int sse) | |||
2629 | | movzx OP, PC_OP | 2629 | | movzx OP, PC_OP |
2630 | | movzx RD, PC_RD | 2630 | | movzx RD, PC_RD |
2631 | |.if X64 | 2631 | |.if X64 |
2632 | | jmp aword [DISPATCH+OP*8+GG_DISP_STATIC*8] // Re-dispatch to static ins. | 2632 | | jmp aword [DISPATCH+OP*8+BC__MAX*8] // Re-dispatch to static ins. |
2633 | |.else | 2633 | |.else |
2634 | | jmp aword [DISPATCH+OP*4+GG_DISP_STATIC*4] // Re-dispatch to static ins. | 2634 | | jmp aword [DISPATCH+OP*4+BC__MAX*4] // Re-dispatch to static ins. |
2635 | |.endif | 2635 | |.endif |
2636 | | | 2636 | | |
2637 | |->cont_hook: // Continue from hook yield. | 2637 | |->cont_hook: // Continue from hook yield. |
diff --git a/src/buildvm_x86.h b/src/buildvm_x86.h index 3741b60b..6fd8eb00 100644 --- a/src/buildvm_x86.h +++ b/src/buildvm_x86.h | |||
@@ -1140,7 +1140,7 @@ static void build_subroutines(BuildCtx *ctx, int cmov, int sse) | |||
1140 | dasm_put(Dst, 1393, Dt1(->base), Dt1(->base), Dt1(->top), FRAME_CONT, Dt7(->gate), Dt1(->base), Dt1(->base)); | 1140 | dasm_put(Dst, 1393, Dt1(->base), Dt1(->base), Dt1(->top), FRAME_CONT, Dt7(->gate), Dt1(->base), Dt1(->base)); |
1141 | dasm_put(Dst, 1600, -BCBIAS_J*4, LJ_TISTRUECOND, LJ_TISTRUECOND, Dt1(->base)); | 1141 | dasm_put(Dst, 1600, -BCBIAS_J*4, LJ_TISTRUECOND, LJ_TISTRUECOND, Dt1(->base)); |
1142 | dasm_put(Dst, 1711, Dt1(->base), Dt1(->base), FRAME_CONT, LJ_TFUNC); | 1142 | dasm_put(Dst, 1711, Dt1(->base), Dt1(->base), FRAME_CONT, LJ_TFUNC); |
1143 | dasm_put(Dst, 1840, Dt7(->gate), Dt1(->base), Dt1(->base), Dt1(->base), Dt1(->base), Dt7(->gate), Dt1(->base), Dt1(->base), GG_DISP_STATIC*4, 1+1); | 1143 | dasm_put(Dst, 1840, Dt7(->gate), Dt1(->base), Dt1(->base), Dt1(->base), Dt1(->base), Dt7(->gate), Dt1(->base), Dt1(->base), BC__MAX*4, 1+1); |
1144 | dasm_put(Dst, 2000, LJ_TISTRUECOND, 1+1, ~LJ_TNUMX); | 1144 | dasm_put(Dst, 2000, LJ_TISTRUECOND, 1+1, ~LJ_TNUMX); |
1145 | if (cmov) { | 1145 | if (cmov) { |
1146 | dasm_put(Dst, 2096); | 1146 | dasm_put(Dst, 2096); |
@@ -1458,7 +1458,7 @@ static void build_subroutines(BuildCtx *ctx, int cmov, int sse) | |||
1458 | dasm_put(Dst, 8406, DISPATCH_GL(hookmask), HOOK_VMEVENT, HOOK_ACTIVE, LUA_MASKLINE|LUA_MASKCOUNT, DISPATCH_GL(hookcount)); | 1458 | dasm_put(Dst, 8406, DISPATCH_GL(hookmask), HOOK_VMEVENT, HOOK_ACTIVE, LUA_MASKLINE|LUA_MASKCOUNT, DISPATCH_GL(hookcount)); |
1459 | #endif | 1459 | #endif |
1460 | dasm_put(Dst, 8437, DISPATCH_GL(hookmask), HOOK_ACTIVE, LUA_MASKLINE|LUA_MASKCOUNT, DISPATCH_GL(hookcount), LUA_MASKLINE, Dt1(->base), Dt1(->base)); | 1460 | dasm_put(Dst, 8437, DISPATCH_GL(hookmask), HOOK_ACTIVE, LUA_MASKLINE|LUA_MASKCOUNT, DISPATCH_GL(hookcount), LUA_MASKLINE, Dt1(->base), Dt1(->base)); |
1461 | dasm_put(Dst, 8503, GG_DISP_STATIC*4); | 1461 | dasm_put(Dst, 8503, BC__MAX*4); |
1462 | #if LJ_HASJIT | 1462 | #if LJ_HASJIT |
1463 | dasm_put(Dst, 8538, Dt1(->base), GG_DISP2J, DISPATCH_J(L)); | 1463 | dasm_put(Dst, 8538, Dt1(->base), GG_DISP2J, DISPATCH_J(L)); |
1464 | #endif | 1464 | #endif |
diff --git a/src/lib_jit.c b/src/lib_jit.c index fb551315..8fda41d0 100644 --- a/src/lib_jit.c +++ b/src/lib_jit.c | |||
@@ -15,6 +15,7 @@ | |||
15 | #include "lj_err.h" | 15 | #include "lj_err.h" |
16 | #include "lj_str.h" | 16 | #include "lj_str.h" |
17 | #include "lj_tab.h" | 17 | #include "lj_tab.h" |
18 | #include "lj_bc.h" | ||
18 | #if LJ_HASJIT | 19 | #if LJ_HASJIT |
19 | #include "lj_ir.h" | 20 | #include "lj_ir.h" |
20 | #include "lj_jit.h" | 21 | #include "lj_jit.h" |
diff --git a/src/lj_asm.c b/src/lj_asm.c index 55bc814e..3a2fee71 100644 --- a/src/lj_asm.c +++ b/src/lj_asm.c | |||
@@ -906,7 +906,7 @@ static MCode *asm_exitstub_gen(ASMState *as, ExitNo group) | |||
906 | *mxp++ = MODRM(XM_OFS8, 0, RID_ESP); | 906 | *mxp++ = MODRM(XM_OFS8, 0, RID_ESP); |
907 | *mxp++ = MODRM(XM_SCALE1, RID_ESP, RID_ESP); | 907 | *mxp++ = MODRM(XM_SCALE1, RID_ESP, RID_ESP); |
908 | *mxp++ = 2*sizeof(void *); | 908 | *mxp++ = 2*sizeof(void *); |
909 | *(int32_t *)mxp = ptr2addr(J2GG(as->J)->dispatch); mxp += 4; | 909 | *(int32_t *)mxp = ptr2addr(GG2DISP(J2GG(as->J))); mxp += 4; |
910 | /* Jump to exit handler which fills in the ExitState. */ | 910 | /* Jump to exit handler which fills in the ExitState. */ |
911 | *mxp++ = XI_JMP; mxp += 4; | 911 | *mxp++ = XI_JMP; mxp += 4; |
912 | *((int32_t *)(mxp-4)) = (int32_t)((MCode *)lj_vm_exit_handler - mxp); | 912 | *((int32_t *)(mxp-4)) = (int32_t)((MCode *)lj_vm_exit_handler - mxp); |
@@ -3066,7 +3066,7 @@ static void asm_tail_sync(ASMState *as) | |||
3066 | 3066 | ||
3067 | if (as->T->link == TRACE_INTERP) { | 3067 | if (as->T->link == TRACE_INTERP) { |
3068 | /* Setup fixed registers for exit to interpreter. */ | 3068 | /* Setup fixed registers for exit to interpreter. */ |
3069 | emit_loada(as, RID_DISPATCH, J2GG(as->J)->dispatch); | 3069 | emit_loada(as, RID_DISPATCH, GG2DISP(J2GG(as->J))); |
3070 | emit_loadi(as, RID_PC, (int32_t)map[nent]); | 3070 | emit_loadi(as, RID_PC, (int32_t)map[nent]); |
3071 | } else if (newbase) { | 3071 | } else if (newbase) { |
3072 | /* Save modified BASE for linking to trace with higher start frame. */ | 3072 | /* Save modified BASE for linking to trace with higher start frame. */ |
diff --git a/src/lj_dispatch.c b/src/lj_dispatch.c index e2605e96..54cc9006 100644 --- a/src/lj_dispatch.c +++ b/src/lj_dispatch.c | |||
@@ -19,13 +19,15 @@ | |||
19 | #include "lj_vm.h" | 19 | #include "lj_vm.h" |
20 | #include "luajit.h" | 20 | #include "luajit.h" |
21 | 21 | ||
22 | #define GG_DISP_STATIC BC__MAX | ||
23 | |||
22 | /* -- Dispatch table management ------------------------------------------- */ | 24 | /* -- Dispatch table management ------------------------------------------- */ |
23 | 25 | ||
24 | /* Initialize instruction dispatch table and hot counters. */ | 26 | /* Initialize instruction dispatch table and hot counters. */ |
25 | void lj_dispatch_init(GG_State *GG) | 27 | void lj_dispatch_init(GG_State *GG) |
26 | { | 28 | { |
27 | uint32_t i; | 29 | uint32_t i; |
28 | ASMFunction *disp = GG->dispatch; | 30 | ASMFunction *disp = GG2DISP(GG); |
29 | for (i = 0; i < BC__MAX; i++) | 31 | for (i = 0; i < BC__MAX; i++) |
30 | disp[GG_DISP_STATIC+i] = disp[i] = makeasmfunc(lj_bc_ofs[i]); | 32 | disp[GG_DISP_STATIC+i] = disp[i] = makeasmfunc(lj_bc_ofs[i]); |
31 | /* The JIT engine is off by default. luaopen_jit() turns it on. */ | 33 | /* The JIT engine is off by default. luaopen_jit() turns it on. */ |
@@ -57,7 +59,7 @@ void lj_dispatch_update(global_State *g) | |||
57 | #endif | 59 | #endif |
58 | mode |= (g->hookmask & HOOK_EVENTMASK) ? 2 : 0; | 60 | mode |= (g->hookmask & HOOK_EVENTMASK) ? 2 : 0; |
59 | if (oldmode != mode) { /* Mode changed? */ | 61 | if (oldmode != mode) { /* Mode changed? */ |
60 | ASMFunction *disp = G2GG(g)->dispatch; | 62 | ASMFunction *disp = GG2DISP(G2GG(g)); |
61 | ASMFunction f_forl, f_iterl, f_loop; | 63 | ASMFunction f_forl, f_iterl, f_loop; |
62 | g->dispatchmode = mode; | 64 | g->dispatchmode = mode; |
63 | if ((mode & 5) == 1) { /* Hotcount if JIT is on, but not when recording. */ | 65 | if ((mode & 5) == 1) { /* Hotcount if JIT is on, but not when recording. */ |
diff --git a/src/lj_dispatch.h b/src/lj_dispatch.h index cb5e5f64..bbbfa0be 100644 --- a/src/lj_dispatch.h +++ b/src/lj_dispatch.h | |||
@@ -7,7 +7,6 @@ | |||
7 | #define _LJ_DISPATCH_H | 7 | #define _LJ_DISPATCH_H |
8 | 8 | ||
9 | #include "lj_obj.h" | 9 | #include "lj_obj.h" |
10 | #include "lj_bc.h" | ||
11 | #if LJ_HASJIT | 10 | #if LJ_HASJIT |
12 | #include "lj_jit.h" | 11 | #include "lj_jit.h" |
13 | #endif | 12 | #endif |
@@ -30,24 +29,22 @@ typedef struct GG_State { | |||
30 | jit_State J; /* JIT state. */ | 29 | jit_State J; /* JIT state. */ |
31 | HotCount hotcount[HOTCOUNT_SIZE]; /* Hot counters. */ | 30 | HotCount hotcount[HOTCOUNT_SIZE]; /* Hot counters. */ |
32 | #endif | 31 | #endif |
33 | ASMFunction dispatch[2*BC__MAX]; /* Instruction dispatch tables. */ | 32 | /* Instruction dispatch tables follow. */ |
34 | } GG_State; | 33 | } GG_State; |
35 | 34 | ||
36 | #define GG_DISP_STATIC BC__MAX | ||
37 | |||
38 | #define GG_OFS(field) ((int)offsetof(GG_State, field)) | 35 | #define GG_OFS(field) ((int)offsetof(GG_State, field)) |
39 | #define G2GG(gl) \ | 36 | #define GG_OFS_DISP ((int)sizeof(GG_State)) |
40 | ((GG_State *)(((char *)(gl))-((char *)(&((GG_State *)0)->g)))) | 37 | #define GG2DISP(gg) ((ASMFunction *)((char *)(gg) + GG_OFS_DISP)) |
41 | #define J2GG(j) \ | 38 | #define G2GG(gl) ((GG_State *)((char *)(gl) - GG_OFS(g))) |
42 | ((GG_State *)(((char *)(j))-((char *)(&((GG_State *)0)->J)))) | 39 | #define J2GG(j) ((GG_State *)((char *)(j) - GG_OFS(J))) |
43 | #define L2GG(L) G2GG(G(L)) | 40 | #define L2GG(L) (G2GG(G(L))) |
44 | #define J2G(J) (&J2GG(J)->g) | 41 | #define J2G(J) (&J2GG(J)->g) |
45 | #define G2J(gl) (&G2GG(gl)->J) | 42 | #define G2J(gl) (&G2GG(gl)->J) |
46 | #define L2J(L) (&L2GG(L)->J) | 43 | #define L2J(L) (&L2GG(L)->J) |
47 | #define GG_G2DISP (GG_OFS(dispatch) - GG_OFS(g)) | 44 | #define GG_G2DISP (GG_OFS_DISP - GG_OFS(g)) |
48 | #define GG_DISP2G (GG_OFS(g) - GG_OFS(dispatch)) | 45 | #define GG_DISP2G (GG_OFS(g) - GG_OFS_DISP) |
49 | #define GG_DISP2J (GG_OFS(J) - GG_OFS(dispatch)) | 46 | #define GG_DISP2J (GG_OFS(J) - GG_OFS_DISP) |
50 | #define GG_DISP2HOT (GG_OFS(hotcount) - GG_OFS(dispatch)) | 47 | #define GG_DISP2HOT (GG_OFS(hotcount) - GG_OFS_DISP) |
51 | 48 | ||
52 | #define hotcount_get(gg, pc) \ | 49 | #define hotcount_get(gg, pc) \ |
53 | (gg)->hotcount[(u32ptr(pc)>>2) & (HOTCOUNT_SIZE-1)] | 50 | (gg)->hotcount[(u32ptr(pc)>>2) & (HOTCOUNT_SIZE-1)] |
diff --git a/src/lj_state.c b/src/lj_state.c index 7c8e9c96..69f182ed 100644 --- a/src/lj_state.c +++ b/src/lj_state.c | |||
@@ -119,6 +119,8 @@ static void stack_init(lua_State *L1, lua_State *L) | |||
119 | 119 | ||
120 | /* -- State handling ------------------------------------------------------ */ | 120 | /* -- State handling ------------------------------------------------------ */ |
121 | 121 | ||
122 | #define GG_SIZE (sizeof(GG_State)+(BC__MAX*2)*sizeof(ASMFunction)) | ||
123 | |||
122 | /* Open parts that may cause memory-allocation errors. */ | 124 | /* Open parts that may cause memory-allocation errors. */ |
123 | static TValue *cpluaopen(lua_State *L, lua_CFunction dummy, void *ud) | 125 | static TValue *cpluaopen(lua_State *L, lua_CFunction dummy, void *ud) |
124 | { | 126 | { |
@@ -154,8 +156,8 @@ static void close_state(lua_State *L) | |||
154 | lj_mem_freevec(g, g->strhash, g->strmask+1, GCRef); | 156 | lj_mem_freevec(g, g->strhash, g->strmask+1, GCRef); |
155 | lj_str_freebuf(g, &g->tmpbuf); | 157 | lj_str_freebuf(g, &g->tmpbuf); |
156 | lj_mem_freevec(g, L->stack, L->stacksize, TValue); | 158 | lj_mem_freevec(g, L->stack, L->stacksize, TValue); |
157 | lua_assert(g->gc.total == sizeof(GG_State)); | 159 | lua_assert(g->gc.total == GG_SIZE); |
158 | g->allocf(g->allocd, G2GG(g), sizeof(GG_State), 0); | 160 | g->allocf(g->allocd, G2GG(g), GG_SIZE, 0); |
159 | } | 161 | } |
160 | } | 162 | } |
161 | 163 | ||
@@ -165,7 +167,7 @@ lua_State *lj_state_newstate(lua_Alloc f, void *ud) | |||
165 | LUA_API lua_State *lua_newstate(lua_Alloc f, void *ud) | 167 | LUA_API lua_State *lua_newstate(lua_Alloc f, void *ud) |
166 | #endif | 168 | #endif |
167 | { | 169 | { |
168 | GG_State *GG = cast(GG_State *, f(ud, NULL, 0, sizeof(GG_State))); | 170 | GG_State *GG = cast(GG_State *, f(ud, NULL, 0, GG_SIZE)); |
169 | lua_State *L = &GG->L; | 171 | lua_State *L = &GG->L; |
170 | global_State *g = &GG->g; | 172 | global_State *g = &GG->g; |
171 | if (GG == NULL || !checkptr32(GG)) return NULL; | 173 | if (GG == NULL || !checkptr32(GG)) return NULL; |
@@ -188,7 +190,7 @@ LUA_API lua_State *lua_newstate(lua_Alloc f, void *ud) | |||
188 | g->gc.state = GCSpause; | 190 | g->gc.state = GCSpause; |
189 | setgcref(g->gc.root, obj2gco(L)); | 191 | setgcref(g->gc.root, obj2gco(L)); |
190 | g->gc.sweep = &g->gc.root; | 192 | g->gc.sweep = &g->gc.root; |
191 | g->gc.total = sizeof(GG_State); | 193 | g->gc.total = GG_SIZE; |
192 | g->gc.pause = LUAI_GCPAUSE; | 194 | g->gc.pause = LUAI_GCPAUSE; |
193 | g->gc.stepmul = LUAI_GCMUL; | 195 | g->gc.stepmul = LUAI_GCMUL; |
194 | lj_dispatch_init((GG_State *)L); | 196 | lj_dispatch_init((GG_State *)L); |