All remaining uses should be GC safe now.
Change-Id: I05c962de6ab896f108f70caa1bf937a24e67bfe1
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
_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();
}
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) {
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;
}
// 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.
};
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;
};
virtual void run(int functionIndex);
- void *addConstantTable(QVector<QV4::Value> *values);
+ void *addConstantTable(QVector<QV4::Primitive> *values);
protected:
virtual QV4::CompiledData::CompilationUnit *backendCompileStep();
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();
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;
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();
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;
ReturnedValue NumberPrototype::method_toExponential(SimpleCallContext *ctx)
{
Scope scope(ctx);
- double d = thisNumberValue(ctx).asDouble();
+ double d = thisNumber(ctx);
int fdigits = -1;
ReturnedValue NumberPrototype::method_toPrecision(SimpleCallContext *ctx)
{
Scope scope(ctx);
-
ScopedValue v(scope, thisNumberValue(ctx));
if (!ctx->callData->argc || ctx->callData->args[0].isUndefined())
if (!p)
return Encode::null();
- value = Value::fromReturnedValue(object->getValue(p, attrs));
+ value = object->getValue(p, attrs);
if (!!name)
return name->asReturnedValue();
if (!p)
return Encode::null();
- value = Value::fromReturnedValue(object->getValue(p, attrs));
+ value = object->getValue(p, attrs);
if (!!name)
return name->asReturnedValue();
struct StringObject: Object {
Q_MANAGED
- Value value;
+ SafeValue value;
mutable Property tmpProperty;
StringObject(ExecutionEngine *engine, const ValueRef value);
#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
#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
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)
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)
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
- QV4::Value pixelData;
+ QV4::SafeValue pixelData;
};
DEFINE_MANAGED_VTABLE(QQuickJSContext2DImageData);
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 {
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();
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();