https://bugs.webkit.org/show_bug.cgi?id=112768
Rubber stamped by Mark Hahnenberg.
See http://en.wikipedia.org/wiki/Hash_consing
* heap/GCThreadSharedData.cpp:
(JSC::GCThreadSharedData::GCThreadSharedData):
(JSC::GCThreadSharedData::reset):
* heap/GCThreadSharedData.h:
(GCThreadSharedData):
* heap/SlotVisitor.cpp:
(JSC::SlotVisitor::SlotVisitor):
(JSC::SlotVisitor::setup):
(JSC::SlotVisitor::reset):
(JSC::JSString::tryHashConsLock):
(JSC::JSString::releaseHashConsLock):
(JSC::JSString::shouldTryHashCons):
(JSC::SlotVisitor::internalAppend):
* heap/SlotVisitor.h:
(SlotVisitor):
* runtime/JSGlobalData.cpp:
(JSC::JSGlobalData::JSGlobalData):
* runtime/JSGlobalData.h:
(JSGlobalData):
(JSC::JSGlobalData::haveEnoughNewStringsToHashCons):
(JSC::JSGlobalData::resetNewStringsSinceLastHashCons):
* runtime/JSString.h:
(JSC::JSString::finishCreation):
(JSString):
(JSC::JSString::isHashConsSingleton):
(JSC::JSString::clearHashConsSingleton):
(JSC::JSString::setHashConsSingleton):
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@146383
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2013-03-19 Filip Pizlo <fpizlo@apple.com>
+
+ It's called "Hash Consing" not "Hash Consting"
+ https://bugs.webkit.org/show_bug.cgi?id=112768
+
+ Rubber stamped by Mark Hahnenberg.
+
+ See http://en.wikipedia.org/wiki/Hash_consing
+
+ * heap/GCThreadSharedData.cpp:
+ (JSC::GCThreadSharedData::GCThreadSharedData):
+ (JSC::GCThreadSharedData::reset):
+ * heap/GCThreadSharedData.h:
+ (GCThreadSharedData):
+ * heap/SlotVisitor.cpp:
+ (JSC::SlotVisitor::SlotVisitor):
+ (JSC::SlotVisitor::setup):
+ (JSC::SlotVisitor::reset):
+ (JSC::JSString::tryHashConsLock):
+ (JSC::JSString::releaseHashConsLock):
+ (JSC::JSString::shouldTryHashCons):
+ (JSC::SlotVisitor::internalAppend):
+ * heap/SlotVisitor.h:
+ (SlotVisitor):
+ * runtime/JSGlobalData.cpp:
+ (JSC::JSGlobalData::JSGlobalData):
+ * runtime/JSGlobalData.h:
+ (JSGlobalData):
+ (JSC::JSGlobalData::haveEnoughNewStringsToHashCons):
+ (JSC::JSGlobalData::resetNewStringsSinceLastHashCons):
+ * runtime/JSString.h:
+ (JSC::JSString::finishCreation):
+ (JSString):
+ (JSC::JSString::isHashConsSingleton):
+ (JSC::JSString::clearHashConsSingleton):
+ (JSC::JSString::setHashConsSingleton):
+
2013-03-20 Filip Pizlo <fpizlo@apple.com>
DFG implementation of op_strcat should inline rope allocations
GCThreadSharedData::GCThreadSharedData(JSGlobalData* globalData)
: m_globalData(globalData)
, m_copiedSpace(&globalData->heap.m_storageSpace)
- , m_shouldHashConst(false)
+ , m_shouldHashCons(false)
, m_sharedMarkStack(globalData->heap.blockAllocator())
, m_numberOfActiveParallelMarkers(0)
, m_parallelMarkersShouldExit(false)
#endif
m_weakReferenceHarvesters.removeAll();
- if (m_shouldHashConst) {
- m_globalData->resetNewStringsSinceLastHashConst();
- m_shouldHashConst = false;
+ if (m_shouldHashCons) {
+ m_globalData->resetNewStringsSinceLastHashCons();
+ m_shouldHashCons = false;
}
}
JSGlobalData* m_globalData;
CopiedSpace* m_copiedSpace;
- bool m_shouldHashConst;
+ bool m_shouldHashCons;
Vector<GCThread*> m_gcThreads;
, m_visitCount(0)
, m_isInParallelMode(false)
, m_shared(shared)
- , m_shouldHashConst(false)
+ , m_shouldHashCons(false)
#if !ASSERT_DISABLED
, m_isCheckingForDefaultMarkViolation(false)
, m_isDraining(false)
void SlotVisitor::setup()
{
- m_shared.m_shouldHashConst = m_shared.m_globalData->haveEnoughNewStringsToHashConst();
- m_shouldHashConst = m_shared.m_shouldHashConst;
+ m_shared.m_shouldHashCons = m_shared.m_globalData->haveEnoughNewStringsToHashCons();
+ m_shouldHashCons = m_shared.m_shouldHashCons;
#if ENABLE(PARALLEL_GC)
for (unsigned i = 0; i < m_shared.m_gcThreads.size(); ++i)
- m_shared.m_gcThreads[i]->slotVisitor()->m_shouldHashConst = m_shared.m_shouldHashConst;
+ m_shared.m_gcThreads[i]->slotVisitor()->m_shouldHashCons = m_shared.m_shouldHashCons;
#endif
}
#else
m_opaqueRoots.clear();
#endif
- if (m_shouldHashConst) {
+ if (m_shouldHashCons) {
m_uniqueStrings.clear();
- m_shouldHashConst = false;
+ m_shouldHashCons = false;
}
}
m_opaqueRoots.clear();
}
-ALWAYS_INLINE bool JSString::tryHashConstLock()
+ALWAYS_INLINE bool JSString::tryHashConsLock()
{
#if ENABLE(PARALLEL_GC)
unsigned currentFlags = m_flags;
- if (currentFlags & HashConstLock)
+ if (currentFlags & HashConsLock)
return false;
- unsigned newFlags = currentFlags | HashConstLock;
+ unsigned newFlags = currentFlags | HashConsLock;
if (!WTF::weakCompareAndSwap(&m_flags, currentFlags, newFlags))
return false;
WTF::memoryBarrierAfterLock();
return true;
#else
- if (isHashConstSingleton())
+ if (isHashConsSingleton())
return false;
- m_flags |= HashConstLock;
+ m_flags |= HashConsLock;
return true;
#endif
}
-ALWAYS_INLINE void JSString::releaseHashConstLock()
+ALWAYS_INLINE void JSString::releaseHashConsLock()
{
#if ENABLE(PARALLEL_GC)
WTF::memoryBarrierBeforeUnlock();
#endif
- m_flags &= ~HashConstLock;
+ m_flags &= ~HashConsLock;
}
-ALWAYS_INLINE bool JSString::shouldTryHashConst()
+ALWAYS_INLINE bool JSString::shouldTryHashCons()
{
- return ((length() > 1) && !isRope() && !isHashConstSingleton());
+ return ((length() > 1) && !isRope() && !isHashConsSingleton());
}
ALWAYS_INLINE void SlotVisitor::internalAppend(JSValue* slot)
validate(cell);
- if (m_shouldHashConst && cell->isString()) {
+ if (m_shouldHashCons && cell->isString()) {
JSString* string = jsCast<JSString*>(cell);
- if (string->shouldTryHashConst() && string->tryHashConstLock()) {
+ if (string->shouldTryHashCons() && string->tryHashConsLock()) {
UniqueStringMap::AddResult addResult = m_uniqueStrings.add(string->string().impl(), value);
if (addResult.isNewEntry)
- string->setHashConstSingleton();
+ string->setHashConsSingleton();
else {
JSValue existingJSValue = addResult.iterator->value;
if (value != existingJSValue)
- jsCast<JSString*>(existingJSValue.asCell())->clearHashConstSingleton();
+ jsCast<JSString*>(existingJSValue.asCell())->clearHashConsSingleton();
*slot = existingJSValue;
- string->releaseHashConstLock();
+ string->releaseHashConsLock();
return;
}
- string->releaseHashConstLock();
+ string->releaseHashConsLock();
}
}
GCThreadSharedData& m_shared;
- bool m_shouldHashConst; // Local per-thread copy of shared flag for performance reasons
+ bool m_shouldHashCons; // Local per-thread copy of shared flag for performance reasons
typedef HashMap<StringImpl*, JSValue> UniqueStringMap;
UniqueStringMap m_uniqueStrings;
#if CPU(X86) && ENABLE(JIT)
, m_timeoutCount(512)
#endif
- , m_newStringsSinceLastHashConst(0)
+ , m_newStringsSinceLastHashCons(0)
#if ENABLE(ASSEMBLER)
, m_canUseAssembler(enableAssembler(executableAllocator))
#endif
unsigned m_timeoutCount;
#endif
- unsigned m_newStringsSinceLastHashConst;
+ unsigned m_newStringsSinceLastHashCons;
- static const unsigned s_minNumberOfNewStringsToHashConst = 100;
+ static const unsigned s_minNumberOfNewStringsToHashCons = 100;
- bool haveEnoughNewStringsToHashConst() { return m_newStringsSinceLastHashConst > s_minNumberOfNewStringsToHashConst; }
- void resetNewStringsSinceLastHashConst() { m_newStringsSinceLastHashConst = 0; }
+ bool haveEnoughNewStringsToHashCons() { return m_newStringsSinceLastHashCons > s_minNumberOfNewStringsToHashCons; }
+ void resetNewStringsSinceLastHashCons() { m_newStringsSinceLastHashCons = 0; }
#define registerTypedArrayFunction(type, capitalizedType) \
void registerTypedArrayDescriptor(const capitalizedType##Array*, const TypedArrayDescriptor& descriptor) \
Base::finishCreation(globalData);
m_length = length;
setIs8Bit(m_value.impl()->is8Bit());
- globalData.m_newStringsSinceLastHashConst++;
+ globalData.m_newStringsSinceLastHashCons++;
}
void finishCreation(JSGlobalData& globalData, size_t length, size_t cost)
m_length = length;
setIs8Bit(m_value.impl()->is8Bit());
Heap::heap(this)->reportExtraMemoryCost(cost);
- globalData.m_newStringsSinceLastHashConst++;
+ globalData.m_newStringsSinceLastHashCons++;
}
protected:
Base::finishCreation(globalData);
m_length = 0;
setIs8Bit(true);
- globalData.m_newStringsSinceLastHashConst++;
+ globalData.m_newStringsSinceLastHashCons++;
}
public:
static void visitChildren(JSCell*, SlotVisitor&);
enum {
- HashConstLock = 1u << 2,
- IsHashConstSingleton = 1u << 1,
+ HashConsLock = 1u << 2,
+ IsHashConsSingleton = 1u << 1,
Is8Bit = 1u
};
else
m_flags &= ~Is8Bit;
}
- bool shouldTryHashConst();
- bool isHashConstSingleton() const { return m_flags & IsHashConstSingleton; }
- void clearHashConstSingleton() { m_flags &= ~IsHashConstSingleton; }
- void setHashConstSingleton() { m_flags |= IsHashConstSingleton; }
- bool tryHashConstLock();
- void releaseHashConstLock();
+ bool shouldTryHashCons();
+ bool isHashConsSingleton() const { return m_flags & IsHashConsSingleton; }
+ void clearHashConsSingleton() { m_flags &= ~IsHashConsSingleton; }
+ void setHashConsSingleton() { m_flags |= IsHashConsSingleton; }
+ bool tryHashConsLock();
+ void releaseHashConsLock();
unsigned m_flags;