From 62b9e0f2cad80c48c87b703d6bcef9988fd5c1a0 Mon Sep 17 00:00:00 2001 From: Erik Verbruggen Date: Wed, 23 Jan 2013 13:21:09 +0100 Subject: [PATCH] Fix callBuiltinInvalid for the interpreter. Change-Id: Ifde12261a7c66a7b268129d5fae4ae626e16a00f Reviewed-by: Lars Knoll --- moth/qv4instr_moth_p.h | 9 +++++++++ moth/qv4isel_moth.cpp | 16 +++------------- moth/qv4vme_moth.cpp | 11 ++++++++++- 3 files changed, 22 insertions(+), 14 deletions(-) diff --git a/moth/qv4instr_moth_p.h b/moth/qv4instr_moth_p.h index bafa9aa..d20b84e 100644 --- a/moth/qv4instr_moth_p.h +++ b/moth/qv4instr_moth_p.h @@ -18,6 +18,7 @@ F(Push, push) \ F(CallValue, callValue) \ F(CallProperty, callProperty) \ + F(CallActivationProperty, callActivationProperty) \ F(CallBuiltin, callBuiltin) \ F(CallBuiltinForeachIteratorObject, callBuiltinForeachIteratorObject) \ F(CallBuiltinForeachNextPropertyName, callBuiltinForeachNextPropertyName) \ @@ -152,6 +153,13 @@ union Instr quint32 args; int targetTempIndex; }; + struct instr_callActivationProperty { + MOTH_INSTR_HEADER + VM::String *name; + quint32 argc; + quint32 args; + int targetTempIndex; + }; struct instr_callBuiltin { MOTH_INSTR_HEADER enum { @@ -321,6 +329,7 @@ union Instr instr_push push; instr_callValue callValue; instr_callProperty callProperty; + instr_callActivationProperty callActivationProperty; instr_callBuiltin callBuiltin; instr_callBuiltinForeachIteratorObject callBuiltinForeachIteratorObject; instr_callBuiltinForeachNextPropertyName callBuiltinForeachNextPropertyName; diff --git a/moth/qv4isel_moth.cpp b/moth/qv4isel_moth.cpp index aef7d41..2acdb88 100644 --- a/moth/qv4isel_moth.cpp +++ b/moth/qv4isel_moth.cpp @@ -683,19 +683,10 @@ void InstructionSelection::visitRet(IR::Ret *s) void InstructionSelection::callBuiltinInvalid(IR::Name *func, IR::ExprList *args, IR::Temp *result) { - const int scratchIndex = scratchTempIndex(); - - Instruction::LoadName load; - load.name = engine()->newString(*func->id); - load.targetTempIndex = scratchIndex; - addInstruction(load); - - const int targetTempIndex = result ? result->index : scratchTempIndex(); - - Instruction::CallValue call; + Instruction::CallActivationProperty call; + call.name = engine()->newString(*func->id); prepareCallArgs(args, call.argc, call.args); - call.destIndex = scratchIndex; - call.targetTempIndex = targetTempIndex; + call.targetTempIndex = result ? result->index : scratchTempIndex(); addInstruction(call); } @@ -817,7 +808,6 @@ void InstructionSelection::callBuiltinForeachNextPropertyname(IR::Temp *arg, IR: { Instruction::CallBuiltinForeachNextPropertyName call; call.argTemp = arg->index; - qDebug("result index: %d", result ? result->index : -1); call.targetTempIndex = result ? result->index : scratchTempIndex(); addInstruction(call); } diff --git a/moth/qv4vme_moth.cpp b/moth/qv4vme_moth.cpp index f861996..dff4db6 100644 --- a/moth/qv4vme_moth.cpp +++ b/moth/qv4vme_moth.cpp @@ -221,7 +221,8 @@ VM::Value VME::operator()(QQmlJS::VM::ExecutionContext *context, const uchar *co int argStart = instr.args - context->variableCount(); TRACE(Call, "value index = %d, argStart = %d, argc = %d, result temp index = %d", instr.destIndex, argStart, instr.argc, instr.targetTempIndex); VM::Value *args = stack + argStart; - TEMP(instr.targetTempIndex) = __qmljs_call_value(context, VM::Value::undefinedValue(), TEMP(instr.destIndex), args, instr.argc); + VM::Value result = __qmljs_call_value(context, VM::Value::undefinedValue(), TEMP(instr.destIndex), args, instr.argc); + TEMP(instr.targetTempIndex) = result; MOTH_END_INSTR(CallValue) MOTH_BEGIN_INSTR(CallProperty) @@ -233,6 +234,14 @@ VM::Value VME::operator()(QQmlJS::VM::ExecutionContext *context, const uchar *co TEMP(instr.targetTempIndex) = __qmljs_call_property(context, base, instr.name, args, instr.argc); MOTH_END_INSTR(CallProperty) + MOTH_BEGIN_INSTR(CallActivationProperty) + int argStart = instr.args - context->variableCount(); + // TODO: change this assert everywhere to include a minimum + // TODO: the args calculation is duplicate code, fix that + VM::Value *args = stack + argStart; + TEMP(instr.targetTempIndex) = __qmljs_call_activation_property(context, instr.name, args, instr.argc); + MOTH_END_INSTR(CallActivationProperty) + MOTH_BEGIN_INSTR(CallBuiltin) // TODO: split this into separate instructions switch (instr.builtin) { -- 2.7.4