Make all write operations to Pointer<> types go through a set() method

The new set() method also taked an ExecutionEngine pointer. This makes
it trivial to now add a write barrier for those operations.

Change-Id: I321eccfe6fb279cc240b5c84910e6854f71759f6
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
This commit is contained in:
Lars Knoll 2017-01-31 14:03:51 +01:00
parent 518e258d59
commit 91714e004e
19 changed files with 63 additions and 58 deletions

View File

@ -48,12 +48,13 @@ DEFINE_OBJECT_VTABLE(ArgumentsObject);
void Heap::ArgumentsObject::init(QV4::CallContext *context) void Heap::ArgumentsObject::init(QV4::CallContext *context)
{ {
ExecutionEngine *v4 = context->d()->engine;
Object::init(); Object::init();
fullyCreated = false; fullyCreated = false;
this->context = context->d(); this->context.set(v4, context->d());
Q_ASSERT(vtable() == QV4::ArgumentsObject::staticVTable()); Q_ASSERT(vtable() == QV4::ArgumentsObject::staticVTable());
ExecutionEngine *v4 = context->d()->engine;
Scope scope(v4); Scope scope(v4);
Scoped<QV4::ArgumentsObject> args(scope, this); Scoped<QV4::ArgumentsObject> args(scope, this);
@ -89,7 +90,7 @@ void ArgumentsObject::fullyCreate()
Scope scope(engine()); Scope scope(engine());
Scoped<MemberData> md(scope, d()->mappedArguments); Scoped<MemberData> md(scope, d()->mappedArguments);
if (numAccessors) { if (numAccessors) {
d()->mappedArguments = md->allocate(engine(), numAccessors); d()->mappedArguments.set(scope.engine, md->allocate(engine(), numAccessors));
for (uint i = 0; i < numAccessors; ++i) { for (uint i = 0; i < numAccessors; ++i) {
d()->mappedArguments->values[i] = context()->callData->args[i]; d()->mappedArguments->values[i] = context()->callData->args[i];
arraySet(i, context()->engine->argumentsAccessors + i, Attr_Accessor); arraySet(i, context()->engine->argumentsAccessors + i, Attr_Accessor);

View File

@ -72,7 +72,7 @@ Heap::CallContext *ExecutionContext::newCallContext(Function *function, CallData
c->v4Function = function; c->v4Function = function;
c->strictMode = function->isStrict(); c->strictMode = function->isStrict();
c->outer = this->d(); c->outer.set(d()->engine, this->d());
c->compilationUnit = function->compilationUnit; c->compilationUnit = function->compilationUnit;
c->lookups = c->compilationUnit->runtimeLookups; c->lookups = c->compilationUnit->runtimeLookups;
@ -119,7 +119,7 @@ void ExecutionContext::createMutableBinding(String *name, bool deletable)
Heap::SimpleCallContext *c = static_cast<Heap::SimpleCallContext *>(ctx->d()); Heap::SimpleCallContext *c = static_cast<Heap::SimpleCallContext *>(ctx->d());
if (!activation) { if (!activation) {
if (!c->activation) if (!c->activation)
c->activation = scope.engine->newObject(); c->activation.set(scope.engine, scope.engine->newObject());
activation = c->activation; activation = c->activation;
} }
break; break;
@ -153,21 +153,21 @@ void ExecutionContext::createMutableBinding(String *name, bool deletable)
void Heap::GlobalContext::init(ExecutionEngine *eng) void Heap::GlobalContext::init(ExecutionEngine *eng)
{ {
Heap::ExecutionContext::init(eng, Heap::ExecutionContext::Type_GlobalContext); Heap::ExecutionContext::init(eng, Heap::ExecutionContext::Type_GlobalContext);
global = eng->globalObject->d(); global.set(eng, eng->globalObject->d());
} }
void Heap::CatchContext::init(ExecutionContext *outerContext, String *exceptionVarName, void Heap::CatchContext::init(ExecutionContext *outerContext, String *exceptionVarName,
const Value &exceptionValue) const Value &exceptionValue)
{ {
Heap::ExecutionContext::init(outerContext->engine, Heap::ExecutionContext::Type_CatchContext); Heap::ExecutionContext::init(outerContext->engine, Heap::ExecutionContext::Type_CatchContext);
outer = outerContext; outer.set(engine, outerContext);
strictMode = outer->strictMode; strictMode = outer->strictMode;
callData = outer->callData; callData = outer->callData;
lookups = outer->lookups; lookups = outer->lookups;
constantTable = outer->constantTable; constantTable = outer->constantTable;
compilationUnit = outer->compilationUnit; compilationUnit = outer->compilationUnit;
this->exceptionVarName = exceptionVarName; this->exceptionVarName.set(engine, exceptionVarName);
this->exceptionValue = exceptionValue; this->exceptionValue = exceptionValue;
} }
@ -252,7 +252,7 @@ void ExecutionContext::call(Scope &scope, CallData *callData, Function *function
Scoped<CallContext> ctx(scope, newCallContext(function, callData)); Scoped<CallContext> ctx(scope, newCallContext(function, callData));
if (f) if (f)
ctx->d()->function = f->d(); ctx->d()->function.set(scope.engine, f->d());
scope.engine->pushContext(ctx); scope.engine->pushContext(ctx);
scope.result = Q_V4_PROFILE(scope.engine, function); scope.result = Q_V4_PROFILE(scope.engine, function);
@ -276,7 +276,7 @@ void QV4::ExecutionContext::simpleCall(Scope &scope, CallData *callData, Functio
ctx->compilationUnit = function->compilationUnit; ctx->compilationUnit = function->compilationUnit;
ctx->lookups = function->compilationUnit->runtimeLookups; ctx->lookups = function->compilationUnit->runtimeLookups;
ctx->constantTable = function->compilationUnit->constants; ctx->constantTable = function->compilationUnit->constants;
ctx->outer = this->d(); ctx->outer.set(scope.engine, this->d());
for (int i = callData->argc; i < (int)function->nFormals; ++i) for (int i = callData->argc; i < (int)function->nFormals; ++i)
callData->args[i] = Encode::undefined(); callData->args[i] = Encode::undefined();

View File

@ -189,13 +189,13 @@ DECLARE_HEAP_OBJECT(WithContext, ExecutionContext) {
void init(ExecutionContext *outerContext, Object *with) void init(ExecutionContext *outerContext, Object *with)
{ {
Heap::ExecutionContext::init(outerContext->engine, Heap::ExecutionContext::Type_WithContext); Heap::ExecutionContext::init(outerContext->engine, Heap::ExecutionContext::Type_WithContext);
outer = outerContext; outer.set(engine, outerContext);
callData = outer->callData; callData = outer->callData;
lookups = outer->lookups; lookups = outer->lookups;
constantTable = outer->constantTable; constantTable = outer->constantTable;
compilationUnit = outer->compilationUnit; compilationUnit = outer->compilationUnit;
withObject = with; withObject.set(engine, with);
} }
}; };
V4_ASSERT_IS_TRIVIAL(WithContext) V4_ASSERT_IS_TRIVIAL(WithContext)

View File

@ -73,7 +73,7 @@ void DataViewCtor::construct(const Managed *, Scope &scope, CallData *callData)
} }
Scoped<DataView> a(scope, scope.engine->memoryManager->allocObject<DataView>()); Scoped<DataView> a(scope, scope.engine->memoryManager->allocObject<DataView>());
a->d()->buffer = buffer->d(); a->d()->buffer.set(scope.engine, buffer->d());
a->d()->byteLength = byteLength; a->d()->byteLength = byteLength;
a->d()->byteOffset = byteOffset; a->d()->byteOffset = byteOffset;
scope.result = a.asReturnedValue(); scope.result = a.asReturnedValue();

View File

@ -398,7 +398,7 @@ ExecutionEngine::ExecutionEngine(EvalISelFactory *factory)
// //
// set up the global object // set up the global object
// //
rootContext()->d()->global = globalObject->d(); rootContext()->d()->global.set(scope.engine, globalObject->d());
rootContext()->d()->callData->thisObject = globalObject; rootContext()->d()->callData->thisObject = globalObject;
Q_ASSERT(globalObject->d()->vtable()); Q_ASSERT(globalObject->d()->vtable());
@ -605,7 +605,7 @@ Heap::ArrayObject *ExecutionEngine::newArrayObject(const Value *values, int leng
d->values.alloc = length; d->values.alloc = length;
d->values.size = length; d->values.size = length;
memcpy(&d->values.v, values, length*sizeof(Value)); memcpy(&d->values.v, values, length*sizeof(Value));
a->d()->arrayData = d; a->d()->arrayData.set(this, d);
a->setArrayLengthUnchecked(length); a->setArrayLengthUnchecked(length);
} }
return a->d(); return a->d();

View File

@ -168,7 +168,7 @@ void ErrorObject::method_get_stack(const BuiltinFunction *, Scope &scope, CallDa
if (frame.line >= 0) if (frame.line >= 0)
trace += QLatin1Char(':') + QString::number(frame.line); trace += QLatin1Char(':') + QString::number(frame.line);
} }
This->d()->stack = scope.engine->newString(trace); This->d()->stack.set(scope.engine, scope.engine->newString(trace));
} }
scope.result = This->d()->stack; scope.result = This->d()->stack;
} }

