From 4d21c8b2b68cb575fb901965df349559c9147ed7 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Thu, 14 Feb 2013 15:47:06 +0100 Subject: [PATCH] Convert construct runtime functions to new calling convention Change-Id: I063508ff780d2f6371f77eca7138a09d78e1a45e Reviewed-by: Lars Knoll --- src/v4/llvm_runtime.cpp | 4 ++-- src/v4/moth/qv4vme_moth.cpp | 4 ++-- src/v4/qmljs_runtime.cpp | 26 +++++++++++++++----------- src/v4/qmljs_runtime.h | 4 ++-- src/v4/qv4isel_masm.cpp | 4 ++-- 5 files changed, 23 insertions(+), 19 deletions(-) diff --git a/src/v4/llvm_runtime.cpp b/src/v4/llvm_runtime.cpp index 1dc4800..e89c8c8 100644 --- a/src/v4/llvm_runtime.cpp +++ b/src/v4/llvm_runtime.cpp @@ -415,7 +415,7 @@ void __qmljs_llvm_construct_activation_property(ExecutionContext *context, Value void __qmljs_llvm_construct_value(ExecutionContext *context, Value *result, const Value *func, Value *args, int argc) { - *result = __qmljs_construct_value(context, *func, args, argc); + __qmljs_construct_value(context, result, *func, args, argc); } void __qmljs_llvm_get_activation_property(ExecutionContext *ctx, Value *result, String *name) @@ -440,7 +440,7 @@ void __qmljs_llvm_call_property(ExecutionContext *context, Value *result, const void __qmljs_llvm_construct_property(ExecutionContext *context, Value *result, const Value *base, String *name, Value *args, int argc) { - *result = __qmljs_construct_property(context, *base, name, args, argc); + __qmljs_construct_property(context, result, *base, name, args, argc); } void __qmljs_llvm_get_element(ExecutionContext *ctx, Value *result, Value *object, Value *index) diff --git a/src/v4/moth/qv4vme_moth.cpp b/src/v4/moth/qv4vme_moth.cpp index a8d9243..00db920 100644 --- a/src/v4/moth/qv4vme_moth.cpp +++ b/src/v4/moth/qv4vme_moth.cpp @@ -378,13 +378,13 @@ VM::Value VME::operator()(QQmlJS::VM::ExecutionContext *context, const uchar *co MOTH_BEGIN_INSTR(CreateValue) Q_ASSERT(instr.args + instr.argc < stackSize); VM::Value *args = stack + instr.args; - VALUE(instr.result) = __qmljs_construct_value(context, VALUE(instr.func), args, instr.argc); + __qmljs_construct_value(context, VALUEPTR(instr.result), VALUE(instr.func), args, instr.argc); MOTH_END_INSTR(CreateValue) MOTH_BEGIN_INSTR(CreateProperty) Q_ASSERT(instr.args + instr.argc < stackSize); VM::Value *args = stack + instr.args; - VALUE(instr.result) = __qmljs_construct_property(context, VALUE(instr.base), instr.name, args, instr.argc); + __qmljs_construct_property(context, VALUEPTR(instr.result), VALUE(instr.base), instr.name, args, instr.argc); MOTH_END_INSTR(CreateProperty) MOTH_BEGIN_INSTR(CreateActivationProperty) diff --git a/src/v4/qmljs_runtime.cpp b/src/v4/qmljs_runtime.cpp index d35b6f6..3efeaaa 100644 --- a/src/v4/qmljs_runtime.cpp +++ b/src/v4/qmljs_runtime.cpp @@ -935,32 +935,36 @@ void __qmljs_call_value(ExecutionContext *context, Value *result, const Value *t void __qmljs_construct_activation_property(ExecutionContext *context, Value *result, String *name, Value *args, int argc) { Value func = context->getProperty(name); - Value res = __qmljs_construct_value(context, func, args, argc); - if (result) - *result = res; + __qmljs_construct_value(context, result, func, args, argc); } -Value __qmljs_construct_value(ExecutionContext *context, Value func, Value *args, int argc) +void __qmljs_construct_value(ExecutionContext *context, Value *result, const Value &func, Value *args, int argc) { - if (FunctionObject *f = func.asFunctionObject()) - return f->construct(context, args, argc); + if (FunctionObject *f = func.asFunctionObject()) { + Value res = f->construct(context, args, argc); + if (result) + *result = res; + return; + } context->throwTypeError(); - return Value::undefinedValue(); } -Value __qmljs_construct_property(ExecutionContext *context, Value base, String *name, Value *args, int argc) +void __qmljs_construct_property(ExecutionContext *context, Value *result, const Value &base, String *name, Value *args, int argc) { Value thisObject = base; if (!thisObject.isObject()) thisObject = __qmljs_to_object(base, context); Value func = thisObject.objectValue()->__get__(context, name); - if (FunctionObject *f = func.asFunctionObject()) - return f->construct(context, args, argc); + if (FunctionObject *f = func.asFunctionObject()) { + Value res = f->construct(context, args, argc); + if (result) + *result = res; + return; + } context->throwTypeError(); - return Value::undefinedValue(); } void __qmljs_throw(Value value, ExecutionContext *context) diff --git a/src/v4/qmljs_runtime.h b/src/v4/qmljs_runtime.h index ae9d75b..0662bbc 100644 --- a/src/v4/qmljs_runtime.h +++ b/src/v4/qmljs_runtime.h @@ -98,8 +98,8 @@ void __qmljs_call_element(ExecutionContext *context, Value *result, const Value 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); -Value __qmljs_construct_value(ExecutionContext *context, Value func, Value *args, int argc); +void __qmljs_construct_property(ExecutionContext *context, Value *result, const Value &base, String *name, Value *args, int argc); +void __qmljs_construct_value(ExecutionContext *context, Value *result, const Value &func, Value *args, int argc); void __qmljs_builtin_typeof(ExecutionContext *ctx, Value *result, const Value &val); void __qmljs_builtin_typeof_name(ExecutionContext *context, Value* result, String *name); diff --git a/src/v4/qv4isel_masm.cpp b/src/v4/qv4isel_masm.cpp index f7a4cc4..d91917b 100644 --- a/src/v4/qv4isel_masm.cpp +++ b/src/v4/qv4isel_masm.cpp @@ -897,7 +897,7 @@ void InstructionSelection::constructActivationProperty(IR::Name *func, IR::ExprL void InstructionSelection::constructProperty(IR::Temp *base, const QString &name, IR::ExprList *args, IR::Temp *result) { int argc = prepareVariableArguments(args); - generateFunctionCall(result, __qmljs_construct_property, Assembler::ContextRegister, base, identifier(name), baseAddressForCallArguments(), Assembler::TrustedImm32(argc)); + generateFunctionCall(Assembler::Void, __qmljs_construct_property, Assembler::ContextRegister, Assembler::PointerToValue(result), Assembler::PointerToValue(base), identifier(name), baseAddressForCallArguments(), Assembler::TrustedImm32(argc)); } void InstructionSelection::constructValue(IR::Temp *value, IR::ExprList *args, IR::Temp *result) @@ -905,7 +905,7 @@ void InstructionSelection::constructValue(IR::Temp *value, IR::ExprList *args, I assert(value != 0); int argc = prepareVariableArguments(args); - generateFunctionCall(result, __qmljs_construct_value, Assembler::ContextRegister, value, baseAddressForCallArguments(), Assembler::TrustedImm32(argc)); + generateFunctionCall(Assembler::Void, __qmljs_construct_value, Assembler::ContextRegister, Assembler::PointerToValue(result), Assembler::PointerToValue(value), baseAddressForCallArguments(), Assembler::TrustedImm32(argc)); } void InstructionSelection::visitJump(IR::Jump *s) -- 2.7.4