diff options
Diffstat (limited to 'src/qml/jsruntime')
-rw-r--r-- | src/qml/jsruntime/qv4function.cpp | 2 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4function_p.h | 6 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4functionobject.cpp | 32 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4globalobject.cpp | 3 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4script.cpp | 6 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4vme_moth.cpp | 12 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4vme_moth_p.h | 4 |
7 files changed, 36 insertions, 29 deletions
diff --git a/src/qml/jsruntime/qv4function.cpp b/src/qml/jsruntime/qv4function.cpp index 9907f3e2ba..a7ae365d21 100644 --- a/src/qml/jsruntime/qv4function.cpp +++ b/src/qml/jsruntime/qv4function.cpp @@ -52,7 +52,7 @@ QT_BEGIN_NAMESPACE using namespace QV4; Function::Function(ExecutionEngine *engine, CompiledData::CompilationUnit *unit, const CompiledData::Function *function, - Value (*codePtr)(ExecutionContext *, const uchar *), quint32 _codeSize) + ReturnedValue (*codePtr)(ExecutionContext *, const uchar *), quint32 _codeSize) : name(0) , compiledFunction(function) , compilationUnit(unit) diff --git a/src/qml/jsruntime/qv4function_p.h b/src/qml/jsruntime/qv4function_p.h index e9640fd925..2e03df4871 100644 --- a/src/qml/jsruntime/qv4function_p.h +++ b/src/qml/jsruntime/qv4function_p.h @@ -86,7 +86,7 @@ struct Function { const CompiledData::Function *compiledFunction; CompiledData::CompilationUnit *compilationUnit; - inline Value code(ExecutionContext *ctx, const uchar *data) { + inline ReturnedValue code(ExecutionContext *ctx, const uchar *data) { Value *stack = ctx->engine->jsStackTop; try { return codePtr(ctx, data); @@ -96,7 +96,7 @@ struct Function { } } - Value (*codePtr)(ExecutionContext *, const uchar *); + ReturnedValue (*codePtr)(ExecutionContext *, const uchar *); const uchar *codeData; quint32 codeSize; @@ -104,7 +104,7 @@ struct Function { QVector<String *> locals; Function(ExecutionEngine *engine, CompiledData::CompilationUnit *unit, const CompiledData::Function *function, - Value (*codePtr)(ExecutionContext *, const uchar *), quint32 _codeSize); + ReturnedValue (*codePtr)(ExecutionContext *, const uchar *), quint32 _codeSize); ~Function(); inline QString sourceFile() const { return compilationUnit->fileName(); } diff --git a/src/qml/jsruntime/qv4functionobject.cpp b/src/qml/jsruntime/qv4functionobject.cpp index 4ca2ba8aff..c87fad62b3 100644 --- a/src/qml/jsruntime/qv4functionobject.cpp +++ b/src/qml/jsruntime/qv4functionobject.cpp @@ -405,8 +405,8 @@ ScriptFunction::ScriptFunction(ExecutionContext *scope, Function *function) Value ScriptFunction::construct(Managed *that, CallData *callData) { ScriptFunction *f = static_cast<ScriptFunction *>(that); - SAVE_JS_STACK(f->scope); ExecutionEngine *v4 = f->engine(); + ValueScope scope(v4); InternalClass *ic = v4->objectClass; Value proto = f->memberData[Index_Prototype].value; @@ -418,17 +418,18 @@ Value ScriptFunction::construct(Managed *that, CallData *callData) callData->thisObject = Value::fromObject(obj); ExecutionContext *ctx = context->newCallContext(f, callData); - Value result; + ScopedValue result(scope); + SAVE_JS_STACK(f->scope); try { result = f->function->code(ctx, f->function->codeData); } catch (Exception &ex) { ex.partiallyUnwindContext(context); throw; } + CHECK_JS_STACK(f->scope); ctx->engine->popContext(); - CHECK_JS_STACK(f->scope); - if (result.isObject()) + if (result->isObject()) return result; return Value::fromObject(obj); } @@ -436,9 +437,9 @@ Value ScriptFunction::construct(Managed *that, CallData *callData) Value ScriptFunction::call(Managed *that, CallData *callData) { ScriptFunction *f = static_cast<ScriptFunction *>(that); - SAVE_JS_STACK(f->scope); void *stackSpace; ExecutionContext *context = f->engine()->current; + ValueScope scope(context); CallContext *ctx = context->newCallContext(f, callData); if (!f->strictMode && !callData->thisObject.isObject()) { @@ -449,15 +450,16 @@ Value ScriptFunction::call(Managed *that, CallData *callData) } } - Value result; + ScopedValue result(scope); + SAVE_JS_STACK(f->scope); try { result = f->function->code(ctx, f->function->codeData); } catch (Exception &ex) { ex.partiallyUnwindContext(context); throw; } - ctx->engine->popContext(); CHECK_JS_STACK(f->scope); + ctx->engine->popContext(); return result; } @@ -499,8 +501,8 @@ SimpleScriptFunction::SimpleScriptFunction(ExecutionContext *scope, Function *fu Value SimpleScriptFunction::construct(Managed *that, CallData *callData) { SimpleScriptFunction *f = static_cast<SimpleScriptFunction *>(that); - SAVE_JS_STACK(f->scope); ExecutionEngine *v4 = f->engine(); + ValueScope scope(v4); InternalClass *ic = v4->objectClass; Value proto = f->memberData[Index_Prototype].value; @@ -513,17 +515,18 @@ Value SimpleScriptFunction::construct(Managed *that, CallData *callData) callData->thisObject = Value::fromObject(obj); ExecutionContext *ctx = context->newCallContext(stackSpace, f, callData); - Value result; + ScopedValue result(scope); + SAVE_JS_STACK(f->scope); try { result = f->function->code(ctx, f->function->codeData); } catch (Exception &ex) { ex.partiallyUnwindContext(context); throw; } + CHECK_JS_STACK(f->scope); ctx->engine->popContext(); - CHECK_JS_STACK(f->scope); - if (result.isObject()) + if (result->isObject()) return result; return Value::fromObject(obj); } @@ -531,9 +534,9 @@ Value SimpleScriptFunction::construct(Managed *that, CallData *callData) Value SimpleScriptFunction::call(Managed *that, CallData *callData) { SimpleScriptFunction *f = static_cast<SimpleScriptFunction *>(that); - SAVE_JS_STACK(f->scope); void *stackSpace = alloca(requiredMemoryForExecutionContectSimple(f)); ExecutionContext *context = f->engine()->current; + ValueScope scope(context); ExecutionContext *ctx = context->newCallContext(stackSpace, f, callData); if (!f->strictMode && !callData->thisObject.isObject()) { @@ -544,15 +547,16 @@ Value SimpleScriptFunction::call(Managed *that, CallData *callData) } } - Value result; + ScopedValue result(scope); + SAVE_JS_STACK(f->scope); try { result = f->function->code(ctx, f->function->codeData); } catch (Exception &ex) { ex.partiallyUnwindContext(context); throw; } - ctx->engine->popContext(); CHECK_JS_STACK(f->scope); + ctx->engine->popContext(); return result; } diff --git a/src/qml/jsruntime/qv4globalobject.cpp b/src/qml/jsruntime/qv4globalobject.cpp index 9764a7930f..6176893d68 100644 --- a/src/qml/jsruntime/qv4globalobject.cpp +++ b/src/qml/jsruntime/qv4globalobject.cpp @@ -362,6 +362,7 @@ Value EvalFunction::evalCall(Value /*thisObject*/, Value *args, int argc, bool d ExecutionContext *parentContext = engine()->current; ExecutionEngine *engine = parentContext->engine; ExecutionContext *ctx = parentContext; + ValueScope scope(ctx); if (!directCall) { // the context for eval should be the global scope, so we fake a root @@ -412,7 +413,7 @@ Value EvalFunction::evalCall(Value /*thisObject*/, Value *args, int argc, bool d ctx->compiledFunction = function->compiledFunction; ctx->runtimeStrings = function->compilationUnit->runtimeStrings; - Value result = Value::undefinedValue(); + ScopedValue result(scope); try { result = function->code(ctx, function->codeData); } catch (Exception &ex) { diff --git a/src/qml/jsruntime/qv4script.cpp b/src/qml/jsruntime/qv4script.cpp index e2a4054ea4..23d84a8b47 100644 --- a/src/qml/jsruntime/qv4script.cpp +++ b/src/qml/jsruntime/qv4script.cpp @@ -125,12 +125,13 @@ DEFINE_MANAGED_VTABLE(CompilationUnitHolder); Value QmlBindingWrapper::call(Managed *that, CallData *) { ExecutionEngine *engine = that->engine(); + ValueScope scope(engine); QmlBindingWrapper *This = static_cast<QmlBindingWrapper *>(that); CallContext *ctx = This->qmlContext; std::fill(ctx->locals, ctx->locals + ctx->function->varCount, Value::undefinedValue()); engine->pushContext(ctx); - Value result = This->function->code(ctx, This->function->codeData); + ScopedValue result(scope, This->function->code(ctx, This->function->codeData)); engine->popContext(); return result; @@ -211,6 +212,7 @@ Value Script::run() return Value::undefinedValue(); QV4::ExecutionEngine *engine = scope->engine; + QV4::ValueScope valueScope(engine); if (qml.isEmpty()) { TemporaryAssignment<Function*> savedGlobalCode(engine->globalCode, vmFunction); @@ -227,7 +229,7 @@ Value Script::run() scope->compiledFunction = vmFunction->compiledFunction; scope->runtimeStrings = vmFunction->compilationUnit->runtimeStrings; - QV4::Value result; + QV4::ScopedValue result(valueScope); try { result = vmFunction->code(scope, vmFunction->codeData); } catch (Exception &e) { diff --git a/src/qml/jsruntime/qv4vme_moth.cpp b/src/qml/jsruntime/qv4vme_moth.cpp index caeeeb4672..ff85ae3ebb 100644 --- a/src/qml/jsruntime/qv4vme_moth.cpp +++ b/src/qml/jsruntime/qv4vme_moth.cpp @@ -219,8 +219,8 @@ static inline QV4::Value *getValueRef(QV4::ExecutionContext *context, #endif #define STOREVALUE(param, value) VALUE(param) = QV4::Value::fromReturnedValue((value)) -QV4::Value VME::run(QV4::ExecutionContext *context, const uchar *&code, - QV4::Value *stack, unsigned stackSize +QV4::ReturnedValue VME::run(QV4::ExecutionContext *context, const uchar *&code, + QV4::Value *stack, unsigned stackSize #ifdef MOTH_THREADED_INTERPRETER , void ***storeJumpTable #endif @@ -238,7 +238,7 @@ QV4::Value VME::run(QV4::ExecutionContext *context, const uchar *&code, }; #undef MOTH_INSTR_ADDR *storeJumpTable = jumpTable; - return QV4::Value::undefinedValue(); + return QV4::Value::undefinedValue().asReturnedValue(); } #endif @@ -395,7 +395,7 @@ QV4::Value VME::run(QV4::ExecutionContext *context, const uchar *&code, MOTH_END_INSTR(EnterTry) MOTH_BEGIN_INSTR(CallBuiltinFinishTry) - return QV4::Value(); + return QV4::ReturnedValue(0); MOTH_END_INSTR(CallBuiltinFinishTry) MOTH_BEGIN_INSTR(CallBuiltinPushScope) @@ -551,7 +551,7 @@ QV4::Value VME::run(QV4::ExecutionContext *context, const uchar *&code, context->engine->stackPop(stackSize); QV4::Value &result = VALUE(instr.result); // TRACE(Ret, "returning value %s", result.toString(context)->toQString().toUtf8().constData()); - return result; + return result.asReturnedValue(); MOTH_END_INSTR(Ret) MOTH_BEGIN_INSTR(LoadThis) @@ -601,7 +601,7 @@ void **VME::instructionJumpTable() } #endif -QV4::Value VME::exec(QV4::ExecutionContext *ctxt, const uchar *code) +QV4::ReturnedValue VME::exec(QV4::ExecutionContext *ctxt, const uchar *code) { VME vme; return vme.run(ctxt, code); diff --git a/src/qml/jsruntime/qv4vme_moth_p.h b/src/qml/jsruntime/qv4vme_moth_p.h index aedf865033..04c7f933ab 100644 --- a/src/qml/jsruntime/qv4vme_moth_p.h +++ b/src/qml/jsruntime/qv4vme_moth_p.h @@ -53,14 +53,14 @@ namespace Moth { class VME { public: - static QV4::Value exec(QV4::ExecutionContext *, const uchar *); + static QV4::ReturnedValue exec(QV4::ExecutionContext *, const uchar *); #ifdef MOTH_THREADED_INTERPRETER static void **instructionJumpTable(); #endif private: - QV4::Value run(QV4::ExecutionContext *, const uchar *&code, + QV4::ReturnedValue run(QV4::ExecutionContext *, const uchar *&code, QV4::Value *stack = 0, unsigned stackSize = 0 #ifdef MOTH_THREADED_INTERPRETER , void ***storeJumpTable = 0 |