View File

@ -75,7 +75,7 @@ void Heap::FunctionObject::init(QV4::ExecutionContext *scope, QV4::String *name,
{ {
Object::init(); Object::init();
function = nullptr; function = nullptr;
this->scope = scope->d(); this->scope.set(scope->engine(), scope->d());
Scope s(scope->engine()); Scope s(scope->engine());
ScopedFunctionObject f(s, this); ScopedFunctionObject f(s, this);
f->init(name, createProto); f->init(name, createProto);
@ -86,7 +86,7 @@ void Heap::FunctionObject::init(QV4::ExecutionContext *scope, Function *function
Object::init(); Object::init();
this->function = function; this->function = function;
function->compilationUnit->addref(); function->compilationUnit->addref();
this->scope = scope->d(); this->scope.set(scope->engine(), scope->d());
Scope s(scope->engine()); Scope s(scope->engine());
ScopedString name(s, function->name()); ScopedString name(s, function->name());
ScopedFunctionObject f(s, this); ScopedFunctionObject f(s, this);
@ -104,7 +104,7 @@ void Heap::FunctionObject::init()
{ {
Object::init(); Object::init();
function = nullptr; function = nullptr;
this->scope = internalClass->engine->rootContext()->d(); this->scope.set(internalClass->engine, internalClass->engine->rootContext()->d());
Q_ASSERT(internalClass && internalClass->find(internalClass->engine->id_prototype()) == Index_Prototype); Q_ASSERT(internalClass && internalClass->find(internalClass->engine->id_prototype()) == Index_Prototype);
*propertyData(Index_Prototype) = Encode::undefined(); *propertyData(Index_Prototype) = Encode::undefined();
} }
@ -413,7 +413,7 @@ void ScriptFunction::call(const Managed *that, Scope &scope, CallData *callData)
void Heap::ScriptFunction::init(QV4::ExecutionContext *scope, Function *function) void Heap::ScriptFunction::init(QV4::ExecutionContext *scope, Function *function)
{ {
FunctionObject::init(); FunctionObject::init();
this->scope = scope->d(); this->scope.set(scope->engine(), scope->d());
this->function = function; this->function = function;
function->compilationUnit->addref(); function->compilationUnit->addref();
@ -536,12 +536,12 @@ DEFINE_OBJECT_VTABLE(BoundFunction);
void Heap::BoundFunction::init(QV4::ExecutionContext *scope, QV4::FunctionObject *target, void Heap::BoundFunction::init(QV4::ExecutionContext *scope, QV4::FunctionObject *target,
const Value &boundThis, QV4::MemberData *boundArgs) const Value &boundThis, QV4::MemberData *boundArgs)
{ {
Scope s(scope);
Heap::FunctionObject::init(scope, QStringLiteral("__bound function__")); Heap::FunctionObject::init(scope, QStringLiteral("__bound function__"));
this->target = target->d(); this->target.set(s.engine, target->d());
this->boundArgs = boundArgs ? boundArgs->d() : 0; this->boundArgs.set(s.engine, boundArgs ? boundArgs->d() : 0);
this->boundThis = boundThis; this->boundThis = boundThis;
Scope s(scope);
ScopedObject f(s, this); ScopedObject f(s, this);
ScopedValue l(s, target->get(s.engine->id_length())); ScopedValue l(s, target->get(s.engine->id_length()));

View File

@ -63,7 +63,7 @@ void Object::setInternalClass(InternalClass *ic)
d()->internalClass = ic; d()->internalClass = ic;
bool hasMD = d()->memberData != nullptr; bool hasMD = d()->memberData != nullptr;
if ((!hasMD && ic->size) || (hasMD && d()->memberData->values.size < ic->size)) if ((!hasMD && ic->size) || (hasMD && d()->memberData->values.size < ic->size))
d()->memberData = MemberData::allocate(ic->engine, ic->size, d()->memberData); d()->memberData.set(engine(), MemberData::allocate(ic->engine, ic->size, d()->memberData));
} }
void Object::getProperty(uint index, Property *p, PropertyAttributes *attrs) const void Object::getProperty(uint index, Property *p, PropertyAttributes *attrs) const
@ -89,7 +89,7 @@ bool Object::setPrototype(Object *proto)
return false; return false;
pp = pp->prototype; pp = pp->prototype;
} }
d()->prototype = proto ? proto->d() : 0; d()->prototype.set(engine(), proto ? proto->d() : 0);
return true; return true;
} }

View File

@ -198,7 +198,7 @@ struct Q_QML_EXPORT Object: Managed {
Value *propertyData(uint index) { return d()->propertyData(index); } Value *propertyData(uint index) { return d()->propertyData(index); }
Heap::ArrayData *arrayData() const { return d()->arrayData; } Heap::ArrayData *arrayData() const { return d()->arrayData; }
void setArrayData(ArrayData *a) { d()->arrayData = a->d(); } void setArrayData(ArrayData *a) { d()->arrayData.set(engine(), a->d()); }
void getProperty(uint index, Property *p, PropertyAttributes *attrs) const; void getProperty(uint index, Property *p, PropertyAttributes *attrs) const;
void setProperty(uint index, const Property *p); void setProperty(uint index, const Property *p);

View File

@ -298,14 +298,14 @@ bool QmlContextWrapper::put(Managed *m, String *name, const Value &value)
void Heap::QmlContext::init(QV4::ExecutionContext *outerContext, QV4::QmlContextWrapper *qml) void Heap::QmlContext::init(QV4::ExecutionContext *outerContext, QV4::QmlContextWrapper *qml)
{ {
Heap::ExecutionContext::init(outerContext->engine(), Heap::ExecutionContext::Type_QmlContext); Heap::ExecutionContext::init(outerContext->engine(), Heap::ExecutionContext::Type_QmlContext);
outer = outerContext->d(); outer.set(engine, outerContext->d());
strictMode = false; strictMode = false;
callData = outer->callData; callData = outer->callData;
lookups = outer->lookups; lookups = outer->lookups;
constantTable = outer->constantTable; constantTable = outer->constantTable;
compilationUnit = outer->compilationUnit; compilationUnit = outer->compilationUnit;
this->qml = qml->d(); this->qml.set(engine, qml->d());
} }
Heap::QmlContext *QmlContext::createWorkerContext(ExecutionContext *parent, const QUrl &source, Value *sendFunction) Heap::QmlContext *QmlContext::createWorkerContext(ExecutionContext *parent, const QUrl &source, Value *sendFunction)

View File

@ -1704,7 +1704,7 @@ ReturnedValue QObjectMethod::create(ExecutionContext *scope, const QQmlValueType
Scoped<QObjectMethod> method(valueScope, valueScope.engine->memoryManager->allocObject<QObjectMethod>(scope)); Scoped<QObjectMethod> method(valueScope, valueScope.engine->memoryManager->allocObject<QObjectMethod>(scope));
method->d()->setPropertyCache(valueType->d()->propertyCache()); method->d()->setPropertyCache(valueType->d()->propertyCache());
method->d()->index = index; method->d()->index = index;
method->d()->valueTypeWrapper = valueType->d(); method->d()->valueTypeWrapper.set(valueScope.engine, valueType->d());
return method.asReturnedValue(); return method.asReturnedValue();
} }

View File

@ -74,7 +74,7 @@ void Heap::RegExpObject::init()
Object::init(); Object::init();
Scope scope(internalClass->engine); Scope scope(internalClass->engine);
Scoped<QV4::RegExpObject> o(scope, this); Scoped<QV4::RegExpObject> o(scope, this);
o->d()->value = QV4::RegExp::create(scope.engine, QString(), false, false); o->d()->value.set(scope.engine, QV4::RegExp::create(scope.engine, QString(), false, false));
o->d()->global = false; o->d()->global = false;
o->initProperties(); o->initProperties();
} }
@ -82,9 +82,9 @@ void Heap::RegExpObject::init()
void Heap::RegExpObject::init(QV4::RegExp *value, bool global) void Heap::RegExpObject::init(QV4::RegExp *value, bool global)
{ {
Object::init(); Object::init();
this->global = global;
this->value = value->d();
Scope scope(internalClass->engine); Scope scope(internalClass->engine);
this->global = global;
this->value.set(scope.engine, value->d());
Scoped<QV4::RegExpObject> o(scope, this); Scoped<QV4::RegExpObject> o(scope, this);
o->initProperties(); o->initProperties();
} }
@ -137,7 +137,8 @@ void Heap::RegExpObject::init(const QRegExp &re)
Scope scope(internalClass->engine); Scope scope(internalClass->engine);
Scoped<QV4::RegExpObject> o(scope, this); Scoped<QV4::RegExpObject> o(scope, this);
o->d()->value = QV4::RegExp::create(scope.engine, pattern, re.caseSensitivity() == Qt::CaseInsensitive, false); o->d()->value.set(scope.engine,
QV4::RegExp::create(scope.engine, pattern, re.caseSensitivity() == Qt::CaseInsensitive, false));
o->initProperties(); o->initProperties();
} }
@ -220,7 +221,7 @@ void Heap::RegExpCtor::init(QV4::ExecutionContext *scope)
void Heap::RegExpCtor::clearLastMatch() void Heap::RegExpCtor::clearLastMatch()
{ {
lastMatch = Primitive::nullValue(); lastMatch = Primitive::nullValue();
lastInput = internalClass->engine->id_empty()->d(); lastInput.set(internalClass->engine, internalClass->engine->id_empty()->d());
lastMatchStart = 0; lastMatchStart = 0;
lastMatchEnd = 0; lastMatchEnd = 0;
} }
@ -377,7 +378,7 @@ void RegExpPrototype::method_exec(const BuiltinFunction *, Scope &scope, CallDat
RegExpCtor::Data *dd = regExpCtor->d(); RegExpCtor::Data *dd = regExpCtor->d();
dd->lastMatch = array; dd->lastMatch = array;
dd->lastInput = str->d(); dd->lastInput.set(scope.engine, str->d());
dd->lastMatchStart = matchOffsets[0]; dd->lastMatchStart = matchOffsets[0];
dd->lastMatchEnd = matchOffsets[1]; dd->lastMatchEnd = matchOffsets[1];
@ -414,7 +415,7 @@ void RegExpPrototype::method_compile(const BuiltinFunction *, Scope &scope, Call
scope.engine->regExpCtor()->as<FunctionObject>()->construct(scope, cData); scope.engine->regExpCtor()->as<FunctionObject>()->construct(scope, cData);
Scoped<RegExpObject> re(scope, scope.result.asReturnedValue()); Scoped<RegExpObject> re(scope, scope.result.asReturnedValue());
r->d()->value = re->value(); r->d()->value.set(scope.engine, re->value());
r->d()->global = re->global(); r->d()->global = re->global();
RETURN_UNDEFINED(); RETURN_UNDEFINED();
} }

