From 518e258d59adc976e2e8aa9a7f9ef36d8b8cdb66 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Tue, 31 Jan 2017 13:25:09 +0100 Subject: Make every member of a Heap object aware of its offset inside the object This will allow adding a write barrier to those fields with manageable effort. Change-Id: I7d06d7ffccbcefe66e2524c64c962353c91c2766 Reviewed-by: Simon Hausmann --- src/qml/jsruntime/qv4context_p.h | 2 +- src/qml/jsruntime/qv4functionobject_p.h | 2 +- src/qml/jsruntime/qv4global_p.h | 1 + src/qml/jsruntime/qv4object_p.h | 2 ++ src/qml/jsruntime/qv4regexpobject_p.h | 2 +- src/qml/jsruntime/qv4value_p.h | 5 +++++ 6 files changed, 11 insertions(+), 3 deletions(-) (limited to 'src/qml/jsruntime') diff --git a/src/qml/jsruntime/qv4context_p.h b/src/qml/jsruntime/qv4context_p.h index ccea1dbc80..f544821729 100644 --- a/src/qml/jsruntime/qv4context_p.h +++ b/src/qml/jsruntime/qv4context_p.h @@ -171,7 +171,7 @@ V4_ASSERT_IS_TRIVIAL(GlobalContext) #define CatchContextMembers(class, Member) \ Member(class, Pointer, String *, exceptionVarName) \ - Member(class, Value, Value, exceptionValue) + Member(class, HeapValue, HeapValue, exceptionValue) DECLARE_HEAP_OBJECT(CatchContext, ExecutionContext) { DECLARE_MARK_TABLE(CatchContext); diff --git a/src/qml/jsruntime/qv4functionobject_p.h b/src/qml/jsruntime/qv4functionobject_p.h index 1fc40e6ff6..c7dac7d3e5 100644 --- a/src/qml/jsruntime/qv4functionobject_p.h +++ b/src/qml/jsruntime/qv4functionobject_p.h @@ -123,7 +123,7 @@ struct ScriptFunction : FunctionObject { #define BoundFunctionMembers(class, Member) \ Member(class, Pointer, FunctionObject *, target) \ - Member(class, Value, Value, boundThis) \ + Member(class, HeapValue, HeapValue, boundThis) \ Member(class, Pointer, MemberData *, boundArgs) DECLARE_HEAP_OBJECT(BoundFunction, FunctionObject) { diff --git a/src/qml/jsruntime/qv4global_p.h b/src/qml/jsruntime/qv4global_p.h index ea3e1d750e..cd8fb91f7a 100644 --- a/src/qml/jsruntime/qv4global_p.h +++ b/src/qml/jsruntime/qv4global_p.h @@ -199,6 +199,7 @@ struct ScriptFunction; struct InternalClass; struct Property; struct Value; +template struct HeapValue; template struct ValueArray; struct Lookup; struct ArrayData; diff --git a/src/qml/jsruntime/qv4object_p.h b/src/qml/jsruntime/qv4object_p.h index 5b43710c03..63b132c2e6 100644 --- a/src/qml/jsruntime/qv4object_p.h +++ b/src/qml/jsruntime/qv4object_p.h @@ -82,6 +82,8 @@ DECLARE_HEAP_OBJECT(Object, Base) { Value *propertyData(uint index) { return memberData->values.v + index; } }; +Q_STATIC_ASSERT(Object::markTable == ((2 << 4) | (2 << 6) | (2 << 8))); + } #define V4_OBJECT(superClass) \ diff --git a/src/qml/jsruntime/qv4regexpobject_p.h b/src/qml/jsruntime/qv4regexpobject_p.h index b429524b71..c2eeb32b88 100644 --- a/src/qml/jsruntime/qv4regexpobject_p.h +++ b/src/qml/jsruntime/qv4regexpobject_p.h @@ -86,7 +86,7 @@ DECLARE_HEAP_OBJECT(RegExpObject, Object) { }; #define RegExpCtorMembers(class, Member) \ - Member(class, Value, Value, lastMatch) \ + Member(class, HeapValue, HeapValue, lastMatch) \ Member(class, Pointer, String *, lastInput) \ Member(class, NoMark, int, lastMatchStart) \ Member(class, NoMark, int, lastMatchEnd) diff --git a/src/qml/jsruntime/qv4value_p.h b/src/qml/jsruntime/qv4value_p.h index 771d28dce8..3d7776b736 100644 --- a/src/qml/jsruntime/qv4value_p.h +++ b/src/qml/jsruntime/qv4value_p.h @@ -708,6 +708,11 @@ inline unsigned int Value::toUInt32() const return (unsigned int)toInt32(); } +template +struct HeapValue : Value { + HeapValue &operator = (const Value &other) { setRawValue(other.rawValue()); return *this; } +}; + template struct ValueArray { uint size; -- cgit v1.2.3