Browse Source

Back out history buffer for tailcall counts.

Use an aggregate counter independent of frame depth.
Mike Pall 15 years ago
parent
commit
86494c783d
2 changed files with 3 additions and 5 deletions
  1. 1 1
      src/lj_jit.h
  2. 2 4
      src/lj_record.c

+ 1 - 1
src/lj_jit.h

@@ -231,9 +231,9 @@ typedef struct jit_State {
 
 
   TraceState state;	/* Trace compiler state. */
   TraceState state;	/* Trace compiler state. */
 
 
-  uint64_t tailcalled;	/* History of the number of successive tailcalls. */
   int32_t instunroll;	/* Unroll counter for instable loops. */
   int32_t instunroll;	/* Unroll counter for instable loops. */
   int32_t loopunroll;	/* Unroll counter for loop ops in side traces. */
   int32_t loopunroll;	/* Unroll counter for loop ops in side traces. */
+  int32_t tailcalled;	/* Number of successive tailcalls. */
   int32_t framedepth;	/* Current frame depth. */
   int32_t framedepth;	/* Current frame depth. */
   int32_t retdepth;	/* Return frame depth (count of RETF). */
   int32_t retdepth;	/* Return frame depth (count of RETF). */
 
 

+ 2 - 4
src/lj_record.c

@@ -505,7 +505,6 @@ static void rec_call(jit_State *J, BCReg func, ptrdiff_t nargs)
   rec_call_setup(J, func, nargs);
   rec_call_setup(J, func, nargs);
   /* Bump frame. */
   /* Bump frame. */
   J->framedepth++;
   J->framedepth++;
-  J->tailcalled <<= 8;  /* NYI: tail call history overflow is ignored. */
   J->base += func+1;
   J->base += func+1;
   J->baseslot += func+1;
   J->baseslot += func+1;
 }
 }
@@ -518,7 +517,7 @@ static void rec_tailcall(jit_State *J, BCReg func, ptrdiff_t nargs)
   memmove(&J->base[-1], &J->base[func], sizeof(TRef)*(J->maxslot+1));
   memmove(&J->base[-1], &J->base[func], sizeof(TRef)*(J->maxslot+1));
   /* Note: the new TREF_FRAME is now at J->base[-1] (even for slot #0). */
   /* Note: the new TREF_FRAME is now at J->base[-1] (even for slot #0). */
   /* Tailcalls can form a loop, so count towards the loop unroll limit. */
   /* Tailcalls can form a loop, so count towards the loop unroll limit. */
-  if ((int32_t)(++J->tailcalled & 0xff) > J->loopunroll)
+  if (++J->tailcalled > J->loopunroll)
     lj_trace_err(J, LJ_TRERR_LUNROLL);
     lj_trace_err(J, LJ_TRERR_LUNROLL);
 }
 }
 
 
@@ -527,7 +526,6 @@ static void rec_ret(jit_State *J, BCReg rbase, ptrdiff_t gotresults)
 {
 {
   TValue *frame = J->L->base - 1;
   TValue *frame = J->L->base - 1;
   ptrdiff_t i;
   ptrdiff_t i;
-  J->tailcalled >>= 8;
   for (i = 0; i < gotresults; i++)
   for (i = 0; i < gotresults; i++)
     getslot(J, rbase+i);  /* Ensure all results have a reference. */
     getslot(J, rbase+i);  /* Ensure all results have a reference. */
   while (frame_ispcall(frame)) {  /* Immediately resolve pcall() returns. */
   while (frame_ispcall(frame)) {  /* Immediately resolve pcall() returns. */
@@ -1726,7 +1724,7 @@ static void check_call_unroll(jit_State *J)
     if ((J->slot[s] & TREF_FRAME) && tref_ref(J->slot[s]) == fref)
     if ((J->slot[s] & TREF_FRAME) && tref_ref(J->slot[s]) == fref)
       count++;
       count++;
   if (J->pc == J->startpc) {
   if (J->pc == J->startpc) {
-    if (count + (int32_t)(J->tailcalled & 0xff) > J->param[JIT_P_recunroll]) {
+    if (count + J->tailcalled > J->param[JIT_P_recunroll]) {
       J->pc++;
       J->pc++;
       rec_stop(J, J->curtrace);  /* Up-recursion or tail-recursion. */
       rec_stop(J, J->curtrace);  /* Up-recursion or tail-recursion. */
     }
     }