From d095eae73e6a13dc8b06672d0d98a6221df7b6c7 Mon Sep 17 00:00:00 2001 From: Luke Gorrie Date: Fri, 28 Jul 2017 09:25:28 +0000 Subject: [PATCH 1/7] raptorjit.nix: Fix executable name / broken build --- raptorjit.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/raptorjit.nix b/raptorjit.nix index 152a62e089..dbe7d9c918 100644 --- a/raptorjit.nix +++ b/raptorjit.nix @@ -12,7 +12,7 @@ mkDerivation rec { buildInputs = [ luajit ]; # LuaJIT to bootstrap DynASM installPhase = '' mkdir -p $out/bin - cp src/luajit $out/bin/raptorjit + cp src/raptorjit $out/bin/raptorjit ''; enableParallelBuilding = true; # Do 'make -j' From 8ec77f9879c23b3b348e65b71c26caf9767db2eb Mon Sep 17 00:00:00 2001 From: Luke Gorrie Date: Fri, 28 Jul 2017 09:31:43 +0000 Subject: [PATCH 2/7] .travis.yml: Update Travis-CI config (was not testing) --- .travis.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 25ac9051de..f1f11bbc22 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,10 +1,8 @@ language: nix sudo: false -env: +script: - nix-build -A test-O3 - nix-build -A test-O2 - nix-build -A test-O1 - nix-build -A test-nojit - nix-build -A check-generated-code --arg check true -script: - - $test From 076d161ebf3cf6bf8c16b8ec32244655df9a173c Mon Sep 17 00:00:00 2001 From: Luke Gorrie Date: Fri, 28 Jul 2017 09:40:42 +0000 Subject: [PATCH 3/7] check-generated-code.nix: Fixed --- check-generated-code.nix | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/check-generated-code.nix b/check-generated-code.nix index a408a44b69..a6413c6c2d 100644 --- a/check-generated-code.nix +++ b/check-generated-code.nix @@ -9,23 +9,10 @@ in overrideDerivation raptorjit (as: { - preBuild = '' - pushd src - mkdir old - for f in ${generatedFiles}; do - cp $f old/ - done - popd - '' + as.preBuild; checkPhase = '' - pushd src - mkdir new for f in ${generatedFiles}; do - cp $f new/ + diff -u src/$f src/reusevm/$f done - echo "Checking that in-tree generated VM code is up-to-date..." - diff -u old new || (echo "Error: Stale generated code"; exit 1) - popd ''; doCheck = true; }) From d27d4d4fce93dfd76b290e6a9f70c9c8e00a7b01 Mon Sep 17 00:00:00 2001 From: Luke Gorrie Date: Fri, 28 Jul 2017 09:44:27 +0000 Subject: [PATCH 4/7] check-generated-code.nix: Tweak order of diff args --- check-generated-code.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/check-generated-code.nix b/check-generated-code.nix index a6413c6c2d..46efe67f84 100644 --- a/check-generated-code.nix +++ b/check-generated-code.nix @@ -11,7 +11,7 @@ overrideDerivation raptorjit (as: { checkPhase = '' for f in ${generatedFiles}; do - diff -u src/$f src/reusevm/$f + diff -u src/reusevm/$f src/$f done ''; doCheck = true; From 300d14e74ad326312434d29b1ec3931868f78f57 Mon Sep 17 00:00:00 2001 From: Luke Gorrie Date: Fri, 28 Jul 2017 09:48:50 +0000 Subject: [PATCH 5/7] reusevm: Updated generated code --- src/reusevm/lj_ffdef.h | 5 +++++ src/reusevm/lj_libdef.h | 23 +++++++++++++++++++---- src/reusevm/lj_recdef.h | 5 +++++ 3 files changed, 29 insertions(+), 4 deletions(-) diff --git a/src/reusevm/lj_ffdef.h b/src/reusevm/lj_ffdef.h index d4d09cb0e1..64107959dd 100644 --- a/src/reusevm/lj_ffdef.h +++ b/src/reusevm/lj_ffdef.h @@ -146,6 +146,11 @@ FFDEF(jit_off) FFDEF(jit_flush) FFDEF(jit_status) FFDEF(jit_opt_start) +FFDEF(jit_vmprofile_open) +FFDEF(jit_vmprofile_close) +FFDEF(jit_vmprofile_select) +FFDEF(jit_vmprofile_start) +FFDEF(jit_vmprofile_stop) FFDEF(ffi_meta___index) FFDEF(ffi_meta___newindex) FFDEF(ffi_meta___eq) diff --git a/src/reusevm/lj_libdef.h b/src/reusevm/lj_libdef.h index 0cdd586855..cc5bd1f812 100644 --- a/src/reusevm/lj_libdef.h +++ b/src/reusevm/lj_libdef.h @@ -291,6 +291,21 @@ static const uint8_t lj_lib_init_jit_opt[] = { }; #endif +#ifdef LJLIB_MODULE_jit_vmprofile +#undef LJLIB_MODULE_jit_vmprofile +static const lua_CFunction lj_lib_cf_jit_vmprofile[] = { + lj_cf_jit_vmprofile_open, + lj_cf_jit_vmprofile_close, + lj_cf_jit_vmprofile_select, + lj_cf_jit_vmprofile_start, + 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, +115,116,97,114,116,4,115,116,111,112,255 +}; +#endif + #ifdef LJLIB_MODULE_ffi_meta #undef LJLIB_MODULE_ffi_meta static const lua_CFunction lj_lib_cf_ffi_meta[] = { @@ -314,7 +329,7 @@ static const lua_CFunction lj_lib_cf_ffi_meta[] = { lj_cf_ffi_meta___ipairs }; static const uint8_t lj_lib_init_ffi_meta[] = { -148,57,19,7,95,95,105,110,100,101,120,10,95,95,110,101,119,105,110,100,101, +153,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, @@ -332,7 +347,7 @@ static const lua_CFunction lj_lib_cf_ffi_clib[] = { lj_cf_ffi_clib___gc }; static const uint8_t lj_lib_init_ffi_clib[] = { -166,57,3,7,95,95,105,110,100,101,120,10,95,95,110,101,119,105,110,100,101,120, +171,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 @@ -344,7 +359,7 @@ static const lua_CFunction lj_lib_cf_ffi_callback[] = { lj_cf_ffi_callback_set }; static const uint8_t lj_lib_init_ffi_callback[] = { -169,57,3,4,102,114,101,101,3,115,101,116,252,1,199,95,95,105,110,100,101,120, +174,57,3,4,102,114,101,101,3,115,101,116,252,1,199,95,95,105,110,100,101,120, 250,255 }; #endif @@ -371,7 +386,7 @@ static const lua_CFunction lj_lib_cf_ffi[] = { lj_cf_ffi_load }; static const uint8_t lj_lib_init_ffi[] = { -171,57,23,4,99,100,101,102,3,110,101,119,4,99,97,115,116,6,116,121,112,101, +176,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 4e2e6fc256..312ff199e9 100644 --- a/src/reusevm/lj_recdef.h +++ b/src/reusevm/lj_recdef.h @@ -149,6 +149,11 @@ static const uint16_t recff_idmap[] = { 0, 0, 0, +0, +0, +0, +0, +0, 0x2f00+(0), 0x2f00+(1), 0x3000+(MM_eq), From 4aaa844b8b749d9fe55727dc47224d972c60ea40 Mon Sep 17 00:00:00 2001 From: Luke Gorrie Date: Fri, 28 Jul 2017 10:01:18 +0000 Subject: [PATCH 6/7] lj_jit.h: Save 'parent' and 'exitno' fields in GCtrace For debugging purposes it is very useful to be able to refer to the origin of a trace (parent/exit) and so this change stores that information persistently in GCtrace instead of only ephemerally in jit_State. These fields are now duplicated in jit_State (valid while recording) and GCtrace (valid after recording.) This duplication could be avoided by putting them only in GCtrace and accessing them via J->cur but this would be a more noisy change since the existing fields are accessed from many places including DynASM macros. --- src/lj_jit.h | 2 ++ src/lj_trace.c | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/lj_jit.h b/src/lj_jit.h index b3408e9bb2..8a522973bb 100644 --- a/src/lj_jit.h +++ b/src/lj_jit.h @@ -199,6 +199,8 @@ typedef struct GCtrace { TraceNo1 root; /* Root trace of side trace (or 0 for root traces). */ TraceNo1 nextroot; /* Next root trace for same prototype. */ TraceNo1 nextside; /* Next side trace of same root trace. */ + TraceNo1 parent; /* Parent of this trace (or 0 for root traces). */ + ExitNo exitno; /* Exit number in parent (valid for side-traces only). */ uint8_t sinktags; /* Trace has SINK tags. */ uint8_t unused1; } GCtrace; diff --git a/src/lj_trace.c b/src/lj_trace.c index 0b674ec276..99c49fa0a9 100644 --- a/src/lj_trace.c +++ b/src/lj_trace.c @@ -109,6 +109,8 @@ static void trace_save(jit_State *J, GCtrace *T) size_t szins = (J->cur.nins-J->cur.nk)*sizeof(IRIns); char *p = (char *)T + sztr; memcpy(T, &J->cur, sizeof(GCtrace)); + T->parent = J->parent; + T->exitno = J->exitno; setgcrefr(T->nextgc, J2G(J)->gc.root); setgcrefp(J2G(J)->gc.root, T); newwhite(J2G(J), T); From fcf7053ddd8da467b90038f499cc8eb21e75c672 Mon Sep 17 00:00:00 2001 From: Luke Gorrie Date: Fri, 28 Jul 2017 10:23:51 +0000 Subject: [PATCH 7/7] check-generated-code.nix: Add more verbosity Just to be clear about what is actually being checked. --- check-generated-code.nix | 2 ++ 1 file changed, 2 insertions(+) diff --git a/check-generated-code.nix b/check-generated-code.nix index 46efe67f84..78ff51b2f8 100644 --- a/check-generated-code.nix +++ b/check-generated-code.nix @@ -11,8 +11,10 @@ overrideDerivation raptorjit (as: { checkPhase = '' for f in ${generatedFiles}; do + echo "checking $f.." diff -u src/reusevm/$f src/$f done + echo "all files ok" ''; doCheck = true; })