Call helper
authorSimon Hausmann <simon.hausmann@digia.com>
Mon, 1 Oct 2012 19:59:09 +0000 (21:59 +0200)
committerSimon Hausmann <simon.hausmann@digia.com>
Mon, 1 Oct 2012 19:59:09 +0000 (21:59 +0200)
qv4isel_masm.cpp
qv4isel_masm_p.h

index 71e58eb..953b8fa 100644 (file)
@@ -181,16 +181,10 @@ void InstructionSelection::visitCJump(IR::CJump *s)
 void InstructionSelection::visitRet(IR::Ret *s)
 {
     if (IR::Temp *t = s->expr->asTemp()) {
-        Address addr = loadTempAddress(Gpr0, t);
-        add32(TrustedImm32(addr.offset), addr.base, Gpr0);
-        push(Gpr0);
-
+        Address addr = loadTempAddress(Gpr1, t);
+        add32(TrustedImm32(addr.offset), addr.base, Gpr1);
         add32(TrustedImm32(offsetof(Context, result)), ContextRegister, Gpr0);
-        push(Gpr0);
-
-        callAbsolute(__qmljs_copy);
-
-        add32(TrustedImm32(2 * sizeof(void*)), StackPointerRegister);
+        callHelper(__qmljs_copy, Gpr1, Gpr0);
         return;
     }
     Q_UNIMPLEMENTED();
index d4f4c44..34e96ed 100644 (file)
@@ -83,6 +83,30 @@ private:
         _callsToLink.append(ctl);
     }
 
+    template <typename Arg1>
+    void callHelper(FunctionPtr function, Arg1 arg1) {
+        push(arg1);
+        callAbsolute(function);
+        add32(TrustedImm32(1 * sizeof(void*)), StackPointerRegister);
+    }
+
+    template <typename Arg1, typename Arg2>
+    void callHelper(FunctionPtr function, Arg1 arg1, Arg2 arg2) {
+        push(arg2);
+        push(arg1);
+        callAbsolute(function);
+        add32(TrustedImm32(2 * sizeof(void*)), StackPointerRegister);
+    }
+
+    template <typename Arg1, typename Arg2, typename Arg3>
+    void callHelper(FunctionPtr function, Arg1 arg1, Arg2 arg2, Arg3 arg3) {
+        push(arg3);
+        push(arg2);
+        push(arg1);
+        callAbsolute(function);
+        add32(TrustedImm32(3 * sizeof(void*)), StackPointerRegister);
+    }
+
     struct CallToLink {
         Call call;
         FunctionPtr externalFunction;