diff options
author | Lars Knoll <lars.knoll@qt.io> | 2017-02-03 21:05:43 +0100 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2017-03-09 08:58:52 +0000 |
commit | 1a61d609345b0222c41f93f445a6fd517a76cf48 (patch) | |
tree | a46cd6d9e5d4dfe557d0de931c8253f43d21a0b0 /src/qml/jsruntime | |
parent | d7aa952e143accc18d54707d956d019272197078 (diff) |
move locals over to be write barrier safe
Change-Id: I56b1dab62ff432273ee8549b0496bd0f3fc655ea
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml/jsruntime')
-rw-r--r-- | src/qml/jsruntime/qv4arraydata_p.h | 2 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4context.cpp | 11 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4global_p.h | 1 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4memberdata_p.h | 2 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4value_p.h | 23 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4vme_moth.cpp | 2 |
6 files changed, 12 insertions, 29 deletions
diff --git a/src/qml/jsruntime/qv4arraydata_p.h b/src/qml/jsruntime/qv4arraydata_p.h index f7f007d128..c2c81e886b 100644 --- a/src/qml/jsruntime/qv4arraydata_p.h +++ b/src/qml/jsruntime/qv4arraydata_p.h @@ -96,7 +96,7 @@ namespace Heap { Member(class, NoMark, PropertyAttributes *, attrs) \ Member(class, NoMark, ReturnedValue, freeList) \ Member(class, NoMark, SparseArray *, sparse) \ - Member(class, ValueArray, HeapValueArray, values) + Member(class, ValueArray, ValueArray, values) DECLARE_HEAP_OBJECT(ArrayData, Base) { DECLARE_MARK_TABLE(ArrayData); diff --git a/src/qml/jsruntime/qv4context.cpp b/src/qml/jsruntime/qv4context.cpp index 667b8dbb24..be53b14786 100644 --- a/src/qml/jsruntime/qv4context.cpp +++ b/src/qml/jsruntime/qv4context.cpp @@ -82,10 +82,15 @@ Heap::CallContext *ExecutionContext::newCallContext(Function *function, CallData uint nLocals = compiledFunction->nLocals; c->locals.size = nLocals; c->locals.alloc = localsAndFormals; +#if QT_POINTER_SIZE == 8 + // memory allocated from the JS heap is 0 initialized, so skip the std::fill() below + Q_ASSERT(Primitive::undefinedValue().asReturnedValue() == 0); +#else if (nLocals) - std::fill(c->locals.v, c->locals.v + nLocals, Primitive::undefinedValue()); + std::fill(c->locals.values, c->locals.values + nLocals, Primitive::undefinedValue()); +#endif - c->callData = reinterpret_cast<CallData *>(c->locals.v + nLocals); + c->callData = reinterpret_cast<CallData *>(c->locals.values + nLocals); ::memcpy(c->callData, callData, sizeof(CallData) - sizeof(Value) + static_cast<uint>(callData->argc) * sizeof(Value)); if (callData->argc < static_cast<int>(compiledFunction->nFormals)) std::fill(c->callData->args + c->callData->argc, c->callData->args + compiledFunction->nFormals, Primitive::undefinedValue()); @@ -330,7 +335,7 @@ void ExecutionContext::setProperty(String *name, const Value &value) } else { Q_ASSERT(c->type = Heap::ExecutionContext::Type_CallContext); index -= c->v4Function->nFormals; - static_cast<Heap::CallContext *>(c)->locals[index] = value; + static_cast<Heap::CallContext *>(c)->locals.set(scope.engine, index, value); } return; } diff --git a/src/qml/jsruntime/qv4global_p.h b/src/qml/jsruntime/qv4global_p.h index 68418ba770..cd8fb91f7a 100644 --- a/src/qml/jsruntime/qv4global_p.h +++ b/src/qml/jsruntime/qv4global_p.h @@ -201,7 +201,6 @@ struct Property; struct Value; template<size_t> struct HeapValue; template<size_t> struct ValueArray; -template<size_t> struct HeapValueArray; struct Lookup; struct ArrayData; struct VTable; diff --git a/src/qml/jsruntime/qv4memberdata_p.h b/src/qml/jsruntime/qv4memberdata_p.h index dff7c09a4c..fbe66757e0 100644 --- a/src/qml/jsruntime/qv4memberdata_p.h +++ b/src/qml/jsruntime/qv4memberdata_p.h @@ -60,7 +60,7 @@ namespace QV4 { namespace Heap { #define MemberDataMembers(class, Member) \ - Member(class, ValueArray, HeapValueArray, values) + Member(class, ValueArray, ValueArray, values) DECLARE_HEAP_OBJECT(MemberData, Base) { DECLARE_MARK_TABLE(MemberData); diff --git a/src/qml/jsruntime/qv4value_p.h b/src/qml/jsruntime/qv4value_p.h index 4c46eccbd3..bb2132c85e 100644 --- a/src/qml/jsruntime/qv4value_p.h +++ b/src/qml/jsruntime/qv4value_p.h @@ -717,7 +717,7 @@ struct HeapValue : Value { }; template <size_t offset> -struct HeapValueArray { +struct ValueArray { uint size; uint alloc; Value values[1]; @@ -754,27 +754,6 @@ struct HeapValueArray { } }; -template <size_t offset> -struct ValueArray { - uint size; - uint alloc; - Value v[1]; - - void set(ExecutionEngine *e, uint index, Value newVal) { - Q_UNUSED(e); - v[index] = newVal; - } - - inline Value &operator[] (uint index) { - Q_ASSERT(index < alloc); - return v[index]; - } - inline const Value &operator[] (uint index) const { - Q_ASSERT(index < alloc); - return v[index]; - } -}; - } QT_END_NAMESPACE diff --git a/src/qml/jsruntime/qv4vme_moth.cpp b/src/qml/jsruntime/qv4vme_moth.cpp index 73db76e105..80a40be5d2 100644 --- a/src/qml/jsruntime/qv4vme_moth.cpp +++ b/src/qml/jsruntime/qv4vme_moth.cpp @@ -417,7 +417,7 @@ QV4::ReturnedValue VME::run(ExecutionEngine *engine, const uchar *code } else if (scope->type == QV4::Heap::ExecutionContext::Type_CallContext) { QV4::Heap::CallContext *cc = static_cast<QV4::Heap::CallContext *>(scope); scopes[2*i + 2] = cc->callData->args; - scopes[2*i + 3] = cc->locals.v; + scopes[2*i + 3] = cc->locals.values; } else { scopes[2*i + 2] = 0; scopes[2*i + 3] = 0; |