diff --git a/include/hermes/VM/Callable.h b/include/hermes/VM/Callable.h index 5eccce24c3a..c4df2920045 100644 --- a/include/hermes/VM/Callable.h +++ b/include/hermes/VM/Callable.h @@ -92,7 +92,11 @@ class Environment final Runtime &runtime, Handle parentEnvironment, uint32_t size) - : parentEnvironment_(runtime, parentEnvironment.get(), runtime.getHeap()), + : parentEnvironment_( + runtime, + parentEnvironment.get(), + runtime.getHeap(), + this), size_(size) { // Initialize all slots to 'undefined'. GCHermesValue::uninitialized_fill( @@ -340,7 +344,7 @@ class Callable : public JSObject { HiddenClass *clazz, Handle env) : JSObject(runtime, parent, clazz), - environment_(runtime, *env, runtime.getHeap()) {} + environment_(runtime, *env, runtime.getHeap(), this) {} Callable(Runtime &runtime, JSObject *parent, HiddenClass *clazz) : JSObject(runtime, parent, clazz), environment_() {} @@ -363,7 +367,8 @@ Environment::Environment( runtime, // TODO: Consider keeping the parent as a compressed pointer. parentFn->getEnvironment(runtime), - runtime.getHeap()), + runtime.getHeap(), + this), size_(size) { // Initialize all slots to 'undefined'. GCHermesValue::uninitialized_fill( @@ -441,8 +446,8 @@ class BoundFunction final : public Callable { Handle target, Handle argStorage) : Callable(runtime, *parent, *clazz), - target_(runtime, *target, runtime.getHeap()), - argStorage_(runtime, *argStorage, runtime.getHeap()) {} + target_(runtime, *target, runtime.getHeap(), this), + argStorage_(runtime, *argStorage, runtime.getHeap(), this) {} private: /// Return a pointer to the stored arguments, including \c this. \c this is @@ -1021,7 +1026,7 @@ class JSFunction : public Callable { CodeBlock *codeBlock) : Callable(runtime, *parent, *clazz, environment), codeBlock_(codeBlock), - domain_(runtime, *domain, runtime.getHeap()) { + domain_(runtime, *domain, runtime.getHeap(), this) { assert( !vt.finalize_ == (kHasFinalizer != HasFinalizer::Yes) && "kHasFinalizer invalid value"); diff --git a/include/hermes/VM/GCPointer-inline.h b/include/hermes/VM/GCPointer-inline.h index 413204525f6..8bc08d95af6 100644 --- a/include/hermes/VM/GCPointer-inline.h +++ b/include/hermes/VM/GCPointer-inline.h @@ -20,11 +20,13 @@ GCPointerBase::GCPointerBase( PointerBase &base, GCCell *ptr, GC &gc, + const GCCell *owningObj, NeedsBarriers) : CompressedPointer(CompressedPointer::encode(ptr, base)) { assert( (!ptr || gc.validPointer(ptr)) && "Cannot construct a GCPointer from an invalid pointer"); + (void)owningObj; if (NeedsBarriers::value) { gc.constructorWriteBarrier(this, ptr); } else { diff --git a/include/hermes/VM/GCPointer.h b/include/hermes/VM/GCPointer.h index 60d86966caf..e7451417e53 100644 --- a/include/hermes/VM/GCPointer.h +++ b/include/hermes/VM/GCPointer.h @@ -25,7 +25,12 @@ class GCPointerBase : public CompressedPointer { explicit GCPointerBase(std::nullptr_t) : CompressedPointer(nullptr) {} template - inline GCPointerBase(PointerBase &base, GCCell *ptr, GC &gc, NeedsBarriers); + inline GCPointerBase( + PointerBase &base, + GCCell *ptr, + GC &gc, + const GCCell *owningObj, + NeedsBarriers); public: // These classes are used as arguments to GCPointer constructors, to @@ -69,14 +74,19 @@ class GCPointer : public GCPointerBase { /// this argument is unused, but its type's boolean value constant indicates /// whether barriers are required.) template - GCPointer(PointerBase &base, T *ptr, GC &gc, NeedsBarriers needsBarriers) - : GCPointerBase(base, ptr, gc, needsBarriers) {} + GCPointer( + PointerBase &base, + T *ptr, + GC &gc, + const GCCell *owningObj, + NeedsBarriers needsBarriers) + : GCPointerBase(base, ptr, gc, owningObj, needsBarriers) {} /// Same as the constructor above, with the default for /// NeedsBarriers as "YesBarriers". (We can't use default template /// arguments with the idiom used above.) - inline GCPointer(PointerBase &base, T *ptr, GC &gc) - : GCPointer(base, ptr, gc, YesBarriers()) {} + inline GCPointer(PointerBase &base, T *ptr, GC &gc, const GCCell *owningObj) + : GCPointer(base, ptr, gc, owningObj, YesBarriers()) {} /// We are not allowed to copy-construct or assign GCPointers. GCPointer(const GCPointerBase &) = delete; diff --git a/include/hermes/VM/HiddenClass.h b/include/hermes/VM/HiddenClass.h index 2870132b914..4e9a0eab867 100644 --- a/include/hermes/VM/HiddenClass.h +++ b/include/hermes/VM/HiddenClass.h @@ -495,7 +495,7 @@ class HiddenClass final : public GCCell { propertyFlags_(propertyFlags), flags_(flags), numProperties_(numProperties), - parent_(runtime, *parent, runtime.getHeap()) { + parent_(runtime, *parent, runtime.getHeap(), this) { assert(propertyFlags.isValid() && "propertyFlags must be valid"); } diff --git a/include/hermes/VM/JSArray.h b/include/hermes/VM/JSArray.h index 4aeec334366..7d1036dbe50 100644 --- a/include/hermes/VM/JSArray.h +++ b/include/hermes/VM/JSArray.h @@ -430,7 +430,7 @@ class JSArrayIterator : public JSObject { Handle iteratedObject, IterationKind iterationKind) : JSObject(runtime, *parent, *clazz), - iteratedObject_(runtime, *iteratedObject, runtime.getHeap()), + iteratedObject_(runtime, *iteratedObject, runtime.getHeap(), this), iterationKind_(iterationKind) {} private: diff --git a/include/hermes/VM/JSObject.h b/include/hermes/VM/JSObject.h index 47bcca3716a..da41f62e514 100644 --- a/include/hermes/VM/JSObject.h +++ b/include/hermes/VM/JSObject.h @@ -279,8 +279,8 @@ class JSObject : public GCCell { JSObject *parent, HiddenClass *clazz, NeedsBarriers needsBarriers) - : parent_(runtime, parent, runtime.getHeap(), needsBarriers), - clazz_(runtime, clazz, runtime.getHeap(), needsBarriers), + : parent_(runtime, parent, runtime.getHeap(), this, needsBarriers), + clazz_(runtime, clazz, runtime.getHeap(), this, needsBarriers), propStorage_(nullptr) { // Direct property slots are initialized by initDirectPropStorage. } @@ -291,8 +291,8 @@ class JSObject : public GCCell { Handle parent, Handle clazz, NeedsBarriers needsBarriers) - : parent_(runtime, *parent, runtime.getHeap(), needsBarriers), - clazz_(runtime, *clazz, runtime.getHeap(), needsBarriers), + : parent_(runtime, *parent, runtime.getHeap(), this, needsBarriers), + clazz_(runtime, *clazz, runtime.getHeap(), this, needsBarriers), propStorage_(nullptr) { // Direct property slots are initialized by initDirectPropStorage. } diff --git a/include/hermes/VM/JSRegExp.h b/include/hermes/VM/JSRegExp.h index 94087984050..19b8ab0cf77 100644 --- a/include/hermes/VM/JSRegExp.h +++ b/include/hermes/VM/JSRegExp.h @@ -131,7 +131,8 @@ class JSRegExp final : public JSObject { pattern_( runtime, runtime.getPredefinedString(Predefined::emptyString), - runtime.getHeap()) {} + runtime.getHeap(), + this) {} private: ~JSRegExp(); diff --git a/include/hermes/VM/JSRegExpStringIterator.h b/include/hermes/VM/JSRegExpStringIterator.h index 3258d836be1..1733c4a6b4c 100644 --- a/include/hermes/VM/JSRegExpStringIterator.h +++ b/include/hermes/VM/JSRegExpStringIterator.h @@ -54,8 +54,8 @@ class JSRegExpStringIterator : public JSObject { bool global, bool unicode) : JSObject(runtime, *parent, *clazz), - iteratedRegExp_(runtime, *iteratedRegExp, runtime.getHeap()), - iteratedString_(runtime, *iteratedString, runtime.getHeap()), + iteratedRegExp_(runtime, *iteratedRegExp, runtime.getHeap(), this), + iteratedString_(runtime, *iteratedString, runtime.getHeap(), this), global_(global), unicode_(unicode) {} diff --git a/include/hermes/VM/PrimitiveBox.h b/include/hermes/VM/PrimitiveBox.h index f823e0cb22c..0de37a2a450 100644 --- a/include/hermes/VM/PrimitiveBox.h +++ b/include/hermes/VM/PrimitiveBox.h @@ -66,7 +66,7 @@ class JSString final : public JSObject { Handle parent, Handle clazz) : JSObject(runtime, *parent, *clazz), - primitiveValue_(runtime, *value, runtime.getHeap()) { + primitiveValue_(runtime, *value, runtime.getHeap(), this) { flags_.indexedStorage = true; flags_.fastIndexProperties = true; } @@ -157,7 +157,7 @@ class JSStringIterator : public JSObject { Handle clazz, Handle iteratedString) : JSObject(runtime, *parent, *clazz), - iteratedString_(runtime, *iteratedString, runtime.getHeap()) {} + iteratedString_(runtime, *iteratedString, runtime.getHeap(), this) {} private: /// [[IteratedString]] @@ -221,7 +221,7 @@ class JSBigInt final : public JSObject { Handle parent, Handle clazz) : JSObject(runtime, *parent, *clazz), - primitiveValue_(runtime, *value, runtime.getHeap()) {} + primitiveValue_(runtime, *value, runtime.getHeap(), this) {} private: GCPointer primitiveValue_; diff --git a/include/hermes/VM/PropertyAccessor.h b/include/hermes/VM/PropertyAccessor.h index 3fe62fa5c64..4a65e224ecc 100644 --- a/include/hermes/VM/PropertyAccessor.h +++ b/include/hermes/VM/PropertyAccessor.h @@ -20,8 +20,8 @@ class PropertyAccessor final : public GCCell { Runtime &runtime, Handle getter, Handle setter) - : getter(runtime, *getter, runtime.getHeap()), - setter(runtime, *setter, runtime.getHeap()) {} + : getter(runtime, *getter, runtime.getHeap(), this), + setter(runtime, *setter, runtime.getHeap(), this) {} static const VTable vt; diff --git a/lib/VM/JSCallSite.cpp b/lib/VM/JSCallSite.cpp index 2e6f0c71f5e..677a9f95fba 100644 --- a/lib/VM/JSCallSite.cpp +++ b/lib/VM/JSCallSite.cpp @@ -40,7 +40,7 @@ JSCallSite::JSCallSite( Handle error, size_t stackFrameIndex) : JSObject(runtime, *parent, *clazz), - error_(runtime, *error, runtime.getHeap()), + error_(runtime, *error, runtime.getHeap(), this), stackFrameIndex_(stackFrameIndex) { assert( error_.getNonNull(runtime)->getStackTrace() &&