aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/memory/qv4writebarrier_p.h
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2017-11-02 16:02:10 +0100
committerLars Knoll <lars.knoll@qt.io>2017-11-14 21:45:42 +0000
commit002fdc48d43e4fd67921e0cd46c28d28aee06848 (patch)
tree08fdc81dc91153649d8b6c6514ed3b49ad970064 /src/qml/memory/qv4writebarrier_p.h
parent010197a42150ee73a17cb53fbe397a6c55b2d342 (diff)
Bring back markObjects(), this time generated
Doing the marking of objects in a function instead of using the table seems to be somewhat faster. Change-Id: I9ec00cc0264f9a15c69b285db493bee31d99bf96 Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
Diffstat (limited to 'src/qml/memory/qv4writebarrier_p.h')
-rw-r--r--src/qml/memory/qv4writebarrier_p.h36
1 files changed, 31 insertions, 5 deletions
diff --git a/src/qml/memory/qv4writebarrier_p.h b/src/qml/memory/qv4writebarrier_p.h
index f55c724c12..4ec224cc36 100644
--- a/src/qml/memory/qv4writebarrier_p.h
+++ b/src/qml/memory/qv4writebarrier_p.h
@@ -114,8 +114,8 @@ namespace Heap {
template <typename T, size_t o>
struct Pointer {
static Q_CONSTEXPR size_t offset = o;
- T operator->() const { return ptr; }
- operator T () const { return ptr; }
+ T operator->() const { return get(); }
+ operator T () const { return get(); }
Heap::Base *base() {
Heap::Base *base = reinterpret_cast<Heap::Base *>(this) - (offset/sizeof(Heap::Base));
@@ -124,16 +124,18 @@ struct Pointer {
}
void set(EngineBase *e, T newVal) {
- WriteBarrier::write(e, base(), reinterpret_cast<Heap::Base **>(&ptr), reinterpret_cast<Heap::Base *>(newVal));
+ WriteBarrier::write(e, base(), &ptr, reinterpret_cast<Heap::Base *>(newVal));
}
- T get() { return ptr; }
+ T get() const { return reinterpret_cast<T>(ptr); }
template <typename Type>
Type *cast() { return static_cast<Type *>(ptr); }
+ Heap::Base *heapObject() const { return ptr; }
+
private:
- T ptr;
+ Heap::Base *ptr;
};
typedef Pointer<char *, 0> V4PointerCheck;
V4_ASSERT_IS_TRIVIAL(V4PointerCheck)
@@ -194,6 +196,30 @@ struct ValueArray {
values[i] = values[i + n];
}
}
+
+ void mark(MarkStack *markStack) {
+ Value *v = values;
+ const Value *end = v + alloc;
+ if (alloc > 32*1024) {
+ // drain from time to time to avoid overflows in the js stack
+ Heap::Base **currentBase = markStack->top;
+ while (v < end) {
+ v->mark(markStack);
+ ++v;
+ if (markStack->top >= currentBase + 32*1024) {
+ Heap::Base **oldBase = markStack->base;
+ markStack->base = currentBase;
+ markStack->drain();
+ markStack->base = oldBase;
+ }
+ }
+ } else {
+ while (v < end) {
+ v->mark(markStack);
+ ++v;
+ }
+ }
+ }
};
// It's really important that the offset of values in this structure is