Implement call value and property
authorSimon Hausmann <simon.hausmann@digia.com>
Sun, 7 Oct 2012 19:57:10 +0000 (21:57 +0200)
committerSimon Hausmann <simon.hausmann@digia.com>
Sun, 7 Oct 2012 19:57:10 +0000 (21:57 +0200)
masm/assembler/MacroAssemblerCodeRef.h
qv4isel_masm.cpp
qv4isel_masm_p.h

index c2af240..2978f10 100644 (file)
@@ -134,6 +134,14 @@ public:
         ASSERT_VALID_CODE_POINTER(m_value);
     }
 
+    template<typename returnType, typename argType1, typename argType2, typename argType3, typename argType4, typename argType5, typename argType6>
+    FunctionPtr(returnType(*value)(argType1, argType2, argType3, argType4, argType5, argType6))
+        : m_value((void*)value)
+    {
+        ASSERT_VALID_CODE_POINTER(m_value);
+    }
+
+
 // MSVC doesn't seem to treat functions with different calling conventions as
 // different types; these methods already defined for fastcall, below.
 #if CALLING_CONVENTION_IS_STDCALL && !OS(WINDOWS)
index 7499bd0..9c9984f 100644 (file)
@@ -135,10 +135,25 @@ void InstructionSelection::callActivationProperty(IR::Call *call, IR::Temp *resu
 
 void InstructionSelection::callValue(IR::Call *call, IR::Temp *result)
 {
+    IR::Temp *baseTemp = call->base->asTemp();
+    assert(baseTemp != 0);
+
+    int argc = prepareVariableArguments(call->args);
+    IR::Temp* thisObject = 0;
+    generateFunctionCall(__qmljs_call_value, ContextRegister, result, baseTemp, thisObject, baseAddressForCallArguments(), TrustedImm32(argc));
+    checkExceptions();
 }
 
 void InstructionSelection::callProperty(IR::Call *call, IR::Temp *result)
 {
+    IR::Member *member = call->base->asMember();
+    assert(member != 0);
+    assert(member->base->asTemp() != 0);
+
+    int argc = prepareVariableArguments(call->args);
+    IR::Temp* thisObject = 0;
+    generateFunctionCall(__qmljs_call_property, ContextRegister, result, member->base->asTemp(), identifier(*member->name), baseAddressForCallArguments(), TrustedImm32(argc));
+    checkExceptions();
 }
 
 void InstructionSelection::constructActivationProperty(IR::New *call, IR::Temp *result)
index 2dde989..8a4af26 100644 (file)
@@ -149,6 +149,19 @@ private:
         push(TrustedImmPtr(name));
     }
 
+    template <typename Arg1, typename Arg2, typename Arg3, typename Arg4, typename Arg5, typename Arg6>
+    void generateFunctionCall(FunctionPtr function, Arg1 arg1, Arg2 arg2, Arg3 arg3, Arg4 arg4, Arg5 arg5, Arg6 arg6)
+    {
+        // Reverse order
+        push(arg6);
+        push(arg5);
+        push(arg4);
+        push(arg3);
+        push(arg2);
+        push(arg1);
+        callAbsolute(function);
+        add32(TrustedImm32(6 * sizeof(void*)), StackPointerRegister);
+    }
     template <typename Arg1, typename Arg2, typename Arg3, typename Arg4, typename Arg5>
     void generateFunctionCall(FunctionPtr function, Arg1 arg1, Arg2 arg2, Arg3 arg3, Arg4 arg4, Arg5 arg5)
     {