From b459c43c5d119507f888ac9ab1ca96f8e7bb6e34 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Wed, 9 Aug 2017 16:32:18 +0200 Subject: Always retrieve the this object from the stack There is actually no point in even having it in the context, as it's immutable and can't become part of a closure. Change-Id: I375fd07b9c442d667488430ebd246e174fdb243f Reviewed-by: Simon Hausmann --- src/qml/compiler/qv4codegen.cpp | 11 +++-------- src/qml/jsruntime/qv4runtime.cpp | 12 ------------ src/qml/jsruntime/qv4runtimeapi_p.h | 1 - src/qml/jsruntime/qv4vme_moth.cpp | 16 ++++++---------- 4 files changed, 9 insertions(+), 31 deletions(-) diff --git a/src/qml/compiler/qv4codegen.cpp b/src/qml/compiler/qv4codegen.cpp index f62e1672da..eee9d05d52 100644 --- a/src/qml/compiler/qv4codegen.cpp +++ b/src/qml/compiler/qv4codegen.cpp @@ -3027,14 +3027,9 @@ void Codegen::Reference::loadInAccumulator() const } return; case This: { Context *c = codegen->currentContext(); - if (c->canUseSimpleCall()) { - Instruction::LoadReg load; - load.reg = Moth::StackSlot::createArgument(c->arguments.size(), -1); - codegen->bytecodeGenerator->addInstruction(load); - } else { - Instruction::LoadThis load; - codegen->bytecodeGenerator->addInstruction(load); - } + Instruction::LoadReg load; + load.reg = Moth::StackSlot::createArgument(c->arguments.size(), -1); + codegen->bytecodeGenerator->addInstruction(load); } return; case Invalid: break; diff --git a/src/qml/jsruntime/qv4runtime.cpp b/src/qml/jsruntime/qv4runtime.cpp index ac1faae6c9..8a630b451c 100644 --- a/src/qml/jsruntime/qv4runtime.cpp +++ b/src/qml/jsruntime/qv4runtime.cpp @@ -1405,18 +1405,6 @@ QV4::ReturnedValue Runtime::method_loadQmlSingleton(QV4::NoThrowEngine *engine, return engine->qmlSingletonWrapper(name); } -void Runtime::method_convertThisToObject(ExecutionEngine *engine) -{ - Value *t = &engine->currentContext()->d()->callData->thisObject; - if (t->isObject()) - return; - if (t->isNullOrUndefined()) { - *t = engine->globalObject->asReturnedValue(); - } else { - *t = t->toObject(engine)->asReturnedValue(); - } -} - ReturnedValue Runtime::method_uMinus(const Value &value) { TRACE1(value); diff --git a/src/qml/jsruntime/qv4runtimeapi_p.h b/src/qml/jsruntime/qv4runtimeapi_p.h index caaefa2f75..e7f9a04434 100644 --- a/src/qml/jsruntime/qv4runtimeapi_p.h +++ b/src/qml/jsruntime/qv4runtimeapi_p.h @@ -139,7 +139,6 @@ struct ExceptionCheck { F(void, declareVar, (ExecutionEngine *engine, bool deletable, int nameIndex)) \ F(ReturnedValue, createMappedArgumentsObject, (ExecutionEngine *engine)) \ F(ReturnedValue, createUnmappedArgumentsObject, (ExecutionEngine *engine)) \ - F(void, convertThisToObject, (ExecutionEngine *engine)) \ \ /* literals */ \ F(ReturnedValue, arrayLiteral, (ExecutionEngine *engine, Value *values, uint length)) \ diff --git a/src/qml/jsruntime/qv4vme_moth.cpp b/src/qml/jsruntime/qv4vme_moth.cpp index e98d5a7677..7655f898c3 100644 --- a/src/qml/jsruntime/qv4vme_moth.cpp +++ b/src/qml/jsruntime/qv4vme_moth.cpp @@ -746,17 +746,13 @@ QV4::ReturnedValue VME::exec(const FunctionObject *jsFunction, CallData *callDat MOTH_END_INSTR(CreateUnmappedArgumentsObject) MOTH_BEGIN_INSTR(ConvertThisToObject) - if (function->canUseSimpleFunction()) { - Value *t = &stack[-(int)function->nFormals - 1]; - if (!t->isObject()) { - if (t->isNullOrUndefined()) { - *t = engine->globalObject->asReturnedValue(); - } else { - *t = t->toObject(engine)->asReturnedValue(); - } + Value *t = &stack[-(int)function->nFormals - 1]; + if (!t->isObject()) { + if (t->isNullOrUndefined()) { + *t = engine->globalObject->asReturnedValue(); + } else { + *t = t->toObject(engine)->asReturnedValue(); } - } else { - Runtime::method_convertThisToObject(engine); } CHECK_EXCEPTION; MOTH_END_INSTR(ConvertThisToObject) -- cgit v1.2.3