View File

@ -77,14 +77,14 @@ void Heap::StringObject::init()
{ {
Object::init(); Object::init();
Q_ASSERT(vtable() == QV4::StringObject::staticVTable()); Q_ASSERT(vtable() == QV4::StringObject::staticVTable());
string = internalClass->engine->id_empty()->d(); string.set(internalClass->engine, internalClass->engine->id_empty()->d());
*propertyData(LengthPropertyIndex) = Primitive::fromInt32(0); *propertyData(LengthPropertyIndex) = Primitive::fromInt32(0);
} }
void Heap::StringObject::init(const QV4::String *str) void Heap::StringObject::init(const QV4::String *str)
{ {
Object::init(); Object::init();
string = str->d(); string.set(internalClass->engine, str->d());
*propertyData(LengthPropertyIndex) = Primitive::fromInt32(length()); *propertyData(LengthPropertyIndex) = Primitive::fromInt32(length());
} }

View File

@ -229,8 +229,8 @@ void TypedArrayCtor::construct(const Managed *m, Scope &scope, CallData *callDat
return; return;
} }
Scoped<TypedArray > array(scope, TypedArray::create(scope.engine, that->d()->type)); Scoped<TypedArray> array(scope, TypedArray::create(scope.engine, that->d()->type));
array->d()->buffer = buffer->d(); array->d()->buffer.set(scope.engine, buffer->d());
array->d()->byteLength = byteLength; array->d()->byteLength = byteLength;
array->d()->byteOffset = 0; array->d()->byteOffset = 0;
@ -252,8 +252,8 @@ void TypedArrayCtor::construct(const Managed *m, Scope &scope, CallData *callDat
return; return;
} }
Scoped<TypedArray > array(scope, TypedArray::create(scope.engine, that->d()->type)); Scoped<TypedArray> array(scope, TypedArray::create(scope.engine, that->d()->type));
array->d()->buffer = newBuffer->d(); array->d()->buffer.set(scope.engine, newBuffer->d());
array->d()->byteLength = destByteLength; array->d()->byteLength = destByteLength;
array->d()->byteOffset = 0; array->d()->byteOffset = 0;
@ -311,8 +311,8 @@ void TypedArrayCtor::construct(const Managed *m, Scope &scope, CallData *callDat
byteLength = (uint)l; byteLength = (uint)l;
} }
Scoped<TypedArray > array(scope, TypedArray::create(scope.engine, that->d()->type)); Scoped<TypedArray> array(scope, TypedArray::create(scope.engine, that->d()->type));
array->d()->buffer = buffer->d(); array->d()->buffer.set(scope.engine, buffer->d());
array->d()->byteLength = byteLength; array->d()->byteLength = byteLength;
array->d()->byteOffset = byteOffset; array->d()->byteOffset = byteOffset;
scope.result = array.asReturnedValue(); scope.result = array.asReturnedValue();
@ -335,8 +335,8 @@ void TypedArrayCtor::construct(const Managed *m, Scope &scope, CallData *callDat
return; return;
} }
Scoped<TypedArray > array(scope, TypedArray::create(scope.engine, that->d()->type)); Scoped<TypedArray> array(scope, TypedArray::create(scope.engine, that->d()->type));
array->d()->buffer = newBuffer->d(); array->d()->buffer.set(scope.engine, newBuffer->d());
array->d()->byteLength = l * elementSize; array->d()->byteLength = l * elementSize;
array->d()->byteOffset = 0; array->d()->byteOffset = 0;

