2011-05-10 Geoffrey Garen <ggaren@apple.com>
Reviewed by Darin Adler.
Fixed up some #include dependencies so the WriteBarrier class can actually call Heap::writeBarrier
https://bugs.webkit.org/show_bug.cgi?id=60532
* GNUmakefile.list.am:
* JavaScriptCore.gypi:
* JavaScriptCore.xcodeproj/project.pbxproj: Build!
* heap/Handle.h: Moved HandleTypes to its own header because that's the
WebKit style, and it was necessary to resolve a circular dependency
between Handle.h and WriteBarrier.h.
* heap/Heap.h:
(JSC::Heap::writeBarrier): Added an inline no-op writeBarrier(), to
verify that all the code is in the right place.
* heap/MarkStack.h: Moved WriteBarrier operations to WriteBarrier.h to
resolve a circular dependency.
* runtime/ArgList.h:
* runtime/JSCell.h: #include WriteBarrier.h since we don't get it for
free anymore.
* runtime/PropertyMapHashTable.h:
(JSC::PropertyTable::PropertyTable): Call the real writeBarrier()
function, now that it exists.
* runtime/SmallStrings.h: Removed a stray #include to resolve a circular
dependency.
* runtime/WriteBarrier.h:
(JSC::WriteBarrierBase::set):
(JSC::MarkStack::append):
(JSC::MarkStack::appendValues): Updated to match the changes above.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@86209 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/JavaScriptCore/runtime/ArgList.h b/Source/JavaScriptCore/runtime/ArgList.h
index bb2d284..ef7809f 100644
--- a/Source/JavaScriptCore/runtime/ArgList.h
+++ b/Source/JavaScriptCore/runtime/ArgList.h
@@ -24,6 +24,7 @@
#include "CallFrame.h"
#include "Register.h"
+#include "WriteBarrier.h"
#include <wtf/HashSet.h>
#include <wtf/Vector.h>
diff --git a/Source/JavaScriptCore/runtime/JSCell.h b/Source/JavaScriptCore/runtime/JSCell.h
index 1662163..08aab62 100644
--- a/Source/JavaScriptCore/runtime/JSCell.h
+++ b/Source/JavaScriptCore/runtime/JSCell.h
@@ -30,6 +30,7 @@
#include "JSLock.h"
#include "JSValueInlineMethods.h"
#include "MarkStack.h"
+#include "WriteBarrier.h"
#include <wtf/Noncopyable.h>
namespace JSC {
diff --git a/Source/JavaScriptCore/runtime/PropertyMapHashTable.h b/Source/JavaScriptCore/runtime/PropertyMapHashTable.h
index 0358f1a..6ea593a 100644
--- a/Source/JavaScriptCore/runtime/PropertyMapHashTable.h
+++ b/Source/JavaScriptCore/runtime/PropertyMapHashTable.h
@@ -245,7 +245,7 @@
ASSERT(isPowerOf2(m_indexSize));
}
-inline PropertyTable::PropertyTable(JSGlobalData& globalData, JSCell* owner, const PropertyTable& other)
+inline PropertyTable::PropertyTable(JSGlobalData&, JSCell* owner, const PropertyTable& other)
: m_indexSize(other.m_indexSize)
, m_indexMask(other.m_indexMask)
, m_index(static_cast<unsigned*>(fastMalloc(dataSize())))
@@ -259,7 +259,7 @@
iterator end = this->end();
for (iterator iter = begin(); iter != end; ++iter) {
iter->key->ref();
- writeBarrier(globalData, owner, iter->specificValue.get());
+ Heap::writeBarrier(owner, iter->specificValue.get());
}
// Copy the m_deletedOffsets vector.
@@ -268,7 +268,7 @@
m_deletedOffsets = adoptPtr(new Vector<unsigned>(*otherDeletedOffsets));
}
-inline PropertyTable::PropertyTable(JSGlobalData& globalData, JSCell* owner, unsigned initialCapacity, const PropertyTable& other)
+inline PropertyTable::PropertyTable(JSGlobalData&, JSCell* owner, unsigned initialCapacity, const PropertyTable& other)
: m_indexSize(sizeForCapacity(initialCapacity))
, m_indexMask(m_indexSize - 1)
, m_index(static_cast<unsigned*>(fastZeroedMalloc(dataSize())))
@@ -283,7 +283,7 @@
ASSERT(canInsert());
reinsert(*iter);
iter->key->ref();
- writeBarrier(globalData, owner, iter->specificValue.get());
+ Heap::writeBarrier(owner, iter->specificValue.get());
}
// Copy the m_deletedOffsets vector.
diff --git a/Source/JavaScriptCore/runtime/SmallStrings.h b/Source/JavaScriptCore/runtime/SmallStrings.h
index 17607bb..e762e1f 100644
--- a/Source/JavaScriptCore/runtime/SmallStrings.h
+++ b/Source/JavaScriptCore/runtime/SmallStrings.h
@@ -27,7 +27,6 @@
#define SmallStrings_h
#include "UString.h"
-#include "WriteBarrier.h"
#include <wtf/FixedArray.h>
#include <wtf/OwnPtr.h>
diff --git a/Source/JavaScriptCore/runtime/WriteBarrier.h b/Source/JavaScriptCore/runtime/WriteBarrier.h
index 32cb968..bc28651 100644
--- a/Source/JavaScriptCore/runtime/WriteBarrier.h
+++ b/Source/JavaScriptCore/runtime/WriteBarrier.h
@@ -26,39 +26,24 @@
#ifndef WriteBarrier_h
#define WriteBarrier_h
-#include "JSValue.h"
+#include "HandleTypes.h"
+#include "Heap.h"
namespace JSC {
+
class JSCell;
class JSGlobalData;
-inline void writeBarrier(JSGlobalData&, const JSCell*, JSValue)
-{
-}
-
-inline void writeBarrier(JSGlobalData&, const JSCell*, JSCell*)
-{
-}
-
-typedef enum { } Unknown;
-typedef JSValue* HandleSlot;
-
-template <typename T> struct JSValueChecker {
- static const bool IsJSValue = false;
-};
-
-template <> struct JSValueChecker<JSValue> {
- static const bool IsJSValue = true;
-};
+template<class T> class WriteBarrierBase;
+template<> class WriteBarrierBase<JSValue>;
// We have a separate base class with no constructors for use in Unions.
template <typename T> class WriteBarrierBase {
public:
- COMPILE_ASSERT(!JSValueChecker<T>::IsJSValue, WriteBarrier_JSValue_is_invalid__use_unknown);
- void set(JSGlobalData& globalData, const JSCell* owner, T* value)
+ void set(JSGlobalData&, const JSCell* owner, T* value)
{
this->m_cell = reinterpret_cast<JSCell*>(value);
- writeBarrier(globalData, owner, this->m_cell);
+ Heap::writeBarrier(owner, this->m_cell);
#if ENABLE(JSC_ZOMBIES)
ASSERT(!isZombie(owner));
ASSERT(!isZombie(m_cell));
@@ -108,15 +93,16 @@
template <> class WriteBarrierBase<Unknown> {
public:
- void set(JSGlobalData& globalData, const JSCell* owner, JSValue value)
+ void set(JSGlobalData&, const JSCell* owner, JSValue value)
{
#if ENABLE(JSC_ZOMBIES)
ASSERT(!isZombie(owner));
ASSERT(!value.isZombie());
#endif
m_value = JSValue::encode(value);
- writeBarrier(globalData, owner, value);
+ Heap::writeBarrier(owner, value);
}
+
void setWithoutWriteBarrier(JSValue value)
{
#if ENABLE(JSC_ZOMBIES)
@@ -185,6 +171,23 @@
return lhs.get() == rhs.get();
}
+// MarkStack functions
+
+template<typename T> inline void MarkStack::append(WriteBarrierBase<T>* slot)
+{
+ internalAppend(*slot->slot());
+}
+
+inline void MarkStack::appendValues(WriteBarrierBase<Unknown>* barriers, size_t count, MarkSetProperties properties)
+{
+ JSValue* values = barriers->slot();
+#if !ASSERT_DISABLED
+ validateSet(values, count);
+#endif
+ if (count)
+ m_markSets.append(MarkSet(values, values + count, properties));
+}
+
} // namespace JSC
#endif // WriteBarrier_h