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)
void __qmljs_llvm_call_value(ExecutionContext *context, Value *result, const Value *thisObject, const Value *func, Value *args, int argc)
{
- Value that = thisObject ? *thisObject : Value::undefinedValue();
- *result = __qmljs_call_value(context, that, *func, args, argc);
+ __qmljs_call_value(context, result, thisObject, *func, args, argc);
}
void __qmljs_llvm_construct_activation_property(ExecutionContext *context, Value *result, String *name, Value *args, int argc)
void __qmljs_llvm_call_property(ExecutionContext *context, Value *result, const Value *base, String *name, Value *args, int argc)
{
- *result = __qmljs_call_property(context, *base, name, args, argc);
+ __qmljs_call_property(context, result, *base, name, args, argc);
}
void __qmljs_llvm_construct_property(ExecutionContext *context, Value *result, const Value *base, String *name, Value *args, int argc)
#endif // DO_TRACE_INSTR
Q_ASSERT(instr.args + instr.argc < stackSize);
VM::Value *args = stack + instr.args;
- VALUE(instr.result) = __qmljs_call_value(context, VM::Value::undefinedValue(), VALUE(instr.dest), args, instr.argc);
+ __qmljs_call_value(context, VALUEPTR(instr.result), /*thisObject*/0, VALUE(instr.dest), args, instr.argc);
MOTH_END_INSTR(CallValue)
MOTH_BEGIN_INSTR(CallProperty)
TRACE(property name, "%s, args=%u, argc=%u", qPrintable(instr.name->toQString()), instr.args, instr.argc);
Q_ASSERT(instr.args + instr.argc < stackSize);
VM::Value *args = stack + instr.args;
- VALUE(instr.result) = __qmljs_call_property(context, VALUE(instr.base), instr.name, args, instr.argc);
+ __qmljs_call_property(context, VALUEPTR(instr.result), VALUE(instr.base), instr.name, args, instr.argc);
MOTH_END_INSTR(CallProperty)
MOTH_BEGIN_INSTR(CallElement)
Q_ASSERT(instr.args + instr.argc < stackSize);
VM::Value *args = stack + instr.args;
- VALUE(instr.result) = __qmljs_call_element(context, VALUE(instr.base), VALUE(instr.index), args, instr.argc);
+ __qmljs_call_element(context, VALUEPTR(instr.result), VALUE(instr.base), VALUE(instr.index), args, instr.argc);
MOTH_END_INSTR(CallProperty)
MOTH_BEGIN_INSTR(CallActivationProperty)
*result = res;
}
-Value __qmljs_call_property(ExecutionContext *context, Value thisObject, String *name, Value *args, int argc)
+void __qmljs_call_property(ExecutionContext *context, Value *result, const Value &thatObject, String *name, Value *args, int argc)
{
+ Value thisObject = thatObject;
Object *baseObject;
if (thisObject.isString()) {
baseObject = context->engine->stringPrototype;
if (!o)
context->throwTypeError();
- return o->call(context, thisObject, args, argc);
+ Value res = o->call(context, thisObject, args, argc);
+ if (result)
+ *result = res;
}
-Value __qmljs_call_property_lookup(ExecutionContext *context, Value thisObject, uint index, Value *args, int argc)
+void __qmljs_call_property_lookup(ExecutionContext *context, Value *result, const Value &thatObject, uint index, Value *args, int argc)
{
+ Value thisObject = thatObject;
Lookup *l = context->lookups + index;
Object *baseObject;
if (!o)
context->throwTypeError();
- return o->call(context, thisObject, args, argc);
+ Value res = o->call(context, thisObject, args, argc);
+ if (result)
+ *result = res;
}
-Value __qmljs_call_element(ExecutionContext *context, Value that, Value index, Value *args, int argc)
+void __qmljs_call_element(ExecutionContext *context, Value *result, const Value &that, const Value &index, Value *args, int argc)
{
Value thisObject = that;
if (!thisObject.isObject())
if (!o)
context->throwTypeError();
- return o->call(context, thisObject, args, argc);
+ Value res = o->call(context, thisObject, args, argc);
+ if (result)
+ *result = res;
}
-Value __qmljs_call_value(ExecutionContext *context, Value thisObject, Value func, Value *args, int argc)
+void __qmljs_call_value(ExecutionContext *context, Value *result, const Value *thisObject, const Value &func, Value *args, int argc)
{
FunctionObject *o = func.asFunctionObject();
if (!o)
context->throwTypeError();
- return o->call(context, thisObject, args, argc);
+ Value res = o->call(context, thisObject ? *thisObject : Value::undefinedValue(), args, argc);
+ if (result)
+ *result = res;
}
void __qmljs_construct_activation_property(ExecutionContext *context, Value *result, String *name, Value *args, int argc)
// context
void __qmljs_call_activation_property(ExecutionContext *, Value *result, String *name, Value *args, int argc);
-Value __qmljs_call_property(ExecutionContext *context, Value that, String *name, Value *args, int argc);
-Value __qmljs_call_property_lookup(ExecutionContext *context, Value thisObject, uint index, Value *args, int argc);
-Value __qmljs_call_element(ExecutionContext *context, Value that, Value index, Value *args, int argc);
-Value __qmljs_call_value(ExecutionContext *context, Value thisObject, Value func, Value *args, int argc);
+void __qmljs_call_property(ExecutionContext *context, Value *result, const Value &that, String *name, Value *args, int argc);
+void __qmljs_call_property_lookup(ExecutionContext *context, Value *result, const Value &thisObject, uint index, Value *args, int argc);
+void __qmljs_call_element(ExecutionContext *context, Value *result, const Value &that, const Value &index, Value *args, int argc);
+void __qmljs_call_value(ExecutionContext *context, Value *result, const Value *thisObject, const Value &func, Value *args, int argc);
void __qmljs_construct_activation_property(ExecutionContext *, Value *result, String *name, Value *args, int argc);
Value __qmljs_construct_property(ExecutionContext *context, Value base, String *name, Value *args, int argc);
{
int argc = prepareVariableArguments(args);
IR::Temp* thisObject = 0;
- generateFunctionCall(result, __qmljs_call_value, Assembler::ContextRegister, thisObject, value, baseAddressForCallArguments(), Assembler::TrustedImm32(argc));
+ generateFunctionCall(Assembler::Void, __qmljs_call_value, Assembler::ContextRegister, Assembler::PointerToValue(result), Assembler::PointerToValue(thisObject), Assembler::PointerToValue(value), baseAddressForCallArguments(), Assembler::TrustedImm32(argc));
}
void InstructionSelection::loadThisObject(IR::Temp *temp)
if (useFastLookups) {
uint index = addLookup(s);
- generateFunctionCall(result, __qmljs_call_property_lookup,
- Assembler::ContextRegister, base, Assembler::TrustedImm32(index),
+ generateFunctionCall(Assembler::Void, __qmljs_call_property_lookup,
+ Assembler::ContextRegister, Assembler::PointerToValue(result),
+ Assembler::PointerToValue(base), Assembler::TrustedImm32(index),
baseAddressForCallArguments(),
Assembler::TrustedImm32(argc));
} else {
- generateFunctionCall(result, __qmljs_call_property,
- Assembler::ContextRegister, base, s,
+ generateFunctionCall(Assembler::Void, __qmljs_call_property,
+ Assembler::ContextRegister, Assembler::PointerToValue(result),
+ Assembler::PointerToValue(base), s,
baseAddressForCallArguments(),
Assembler::TrustedImm32(argc));
}
assert(base != 0);
int argc = prepareVariableArguments(args);
- generateFunctionCall(result, __qmljs_call_element,
- Assembler::ContextRegister, base, index,
+ generateFunctionCall(Assembler::Void, __qmljs_call_element,
+ Assembler::ContextRegister, Assembler::PointerToValue(result),
+ Assembler::PointerToValue(base), Assembler::PointerToValue(index),
baseAddressForCallArguments(),
Assembler::TrustedImm32(argc));
}
int currentRegisterIndex;
};
- template <typename ArgRet, typename Arg1, typename Arg2, typename Arg3, typename Arg4, typename Arg5>
- void generateFunctionCallImp(ArgRet r, const char* functionName, FunctionPtr function, Arg1 arg1, Arg2 arg2, Arg3 arg3, Arg4 arg4, Arg5 arg5)
+ template <typename ArgRet, typename Arg1, typename Arg2, typename Arg3, typename Arg4, typename Arg5, typename Arg6>
+ void generateFunctionCallImp(ArgRet r, const char* functionName, FunctionPtr function, Arg1 arg1, Arg2 arg2, Arg3 arg3, Arg4 arg4, Arg5 arg5, Arg6 arg6)
{
- int totalNumberOfArgs = 5;
+ int totalNumberOfArgs = 6;
// If necessary reserve space for the return value on the stack and
// pass the pointer to it as the first hidden parameter.
}
ArgumentLoader l(this, totalNumberOfArgs);
+ l.load(arg6);
l.load(arg5);
l.load(arg4);
l.load(arg3);
add32(TrustedImm32(stackSizeToCorrect), StackPointerRegister);
}
+ template <typename ArgRet, typename Arg1, typename Arg2, typename Arg3, typename Arg4, typename Arg5>
+ void generateFunctionCallImp(ArgRet r, const char* functionName, FunctionPtr function, Arg1 arg1, Arg2 arg2, Arg3 arg3, Arg4 arg4, Arg5 arg5)
+ {
+ generateFunctionCallImp(r, functionName, function, arg1, arg2, arg3, arg4, arg5, VoidType());
+ }
+
template <typename ArgRet, typename Arg1, typename Arg2, typename Arg3, typename Arg4>
void generateFunctionCallImp(ArgRet r, const char* functionName, FunctionPtr function, Arg1 arg1, Arg2 arg2, Arg3 arg3, Arg4 arg4)
{
return true;
if (!m_comparefn.isUndefined()) {
Value args[] = { v1, v2 };
- Value result = __qmljs_call_value(m_context, Value::undefinedValue(), m_comparefn, args, 2);
+ Value result = Value::undefinedValue();
+ __qmljs_call_value(m_context, &result, /*thisObject*/0, m_comparefn, args, 2);
return result.toNumber(m_context) <= 0;
}
return v1.toString(m_context)->toQString() < v2.toString(m_context)->toQString();