aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/memory
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2017-01-31 14:03:51 +0100
committerLars Knoll <lars.knoll@qt.io>2017-03-09 08:58:34 +0000
commit91714e004e0c91527e7049ff43565dda682fc2bd (patch)
treebd5ff925acf6c8e1b98667c0b18028576cf94662 /src/qml/memory
parent518e258d59adc976e2e8aa9a7f9ef36d8b8cdb66 (diff)
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>
Diffstat (limited to 'src/qml/memory')
-rw-r--r--src/qml/memory/qv4heap_p.h7
-rw-r--r--src/qml/memory/qv4mm.cpp2
-rw-r--r--src/qml/memory/qv4mm_p.h12
3 files changed, 12 insertions, 9 deletions
diff --git a/src/qml/memory/qv4heap_p.h b/src/qml/memory/qv4heap_p.h
index b3dfa407f8..2cf3e721f9 100644
--- a/src/qml/memory/qv4heap_p.h
+++ b/src/qml/memory/qv4heap_p.h
@@ -167,15 +167,18 @@ V4_ASSERT_IS_TRIVIAL(Base)
template <typename T, size_t o>
struct Pointer {
static Q_CONSTEXPR size_t offset = o;
- static Q_CONSTEXPR quint64 markBits = Mark_Pointer << (o >> 2);
T operator->() 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>
Type *cast() { return static_cast<Type *>(ptr); }
+private:
T ptr;
};
typedef Pointer<char *, 0> V4PointerCheck;
diff --git a/src/qml/memory/qv4mm.cpp b/src/qml/memory/qv4mm.cpp
index edd26cf982..39272850b4 100644
--- a/src/qml/memory/qv4mm.cpp
+++ b/src/qml/memory/qv4mm.cpp
@@ -731,7 +731,7 @@ Heap::Object *MemoryManager::allocObjectWithMemberData(std::size_t size, uint nM
else
m = *blockAllocator.allocate(memberSize, true);
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->values.alloc = static_cast<uint>((memberSize - sizeof(Heap::MemberData) + sizeof(Value))/sizeof(Value));
o->memberData->values.size = o->memberData->values.alloc;
diff --git a/src/qml/memory/qv4mm_p.h b/src/qml/memory/qv4mm_p.h
index 0bd9229792..6e9303acb6 100644
--- a/src/qml/memory/qv4mm_p.h
+++ b/src/qml/memory/qv4mm_p.h
@@ -245,7 +245,7 @@ public:
o->setVtable(ObjectType::staticVTable());
Object *prototype = ObjectType::defaultPrototype(engine);
o->internalClass = ic;
- o->prototype = prototype->d();
+ o->prototype.set(engine, prototype->d());
return static_cast<typename ObjectType::Data *>(o);
}
@@ -272,7 +272,7 @@ public:
{
Scope scope(engine);
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();
return t->d();
}
@@ -282,7 +282,7 @@ public:
{
Scope scope(engine);
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);
return t->d();
}
@@ -292,7 +292,7 @@ public:
{
Scope scope(engine);
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);
return t->d();
}
@@ -302,7 +302,7 @@ public:
{
Scope scope(engine);
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);
return t->d();
}
@@ -312,7 +312,7 @@ public:
{
Scope scope(engine);
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);
return t->d();
}