diff options
| author | Mike Pall <mike> | 2010-02-22 16:57:59 +0100 |
|---|---|---|
| committer | Mike Pall <mike> | 2010-02-22 16:57:59 +0100 |
| commit | 86494c783df79c59d8b92c8ffe110dd9189534e2 (patch) | |
| tree | 80d11db4d74fab967ed906cd361e02be99333fef /src | |
| parent | 19af48316655fac73f6a75a03d65fc6c9a4c7c1a (diff) | |
| download | luajit-86494c783df79c59d8b92c8ffe110dd9189534e2.tar.gz luajit-86494c783df79c59d8b92c8ffe110dd9189534e2.tar.bz2 luajit-86494c783df79c59d8b92c8ffe110dd9189534e2.zip | |
Back out history buffer for tailcall counts.
Use an aggregate counter independent of frame depth.
Diffstat (limited to 'src')
| -rw-r--r-- | src/lj_jit.h | 2 | ||||
| -rw-r--r-- | src/lj_record.c | 6 |
2 files changed, 3 insertions, 5 deletions
diff --git a/src/lj_jit.h b/src/lj_jit.h index 69a066ce..68cebbc2 100644 --- a/src/lj_jit.h +++ b/src/lj_jit.h | |||
| @@ -231,9 +231,9 @@ typedef struct jit_State { | |||
| 231 | 231 | ||
| 232 | TraceState state; /* Trace compiler state. */ | 232 | TraceState state; /* Trace compiler state. */ |
| 233 | 233 | ||
| 234 | uint64_t tailcalled; /* History of the number of successive tailcalls. */ | ||
| 235 | int32_t instunroll; /* Unroll counter for instable loops. */ | 234 | int32_t instunroll; /* Unroll counter for instable loops. */ |
| 236 | int32_t loopunroll; /* Unroll counter for loop ops in side traces. */ | 235 | int32_t loopunroll; /* Unroll counter for loop ops in side traces. */ |
| 236 | int32_t tailcalled; /* Number of successive tailcalls. */ | ||
| 237 | int32_t framedepth; /* Current frame depth. */ | 237 | int32_t framedepth; /* Current frame depth. */ |
| 238 | int32_t retdepth; /* Return frame depth (count of RETF). */ | 238 | int32_t retdepth; /* Return frame depth (count of RETF). */ |
| 239 | 239 | ||
diff --git a/src/lj_record.c b/src/lj_record.c index 45a8ef5f..83d0918f 100644 --- a/src/lj_record.c +++ b/src/lj_record.c | |||
| @@ -505,7 +505,6 @@ static void rec_call(jit_State *J, BCReg func, ptrdiff_t nargs) | |||
| 505 | rec_call_setup(J, func, nargs); | 505 | rec_call_setup(J, func, nargs); |
| 506 | /* Bump frame. */ | 506 | /* Bump frame. */ |
| 507 | J->framedepth++; | 507 | J->framedepth++; |
| 508 | J->tailcalled <<= 8; /* NYI: tail call history overflow is ignored. */ | ||
| 509 | J->base += func+1; | 508 | J->base += func+1; |
| 510 | J->baseslot += func+1; | 509 | J->baseslot += func+1; |
| 511 | } | 510 | } |
| @@ -518,7 +517,7 @@ static void rec_tailcall(jit_State *J, BCReg func, ptrdiff_t nargs) | |||
| 518 | memmove(&J->base[-1], &J->base[func], sizeof(TRef)*(J->maxslot+1)); | 517 | memmove(&J->base[-1], &J->base[func], sizeof(TRef)*(J->maxslot+1)); |
| 519 | /* Note: the new TREF_FRAME is now at J->base[-1] (even for slot #0). */ | 518 | /* Note: the new TREF_FRAME is now at J->base[-1] (even for slot #0). */ |
| 520 | /* Tailcalls can form a loop, so count towards the loop unroll limit. */ | 519 | /* Tailcalls can form a loop, so count towards the loop unroll limit. */ |
| 521 | if ((int32_t)(++J->tailcalled & 0xff) > J->loopunroll) | 520 | if (++J->tailcalled > J->loopunroll) |
| 522 | lj_trace_err(J, LJ_TRERR_LUNROLL); | 521 | lj_trace_err(J, LJ_TRERR_LUNROLL); |
| 523 | } | 522 | } |
| 524 | 523 | ||
| @@ -527,7 +526,6 @@ static void rec_ret(jit_State *J, BCReg rbase, ptrdiff_t gotresults) | |||
| 527 | { | 526 | { |
| 528 | TValue *frame = J->L->base - 1; | 527 | TValue *frame = J->L->base - 1; |
| 529 | ptrdiff_t i; | 528 | ptrdiff_t i; |
| 530 | J->tailcalled >>= 8; | ||
| 531 | for (i = 0; i < gotresults; i++) | 529 | for (i = 0; i < gotresults; i++) |
| 532 | getslot(J, rbase+i); /* Ensure all results have a reference. */ | 530 | getslot(J, rbase+i); /* Ensure all results have a reference. */ |
| 533 | while (frame_ispcall(frame)) { /* Immediately resolve pcall() returns. */ | 531 | while (frame_ispcall(frame)) { /* Immediately resolve pcall() returns. */ |
| @@ -1726,7 +1724,7 @@ static void check_call_unroll(jit_State *J) | |||
| 1726 | if ((J->slot[s] & TREF_FRAME) && tref_ref(J->slot[s]) == fref) | 1724 | if ((J->slot[s] & TREF_FRAME) && tref_ref(J->slot[s]) == fref) |
| 1727 | count++; | 1725 | count++; |
| 1728 | if (J->pc == J->startpc) { | 1726 | if (J->pc == J->startpc) { |
| 1729 | if (count + (int32_t)(J->tailcalled & 0xff) > J->param[JIT_P_recunroll]) { | 1727 | if (count + J->tailcalled > J->param[JIT_P_recunroll]) { |
| 1730 | J->pc++; | 1728 | J->pc++; |
| 1731 | rec_stop(J, J->curtrace); /* Up-recursion or tail-recursion. */ | 1729 | rec_stop(J, J->curtrace); /* Up-recursion or tail-recursion. */ |
| 1732 | } | 1730 | } |