View File

@ -167,15 +167,18 @@ V4_ASSERT_IS_TRIVIAL(Base)
template <typename T, size_t o> template <typename T, size_t o>
struct Pointer { struct Pointer {
static Q_CONSTEXPR size_t offset = o; static Q_CONSTEXPR size_t offset = o;
static Q_CONSTEXPR quint64 markBits = Mark_Pointer << (o >> 2);
T operator->() const { return ptr; } T operator->() const { return ptr; }
operator T () const { return ptr; } operator T () const { return ptr; }
Pointer &operator =(T t) { ptr = t; return *this; } void set(ExecutionEngine *e, T newVal) {
Q_UNUSED(e);
ptr = newVal;
}
template <typename Type> template <typename Type>
Type *cast() { return static_cast<Type *>(ptr); } Type *cast() { return static_cast<Type *>(ptr); }
private:
T ptr; T ptr;
}; };
typedef Pointer<char *, 0> V4PointerCheck; typedef Pointer<char *, 0> V4PointerCheck;

View File

@ -731,7 +731,7 @@ Heap::Object *MemoryManager::allocObjectWithMemberData(std::size_t size, uint nM
else else
m = *blockAllocator.allocate(memberSize, true); m = *blockAllocator.allocate(memberSize, true);
memset(m, 0, memberSize); memset(m, 0, memberSize);
o->memberData = static_cast<Heap::MemberData *>(m); o->memberData.set(engine, static_cast<Heap::MemberData *>(m));
o->memberData->setVtable(MemberData::staticVTable()); o->memberData->setVtable(MemberData::staticVTable());
o->memberData->values.alloc = static_cast<uint>((memberSize - sizeof(Heap::MemberData) + sizeof(Value))/sizeof(Value)); o->memberData->values.alloc = static_cast<uint>((memberSize - sizeof(Heap::MemberData) + sizeof(Value))/sizeof(Value));
o->memberData->values.size = o->memberData->values.alloc; o->memberData->values.size = o->memberData->values.alloc;

View File

@ -245,7 +245,7 @@ public:
o->setVtable(ObjectType::staticVTable()); o->setVtable(ObjectType::staticVTable());
Object *prototype = ObjectType::defaultPrototype(engine); Object *prototype = ObjectType::defaultPrototype(engine);
o->internalClass = ic; o->internalClass = ic;
o->prototype = prototype->d(); o->prototype.set(engine, prototype->d());
return static_cast<typename ObjectType::Data *>(o); return static_cast<typename ObjectType::Data *>(o);
} }
@ -272,7 +272,7 @@ public:
{ {
Scope scope(engine); Scope scope(engine);
Scoped<ObjectType> t(scope, allocateObject<ObjectType>(ic)); Scoped<ObjectType> t(scope, allocateObject<ObjectType>(ic));
t->d_unchecked()->prototype = prototype->d(); t->d_unchecked()->prototype.set(engine, prototype->d());
t->d_unchecked()->init(); t->d_unchecked()->init();
return t->d(); return t->d();
} }
@ -282,7 +282,7 @@ public:
{ {
Scope scope(engine); Scope scope(engine);
Scoped<ObjectType> t(scope, allocateObject<ObjectType>(ic)); Scoped<ObjectType> t(scope, allocateObject<ObjectType>(ic));
t->d_unchecked()->prototype = prototype->d(); t->d_unchecked()->prototype.set(engine, prototype->d());
t->d_unchecked()->init(arg1); t->d_unchecked()->init(arg1);
return t->d(); return t->d();
} }
@ -292,7 +292,7 @@ public:
{ {
Scope scope(engine); Scope scope(engine);
Scoped<ObjectType> t(scope, allocateObject<ObjectType>(ic)); Scoped<ObjectType> t(scope, allocateObject<ObjectType>(ic));
t->d_unchecked()->prototype = prototype->d(); t->d_unchecked()->prototype.set(engine, prototype->d());
t->d_unchecked()->init(arg1, arg2); t->d_unchecked()->init(arg1, arg2);
return t->d(); return t->d();
} }
@ -302,7 +302,7 @@ public:
{ {
Scope scope(engine); Scope scope(engine);
Scoped<ObjectType> t(scope, allocateObject<ObjectType>(ic)); Scoped<ObjectType> t(scope, allocateObject<ObjectType>(ic));
t->d_unchecked()->prototype = prototype->d(); t->d_unchecked()->prototype.set(engine, prototype->d());
t->d_unchecked()->init(arg1, arg2, arg3); t->d_unchecked()->init(arg1, arg2, arg3);
return t->d(); return t->d();
} }
@ -312,7 +312,7 @@ public:
{ {
Scope scope(engine); Scope scope(engine);
Scoped<ObjectType> t(scope, allocateObject<ObjectType>(ic)); Scoped<ObjectType> t(scope, allocateObject<ObjectType>(ic));
t->d_unchecked()->prototype = prototype->d(); t->d_unchecked()->prototype.set(engine, prototype->d());
t->d_unchecked()->init(arg1, arg2, arg3, arg4); t->d_unchecked()->init(arg1, arg2, arg3, arg4);
return t->d(); return t->d();
} }

