diff options
-rw-r--r-- | lib/dump.lua | 30 | ||||
-rw-r--r-- | src/lib_jit.c | 14 | ||||
-rw-r--r-- | src/lj_target.h | 2 |
3 files changed, 40 insertions, 6 deletions
diff --git a/lib/dump.lua b/lib/dump.lua index bb8aa1ce..3a88ef45 100644 --- a/lib/dump.lua +++ b/lib/dump.lua | |||
@@ -76,11 +76,24 @@ local active, out, dumpmode | |||
76 | 76 | ||
77 | ------------------------------------------------------------------------------ | 77 | ------------------------------------------------------------------------------ |
78 | 78 | ||
79 | local symtabmt = { __index = false } | ||
79 | local symtab = {} | 80 | local symtab = {} |
80 | local nexitsym = 0 | 81 | local nexitsym = 0 |
81 | 82 | ||
82 | -- Fill symbol table with trace exit addresses. | 83 | -- Fill nested symbol table with per-trace exit stub addresses. |
83 | local function fillsymtab(nexit) | 84 | local function fillsymtab_tr(tr, nexit) |
85 | local t = {} | ||
86 | symtabmt.__index = t | ||
87 | for i=0,nexit-1 do | ||
88 | local addr = traceexitstub(tr, i) | ||
89 | t[addr] = tostring(i) | ||
90 | end | ||
91 | local addr = traceexitstub(tr, nexit) | ||
92 | if addr then t[addr] = "stack_check" end | ||
93 | end | ||
94 | |||
95 | -- Fill symbol table with trace exit stub addresses. | ||
96 | local function fillsymtab(tr, nexit) | ||
84 | local t = symtab | 97 | local t = symtab |
85 | if nexitsym == 0 then | 98 | if nexitsym == 0 then |
86 | local ircall = vmdef.ircall | 99 | local ircall = vmdef.ircall |
@@ -89,10 +102,17 @@ local function fillsymtab(nexit) | |||
89 | if addr ~= 0 then t[addr] = ircall[i] end | 102 | if addr ~= 0 then t[addr] = ircall[i] end |
90 | end | 103 | end |
91 | end | 104 | end |
92 | if nexit > nexitsym then | 105 | if nexitsym == 1000000 then -- Per-trace exit stubs. |
106 | fillsymtab_tr(tr, nexit) | ||
107 | elseif nexit > nexitsym then -- Shared exit stubs. | ||
93 | for i=nexitsym,nexit-1 do | 108 | for i=nexitsym,nexit-1 do |
94 | local addr = traceexitstub(i) | 109 | local addr = traceexitstub(i) |
95 | if addr == nil then nexit = 1000000; break end | 110 | if addr == nil then -- Fall back to per-trace exit stubs. |
111 | fillsymtab_tr(tr, nexit) | ||
112 | setmetatable(symtab, symtabmt) | ||
113 | nexit = 1000000 | ||
114 | break | ||
115 | end | ||
96 | t[addr] = tostring(i) | 116 | t[addr] = tostring(i) |
97 | end | 117 | end |
98 | nexitsym = nexit | 118 | nexitsym = nexit |
@@ -114,7 +134,7 @@ local function dump_mcode(tr) | |||
114 | out:write("---- TRACE ", tr, " mcode ", #mcode, "\n") | 134 | out:write("---- TRACE ", tr, " mcode ", #mcode, "\n") |
115 | local ctx = disass.create(mcode, addr, dumpwrite) | 135 | local ctx = disass.create(mcode, addr, dumpwrite) |
116 | ctx.hexdump = 0 | 136 | ctx.hexdump = 0 |
117 | ctx.symtab = fillsymtab(info.nexit) | 137 | ctx.symtab = fillsymtab(tr, info.nexit) |
118 | if loop ~= 0 then | 138 | if loop ~= 0 then |
119 | symtab[addr+loop] = "LOOP" | 139 | symtab[addr+loop] = "LOOP" |
120 | ctx:disass(0, loop) | 140 | ctx:disass(0, loop) |
diff --git a/src/lib_jit.c b/src/lib_jit.c index bfafa724..d4277add 100644 --- a/src/lib_jit.c +++ b/src/lib_jit.c | |||
@@ -377,15 +377,27 @@ LJLIB_CF(jit_util_tracemc) | |||
377 | return 0; | 377 | return 0; |
378 | } | 378 | } |
379 | 379 | ||
380 | /* local addr = jit.util.traceexitstub(idx) */ | 380 | /* local addr = jit.util.traceexitstub([tr,] exitno) */ |
381 | LJLIB_CF(jit_util_traceexitstub) | 381 | LJLIB_CF(jit_util_traceexitstub) |
382 | { | 382 | { |
383 | #ifdef EXITSTUBS_PER_GROUP | ||
383 | ExitNo exitno = (ExitNo)lj_lib_checkint(L, 1); | 384 | ExitNo exitno = (ExitNo)lj_lib_checkint(L, 1); |
384 | jit_State *J = L2J(L); | 385 | jit_State *J = L2J(L); |
385 | if (exitno < EXITSTUBS_PER_GROUP*LJ_MAX_EXITSTUBGR) { | 386 | if (exitno < EXITSTUBS_PER_GROUP*LJ_MAX_EXITSTUBGR) { |
386 | setintptrV(L->top-1, (intptr_t)(void *)exitstub_addr(J, exitno)); | 387 | setintptrV(L->top-1, (intptr_t)(void *)exitstub_addr(J, exitno)); |
387 | return 1; | 388 | return 1; |
388 | } | 389 | } |
390 | #else | ||
391 | if (L->top > L->base+1) { /* Don't throw for one-argument variant. */ | ||
392 | GCtrace *T = jit_checktrace(L); | ||
393 | ExitNo exitno = (ExitNo)lj_lib_checkint(L, 2); | ||
394 | ExitNo maxexit = T->root ? T->nsnap+1 : T->nsnap; | ||
395 | if (T && T->mcode != NULL && exitno < maxexit) { | ||
396 | setintptrV(L->top-1, (intptr_t)(void *)exitstub_trace_addr(T, exitno)); | ||
397 | return 1; | ||
398 | } | ||
399 | } | ||
400 | #endif | ||
389 | return 0; | 401 | return 0; |
390 | } | 402 | } |
391 | 403 | ||
diff --git a/src/lj_target.h b/src/lj_target.h index 410ad0a0..33feb17c 100644 --- a/src/lj_target.h +++ b/src/lj_target.h | |||
@@ -131,6 +131,7 @@ typedef uint32_t RegCost; | |||
131 | #error "Missing include for target CPU" | 131 | #error "Missing include for target CPU" |
132 | #endif | 132 | #endif |
133 | 133 | ||
134 | #ifdef EXITSTUBS_PER_GROUP | ||
134 | /* Return the address of an exit stub. */ | 135 | /* Return the address of an exit stub. */ |
135 | static LJ_AINLINE MCode *exitstub_addr(jit_State *J, ExitNo exitno) | 136 | static LJ_AINLINE MCode *exitstub_addr(jit_State *J, ExitNo exitno) |
136 | { | 137 | { |
@@ -138,5 +139,6 @@ static LJ_AINLINE MCode *exitstub_addr(jit_State *J, ExitNo exitno) | |||
138 | return (MCode *)((char *)J->exitstubgroup[exitno / EXITSTUBS_PER_GROUP] + | 139 | return (MCode *)((char *)J->exitstubgroup[exitno / EXITSTUBS_PER_GROUP] + |
139 | EXITSTUB_SPACING*(exitno % EXITSTUBS_PER_GROUP)); | 140 | EXITSTUB_SPACING*(exitno % EXITSTUBS_PER_GROUP)); |
140 | } | 141 | } |
142 | #endif | ||
141 | 143 | ||
142 | #endif | 144 | #endif |