diff options
author | Lars Knoll <[email protected]> | 2013-09-30 20:57:57 +0200 |
---|---|---|
committer | The Qt Project <[email protected]> | 2013-10-02 16:07:33 +0200 |
commit | ac8afca822031f3039dce31525a6ab48c741e73b (patch) | |
tree | 1f65aa3ac5ddd8234bd83125573691294f200707 /src/qml/jsruntime | |
parent | 1e454c8aa6ad0782eee1c8c94ac2780954a08351 (diff) |
Remove some more uses of QV4::Value
All remaining uses should be GC safe now.
Change-Id: I05c962de6ab896f108f70caa1bf937a24e67bfe1
Reviewed-by: Simon Hausmann <[email protected]>
Diffstat (limited to 'src/qml/jsruntime')
-rw-r--r-- | src/qml/jsruntime/qv4context.cpp | 2 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4mm.cpp | 6 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4numberobject.cpp | 29 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4objectiterator.cpp | 4 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4stringobject_p.h | 2 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4vme_moth.cpp | 10 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4vme_moth_p.h | 2 |
7 files changed, 29 insertions, 26 deletions
diff --git a/src/qml/jsruntime/qv4context.cpp b/src/qml/jsruntime/qv4context.cpp index 9dc5e2fe53..674dd46e96 100644 --- a/src/qml/jsruntime/qv4context.cpp +++ b/src/qml/jsruntime/qv4context.cpp @@ -250,7 +250,7 @@ void CallContext::initQmlContext(ExecutionContext *parentContext, ObjectRef qml, this->function = function; this->callData = reinterpret_cast<CallData *>(this + 1); - this->callData->tag = QV4::Value::Integer_Type; + this->callData->tag = QV4::Value::_Integer_Type; this->callData->argc = 0; this->callData->thisObject = Primitive::undefinedValue(); diff --git a/src/qml/jsruntime/qv4mm.cpp b/src/qml/jsruntime/qv4mm.cpp index 54fee80d72..f6adadf719 100644 --- a/src/qml/jsruntime/qv4mm.cpp +++ b/src/qml/jsruntime/qv4mm.cpp @@ -579,12 +579,6 @@ void MemoryManager::unprotect(Managed *m) m_d->protectedObject.remove(m); } -static inline void add(QVector<Managed *> &values, const Value &v) -{ - if (Object *o = v.asObject()) - values.append(o); -} - void MemoryManager::setExecutionEngine(ExecutionEngine *engine) { m_d->engine = engine; diff --git a/src/qml/jsruntime/qv4numberobject.cpp b/src/qml/jsruntime/qv4numberobject.cpp index 06a04b4eb7..3ff4b795f5 100644 --- a/src/qml/jsruntime/qv4numberobject.cpp +++ b/src/qml/jsruntime/qv4numberobject.cpp @@ -100,19 +100,29 @@ void NumberPrototype::init(ExecutionEngine *engine, ObjectRef ctor) defineDefaultProperty(QStringLiteral("toPrecision"), method_toPrecision); } -inline Value thisNumberValue(ExecutionContext *ctx) +inline ReturnedValue thisNumberValue(ExecutionContext *ctx) { if (ctx->callData->thisObject.isNumber()) - return ctx->callData->thisObject; + return ctx->callData->thisObject.asReturnedValue(); NumberObject *n = ctx->callData->thisObject.asNumberObject(); if (!n) ctx->throwTypeError(); - return n->value; + return n->value.asReturnedValue(); +} + +inline double thisNumber(ExecutionContext *ctx) +{ + if (ctx->callData->thisObject.isNumber()) + return ctx->callData->thisObject.asDouble(); + NumberObject *n = ctx->callData->thisObject.asNumberObject(); + if (!n) + ctx->throwTypeError(); + return n->value.asDouble(); } ReturnedValue NumberPrototype::method_toString(SimpleCallContext *ctx) { - double num = thisNumberValue(ctx).asDouble(); + double num = thisNumber(ctx); if (ctx->callData->argc && !ctx->callData->args[0].isUndefined()) { int radix = ctx->callData->args[0].toInt32(); @@ -165,20 +175,20 @@ ReturnedValue NumberPrototype::method_toString(SimpleCallContext *ctx) ReturnedValue NumberPrototype::method_toLocaleString(SimpleCallContext *ctx) { Scope scope(ctx); - Value v = thisNumberValue(ctx); + ScopedValue v(scope, thisNumberValue(ctx)); - ScopedString str(scope, v.toString(ctx)); + ScopedString str(scope, v->toString(ctx)); return str.asReturnedValue(); } ReturnedValue NumberPrototype::method_valueOf(SimpleCallContext *ctx) { - return thisNumberValue(ctx).asReturnedValue(); + return thisNumberValue(ctx); } ReturnedValue NumberPrototype::method_toFixed(SimpleCallContext *ctx) { - double v = thisNumberValue(ctx).asDouble(); + double v = thisNumber(ctx); double fdigits = 0; @@ -206,7 +216,7 @@ ReturnedValue NumberPrototype::method_toFixed(SimpleCallContext *ctx) ReturnedValue NumberPrototype::method_toExponential(SimpleCallContext *ctx) { Scope scope(ctx); - double d = thisNumberValue(ctx).asDouble(); + double d = thisNumber(ctx); int fdigits = -1; @@ -229,7 +239,6 @@ ReturnedValue NumberPrototype::method_toExponential(SimpleCallContext *ctx) ReturnedValue NumberPrototype::method_toPrecision(SimpleCallContext *ctx) { Scope scope(ctx); - ScopedValue v(scope, thisNumberValue(ctx)); if (!ctx->callData->argc || ctx->callData->args[0].isUndefined()) diff --git a/src/qml/jsruntime/qv4objectiterator.cpp b/src/qml/jsruntime/qv4objectiterator.cpp index 2030489ea1..46698b0ad3 100644 --- a/src/qml/jsruntime/qv4objectiterator.cpp +++ b/src/qml/jsruntime/qv4objectiterator.cpp @@ -123,7 +123,7 @@ ReturnedValue ObjectIterator::nextPropertyName(ValueRef value) if (!p) return Encode::null(); - value = Value::fromReturnedValue(object->getValue(p, attrs)); + value = object->getValue(p, attrs); if (!!name) return name->asReturnedValue(); @@ -144,7 +144,7 @@ ReturnedValue ObjectIterator::nextPropertyNameAsString(ValueRef value) if (!p) return Encode::null(); - value = Value::fromReturnedValue(object->getValue(p, attrs)); + value = object->getValue(p, attrs); if (!!name) return name->asReturnedValue(); diff --git a/src/qml/jsruntime/qv4stringobject_p.h b/src/qml/jsruntime/qv4stringobject_p.h index 08892d1222..e6777380a4 100644 --- a/src/qml/jsruntime/qv4stringobject_p.h +++ b/src/qml/jsruntime/qv4stringobject_p.h @@ -52,7 +52,7 @@ namespace QV4 { struct StringObject: Object { Q_MANAGED - Value value; + SafeValue value; mutable Property tmpProperty; StringObject(ExecutionEngine *engine, const ValueRef value); diff --git a/src/qml/jsruntime/qv4vme_moth.cpp b/src/qml/jsruntime/qv4vme_moth.cpp index 52832feb73..a3fc43b39c 100644 --- a/src/qml/jsruntime/qv4vme_moth.cpp +++ b/src/qml/jsruntime/qv4vme_moth.cpp @@ -135,7 +135,7 @@ static VMStats vmStats; #endif // WITH_STATS static inline QV4::Value *getValueRef(QV4::ExecutionContext *context, - QV4::Value* stack, + QV4::SafeValue* stack, const Param ¶m #if !defined(QT_NO_DEBUG) , unsigned stackSize @@ -220,7 +220,7 @@ static inline QV4::Value *getValueRef(QV4::ExecutionContext *context, #define STOREVALUE(param, value) VALUE(param) = QV4::Value::fromReturnedValue((value)) QV4::ReturnedValue VME::run(QV4::ExecutionContext *context, const uchar *&code, - QV4::Value *stack, unsigned stackSize + QV4::SafeValue *stack, unsigned stackSize #ifdef MOTH_THREADED_INTERPRETER , void ***storeJumpTable #endif @@ -311,7 +311,7 @@ QV4::ReturnedValue VME::run(QV4::ExecutionContext *context, const uchar *&code, TRACE(inline, "stack size: %u", instr.value); stackSize = instr.value; stack = context->engine->stackPush(stackSize); - memset(stack, 0, stackSize * sizeof(QV4::Value)); + memset(stack, 0, stackSize * sizeof(QV4::SafeValue)); MOTH_END_INSTR(Push) MOTH_BEGIN_INSTR(CallValue) @@ -456,12 +456,12 @@ QV4::ReturnedValue VME::run(QV4::ExecutionContext *context, const uchar *&code, MOTH_BEGIN_INSTR(CallBuiltinDefineArray) Q_ASSERT(instr.args + instr.argc <= stackSize); - QV4::Value *args = stack + instr.args; + QV4::SafeValue *args = stack + instr.args; STOREVALUE(instr.result, __qmljs_builtin_define_array(context, args, instr.argc)); MOTH_END_INSTR(CallBuiltinDefineArray) MOTH_BEGIN_INSTR(CallBuiltinDefineObjectLiteral) - QV4::Value *args = stack + instr.args; + QV4::SafeValue *args = stack + instr.args; STOREVALUE(instr.result, __qmljs_builtin_define_object_literal(context, args, instr.internalClassId)); MOTH_END_INSTR(CallBuiltinDefineObjectLiteral) diff --git a/src/qml/jsruntime/qv4vme_moth_p.h b/src/qml/jsruntime/qv4vme_moth_p.h index 04c7f933ab..68d8086f52 100644 --- a/src/qml/jsruntime/qv4vme_moth_p.h +++ b/src/qml/jsruntime/qv4vme_moth_p.h @@ -61,7 +61,7 @@ public: private: QV4::ReturnedValue run(QV4::ExecutionContext *, const uchar *&code, - QV4::Value *stack = 0, unsigned stackSize = 0 + QV4::SafeValue *stack = 0, unsigned stackSize = 0 #ifdef MOTH_THREADED_INTERPRETER , void ***storeJumpTable = 0 #endif |