View File

@ -1377,7 +1377,7 @@ void QQmlComponent::incubateObject(QQmlV4Function *args)
if (!valuemap->isUndefined()) if (!valuemap->isUndefined())
r->d()->valuemap = valuemap; r->d()->valuemap = valuemap;
r->d()->qmlContext = v4->qmlContext(); r->d()->qmlContext.set(scope.engine, v4->qmlContext());
r->d()->parent = parent; r->d()->parent = parent;
QQmlIncubator *incubator = r->d()->incubator; QQmlIncubator *incubator = r->d()->incubator;
@ -1476,7 +1476,7 @@ void QV4::Heap::QmlIncubatorObject::init(QQmlIncubator::IncubationMode m)
valuemap = QV4::Primitive::undefinedValue(); valuemap = QV4::Primitive::undefinedValue();
statusChanged = QV4::Primitive::undefinedValue(); statusChanged = QV4::Primitive::undefinedValue();
parent.init(); parent.init();
qmlContext = nullptr; qmlContext.set(internalClass->engine, nullptr);
incubator = new QQmlComponentIncubator(this, m); incubator = new QQmlComponentIncubator(this, m);
} }

View File

@ -1683,7 +1683,7 @@ void QQmlXMLHttpRequestCtor::setupProto()
ExecutionEngine *v4 = engine(); ExecutionEngine *v4 = engine();
Scope scope(v4); Scope scope(v4);
ScopedObject p(scope, v4->newObject()); ScopedObject p(scope, v4->newObject());
d()->proto = p->d(); d()->proto.set(scope.engine, p->d());
// Methods // Methods
p->defineDefaultProperty(QStringLiteral("open"), method_open); p->defineDefaultProperty(QStringLiteral("open"), method_open);