aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime/qv4context.cpp
diff options
context:
space:
mode:
authorLiang Qi <[email protected]>2017-05-29 10:30:39 +0200
committerLars Knoll <[email protected]>2017-06-06 15:59:38 +0200
commitc254cec22a2352a3fcab60244a6ab74f95d45ace (patch)
treed8456def48b09bd3914eb87c57ab53376f92c14f /src/qml/jsruntime/qv4context.cpp
parentc158ca8be49a75026e83751dfd825c5bdd63189a (diff)
parent3f9367cb32533b691cb8c761213f21a524e3d1cb (diff)
Merge remote-tracking branch 'origin/5.9' into dev
Conflicts: .qmake.conf src/qml/jsruntime/qv4argumentsobject.cpp src/qml/jsruntime/qv4arraydata.cpp src/qml/jsruntime/qv4context.cpp src/qml/jsruntime/qv4context_p.h src/qml/jsruntime/qv4errorobject.cpp src/qml/jsruntime/qv4functionobject.cpp src/qml/jsruntime/qv4internalclass.cpp src/qml/jsruntime/qv4lookup.cpp src/qml/jsruntime/qv4managed.cpp src/qml/jsruntime/qv4managed_p.h src/qml/jsruntime/qv4object.cpp src/qml/jsruntime/qv4object_p.h src/qml/jsruntime/qv4qmlcontext.cpp src/qml/jsruntime/qv4runtime.cpp src/qml/jsruntime/qv4vme_moth.cpp src/qml/memory/qv4heap_p.h src/qml/memory/qv4mm.cpp src/qml/memory/qv4mm_p.h src/qml/memory/qv4mmdefs_p.h src/quick/scenegraph/util/qsgdistancefieldutil.cpp src/quick/scenegraph/util/qsgdistancefieldutil_p.h tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp Change-Id: I7ed925d4f5d308f872a58ddf51fdce0c8494ec9c
Diffstat (limited to 'src/qml/jsruntime/qv4context.cpp')
-rw-r--r--src/qml/jsruntime/qv4context.cpp65
1 files changed, 39 insertions, 26 deletions
diff --git a/src/qml/jsruntime/qv4context.cpp b/src/qml/jsruntime/qv4context.cpp
index 02d3af619e..ba72a9e43b 100644
--- a/src/qml/jsruntime/qv4context.cpp
+++ b/src/qml/jsruntime/qv4context.cpp
@@ -65,13 +65,14 @@ Heap::CallContext *ExecutionContext::newCallContext(Function *function, CallData
uint localsAndFormals = function->compiledFunction->nLocals + sizeof(CallData)/sizeof(Value) - 1 + qMax(static_cast<uint>(callData->argc), function->nFormals);
size_t requiredMemory = sizeof(CallContext::Data) - sizeof(Value) + sizeof(Value) * (localsAndFormals);
- Heap::CallContext *c = d()->engine->memoryManager->allocManaged<CallContext>(requiredMemory);
- c->init(d()->engine, Heap::ExecutionContext::Type_CallContext);
+ ExecutionEngine *v4 = engine();
+ Heap::CallContext *c = v4->memoryManager->allocManaged<CallContext>(requiredMemory);
+ c->init(Heap::ExecutionContext::Type_CallContext);
c->v4Function = function;
c->strictMode = function->isStrict();
- c->outer.set(d()->engine, this->d());
+ c->outer.set(v4, this->d());
c->compilationUnit = function->compilationUnit;
c->lookups = function->compilationUnit->runtimeLookups;
@@ -99,14 +100,14 @@ Heap::CallContext *ExecutionContext::newCallContext(Function *function, CallData
Heap::WithContext *ExecutionContext::newWithContext(Heap::Object *with)
{
- return d()->engine->memoryManager->alloc<WithContext>(d(), with);
+ return engine()->memoryManager->alloc<WithContext>(d(), with);
}
Heap::CatchContext *ExecutionContext::newCatchContext(Heap::String *exceptionVarName, ReturnedValue exceptionValue)
{
Scope scope(this);
ScopedValue e(scope, exceptionValue);
- return d()->engine->memoryManager->alloc<CatchContext>(d(), exceptionVarName, e);
+ return engine()->memoryManager->alloc<CatchContext>(d(), exceptionVarName, e);
}
void ExecutionContext::createMutableBinding(String *name, bool deletable)
@@ -156,35 +157,35 @@ void ExecutionContext::createMutableBinding(String *name, bool deletable)
void Heap::GlobalContext::init(ExecutionEngine *eng)
{
- Heap::ExecutionContext::init(eng, Heap::ExecutionContext::Type_GlobalContext);
+ Heap::ExecutionContext::init(Heap::ExecutionContext::Type_GlobalContext);
global.set(eng, eng->globalObject->d());
}
void Heap::CatchContext::init(ExecutionContext *outerContext, String *exceptionVarName,
const Value &exceptionValue)
{
- Heap::ExecutionContext::init(outerContext->engine, Heap::ExecutionContext::Type_CatchContext);
- outer.set(engine, outerContext);
+ Heap::ExecutionContext::init(Heap::ExecutionContext::Type_CatchContext);
+ outer.set(internalClass->engine, outerContext);
strictMode = outer->strictMode;
callData = outer->callData;
lookups = outer->lookups;
constantTable = outer->constantTable;
compilationUnit = outer->compilationUnit;
- this->exceptionVarName.set(engine, exceptionVarName);
- this->exceptionValue.set(engine, exceptionValue);
+ this->exceptionVarName.set(internalClass->engine, exceptionVarName);
+ this->exceptionValue.set(internalClass->engine, exceptionValue);
}
void Heap::WithContext::init(ExecutionContext *outerContext, Object *with)
{
- Heap::ExecutionContext::init(outerContext->engine, Heap::ExecutionContext::Type_WithContext);
- outer.set(engine, outerContext);
+ Heap::ExecutionContext::init(Heap::ExecutionContext::Type_WithContext);
+ outer.set(internalClass->engine, outerContext);
callData = outer->callData;
lookups = outer->lookups;
constantTable = outer->constantTable;
compilationUnit = outer->compilationUnit;
- withObject.set(engine, with);
+ withObject.set(internalClass->engine, with);
}
Identifier * const *SimpleCallContext::formals() const
@@ -211,6 +212,9 @@ unsigned int SimpleCallContext::variableCount() const
bool ExecutionContext::deleteProperty(String *name)
{
+ name->makeIdentifier();
+ Identifier *id = name->identifier();
+
Scope scope(this);
ScopedContext ctx(scope, this);
for (; ctx; ctx = ctx->d()->outer) {
@@ -235,7 +239,7 @@ bool ExecutionContext::deleteProperty(String *name)
}
case Heap::ExecutionContext::Type_CallContext: {
Heap::CallContext *c = static_cast<Heap::CallContext *>(ctx->d());
- uint index = c->v4Function->internalClass->find(name);
+ uint index = c->v4Function->internalClass->find(id);
if (index < UINT_MAX)
// ### throw in strict mode?
return false;
@@ -282,7 +286,7 @@ void QV4::ExecutionContext::simpleCall(Scope &scope, CallData *callData, Functio
ExecutionContextSaver ctxSaver(scope);
- SimpleCallContext::Data *ctx = scope.engine->memoryManager->allocSimpleCallContext(scope.engine);
+ SimpleCallContext::Data *ctx = scope.engine->memoryManager->allocSimpleCallContext();
ctx->strictMode = function->isStrict();
ctx->callData = callData;
@@ -306,6 +310,9 @@ void QV4::ExecutionContext::simpleCall(Scope &scope, CallData *callData, Functio
void ExecutionContext::setProperty(String *name, const Value &value)
{
+ name->makeIdentifier();
+ Identifier *id = name->identifier();
+
Scope scope(this);
ScopedContext ctx(scope, this);
ScopedObject activation(scope);
@@ -337,7 +344,7 @@ void ExecutionContext::setProperty(String *name, const Value &value)
case Heap::ExecutionContext::Type_SimpleCallContext: {
Heap::SimpleCallContext *c = static_cast<Heap::SimpleCallContext *>(ctx->d());
if (c->v4Function) {
- uint index = c->v4Function->internalClass->find(name);
+ uint index = c->v4Function->internalClass->find(id);
if (index < UINT_MAX) {
if (index < c->v4Function->nFormals) {
c->callData->args[c->v4Function->nFormals - index - 1] = value;
@@ -360,7 +367,7 @@ void ExecutionContext::setProperty(String *name, const Value &value)
}
if (activation) {
- uint member = activation->internalClass()->find(name);
+ uint member = activation->internalClass()->find(id);
if (member < UINT_MAX) {
activation->putValue(member, value);
return;
@@ -368,21 +375,21 @@ void ExecutionContext::setProperty(String *name, const Value &value)
}
}
- if (d()->strictMode || name->equals(d()->engine->id_this())) {
+ if (d()->strictMode || name->equals(engine()->id_this())) {
ScopedValue n(scope, name->asReturnedValue());
engine()->throwReferenceError(n);
return;
}
- d()->engine->globalObject->put(name, value);
+ engine()->globalObject->put(name, value);
}
ReturnedValue ExecutionContext::getProperty(String *name)
{
Scope scope(this);
ScopedValue v(scope);
- name->makeIdentifier(scope.engine);
+ name->makeIdentifier();
- if (name->equals(d()->engine->id_this()))
+ if (name->equals(engine()->id_this()))
return thisObject().asReturnedValue();
ScopedContext ctx(scope, this);
@@ -413,7 +420,10 @@ ReturnedValue ExecutionContext::getProperty(String *name)
}
case Heap::ExecutionContext::Type_CallContext: {
Heap::CallContext *c = static_cast<Heap::CallContext *>(ctx->d());
- uint index = c->v4Function->internalClass->find(name);
+ name->makeIdentifier();
+ Identifier *id = name->identifier();
+
+ uint index = c->v4Function->internalClass->find(id);
if (index < UINT_MAX) {
if (index < c->v4Function->nFormals)
return c->callData->args[c->v4Function->nFormals - index - 1].asReturnedValue();
@@ -456,9 +466,9 @@ ReturnedValue ExecutionContext::getPropertyAndBase(String *name, Value *base)
Scope scope(this);
ScopedValue v(scope);
base->setM(0);
- name->makeIdentifier(scope.engine);
+ name->makeIdentifier();
- if (name->equals(d()->engine->id_this()))
+ if (name->equals(engine()->id_this()))
return thisObject().asReturnedValue();
ScopedContext ctx(scope, this);
@@ -490,7 +500,10 @@ ReturnedValue ExecutionContext::getPropertyAndBase(String *name, Value *base)
}
case Heap::ExecutionContext::Type_CallContext: {
Heap::CallContext *c = static_cast<Heap::CallContext *>(ctx->d());
- uint index = c->v4Function->internalClass->find(name);
+ name->makeIdentifier();
+ Identifier *id = name->identifier();
+
+ uint index = c->v4Function->internalClass->find(id);
if (index < UINT_MAX) {
if (index < c->v4Function->nFormals)
return c->callData->args[c->v4Function->nFormals - index - 1].asReturnedValue();
@@ -531,7 +544,7 @@ ReturnedValue ExecutionContext::getPropertyAndBase(String *name, Value *base)
Function *ExecutionContext::getFunction() const
{
- Scope scope(d()->engine);
+ Scope scope(engine());
ScopedContext it(scope, this->d());
for (; it; it = it->d()->outer) {
if (const SimpleCallContext *callCtx = it->asSimpleCallContext())