From e182ae84a17aafd1545c7549560fd8da467741d8 Mon Sep 17 00:00:00 2001 From: Luke Gorrie Date: Sun, 5 Nov 2017 09:02:34 +0000 Subject: [PATCH 1/2] Add jit.tracebarrier() primitive Create an execution barrier that a JIT trace cannot cross. During recording, the current trace must end when it reaches a barrier and then a new root trace starts immediately afterwards. This is implemented as a simple "nop" C library function. The existing "trace stitching" mechanism provides the required semantics i.e. stop current trace, call nop function, start new trace with linkage. --- src/lib_jit.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/lib_jit.c b/src/lib_jit.c index 7411328970..fdd99fd325 100644 --- a/src/lib_jit.c +++ b/src/lib_jit.c @@ -99,6 +99,12 @@ LJLIB_CF(jit_status) return (int)(L->top - L->base); } +/* Calling this forces a trace stitch. */ +LJLIB_CF(jit_tracebarrier) +{ + return 0; +} + LJLIB_PUSH(top-5) LJLIB_SET(os) LJLIB_PUSH(top-4) LJLIB_SET(arch) LJLIB_PUSH(top-3) LJLIB_SET(version_num) From 0be85c638ea341e6ab2ecae4e6f4bb3a84931918 Mon Sep 17 00:00:00 2001 From: Luke Gorrie Date: Tue, 7 Nov 2017 10:01:40 +0000 Subject: [PATCH 2/2] src/reusevm: update generated files --- src/reusevm/lj_ffdef.h | 1 + src/reusevm/lj_libdef.h | 23 ++++++++++++----------- src/reusevm/lj_recdef.h | 1 + 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/src/reusevm/lj_ffdef.h b/src/reusevm/lj_ffdef.h index 64107959dd..ffd183b9ca 100644 --- a/src/reusevm/lj_ffdef.h +++ b/src/reusevm/lj_ffdef.h @@ -145,6 +145,7 @@ FFDEF(jit_on) FFDEF(jit_off) FFDEF(jit_flush) FFDEF(jit_status) +FFDEF(jit_tracebarrier) FFDEF(jit_opt_start) FFDEF(jit_vmprofile_open) FFDEF(jit_vmprofile_close) diff --git a/src/reusevm/lj_libdef.h b/src/reusevm/lj_libdef.h index cc5bd1f812..862dc6e0bf 100644 --- a/src/reusevm/lj_libdef.h +++ b/src/reusevm/lj_libdef.h @@ -271,13 +271,14 @@ static const lua_CFunction lj_lib_cf_jit[] = { lj_cf_jit_on, lj_cf_jit_off, lj_cf_jit_flush, - lj_cf_jit_status + lj_cf_jit_status, + lj_cf_jit_tracebarrier }; static const uint8_t lj_lib_init_jit[] = { -143,57,8,2,111,110,3,111,102,102,5,102,108,117,115,104,6,115,116,97,116,117, -115,252,5,194,111,115,250,252,4,196,97,114,99,104,250,252,3,203,118,101,114, -115,105,111,110,95,110,117,109,250,252,2,199,118,101,114,115,105,111,110,250, -255 +143,57,9,2,111,110,3,111,102,102,5,102,108,117,115,104,6,115,116,97,116,117, +115,12,116,114,97,99,101,98,97,114,114,105,101,114,252,5,194,111,115,250,252, +4,196,97,114,99,104,250,252,3,203,118,101,114,115,105,111,110,95,110,117,109, +250,252,2,199,118,101,114,115,105,111,110,250,255 }; #endif @@ -287,7 +288,7 @@ static const lua_CFunction lj_lib_cf_jit_opt[] = { lj_cf_jit_opt_start }; static const uint8_t lj_lib_init_jit_opt[] = { -147,57,1,5,115,116,97,114,116,255 +148,57,1,5,115,116,97,114,116,255 }; #endif @@ -301,7 +302,7 @@ static const lua_CFunction lj_lib_cf_jit_vmprofile[] = { lj_cf_jit_vmprofile_stop }; static const uint8_t lj_lib_init_jit_vmprofile[] = { -148,57,5,4,111,112,101,110,5,99,108,111,115,101,6,115,101,108,101,99,116,5, +149,57,5,4,111,112,101,110,5,99,108,111,115,101,6,115,101,108,101,99,116,5, 115,116,97,114,116,4,115,116,111,112,255 }; #endif @@ -329,7 +330,7 @@ static const lua_CFunction lj_lib_cf_ffi_meta[] = { lj_cf_ffi_meta___ipairs }; static const uint8_t lj_lib_init_ffi_meta[] = { -153,57,19,7,95,95,105,110,100,101,120,10,95,95,110,101,119,105,110,100,101, +154,57,19,7,95,95,105,110,100,101,120,10,95,95,110,101,119,105,110,100,101, 120,4,95,95,101,113,5,95,95,108,101,110,4,95,95,108,116,4,95,95,108,101,8,95, 95,99,111,110,99,97,116,6,95,95,99,97,108,108,5,95,95,97,100,100,5,95,95,115, 117,98,5,95,95,109,117,108,5,95,95,100,105,118,5,95,95,109,111,100,5,95,95, @@ -347,7 +348,7 @@ static const lua_CFunction lj_lib_cf_ffi_clib[] = { lj_cf_ffi_clib___gc }; static const uint8_t lj_lib_init_ffi_clib[] = { -171,57,3,7,95,95,105,110,100,101,120,10,95,95,110,101,119,105,110,100,101,120, +172,57,3,7,95,95,105,110,100,101,120,10,95,95,110,101,119,105,110,100,101,120, 4,95,95,103,99,255 }; #endif @@ -359,7 +360,7 @@ static const lua_CFunction lj_lib_cf_ffi_callback[] = { lj_cf_ffi_callback_set }; static const uint8_t lj_lib_init_ffi_callback[] = { -174,57,3,4,102,114,101,101,3,115,101,116,252,1,199,95,95,105,110,100,101,120, +175,57,3,4,102,114,101,101,3,115,101,116,252,1,199,95,95,105,110,100,101,120, 250,255 }; #endif @@ -386,7 +387,7 @@ static const lua_CFunction lj_lib_cf_ffi[] = { lj_cf_ffi_load }; static const uint8_t lj_lib_init_ffi[] = { -176,57,23,4,99,100,101,102,3,110,101,119,4,99,97,115,116,6,116,121,112,101, +177,57,23,4,99,100,101,102,3,110,101,119,4,99,97,115,116,6,116,121,112,101, 111,102,8,116,121,112,101,105,110,102,111,6,105,115,116,121,112,101,6,115,105, 122,101,111,102,7,97,108,105,103,110,111,102,8,111,102,102,115,101,116,111, 102,5,101,114,114,110,111,6,115,116,114,105,110,103,4,99,111,112,121,4,102, diff --git a/src/reusevm/lj_recdef.h b/src/reusevm/lj_recdef.h index 312ff199e9..436754f308 100644 --- a/src/reusevm/lj_recdef.h +++ b/src/reusevm/lj_recdef.h @@ -154,6 +154,7 @@ static const uint16_t recff_idmap[] = { 0, 0, 0, +0, 0x2f00+(0), 0x2f00+(1), 0x3000+(MM_eq),