aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@digia.com>2013-09-30 20:57:57 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-10-02 16:07:33 +0200
commitac8afca822031f3039dce31525a6ab48c741e73b (patch)
tree1f65aa3ac5ddd8234bd83125573691294f200707
parent1e454c8aa6ad0782eee1c8c94ac2780954a08351 (diff)
Remove some more uses of QV4::Value
All remaining uses should be GC safe now. Change-Id: I05c962de6ab896f108f70caa1bf937a24e67bfe1 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
-rw-r--r--src/qml/compiler/qv4isel_masm.cpp12
-rw-r--r--src/qml/compiler/qv4isel_masm_p.h10
-rw-r--r--src/qml/jsruntime/qv4context.cpp2
-rw-r--r--src/qml/jsruntime/qv4mm.cpp6
-rw-r--r--src/qml/jsruntime/qv4numberobject.cpp29
-rw-r--r--src/qml/jsruntime/qv4objectiterator.cpp4
-rw-r--r--src/qml/jsruntime/qv4stringobject_p.h2
-rw-r--r--src/qml/jsruntime/qv4vme_moth.cpp10
-rw-r--r--src/qml/jsruntime/qv4vme_moth_p.h2
-rw-r--r--src/quick/items/context2d/qquickcontext2d.cpp8
10 files changed, 44 insertions, 41 deletions
diff --git a/src/qml/compiler/qv4isel_masm.cpp b/src/qml/compiler/qv4isel_masm.cpp
index 6dabbce5f8..6afbee2400 100644
--- a/src/qml/compiler/qv4isel_masm.cpp
+++ b/src/qml/compiler/qv4isel_masm.cpp
@@ -699,12 +699,12 @@ void InstructionSelection::run(int functionIndex)
_as = oldAssembler;
}
-void *InstructionSelection::addConstantTable(QVector<Value> *values)
+void *InstructionSelection::addConstantTable(QVector<Primitive> *values)
{
compilationUnit->constantValues.append(*values);
values->clear();
- QVector<QV4::Value> &finalValues = compilationUnit->constantValues.last();
+ QVector<QV4::Primitive> &finalValues = compilationUnit->constantValues.last();
finalValues.squeeze();
return finalValues.data();
}
@@ -1872,14 +1872,14 @@ int InstructionSelection::prepareCallData(V4IR::ExprList* args, V4IR::Expr *this
QT_BEGIN_NAMESPACE
namespace QV4 {
-bool operator==(const Value &v1, const Value &v2)
+bool operator==(const Primitive &v1, const Primitive &v2)
{
return v1.rawValue() == v2.rawValue();
}
} // QV4 namespace
QT_END_NAMESPACE
-int Assembler::ConstantTable::add(const Value &v)
+int Assembler::ConstantTable::add(const Primitive &v)
{
int idx = _values.indexOf(v);
if (idx == -1) {
@@ -1895,12 +1895,12 @@ Assembler::ImplicitAddress Assembler::ConstantTable::loadValueAddress(V4IR::Cons
return loadValueAddress(convertToValue(c), baseReg);
}
-Assembler::ImplicitAddress Assembler::ConstantTable::loadValueAddress(const Value &v,
+Assembler::ImplicitAddress Assembler::ConstantTable::loadValueAddress(const Primitive &v,
RegisterID baseReg)
{
_toPatch.append(_as->moveWithPatch(TrustedImmPtr(0), baseReg));
ImplicitAddress addr(baseReg);
- addr.offset = add(v) * sizeof(QV4::Value);
+ addr.offset = add(v) * sizeof(QV4::Primitive);
Q_ASSERT(addr.offset >= 0);
return addr;
}
diff --git a/src/qml/compiler/qv4isel_masm_p.h b/src/qml/compiler/qv4isel_masm_p.h
index 20b0c1b7e8..a689cdf63e 100644
--- a/src/qml/compiler/qv4isel_masm_p.h
+++ b/src/qml/compiler/qv4isel_masm_p.h
@@ -72,7 +72,7 @@ struct CompilationUnit : public QV4::CompiledData::CompilationUnit
// Coderef + execution engine
QVector<JSC::MacroAssemblerCodeRef> codeRefs;
- QList<QVector<QV4::Value> > constantValues;
+ QList<QVector<QV4::Primitive> > constantValues;
QVector<int> codeSizes; // corresponding to the endOfCode labels. MacroAssemblerCodeRef's size may
// be larger, as for example on ARM we append the exception handling table.
};
@@ -387,14 +387,14 @@ public:
public:
ConstantTable(Assembler *as): _as(as) {}
- int add(const QV4::Value &v);
+ int add(const QV4::Primitive &v);
ImplicitAddress loadValueAddress(V4IR::Const *c, RegisterID baseReg);
- ImplicitAddress loadValueAddress(const QV4::Value &v, RegisterID baseReg);
+ ImplicitAddress loadValueAddress(const QV4::Primitive &v, RegisterID baseReg);
void finalize(JSC::LinkBuffer &linkBuffer, InstructionSelection *isel);
private:
Assembler *_as;
- QVector<QV4::Value> _values;
+ QVector<QV4::Primitive> _values;
QVector<DataLabelPtr> _toPatch;
};
@@ -1361,7 +1361,7 @@ public:
virtual void run(int functionIndex);
- void *addConstantTable(QVector<QV4::Value> *values);
+ void *addConstantTable(QVector<QV4::Primitive> *values);
protected:
virtual QV4::CompiledData::CompilationUnit *backendCompileStep();
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 &param
#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
diff --git a/src/quick/items/context2d/qquickcontext2d.cpp b/src/quick/items/context2d/qquickcontext2d.cpp
index 02a813e17f..bab9a2ce17 100644
--- a/src/quick/items/context2d/qquickcontext2d.cpp
+++ b/src/quick/items/context2d/qquickcontext2d.cpp
@@ -906,7 +906,7 @@ struct QQuickJSContext2DImageData : public QV4::Object
- QV4::Value pixelData;
+ QV4::SafeValue pixelData;
};
DEFINE_MANAGED_VTABLE(QQuickJSContext2DImageData);
@@ -2975,7 +2975,7 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_drawImage(QV4::SimpleCallC
V4THROW_DOM(DOMEXCEPTION_TYPE_MISMATCH_ERR, "drawImage(), type mismatch");
}
} else if (QQuickJSContext2DImageData *imageData = arg->as<QQuickJSContext2DImageData>()) {
- QQuickJSContext2DPixelData *pix = imageData->pixelData.as<QQuickJSContext2DPixelData>();
+ QV4::Scoped<QQuickJSContext2DPixelData> pix(scope, imageData->pixelData.as<QQuickJSContext2DPixelData>());
if (pix && !pix->image.isNull()) {
pixmap.take(new QQuickCanvasPixmap(pix->image, r->context->canvas()->window()));
} else {
@@ -3240,7 +3240,7 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_createImageData(QV4::Simpl
if (ctx->callData->argc == 1) {
QV4::ScopedValue arg0(scope, ctx->callData->args[0]);
if (QQuickJSContext2DImageData *imgData = arg0->as<QQuickJSContext2DImageData>()) {
- QQuickJSContext2DPixelData *pa = imgData->pixelData.as<QQuickJSContext2DPixelData>();
+ QV4::Scoped<QQuickJSContext2DPixelData> pa(scope, imgData->pixelData.as<QQuickJSContext2DPixelData>());
if (pa) {
qreal w = pa->image.width();
qreal h = pa->image.height();
@@ -3320,7 +3320,7 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_putImageData(QV4::SimpleCa
if (!imageData)
return ctx->callData->thisObject.asReturnedValue();
- QQuickJSContext2DPixelData *pixelArray = imageData->pixelData.as<QQuickJSContext2DPixelData>();
+ QV4::Scoped<QQuickJSContext2DPixelData> pixelArray(scope, imageData->pixelData.as<QQuickJSContext2DPixelData>());
if (pixelArray) {
w = pixelArray->image.width();
h = pixelArray->image.height();