diff options
author | Lars Knoll <lars.knoll@qt.io> | 2017-02-03 16:28:17 +0100 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2017-03-09 08:58:46 +0000 |
commit | df3256b1f1eaa3ff9137ad1da36508365d978a8a (patch) | |
tree | a9d7fdb2dc49efbfd4d4809a8525b864ffb2b60c /src/qml/jsruntime/qv4value_p.h | |
parent | ae92e34a0c3e8a2df88a854081678fa35c4f6b42 (diff) |
Go through proper set() functions when writing to MemberData
This is required, so we only have to add the write barrier
in one place.
Change-Id: I4e8bde823b30ad18f043312ac3f1ed46597b91a7
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml/jsruntime/qv4value_p.h')
-rw-r--r-- | src/qml/jsruntime/qv4value_p.h | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/src/qml/jsruntime/qv4value_p.h b/src/qml/jsruntime/qv4value_p.h index 93b0dfb6d4..4c46eccbd3 100644 --- a/src/qml/jsruntime/qv4value_p.h +++ b/src/qml/jsruntime/qv4value_p.h @@ -717,6 +717,44 @@ struct HeapValue : Value { }; template <size_t offset> +struct HeapValueArray { + uint size; + uint alloc; + Value values[1]; + + void set(ExecutionEngine *e, uint index, Value v) { + Q_UNUSED(e); + Q_ASSERT(index < alloc); + values[index] = v; + } + void set(ExecutionEngine *e, uint index, Heap::Base *b) { + Q_UNUSED(e); + Q_ASSERT(index < alloc); + values[index] = b; + } + inline const Value &operator[] (uint index) const { + Q_ASSERT(index < alloc); + return values[index]; + } + inline const Value *data() const { + return values; + } + + void insertData(ExecutionEngine *e, uint index, Value v) { + for (uint i = size - 1; i > index; --i) { + values[i] = values[i - 1]; + } + set(e, index, v); + } + void removeData(ExecutionEngine *e, uint index, int n = 1) { + Q_UNUSED(e); + for (uint i = index; i < size - n; ++i) { + values[i] = values[i + n]; + } + } +}; + +template <size_t offset> struct ValueArray { uint size; uint alloc; |