<?xml version="1.0"?>
<paste-with-annotations>
  <paste>
    <number>
      <integer>60608</integer>
    </number>
    <user>
      <string>olliej</string>
    </user>
    <title>
      <string>assertion-fu for othermaciej</string>
    </title>
    <contents>
      <string>diff --git a/JavaScriptCore/VM/Machine.cpp b/JavaScriptCore/VM/Machine.cpp
index 71d397e..a5365f3 100644
--- a/JavaScriptCore/VM/Machine.cpp
+++ b/JavaScriptCore/VM/Machine.cpp
@@ -726,7 +726,16 @@ JSValue* Machine::privateExecute(ExecutionFlag flag, ExecState* exec, RegisterFi
     Register** registerBase = registerFile-&gt;basePointer();
     Instruction* vPC = codeBlock-&gt;instructions.begin();
     JSValue** k = codeBlock-&gt;jsValues.data();
-    
+#ifndef NDEBUG
+    int originalRegisterOffset;
+#define UPDATE_OFFSET() do { originalRegisterOffset = (r - *registerBase); } while(0)
+#define CHECK_OFFSET() ASSERT(originalRegisterOffset == (r - *registerBase))
+    UPDATE_OFFSET();
+#else
+#define UPDATE_OFFSET()
+#define CHECK_OFFSET()
+#endif
+
     registerFile-&gt;setSafeForReentry(false);
 #define VM_CHECK_EXCEPTION() \
      do { \
@@ -738,12 +747,12 @@ JSValue* Machine::privateExecute(ExecutionFlag flag, ExecState* exec, RegisterFi
     } while (0)
 
 #if HAVE(COMPUTED_GOTO)
-    #define NEXT_OPCODE goto *vPC-&gt;u.opcode
-    #define BEGIN_OPCODE(opcode) opcode:
+    #define NEXT_OPCODE CHECK_OFFSET(); goto *vPC-&gt;u.opcode
+    #define BEGIN_OPCODE(opcode) opcode: UPDATE_OFFSET();
     NEXT_OPCODE;
 #else
-    #define NEXT_OPCODE continue
-    #define BEGIN_OPCODE(opcode) case opcode:
+    #define NEXT_OPCODE CHECK_OFFSET(); continue
+    #define BEGIN_OPCODE(opcode) case opcode: UPDATE_OFFSET();
     while(1) // iterator loop begins
     switch (vPC-&gt;u.opcode)
 #endif
@@ -1599,6 +1608,8 @@ JSValue* Machine::privateExecute(ExecutionFlag flag, ExecState* exec, RegisterFi
             r[r0].u.jsValue = result;
             
             ++vPC;
+            
+            UPDATE_OFFSET();
             NEXT_OPCODE;
         }
         
@@ -1649,7 +1660,8 @@ JSValue* Machine::privateExecute(ExecutionFlag flag, ExecState* exec, RegisterFi
             setScopeChain(exec, scopeChain, scopeChainForCall(functionBodyNode, codeBlock, callDataScopeChain, registerBase, r));
             k = codeBlock-&gt;jsValues.data();
             vPC = codeBlock-&gt;instructions.begin();
-
+            
+            UPDATE_OFFSET();
             NEXT_OPCODE;
         }
 
@@ -1669,7 +1681,8 @@ JSValue* Machine::privateExecute(ExecutionFlag flag, ExecState* exec, RegisterFi
             r[r0].u.jsValue = returnValue;
 
             VM_CHECK_EXCEPTION();
-
+            
+            UPDATE_OFFSET();
             ++vPC;
             NEXT_OPCODE;
         }
@@ -1714,6 +1727,7 @@ JSValue* Machine::privateExecute(ExecutionFlag flag, ExecState* exec, RegisterFi
         int r0 = callFrame[ReturnValueRegister].u.i;
         r[r0].u.jsValue = returnValue;
         
+        UPDATE_OFFSET();
         NEXT_OPCODE;
     }
     BEGIN_OPCODE(op_construct) {
@@ -1759,7 +1773,7 @@ JSValue* Machine::privateExecute(ExecutionFlag flag, ExecState* exec, RegisterFi
             setScopeChain(exec, scopeChain, scopeChainForCall(functionBodyNode, codeBlock, callDataScopeChain, registerBase, r));
             k = codeBlock-&gt;jsValues.data();
             vPC = codeBlock-&gt;instructions.begin();
-
+            UPDATE_OFFSET();
             NEXT_OPCODE;
         }
 
@@ -1776,6 +1790,7 @@ JSValue* Machine::privateExecute(ExecutionFlag flag, ExecState* exec, RegisterFi
             r[r0].u.jsValue = returnValue;
             
             ++vPC;
+            UPDATE_OFFSET();
             NEXT_OPCODE;
         }
 

</string>
    </contents>
    <universal-time>
      <integer>3419535585</integer>
    </universal-time>
    <channel>
      <string>#webkit</string>
    </channel>
    <colorization-mode>
      <string></string>
    </colorization-mode>
    <maybe-spam>
      <null/>
    </maybe-spam>
    <is-unicode>
      <keyword>TRUE</keyword>
    </is-unicode>
  </paste>
</paste-with-annotations>