Fix the cloop due to GenGC
https://bugs.webkit.org/show_bug.cgi?id=128137

Reviewed by Geoffrey Garen.

* llint/LLIntSlowPaths.cpp:
(JSC::LLInt::llint_write_barrier_slow):
* llint/LLIntSlowPaths.h:
* llint/LowLevelInterpreter.cpp:
(JSC::CLoopRegister::operator JSCell*):
* llint/LowLevelInterpreter32_64.asm:
* llint/LowLevelInterpreter64.asm:
* offlineasm/cloop.rb:
* offlineasm/instructions.rb:


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@163345 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/JavaScriptCore/ChangeLog b/Source/JavaScriptCore/ChangeLog
index da2d903..c04220e 100644
--- a/Source/JavaScriptCore/ChangeLog
+++ b/Source/JavaScriptCore/ChangeLog
@@ -1,3 +1,20 @@
+2014-02-03  Mark Hahnenberg  <mhahnenberg@apple.com>
+
+        Fix the cloop due to GenGC
+        https://bugs.webkit.org/show_bug.cgi?id=128137
+
+        Reviewed by Geoffrey Garen.
+
+        * llint/LLIntSlowPaths.cpp:
+        (JSC::LLInt::llint_write_barrier_slow):
+        * llint/LLIntSlowPaths.h:
+        * llint/LowLevelInterpreter.cpp:
+        (JSC::CLoopRegister::operator JSCell*):
+        * llint/LowLevelInterpreter32_64.asm:
+        * llint/LowLevelInterpreter64.asm:
+        * offlineasm/cloop.rb:
+        * offlineasm/instructions.rb:
+
 2014-02-03  Michael Saboff  <msaboff@apple.com>
 
         REGRESSION (r163011-r163031): Web Inspector: Latest nightly crashes when showing the Web Inspector
diff --git a/Source/JavaScriptCore/llint/LLIntSlowPaths.cpp b/Source/JavaScriptCore/llint/LLIntSlowPaths.cpp
index 079b272..070a8d6 100644
--- a/Source/JavaScriptCore/llint/LLIntSlowPaths.cpp
+++ b/Source/JavaScriptCore/llint/LLIntSlowPaths.cpp
@@ -1436,10 +1436,9 @@
 }
 #endif
 
-extern "C" SlowPathReturnType llint_write_barrier_slow(ExecState*, JSCell* cell)
+extern "C" void llint_write_barrier_slow(ExecState*, JSCell* cell)
 {
     Heap::writeBarrier(cell);
-    return encodeResult(0, 0);
 }
 
 } } // namespace JSC::LLInt
diff --git a/Source/JavaScriptCore/llint/LLIntSlowPaths.h b/Source/JavaScriptCore/llint/LLIntSlowPaths.h
index 154317c..6bc0dfd 100644
--- a/Source/JavaScriptCore/llint/LLIntSlowPaths.h
+++ b/Source/JavaScriptCore/llint/LLIntSlowPaths.h
@@ -42,7 +42,7 @@
 
 extern "C" SlowPathReturnType llint_trace_operand(ExecState*, Instruction*, int fromWhere, int operand);
 extern "C" SlowPathReturnType llint_trace_value(ExecState*, Instruction*, int fromWhere, int operand);
-extern "C" SlowPathReturnType llint_write_barrier_slow(ExecState*, JSCell*) WTF_INTERNAL;
+extern "C" void llint_write_barrier_slow(ExecState*, JSCell*) WTF_INTERNAL;
 
 #define LLINT_SLOW_PATH_DECL(name) \
     extern "C" SlowPathReturnType llint_##name(ExecState* exec, Instruction* pc)
diff --git a/Source/JavaScriptCore/llint/LowLevelInterpreter.cpp b/Source/JavaScriptCore/llint/LowLevelInterpreter.cpp
index dfd8373..8da6c88 100644
--- a/Source/JavaScriptCore/llint/LowLevelInterpreter.cpp
+++ b/Source/JavaScriptCore/llint/LowLevelInterpreter.cpp
@@ -225,6 +225,7 @@
         ExecState* execState;
         void* instruction;
         VM* vm;
+        JSCell* cell;
         ProtoCallFrame* protoCallFrame;
         NativeFunction nativeFunc;
 #if USE(JSVALUE64)
@@ -241,6 +242,7 @@
     operator VM*() { return vm; }
     operator ProtoCallFrame*() { return protoCallFrame; }
     operator Register*() { return reinterpret_cast<Register*>(vp); }
+    operator JSCell*() { return cell; }
 
 #if USE(JSVALUE64)
     inline void clearHighWord() { i32padding = 0; }
diff --git a/Source/JavaScriptCore/llint/LowLevelInterpreter32_64.asm b/Source/JavaScriptCore/llint/LowLevelInterpreter32_64.asm
index 1ddccd5..f04225b 100644
--- a/Source/JavaScriptCore/llint/LowLevelInterpreter32_64.asm
+++ b/Source/JavaScriptCore/llint/LowLevelInterpreter32_64.asm
@@ -117,6 +117,14 @@
     end
 end
 
