summaryrefslogtreecommitdiff
path: root/Source/JavaScriptCore/runtime/WriteBarrier.h
diff options
context:
space:
mode:
Diffstat (limited to 'Source/JavaScriptCore/runtime/WriteBarrier.h')
-rw-r--r--Source/JavaScriptCore/runtime/WriteBarrier.h60
1 files changed, 18 insertions, 42 deletions
diff --git a/Source/JavaScriptCore/runtime/WriteBarrier.h b/Source/JavaScriptCore/runtime/WriteBarrier.h
index 06161cd98..26b395721 100644
--- a/Source/JavaScriptCore/runtime/WriteBarrier.h
+++ b/Source/JavaScriptCore/runtime/WriteBarrier.h
@@ -23,8 +23,7 @@
* THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef WriteBarrier_h
-#define WriteBarrier_h
+#pragma once
#include "GCAssertions.h"
#include "HandleTypes.h"
@@ -71,13 +70,7 @@ 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& vm, const JSCell* owner, T* value)
- {
- ASSERT(value);
- ASSERT(!Options::enableConcurrentJIT() || !isCompilationThread());
- validateCell(value);
- setEarlyValue(vm, owner, value);
- }
+ void set(VM&, const JSCell* owner, T* 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.
@@ -86,20 +79,11 @@ public:
m_cell = other.m_cell;
}
- void setMayBeNull(VM& vm, const JSCell* owner, T* value)
- {
- if (value)
- validateCell(value);
- setEarlyValue(vm, owner, value);
- }
+ void setMayBeNull(VM&, const JSCell* owner, T* 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)
- {
- this->m_cell = reinterpret_cast<JSCell*>(value);
- Heap::writeBarrier(owner, this->m_cell);
- }
+ void setEarlyValue(VM&, const JSCell* owner, T* value);
T* get() const
{
@@ -128,8 +112,7 @@ public:
T** slot() { return reinterpret_cast<T**>(&m_cell); }
- typedef T* (WriteBarrierBase::*UnspecifiedBoolType);
- operator UnspecifiedBoolType*() const { return m_cell ? reinterpret_cast<UnspecifiedBoolType*>(1) : 0; }
+ explicit operator bool() const { return m_cell; }
bool operator!() const { return !m_cell; }
@@ -141,9 +124,7 @@ 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;
@@ -151,13 +132,7 @@ private:
template <> class WriteBarrierBase<Unknown> {
public:
- void set(VM&, const JSCell* owner, JSValue value)
- {
- ASSERT(!Options::enableConcurrentJIT() || !isCompilationThread());
- m_value = JSValue::encode(value);
- Heap::writeBarrier(owner, value);
- }
-
+ void set(VM&, const JSCell* owner, JSValue);
void setWithoutWriteBarrier(JSValue value)
{
m_value = JSValue::encode(value);
@@ -169,26 +144,22 @@ 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()
+ JSValue* slot() const
{
- union {
- EncodedJSValue* v;
- JSValue* slot;
- } u;
- u.v = &m_value;
- return u.slot;
+ return bitwise_cast<JSValue*>(&m_value);
}
int32_t* tagPointer() { return &bitwise_cast<EncodedValueDescriptor*>(&m_value)->asBits.tag; }
int32_t* payloadPointer() { return &bitwise_cast<EncodedValueDescriptor*>(&m_value)->asBits.payload; }
- typedef JSValue (WriteBarrierBase::*UnspecifiedBoolType);
- operator UnspecifiedBoolType*() const { return get() ? reinterpret_cast<UnspecifiedBoolType*>(1) : 0; }
+ explicit operator bool() const { return !!get(); }
bool operator!() const { return !get(); }
private:
@@ -196,6 +167,7 @@ private:
};
template <typename T> class WriteBarrier : public WriteBarrierBase<T> {
+ WTF_MAKE_FAST_ALLOCATED;
public:
WriteBarrier()
{
@@ -220,12 +192,18 @@ 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)
{
@@ -245,5 +223,3 @@ template <typename U, typename V> inline bool operator==(const WriteBarrierBase<
}
} // namespace JSC
-
-#endif // WriteBarrier_h