diff options
Diffstat (limited to 'src/qml/jsruntime/qv4mapobject.cpp')
-rw-r--r-- | src/qml/jsruntime/qv4mapobject.cpp | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/src/qml/jsruntime/qv4mapobject.cpp b/src/qml/jsruntime/qv4mapobject.cpp index 4bb9617b93..94cac02556 100644 --- a/src/qml/jsruntime/qv4mapobject.cpp +++ b/src/qml/jsruntime/qv4mapobject.cpp @@ -12,14 +12,14 @@ DEFINE_OBJECT_VTABLE(WeakMapCtor); DEFINE_OBJECT_VTABLE(MapCtor); DEFINE_OBJECT_VTABLE(MapObject); -void Heap::WeakMapCtor::init(QV4::ExecutionContext *scope) +void Heap::WeakMapCtor::init(QV4::ExecutionEngine *engine) { - Heap::FunctionObject::init(scope, QStringLiteral("WeakMap")); + Heap::FunctionObject::init(engine, QStringLiteral("WeakMap")); } -void Heap::MapCtor::init(QV4::ExecutionContext *scope) +void Heap::MapCtor::init(QV4::ExecutionEngine *engine) { - Heap::FunctionObject::init(scope, QStringLiteral("Map")); + Heap::FunctionObject::init(engine, QStringLiteral("Map")); } ReturnedValue WeakMapCtor::construct(const FunctionObject *f, const Value *argv, int argc, const Value *newTarget, bool weakMap) @@ -214,6 +214,16 @@ ReturnedValue WeakMapPrototype::method_set(const FunctionObject *b, const Value (!argc || !argv[0].isObject())) return scope.engine->throwTypeError(); + QV4::WriteBarrier::markCustom(scope.engine, [&](QV4::MarkStack *ms) { + if (scope.engine->memoryManager->gcStateMachine->state <= GCState::FreeWeakMaps) + return; + argv[0].heapObject()->mark(ms); + if (argc > 1) { + if (auto *h = argv[1].heapObject()) + h->mark(ms); + } + }); + that->d()->esTable->set(argv[0], argc > 1 ? argv[1] : Value::undefinedValue()); return that.asReturnedValue(); } @@ -317,6 +327,14 @@ ReturnedValue MapPrototype::method_set(const FunctionObject *b, const Value *thi if (!that || that->d()->isWeakMap) return scope.engine->throwTypeError(); + QV4::WriteBarrier::markCustom(scope.engine, [&](QV4::MarkStack *ms) { + argv[0].heapObject()->mark(ms); + if (argc > 1) { + if (auto *h = argv[1].heapObject()) + h->mark(ms); + } + }); + that->d()->esTable->set(argc ? argv[0] : Value::undefinedValue(), argc > 1 ? argv[1] : Value::undefinedValue()); return that.asReturnedValue(); } |