diff options
author | Lorry Tar Creator <lorry-tar-importer@lorry> | 2016-04-10 09:28:39 +0000 |
---|---|---|
committer | Lorry Tar Creator <lorry-tar-importer@lorry> | 2016-04-10 09:28:39 +0000 |
commit | 32761a6cee1d0dee366b885b7b9c777e67885688 (patch) | |
tree | d6bec92bebfb216f4126356e55518842c2f476a1 /Source/JavaScriptCore/runtime/WriteBarrier.h | |
parent | a4e969f4965059196ca948db781e52f7cfebf19e (diff) | |
download | WebKitGtk-tarball-32761a6cee1d0dee366b885b7b9c777e67885688.tar.gz |
webkitgtk-2.4.11webkitgtk-2.4.11
Diffstat (limited to 'Source/JavaScriptCore/runtime/WriteBarrier.h')
-rw-r--r-- | Source/JavaScriptCore/runtime/WriteBarrier.h | 55 |
1 files changed, 38 insertions, 17 deletions
diff --git a/Source/JavaScriptCore/runtime/WriteBarrier.h b/Source/JavaScriptCore/runtime/WriteBarrier.h index b727d185e..06161cd98 100644 --- a/Source/JavaScriptCore/runtime/WriteBarrier.h +++ b/Source/JavaScriptCore/runtime/WriteBarrier.h @@ -71,7 +71,13 @@ template<class T> inline void validateCell(T) // We have a separate base class with no constructors for use in Unions. template <typename T> class WriteBarrierBase { public: - void set(VM&, const JSCell* owner, T* value); + void set(VM& vm, const JSCell* owner, T* value) + { + ASSERT(value); + ASSERT(!Options::enableConcurrentJIT() || !isCompilationThread()); + validateCell(value); + setEarlyValue(vm, owner, value); + } // This is meant to be used like operator=, but is called copyFrom instead, in // order to kindly inform the C++ compiler that its advice is not appreciated. @@ -80,11 +86,20 @@ public: m_cell = other.m_cell; } - void setMayBeNull(VM&, const JSCell* owner, T* value); + void setMayBeNull(VM& vm, const JSCell* owner, T* value) + { + if (value) + validateCell(value); + setEarlyValue(vm, owner, value); + } // Should only be used by JSCell during early initialisation // when some basic types aren't yet completely instantiated - void setEarlyValue(VM&, const JSCell* owner, T* value); + void setEarlyValue(VM&, const JSCell* owner, T* value) + { + this->m_cell = reinterpret_cast<JSCell*>(value); + Heap::writeBarrier(owner, this->m_cell); + } T* get() const { @@ -113,7 +128,8 @@ public: T** slot() { return reinterpret_cast<T**>(&m_cell); } - explicit operator bool() const { return m_cell; } + typedef T* (WriteBarrierBase::*UnspecifiedBoolType); + operator UnspecifiedBoolType*() const { return m_cell ? reinterpret_cast<UnspecifiedBoolType*>(1) : 0; } bool operator!() const { return !m_cell; } @@ -125,7 +141,9 @@ public: this->m_cell = reinterpret_cast<JSCell*>(value); } +#if ENABLE(GC_VALIDATION) T* unvalidatedGet() const { return reinterpret_cast<T*>(static_cast<void*>(m_cell)); } +#endif private: JSCell* m_cell; @@ -133,7 +151,13 @@ private: template <> class WriteBarrierBase<Unknown> { public: - void set(VM&, const JSCell* owner, JSValue); + void set(VM&, const JSCell* owner, JSValue value) + { + ASSERT(!Options::enableConcurrentJIT() || !isCompilationThread()); + m_value = JSValue::encode(value); + Heap::writeBarrier(owner, value); + } + void setWithoutWriteBarrier(JSValue value) { m_value = JSValue::encode(value); @@ -145,22 +169,26 @@ public: } void clear() { m_value = JSValue::encode(JSValue()); } void setUndefined() { m_value = JSValue::encode(jsUndefined()); } - void setStartingValue(JSValue value) { m_value = JSValue::encode(value); } bool isNumber() const { return get().isNumber(); } bool isObject() const { return get().isObject(); } bool isNull() const { return get().isNull(); } bool isGetterSetter() const { return get().isGetterSetter(); } - bool isCustomGetterSetter() const { return get().isCustomGetterSetter(); } - JSValue* slot() const + JSValue* slot() { - return bitwise_cast<JSValue*>(&m_value); + union { + EncodedJSValue* v; + JSValue* slot; + } u; + u.v = &m_value; + return u.slot; } int32_t* tagPointer() { return &bitwise_cast<EncodedValueDescriptor*>(&m_value)->asBits.tag; } int32_t* payloadPointer() { return &bitwise_cast<EncodedValueDescriptor*>(&m_value)->asBits.payload; } - explicit operator bool() const { return !!get(); } + typedef JSValue (WriteBarrierBase::*UnspecifiedBoolType); + operator UnspecifiedBoolType*() const { return get() ? reinterpret_cast<UnspecifiedBoolType*>(1) : 0; } bool operator!() const { return !get(); } private: @@ -168,7 +196,6 @@ private: }; template <typename T> class WriteBarrier : public WriteBarrierBase<T> { - WTF_MAKE_FAST_ALLOCATED; public: WriteBarrier() { @@ -193,18 +220,12 @@ public: } }; -enum UndefinedWriteBarrierTagType { UndefinedWriteBarrierTag }; template <> class WriteBarrier<Unknown> : public WriteBarrierBase<Unknown> { - WTF_MAKE_FAST_ALLOCATED; public: WriteBarrier() { this->setWithoutWriteBarrier(JSValue()); } - WriteBarrier(UndefinedWriteBarrierTagType) - { - this->setWithoutWriteBarrier(jsUndefined()); - } WriteBarrier(VM& vm, const JSCell* owner, JSValue value) { |