]> git.ipfire.org Git - thirdparty/LuaJIT.git/commitdiff
Another fix for the trace flush logic. I'll get this right someday.
authorMike Pall <mike>
Sat, 22 Jan 2011 19:32:23 +0000 (20:32 +0100)
committerMike Pall <mike>
Sat, 22 Jan 2011 19:32:23 +0000 (20:32 +0100)
Thanks to David Manura.

doc/ext_jit.html
src/lj_trace.c

index fc494382f8146555f0a8919df6ce0ee7aa70262c..36e306a8b4ab63e5a53e5d9a94757a4a733af619 100644 (file)
@@ -116,9 +116,9 @@ debugging purposes.
 
 <h3 id="jit_flush_tr"><tt>jit.flush(tr)</tt></h3>
 <p>
-Flushes the specified root trace and all of its side traces from the cache.
-The code for the trace will be retained as long as there are any other
-traces which link to it.
+Flushes the root trace, specified by its number, and all of its side
+traces from the cache. The code for the trace will be retained as long
+as there are any other traces which link to it.
 </p>
 
 <h3 id="jit_status"><tt>status, ... = jit.status()</tt></h3>
index c6e87bb59f5028a70089584a1d302ea7afd9059c..612a41bc101b2cf110d8d0646007f35a27e13e0d 100644 (file)
@@ -194,8 +194,9 @@ static void trace_unpatch(jit_State *J, GCtrace *T)
     lua_assert(bc_op(*pc) == BC_JFORI);
     setbc_op(pc, BC_FORI);
     break;
+  case BC_JITERL:
   case BC_JLOOP:
-    lua_assert(op == BC_LOOP || bc_isret(op));
+    lua_assert(op == BC_ITERL || op == BC_LOOP || bc_isret(op));
     *pc = T->startins;
     break;
   case BC_JMP:
@@ -227,11 +228,13 @@ static void trace_flushroot(jit_State *J, GCtrace *T)
     pt->trace = T->nextroot;
   } else {  /* Otherwise search in chain of root traces. */
     GCtrace *T2 = traceref(J, pt->trace);
-    for (; T2->nextroot; T2 = traceref(J, T2->nextroot))
-      if (T2->nextroot == T->traceno) {
-       T2->nextroot = T->nextroot;  /* Unlink from chain. */
-       break;
-      }
+    if (T2) {
+      for (; T2->nextroot; T2 = traceref(J, T2->nextroot))
+       if (T2->nextroot == T->traceno) {
+         T2->nextroot = T->nextroot;  /* Unlink from chain. */
+         break;
+       }
+    }
   }
 }