diff options
Diffstat (limited to 'Source/JavaScriptCore/runtime/Identifier.h')
-rw-r--r-- | Source/JavaScriptCore/runtime/Identifier.h | 52 |
1 files changed, 29 insertions, 23 deletions
diff --git a/Source/JavaScriptCore/runtime/Identifier.h b/Source/JavaScriptCore/runtime/Identifier.h index dcb739ec3..75b68b6e1 100644 --- a/Source/JavaScriptCore/runtime/Identifier.h +++ b/Source/JavaScriptCore/runtime/Identifier.h @@ -21,7 +21,7 @@ #ifndef Identifier_h #define Identifier_h -#include "JSGlobalData.h" +#include "VM.h" #include <wtf/ThreadSpecific.h> #include <wtf/WTFThreadData.h> #include <wtf/text/CString.h> @@ -42,15 +42,15 @@ namespace JSC { template<unsigned charactersCount> Identifier(ExecState* exec, const char (&characters)[charactersCount]) : m_string(add(exec, characters)) { } template<unsigned charactersCount> - Identifier(JSGlobalData* globalData, const char (&characters)[charactersCount]) : m_string(add(globalData, characters)) { } + Identifier(VM* vm, const char (&characters)[charactersCount]) : m_string(add(vm, characters)) { } Identifier(ExecState* exec, StringImpl* rep) : m_string(add(exec, rep)) { } Identifier(ExecState* exec, const String& s) : m_string(add(exec, s.impl())) { } - Identifier(JSGlobalData* globalData, const LChar* s, int length) : m_string(add(globalData, s, length)) { } - Identifier(JSGlobalData* globalData, const UChar* s, int length) : m_string(add(globalData, s, length)) { } - Identifier(JSGlobalData* globalData, StringImpl* rep) : m_string(add(globalData, rep)) { } - Identifier(JSGlobalData* globalData, const String& s) : m_string(add(globalData, s.impl())) { } + Identifier(VM* vm, const LChar* s, int length) : m_string(add(vm, s, length)) { } + Identifier(VM* vm, const UChar* s, int length) : m_string(add(vm, s, length)) { } + Identifier(VM* vm, StringImpl* rep) : m_string(add(vm, rep)) { } + Identifier(VM* vm, const String& s) : m_string(add(vm, s.impl())) { } const String& string() const { return m_string; } StringImpl* impl() const { return m_string.impl(); } @@ -60,14 +60,14 @@ namespace JSC { CString ascii() const { return m_string.ascii(); } - static Identifier createLCharFromUChar(JSGlobalData* globalData, const UChar* s, int length) { return Identifier(globalData, add8(globalData, s, length)); } + static Identifier createLCharFromUChar(VM* vm, const UChar* s, int length) { return Identifier(vm, add8(vm, s, length)); } JS_EXPORT_PRIVATE static Identifier from(ExecState* exec, unsigned y); JS_EXPORT_PRIVATE static Identifier from(ExecState* exec, int y); static Identifier from(ExecState* exec, double y); - static Identifier from(JSGlobalData*, unsigned y); - static Identifier from(JSGlobalData*, int y); - static Identifier from(JSGlobalData*, double y); + static Identifier from(VM*, unsigned y); + static Identifier from(VM*, int y); + static Identifier from(VM*, double y); bool isNull() const { return m_string.isNull(); } bool isEmpty() const { return m_string.isEmpty(); } @@ -87,7 +87,7 @@ namespace JSC { static bool equal(const StringImpl* a, const StringImpl* b) { return ::equal(a, b); } // Only to be used with string literals. - static PassRefPtr<StringImpl> add(JSGlobalData*, const char*); + static PassRefPtr<StringImpl> add(VM*, const char*); JS_EXPORT_PRIVATE static PassRefPtr<StringImpl> add(ExecState*, const char*); private: @@ -99,8 +99,8 @@ namespace JSC { static bool equal(const Identifier& a, const Identifier& b) { return a.m_string.impl() == b.m_string.impl(); } static bool equal(const Identifier& a, const LChar* b) { return equal(a.m_string.impl(), b); } - template <typename T> static PassRefPtr<StringImpl> add(JSGlobalData*, const T*, int length); - static PassRefPtr<StringImpl> add8(JSGlobalData*, const UChar*, int length); + template <typename T> static PassRefPtr<StringImpl> add(VM*, const T*, int length); + static PassRefPtr<StringImpl> add8(VM*, const UChar*, int length); template <typename T> ALWAYS_INLINE static bool canUseSingleCharacterString(T); static PassRefPtr<StringImpl> add(ExecState* exec, StringImpl* r) @@ -112,21 +112,21 @@ namespace JSC { return r; return addSlowCase(exec, r); } - static PassRefPtr<StringImpl> add(JSGlobalData* globalData, StringImpl* r) + static PassRefPtr<StringImpl> add(VM* vm, StringImpl* r) { #ifndef NDEBUG - checkCurrentIdentifierTable(globalData); + checkCurrentIdentifierTable(vm); #endif if (r->isIdentifier()) return r; - return addSlowCase(globalData, r); + return addSlowCase(vm, r); } JS_EXPORT_PRIVATE static PassRefPtr<StringImpl> addSlowCase(ExecState*, StringImpl* r); - JS_EXPORT_PRIVATE static PassRefPtr<StringImpl> addSlowCase(JSGlobalData*, StringImpl* r); + JS_EXPORT_PRIVATE static PassRefPtr<StringImpl> addSlowCase(VM*, StringImpl* r); JS_EXPORT_PRIVATE static void checkCurrentIdentifierTable(ExecState*); - JS_EXPORT_PRIVATE static void checkCurrentIdentifierTable(JSGlobalData*); + JS_EXPORT_PRIVATE static void checkCurrentIdentifierTable(VM*); }; template <> ALWAYS_INLINE bool Identifier::canUseSingleCharacterString(LChar) @@ -150,7 +150,7 @@ namespace JSC { struct IdentifierCharBufferTranslator { static unsigned hash(const CharBuffer<T>& buf) { - return StringHasher::computeHashAndMaskTop8Bits<T>(buf.s, buf.length); + return StringHasher::computeHashAndMaskTop8Bits(buf.s, buf.length); } static bool equal(StringImpl* str, const CharBuffer<T>& buf) @@ -170,18 +170,18 @@ namespace JSC { }; template <typename T> - PassRefPtr<StringImpl> Identifier::add(JSGlobalData* globalData, const T* s, int length) + PassRefPtr<StringImpl> Identifier::add(VM* vm, const T* s, int length) { if (length == 1) { T c = s[0]; if (canUseSingleCharacterString(c)) - return add(globalData, globalData->smallStrings.singleCharacterStringRep(c)); + return add(vm, vm->smallStrings.singleCharacterStringRep(c)); } if (!length) return StringImpl::empty(); CharBuffer<T> buf = { s, static_cast<unsigned>(length) }; - HashSet<StringImpl*>::AddResult addResult = globalData->identifierTable->add<CharBuffer<T>, IdentifierCharBufferTranslator<T> >(buf); + HashSet<StringImpl*>::AddResult addResult = vm->identifierTable->add<CharBuffer<T>, IdentifierCharBufferTranslator<T> >(buf); // If the string is newly-translated, then we need to adopt it. // The boolean in the pair tells us if that is so. @@ -251,11 +251,17 @@ namespace JSC { template<typename U, typename V> HashSet<StringImpl*>::AddResult IdentifierTable::add(U value) { - HashSet<StringImpl*>::AddResult result = m_table.add<U, V>(value); + HashSet<StringImpl*>::AddResult result = m_table.add<V>(value); (*result.iterator)->setIsIdentifier(true); return result; } } // namespace JSC +namespace WTF { + +template <> struct VectorTraits<JSC::Identifier> : SimpleClassVectorTraits { }; + +} // namespace WTF + #endif // Identifier_h |