From d441d6f39bb846989d95bcf5caf387b42414718d Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Fri, 13 Sep 2013 12:51:20 +0200 Subject: Import Qt5x2 branch of QtWebkit for Qt 5.2 Importing a new snapshot of webkit. Change-Id: I2d01ad12cdc8af8cb015387641120a9d7ea5f10c Reviewed-by: Allan Sandfeld Jensen --- Source/JavaScriptCore/runtime/Identifier.cpp | 64 +++++++++++++--------------- 1 file changed, 29 insertions(+), 35 deletions(-) (limited to 'Source/JavaScriptCore/runtime/Identifier.cpp') diff --git a/Source/JavaScriptCore/runtime/Identifier.cpp b/Source/JavaScriptCore/runtime/Identifier.cpp index 583c12bb1..ad61b493a 100644 --- a/Source/JavaScriptCore/runtime/Identifier.cpp +++ b/Source/JavaScriptCore/runtime/Identifier.cpp @@ -25,6 +25,7 @@ #include "JSObject.h" #include "JSScope.h" #include "NumericStrings.h" +#include "Operations.h" #include #include #include @@ -50,7 +51,7 @@ void deleteIdentifierTable(IdentifierTable* table) struct IdentifierASCIIStringTranslator { static unsigned hash(const LChar* c) { - return StringHasher::computeHashAndMaskTop8Bits(c); + return StringHasher::computeHashAndMaskTop8Bits(c); } static bool equal(StringImpl* r, const LChar* s) @@ -69,7 +70,7 @@ struct IdentifierASCIIStringTranslator { struct IdentifierLCharFromUCharTranslator { static unsigned hash(const CharBuffer& buf) { - return StringHasher::computeHashAndMaskTop8Bits(buf.s, buf.length); + return StringHasher::computeHashAndMaskTop8Bits(buf.s, buf.length); } static bool equal(StringImpl* str, const CharBuffer& buf) @@ -87,19 +88,14 @@ struct IdentifierLCharFromUCharTranslator { } }; -PassRefPtr Identifier::add(JSGlobalData* globalData, const char* c) +PassRefPtr Identifier::add(VM* vm, const char* c) { ASSERT(c); ASSERT(c[0]); if (!c[1]) - return add(globalData, globalData->smallStrings.singleCharacterStringRep(c[0])); + return add(vm, vm->smallStrings.singleCharacterStringRep(c[0])); - IdentifierTable& identifierTable = *globalData->identifierTable; - LiteralIdentifierTable& literalIdentifierTable = identifierTable.literalTable(); - - const LiteralIdentifierTable::iterator& iter = literalIdentifierTable.find(c); - if (iter != literalIdentifierTable.end()) - return iter->value; + IdentifierTable& identifierTable = *vm->identifierTable; HashSet::AddResult addResult = identifierTable.add(reinterpret_cast(c)); @@ -107,36 +103,34 @@ PassRefPtr Identifier::add(JSGlobalData* globalData, const char* c) // The boolean in the pair tells us if that is so. RefPtr addedString = addResult.isNewEntry ? adoptRef(*addResult.iterator) : *addResult.iterator; - literalIdentifierTable.add(c, addedString.get()); - return addedString.release(); } PassRefPtr Identifier::add(ExecState* exec, const char* c) { - return add(&exec->globalData(), c); + return add(&exec->vm(), c); } -PassRefPtr Identifier::add8(JSGlobalData* globalData, const UChar* s, int length) +PassRefPtr Identifier::add8(VM* vm, const UChar* s, int length) { if (length == 1) { UChar c = s[0]; ASSERT(c <= 0xff); if (canUseSingleCharacterString(c)) - return add(globalData, globalData->smallStrings.singleCharacterStringRep(c)); + return add(vm, vm->smallStrings.singleCharacterStringRep(c)); } if (!length) return StringImpl::empty(); CharBuffer buf = { s, static_cast(length) }; - HashSet::AddResult addResult = globalData->identifierTable->add, IdentifierLCharFromUCharTranslator >(buf); + HashSet::AddResult addResult = vm->identifierTable->add, IdentifierLCharFromUCharTranslator >(buf); // If the string is newly-translated, then we need to adopt it. // The boolean in the pair tells us if that is so. return addResult.isNewEntry ? adoptRef(*addResult.iterator) : *addResult.iterator; } -PassRefPtr Identifier::addSlowCase(JSGlobalData* globalData, StringImpl* r) +PassRefPtr Identifier::addSlowCase(VM* vm, StringImpl* r) { ASSERT(!r->isIdentifier()); // The empty & null strings are static singletons, and static strings are handled @@ -146,68 +140,68 @@ PassRefPtr Identifier::addSlowCase(JSGlobalData* globalData, StringI if (r->length() == 1) { UChar c = (*r)[0]; if (c <= maxSingleCharacterString) - r = globalData->smallStrings.singleCharacterStringRep(c); + r = vm->smallStrings.singleCharacterStringRep(c); if (r->isIdentifier()) return r; } - return *globalData->identifierTable->add(r).iterator; + return *vm->identifierTable->add(r).iterator; } PassRefPtr Identifier::addSlowCase(ExecState* exec, StringImpl* r) { - return addSlowCase(&exec->globalData(), r); + return addSlowCase(&exec->vm(), r); } Identifier Identifier::from(ExecState* exec, unsigned value) { - return Identifier(exec, exec->globalData().numericStrings.add(value)); + return Identifier(exec, exec->vm().numericStrings.add(value)); } Identifier Identifier::from(ExecState* exec, int value) { - return Identifier(exec, exec->globalData().numericStrings.add(value)); + return Identifier(exec, exec->vm().numericStrings.add(value)); } Identifier Identifier::from(ExecState* exec, double value) { - return Identifier(exec, exec->globalData().numericStrings.add(value)); + return Identifier(exec, exec->vm().numericStrings.add(value)); } -Identifier Identifier::from(JSGlobalData* globalData, unsigned value) +Identifier Identifier::from(VM* vm, unsigned value) { - return Identifier(globalData, globalData->numericStrings.add(value)); + return Identifier(vm, vm->numericStrings.add(value)); } -Identifier Identifier::from(JSGlobalData* globalData, int value) +Identifier Identifier::from(VM* vm, int value) { - return Identifier(globalData, globalData->numericStrings.add(value)); + return Identifier(vm, vm->numericStrings.add(value)); } -Identifier Identifier::from(JSGlobalData* globalData, double value) +Identifier Identifier::from(VM* vm, double value) { - return Identifier(globalData, globalData->numericStrings.add(value)); + return Identifier(vm, vm->numericStrings.add(value)); } #ifndef NDEBUG -void Identifier::checkCurrentIdentifierTable(JSGlobalData* globalData) +void Identifier::checkCurrentIdentifierTable(VM* vm) { // Check the identifier table accessible through the threadspecific matches the - // globalData's identifier table. - ASSERT_UNUSED(globalData, globalData->identifierTable == wtfThreadData().currentIdentifierTable()); + // vm's identifier table. + ASSERT_UNUSED(vm, vm->identifierTable == wtfThreadData().currentIdentifierTable()); } void Identifier::checkCurrentIdentifierTable(ExecState* exec) { - checkCurrentIdentifierTable(&exec->globalData()); + checkCurrentIdentifierTable(&exec->vm()); } #else // These only exists so that our exports are the same for debug and release builds. -// This would be an ASSERT_NOT_REACHED(), but we're in NDEBUG only code here! -NO_RETURN_DUE_TO_CRASH void Identifier::checkCurrentIdentifierTable(JSGlobalData*) { CRASH(); } +// This would be an RELEASE_ASSERT_NOT_REACHED(), but we're in NDEBUG only code here! +NO_RETURN_DUE_TO_CRASH void Identifier::checkCurrentIdentifierTable(VM*) { CRASH(); } NO_RETURN_DUE_TO_CRASH void Identifier::checkCurrentIdentifierTable(ExecState*) { CRASH(); } #endif -- cgit v1.2.1