+macro cCall2Void(function, arg1, arg2)
+    if C_LOOP
+        cloopCallSlowPathVoid function, arg1, arg2
+    else
+        cCall2(function, arg1, arg2)
+    end
+end
+
 # This barely works. arg3 and arg4 should probably be immediates.
 macro cCall4(function, arg1, arg2, arg3, arg4)
     if ARM or ARMv7 or ARMv7_TRADITIONAL or MIPS
@@ -525,7 +533,7 @@
                 push cfr, PC
                 # We make two extra slots because cCall2 will poke.
                 subp 8, sp
-                cCall2(_llint_write_barrier_slow, cfr, t2)
+                cCall2Void(_llint_write_barrier_slow, cfr, t2)
                 addp 8, sp
                 pop PC, cfr
             end
@@ -558,7 +566,7 @@
                 push cfr, PC
                 # We make two extra slots because cCall2 will poke.
                 subp 8, sp
-                cCall2(_llint_write_barrier_slow, cfr, t3)
+                cCall2Void(_llint_write_barrier_slow, cfr, t3)
                 addp 8, sp
                 pop PC, cfr
             end
diff --git a/Source/JavaScriptCore/llint/LowLevelInterpreter64.asm b/Source/JavaScriptCore/llint/LowLevelInterpreter64.asm
index d20bb65..b4c4527 100644
--- a/Source/JavaScriptCore/llint/LowLevelInterpreter64.asm
+++ b/Source/JavaScriptCore/llint/LowLevelInterpreter64.asm
@@ -68,6 +68,14 @@
     end
 end
 
+macro cCall2Void(function, arg1, arg2)
+    if C_LOOP
+        cloopCallSlowPathVoid function, arg1, arg2
+    else
+        cCall2(function, arg1, arg2)
+    end
+end
+
 # This barely works. arg3 and arg4 should probably be immediates.
 macro cCall4(function, arg1, arg2, arg3, arg4)
     checkStackPointerAlignment(t4, 0xbad0c004)
@@ -390,7 +398,7 @@
             macro(marked)
                 btbz marked, .writeBarrierDone
                 push PB, PC
-                cCall2(_llint_write_barrier_slow, cfr, t2)
+                cCall2Void(_llint_write_barrier_slow, cfr, t2)
                 pop PC, PB
             end
         )
@@ -421,7 +429,7 @@
             macro(marked)
                 btbz marked, .writeBarrierDone
                 push PB, PC
-                cCall2(_llint_write_barrier_slow, cfr, t3)
+                cCall2Void(_llint_write_barrier_slow, cfr, t3)
                 pop PC, PB
             end
         )
diff --git a/Source/JavaScriptCore/offlineasm/cloop.rb b/Source/JavaScriptCore/offlineasm/cloop.rb
index 9b92047..ff9310b 100644
--- a/Source/JavaScriptCore/offlineasm/cloop.rb
+++ b/Source/JavaScriptCore/offlineasm/cloop.rb
@@ -548,6 +548,10 @@
     $asm.putc "}"
 end
 
+def cloopEmitCallSlowPathVoid(operands)
+    $asm.putc "#{operands[0].cLabel}(#{operands[1].clDump}, #{operands[2].clDump});"
+end
+
 class Instruction
     @@didReturnFromJSLabelCounter = 0
 
@@ -1088,9 +1092,15 @@
         when "memfence"
 
         when "push"
-            $asm.putc "PUSH(#{operands[0].clDump});"
+            operands.each {
+                | op |
+                $asm.putc "PUSH(#{op.clDump});"
+            }
         when "pop"
-            $asm.putc "POP(#{operands[0].clDump});"
+            operands.each {
+                | op |
+                $asm.putc "POP(#{op.clDump});"
+            }
 
         when "pushCalleeSaves"
         when "popCalleeSaves"
@@ -1133,6 +1143,9 @@
         when "cloopCallSlowPath"
             cloopEmitCallSlowPath(operands)
 
+        when "cloopCallSlowPathVoid"
+            cloopEmitCallSlowPathVoid(operands)
+
         # For debugging only. This is used to insert instrumentation into the
         # generated LLIntAssembly.h during llint development only. Do not use
         # for production code.
diff --git a/Source/JavaScriptCore/offlineasm/instructions.rb b/Source/JavaScriptCore/offlineasm/instructions.rb
index 989ee82..c0ca1c3 100644
--- a/Source/JavaScriptCore/offlineasm/instructions.rb
+++ b/Source/JavaScriptCore/offlineasm/instructions.rb
@@ -304,10 +304,11 @@
 
 CXX_INSTRUCTIONS =
     [
-     "cloopCrash",           # no operands
-     "cloopCallJSFunction",  # operands: callee
-     "cloopCallNative",      # operands: callee
-     "cloopCallSlowPath",    # operands: callTarget, currentFrame, currentPC
+     "cloopCrash",              # no operands
+     "cloopCallJSFunction",     # operands: callee
+     "cloopCallNative",         # operands: callee
+     "cloopCallSlowPath",       # operands: callTarget, currentFrame, currentPC
+     "cloopCallSlowPathVoid",   # operands: callTarget, currentFrame, currentPC
 
      # For debugging only:
      # Takes no operands but simply emits whatever follows in // comments as