Skip to content

Commit a25f74a

Browse files
committed
Clean up Identifier factories to clarify the meaning of StringImpl*
https://bugs.webkit.org/show_bug.cgi?id=143146 Reviewed by Filip Pizlo. Source/JavaScriptCore: In the a lot of places, `Identifier(VM*/ExecState*, StringImpl*)` constructor is used. However, it's ambiguous because `StringImpl*` has 2 different meanings. 1) normal string, it is replacable with `WTFString` and 2) `uid`, which holds `isSymbol` information to represent Symbols. So we dropped Identifier constructors for strings and instead, introduced 2 factory functions. + `Identifier::fromString(VM*/ExecState*, const String&)`. Just construct Identifier from strings. The symbol-ness of StringImpl* is not kept. + `Identifier::fromUid(VM*/ExecState*, StringImpl*)`. This function is used for 2) `uid`. So symbol-ness of `StringImpl*` is kept. And to clean up `StringImpl` which is used as uid, we introduce `StringKind` into `StringImpl`. There's 3 kinds 1. StringNormal (non-atomic, non-symbol) 2. StringAtomic (atomic, non-symbol) 3. StringSymbol (non-atomic, symbol) They are mutually exclusive. And (atomic, symbol) case should not exist. * API/JSCallbackObjectFunctions.h: (JSC::JSCallbackObject<Parent>::getOwnNonIndexPropertyNames): * API/JSObjectRef.cpp: (JSObjectMakeFunction): * API/OpaqueJSString.cpp: (OpaqueJSString::identifier): * bindings/ScriptFunctionCall.cpp: (Deprecated::ScriptFunctionCall::call): * builtins/BuiltinExecutables.cpp: (JSC::BuiltinExecutables::createExecutableInternal): * builtins/BuiltinNames.h: (JSC::BuiltinNames::BuiltinNames): * bytecompiler/BytecodeGenerator.cpp: (JSC::BytecodeGenerator::BytecodeGenerator): (JSC::BytecodeGenerator::emitThrowReferenceError): (JSC::BytecodeGenerator::emitThrowTypeError): (JSC::BytecodeGenerator::emitReadOnlyExceptionIfNeeded): (JSC::BytecodeGenerator::emitEnumeration): * dfg/DFGDesiredIdentifiers.cpp: (JSC::DFG::DesiredIdentifiers::reallyAdd): * inspector/JSInjectedScriptHost.cpp: (Inspector::JSInjectedScriptHost::functionDetails): (Inspector::constructInternalProperty): (Inspector::JSInjectedScriptHost::weakMapEntries): (Inspector::JSInjectedScriptHost::iteratorEntries): * inspector/JSInjectedScriptHostPrototype.cpp: (Inspector::JSInjectedScriptHostPrototype::finishCreation): * inspector/JSJavaScriptCallFramePrototype.cpp: * inspector/ScriptCallStackFactory.cpp: (Inspector::extractSourceInformationFromException): * jit/JITOperations.cpp: * jsc.cpp: (GlobalObject::finishCreation): (GlobalObject::addFunction): (GlobalObject::addConstructableFunction): (functionRun): (runWithScripts): * llint/LLIntData.cpp: (JSC::LLInt::Data::performAssertions): * llint/LowLevelInterpreter.asm: * parser/ASTBuilder.h: (JSC::ASTBuilder::addVar): * parser/Parser.cpp: (JSC::Parser<LexerType>::parseInner): (JSC::Parser<LexerType>::createBindingPattern): * parser/ParserArena.h: (JSC::IdentifierArena::makeIdentifier): (JSC::IdentifierArena::makeIdentifierLCharFromUChar): (JSC::IdentifierArena::makeNumericIdentifier): * runtime/ArgumentsIteratorPrototype.cpp: (JSC::ArgumentsIteratorPrototype::finishCreation): * runtime/ArrayIteratorPrototype.cpp: (JSC::ArrayIteratorPrototype::finishCreation): * runtime/ArrayPrototype.cpp: (JSC::ArrayPrototype::finishCreation): (JSC::arrayProtoFuncPush): * runtime/ClonedArguments.cpp: (JSC::ClonedArguments::getOwnPropertySlot): * runtime/CommonIdentifiers.cpp: (JSC::CommonIdentifiers::CommonIdentifiers): * runtime/CommonIdentifiers.h: * runtime/Error.cpp: (JSC::addErrorInfo): (JSC::hasErrorInfo): * runtime/ExceptionHelpers.cpp: (JSC::createUndefinedVariableError): * runtime/GenericArgumentsInlines.h: (JSC::GenericArguments<Type>::getOwnPropertySlot): * runtime/Identifier.h: (JSC::Identifier::isSymbol): (JSC::Identifier::Identifier): (JSC::Identifier::from): Deleted. * runtime/IdentifierInlines.h: (JSC::Identifier::Identifier): (JSC::Identifier::fromUid): (JSC::Identifier::fromString): * runtime/JSCJSValue.cpp: (JSC::JSValue::dumpInContextAssumingStructure): * runtime/JSCJSValueInlines.h: (JSC::JSValue::toPropertyKey): * runtime/JSGlobalObject.cpp: (JSC::JSGlobalObject::init): * runtime/JSLexicalEnvironment.cpp: (JSC::JSLexicalEnvironment::getOwnNonIndexPropertyNames): * runtime/JSObject.cpp: (JSC::getClassPropertyNames): (JSC::JSObject::reifyStaticFunctionsForDelete): * runtime/JSObject.h: (JSC::makeIdentifier): * runtime/JSPromiseConstructor.cpp: (JSC::JSPromiseConstructorFuncRace): (JSC::JSPromiseConstructorFuncAll): * runtime/JSString.h: (JSC::JSString::toIdentifier): * runtime/JSSymbolTableObject.cpp: (JSC::JSSymbolTableObject::getOwnNonIndexPropertyNames): * runtime/LiteralParser.cpp: (JSC::LiteralParser<CharType>::tryJSONPParse): (JSC::LiteralParser<CharType>::makeIdentifier): * runtime/Lookup.h: (JSC::reifyStaticProperties): * runtime/MapConstructor.cpp: (JSC::constructMap): * runtime/MapIteratorPrototype.cpp: (JSC::MapIteratorPrototype::finishCreation): * runtime/MapPrototype.cpp: (JSC::MapPrototype::finishCreation): * runtime/MathObject.cpp: (JSC::MathObject::finishCreation): * runtime/NumberConstructor.cpp: (JSC::NumberConstructor::finishCreation): * runtime/ObjectConstructor.cpp: (JSC::ObjectConstructor::finishCreation): * runtime/PrivateName.h: (JSC::PrivateName::PrivateName): * runtime/PropertyMapHashTable.h: (JSC::PropertyTable::find): (JSC::PropertyTable::get): * runtime/PropertyName.h: (JSC::PropertyName::PropertyName): (JSC::PropertyName::publicName): (JSC::PropertyName::asIndex): * runtime/PropertyNameArray.cpp: (JSC::PropertyNameArray::add): * runtime/PropertyNameArray.h: (JSC::PropertyNameArray::addKnownUnique): * runtime/RegExpConstructor.cpp: (JSC::RegExpConstructor::finishCreation): * runtime/SetConstructor.cpp: (JSC::constructSet): * runtime/SetIteratorPrototype.cpp: (JSC::SetIteratorPrototype::finishCreation): * runtime/SetPrototype.cpp: (JSC::SetPrototype::finishCreation): * runtime/StringIteratorPrototype.cpp: (JSC::StringIteratorPrototype::finishCreation): * runtime/StringPrototype.cpp: (JSC::StringPrototype::finishCreation): * runtime/Structure.cpp: (JSC::Structure::getPropertyNamesFromStructure): * runtime/SymbolConstructor.cpp: * runtime/VM.cpp: (JSC::VM::throwException): * runtime/WeakMapConstructor.cpp: (JSC::constructWeakMap): Source/WebCore: Just change Identifier creations. 1. If the code creates Identifier from StringImpl* which is treated as symbol or string(unique id), use Identifier::fromUid. 2. If the code creates Identifier from string, use Identifier::fromString. * Modules/plugins/QuickTimePluginReplacement.mm: (WebCore::QuickTimePluginReplacement::ensureReplacementScriptInjected): (WebCore::QuickTimePluginReplacement::installReplacement): * bindings/js/IDBBindingUtilities.cpp: (WebCore::get): (WebCore::set): * bindings/js/JSCSSStyleDeclarationCustom.cpp: (WebCore::JSCSSStyleDeclaration::getOwnPropertyNames): * bindings/js/JSCallbackData.cpp: (WebCore::JSCallbackData::invokeCallback): * bindings/js/JSCommandLineAPIHostCustom.cpp: (WebCore::getJSListenerFunctions): (WebCore::JSCommandLineAPIHost::getEventListeners): * bindings/js/JSCryptoAlgorithmBuilder.cpp: (WebCore::JSCryptoAlgorithmBuilder::add): * bindings/js/JSCryptoAlgorithmDictionary.cpp: (WebCore::getProperty): (WebCore::getHashAlgorithm): * bindings/js/JSCryptoKeySerializationJWK.cpp: (WebCore::getJSArrayFromJSON): (WebCore::getStringFromJSON): (WebCore::getBooleanFromJSON): (WebCore::addToJSON): (WebCore::buildJSONForRSAComponents): (WebCore::addBoolToJSON): (WebCore::addUsagesToJSON): * bindings/js/JSCustomXPathNSResolver.cpp: (WebCore::JSCustomXPathNSResolver::lookupNamespaceURI): * bindings/js/JSDOMStringMapCustom.cpp: (WebCore::JSDOMStringMap::getOwnPropertyNames): * bindings/js/JSDOMWindowCustom.cpp: (WebCore::JSDOMWindow::defineOwnProperty): (WebCore::JSDOMWindow::setLocation): (WebCore::DialogHandler::dialogCreated): (WebCore::DialogHandler::returnValue): * bindings/js/JSDeviceMotionEventCustom.cpp: (WebCore::readAccelerationArgument): (WebCore::readRotationRateArgument): (WebCore::createAccelerationObject): (WebCore::createRotationRateObject): * bindings/js/JSDictionary.cpp: (WebCore::JSDictionary::tryGetProperty): * bindings/js/JSEventListener.cpp: (WebCore::JSEventListener::handleEvent): * bindings/js/JSHTMLAllCollectionCustom.cpp: (WebCore::callHTMLAllCollection): (WebCore::JSHTMLAllCollection::item): (WebCore::JSHTMLAllCollection::namedItem): * bindings/js/JSHTMLDocumentCustom.cpp: (WebCore::JSHTMLDocument::all): (WebCore::JSHTMLDocument::setAll): (WebCore::JSHTMLDocument::open): * bindings/js/JSHTMLFormControlsCollectionCustom.cpp: (WebCore::JSHTMLFormControlsCollection::namedItem): * bindings/js/JSIDBDatabaseCustom.cpp: (WebCore::JSIDBDatabase::createObjectStore): * bindings/js/JSIDBObjectStoreCustom.cpp: (WebCore::JSIDBObjectStore::createIndex): * bindings/js/JSImageDataCustom.cpp: (WebCore::toJS): * bindings/js/JSInspectorFrontendHostCustom.cpp: (WebCore::populateContextMenuItems): * bindings/js/JSLazyEventListener.cpp: (WebCore::JSLazyEventListener::initializeJSFunction): * bindings/js/JSNodeFilterCondition.cpp: (WebCore::JSNodeFilterCondition::acceptNode): * bindings/js/JSSQLResultSetRowListCustom.cpp: (WebCore::JSSQLResultSetRowList::item): * bindings/js/JSStorageCustom.cpp: (WebCore::JSStorage::getOwnPropertyNames): * bindings/js/ReadableStreamJSSource.cpp: (WebCore::setInternalSlotToObject): (WebCore::getInternalSlotFromObject): * bindings/js/ScriptGlobalObject.cpp: (WebCore::ScriptGlobalObject::set): (WebCore::ScriptGlobalObject::get): (WebCore::ScriptGlobalObject::remove): * bindings/js/SerializedScriptValue.cpp: (WebCore::CloneSerializer::CloneSerializer): (WebCore::CloneSerializer::write): (WebCore::CloneDeserializer::deserialize): * bindings/objc/WebScriptObject.mm: (-[WebScriptObject callWebScriptMethod:withArguments:]): (-[WebScriptObject setValue:forKey:]): (-[WebScriptObject valueForKey:]): (-[WebScriptObject removeWebScriptKey:]): (-[WebScriptObject hasWebScriptKey:]): * bindings/scripts/CodeGeneratorJS.pm: (GenerateImplementation): * bindings/scripts/test/JS/JSFloat64Array.cpp: (WebCore::JSFloat64Array::getOwnPropertyNames): * bindings/scripts/test/JS/JSTestEventTarget.cpp: (WebCore::JSTestEventTarget::getOwnPropertyNames): * bindings/scripts/test/JS/JSTestObj.cpp: (WebCore::setJSTestObjTestSubObjEnabledBySettingConstructor): (WebCore::setJSTestObjConditionalAttr4Constructor): (WebCore::setJSTestObjConditionalAttr5Constructor): (WebCore::setJSTestObjConditionalAttr6Constructor): (WebCore::setJSTestObjReplaceableAttribute): * bridge/c/c_utility.cpp: (JSC::Bindings::identifierFromNPIdentifier): * bridge/objc/objc_runtime.mm: (JSC::Bindings::ObjcFallbackObjectImp::defaultValue): * bridge/testbindings.cpp: (main): * bridge/testbindings.mm: (main): * contentextensions/ContentExtensionParser.cpp: (WebCore::ContentExtensions::loadTrigger): (WebCore::ContentExtensions::loadAction): * html/HTMLMediaElement.cpp: (WebCore::HTMLMediaElement::parseAttribute): * html/HTMLPlugInImageElement.cpp: (WebCore::HTMLPlugInImageElement::didAddUserAgentShadowRoot): * testing/js/WebCoreTestSupport.cpp: (WebCoreTestSupport::injectInternalsObject): Source/WebKit/mac: Just change to Identifier::fromString. * Plugins/Hosted/NetscapePluginHostProxy.mm: (identifierFromIdentifierRep): * Plugins/Hosted/ProxyInstance.mm: (WebKit::ProxyInstance::getPropertyNames): Source/WebKit2: Just change to Identifier::fromString. * WebProcess/Plugins/Netscape/JSNPObject.cpp: (WebKit::JSNPObject::getOwnPropertyNames): * WebProcess/Plugins/Netscape/NPJSObject.cpp: (WebKit::identifierFromIdentifierRep): Source/WTF: Introduce StringKind into `StringImpl`. There's 3 kinds 1. StringNormal (non-atomic, non-symbol) 2. StringAtomic (atomic, non-symbol) 3. StringSymbol (non-atomic, symbol) They are mutually exclusive. * wtf/text/AtomicString.cpp: (WTF::AtomicString::addSlowCase): (WTF::AtomicString::findSlowCase): When registering a string into AtomicStringTable, it should not be a symbol string because symbol and atomic types are mutually exclusive. When a symbol string comes, we extract an owner string from a symbol string by using `StringImpl::extractFoldedStringInSymbol()`. It always succeeds because a symbol (non empty) string is always BufferSubstring and has an owner string. Empty symbol string doesn't have an owner string. This case is filtered by `!string.length()` guard. * wtf/text/AtomicString.h: (WTF::AtomicString::add): (WTF::AtomicString::addWithStringTableProvider): * wtf/text/StringImpl.cpp: (WTF::StringImpl::~StringImpl): (WTF::StringImpl::createSymbol): (WTF::StringImpl::createUnique): Deleted. * wtf/text/StringImpl.h: (WTF::StringImpl::StringImpl): (WTF::StringImpl::createSymbolEmpty): (WTF::StringImpl::flagIsAtomic): (WTF::StringImpl::flagIsSymbol): (WTF::StringImpl::maskStringKind): (WTF::StringImpl::stringKind): (WTF::StringImpl::isSymbol): (WTF::StringImpl::isAtomic): (WTF::StringImpl::setIsAtomic): (WTF::StringImpl::extractFoldedStringInSymbol): (WTF::StringImpl::createUniqueEmpty): Deleted. (WTF::StringImpl::flagIsUnique): Deleted. (WTF::StringImpl::isUnique): Deleted. * wtf/text/StringStatics.cpp: (WTF::StringImpl::hashAndFlagsForSymbol): (WTF::StringImpl::hashAndFlagsForUnique): Deleted. Tools: Simple API tests for StringImpl are added. * TestWebKitAPI/Tests/WTF/StringImpl.cpp: (TestWebKitAPI::TEST): Canonical link: https://commits.webkit.org/161305@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@182205 268f45cc-cd09-0410-ab3c-d52691b4dbfc
1 parent ddeee2d commit a25f74a

119 files changed

Lines changed: 1014 additions & 419 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎Source/JavaScriptCore/API/JSCallbackObjectFunctions.h‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -521,8 +521,10 @@ void JSCallbackObject<Parent>::getOwnNonIndexPropertyNames(JSObject* object, Exe
521521
for (iterator it = staticValues->begin(); it != end; ++it) {
522522
StringImpl* name = it->key.get();
523523
StaticValueEntry* entry = it->value.get();
524-
if (entry->getProperty && (!(entry->attributes & kJSPropertyAttributeDontEnum) || shouldIncludeDontEnumProperties(mode)))
525-
propertyNames.add(Identifier(exec, name));
524+
if (entry->getProperty && (!(entry->attributes & kJSPropertyAttributeDontEnum) || shouldIncludeDontEnumProperties(mode))) {
525+
ASSERT(!name->isSymbol());
526+
propertyNames.add(Identifier::fromString(exec, String(name)));
527+
}
526528
}
527529
}
528530

@@ -532,8 +534,10 @@ void JSCallbackObject<Parent>::getOwnNonIndexPropertyNames(JSObject* object, Exe
532534
for (iterator it = staticFunctions->begin(); it != end; ++it) {
533535
StringImpl* name = it->key.get();
534536
StaticFunctionEntry* entry = it->value.get();
535-
if (!(entry->attributes & kJSPropertyAttributeDontEnum) || shouldIncludeDontEnumProperties(mode))
536-
propertyNames.add(Identifier(exec, name));
537+
if (!(entry->attributes & kJSPropertyAttributeDontEnum) || shouldIncludeDontEnumProperties(mode)) {
538+
ASSERT(!name->isSymbol());
539+
propertyNames.add(Identifier::fromString(exec, String(name)));
540+
}
537541
}
538542
}
539543
}

‎Source/JavaScriptCore/API/JSObjectRef.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ JSObjectRef JSObjectMakeFunction(JSContextRef ctx, JSStringRef name, unsigned pa
140140
JSLockHolder locker(exec);
141141

142142
startingLineNumber = std::max(1, startingLineNumber);
143-
Identifier nameID = name ? name->identifier(&exec->vm()) : Identifier(exec, "anonymous");
143+
Identifier nameID = name ? name->identifier(&exec->vm()) : Identifier::fromString(exec, "anonymous");
144144

145145
MarkedArgumentBuffer args;
146146
for (unsigned i = 0; i < parameterCount; i++)

‎Source/JavaScriptCore/API/OpaqueJSString.cpp‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828

2929
#include "CallFrame.h"
3030
#include "Identifier.h"
31+
#include "IdentifierInlines.h"
3132
#include "JSGlobalObject.h"
3233
#include <wtf/text/StringView.h>
3334

@@ -69,9 +70,9 @@ Identifier OpaqueJSString::identifier(VM* vm) const
6970
return Identifier(Identifier::EmptyIdentifier);
7071

7172
if (m_string.is8Bit())
72-
return Identifier(vm, m_string.characters8(), m_string.length());
73+
return Identifier::fromString(vm, m_string.characters8(), m_string.length());
7374

74-
return Identifier(vm, m_string.characters16(), m_string.length());
75+
return Identifier::fromString(vm, m_string.characters16(), m_string.length());
7576
}
7677

7778
const UChar* OpaqueJSString::characters()

‎Source/JavaScriptCore/ChangeLog‎

Lines changed: 170 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,173 @@
1+
2015-03-31 Yusuke Suzuki <utatane.tea@gmail.com>
2+
3+
Clean up Identifier factories to clarify the meaning of StringImpl*
4+
https://bugs.webkit.org/show_bug.cgi?id=143146
5+
6+
Reviewed by Filip Pizlo.
7+
8+
In the a lot of places, `Identifier(VM*/ExecState*, StringImpl*)` constructor is used.
9+
However, it's ambiguous because `StringImpl*` has 2 different meanings.
10+
1) normal string, it is replacable with `WTFString` and
11+
2) `uid`, which holds `isSymbol` information to represent Symbols.
12+
So we dropped Identifier constructors for strings and instead, introduced 2 factory functions.
13+
+ `Identifier::fromString(VM*/ExecState*, const String&)`.
14+
Just construct Identifier from strings. The symbol-ness of StringImpl* is not kept.
15+
+ `Identifier::fromUid(VM*/ExecState*, StringImpl*)`.
16+
This function is used for 2) `uid`. So symbol-ness of `StringImpl*` is kept.
17+
18+
And to clean up `StringImpl` which is used as uid,
19+
we introduce `StringKind` into `StringImpl`. There's 3 kinds
20+
1. StringNormal (non-atomic, non-symbol)
21+
2. StringAtomic (atomic, non-symbol)
22+
3. StringSymbol (non-atomic, symbol)
23+
They are mutually exclusive. And (atomic, symbol) case should not exist.
24+
25+
* API/JSCallbackObjectFunctions.h:
26+
(JSC::JSCallbackObject<Parent>::getOwnNonIndexPropertyNames):
27+
* API/JSObjectRef.cpp:
28+
(JSObjectMakeFunction):
29+
* API/OpaqueJSString.cpp:
30+
(OpaqueJSString::identifier):
31+
* bindings/ScriptFunctionCall.cpp:
32+
(Deprecated::ScriptFunctionCall::call):
33+
* builtins/BuiltinExecutables.cpp:
34+
(JSC::BuiltinExecutables::createExecutableInternal):
35+
* builtins/BuiltinNames.h:
36+
(JSC::BuiltinNames::BuiltinNames):
37+
* bytecompiler/BytecodeGenerator.cpp:
38+
(JSC::BytecodeGenerator::BytecodeGenerator):
39+
(JSC::BytecodeGenerator::emitThrowReferenceError):
40+
(JSC::BytecodeGenerator::emitThrowTypeError):
41+
(JSC::BytecodeGenerator::emitReadOnlyExceptionIfNeeded):
42+
(JSC::BytecodeGenerator::emitEnumeration):
43+
* dfg/DFGDesiredIdentifiers.cpp:
44+
(JSC::DFG::DesiredIdentifiers::reallyAdd):
45+
* inspector/JSInjectedScriptHost.cpp:
46+
(Inspector::JSInjectedScriptHost::functionDetails):
47+
(Inspector::constructInternalProperty):
48+
(Inspector::JSInjectedScriptHost::weakMapEntries):
49+
(Inspector::JSInjectedScriptHost::iteratorEntries):
50+
* inspector/JSInjectedScriptHostPrototype.cpp:
51+
(Inspector::JSInjectedScriptHostPrototype::finishCreation):
52+
* inspector/JSJavaScriptCallFramePrototype.cpp:
53+
* inspector/ScriptCallStackFactory.cpp:
54+
(Inspector::extractSourceInformationFromException):
55+
* jit/JITOperations.cpp:
56+
* jsc.cpp:
57+
(GlobalObject::finishCreation):
58+
(GlobalObject::addFunction):
59+
(GlobalObject::addConstructableFunction):
60+
(functionRun):
61+
(runWithScripts):
62+
* llint/LLIntData.cpp:
63+
(JSC::LLInt::Data::performAssertions):
64+
* llint/LowLevelInterpreter.asm:
65+
* parser/ASTBuilder.h:
66+
(JSC::ASTBuilder::addVar):
67+
* parser/Parser.cpp:
68+
(JSC::Parser<LexerType>::parseInner):
69+
(JSC::Parser<LexerType>::createBindingPattern):
70+
* parser/ParserArena.h:
71+
(JSC::IdentifierArena::makeIdentifier):
72+
(JSC::IdentifierArena::makeIdentifierLCharFromUChar):
73+
(JSC::IdentifierArena::makeNumericIdentifier):
74+
* runtime/ArgumentsIteratorPrototype.cpp:
75+
(JSC::ArgumentsIteratorPrototype::finishCreation):
76+
* runtime/ArrayIteratorPrototype.cpp:
77+
(JSC::ArrayIteratorPrototype::finishCreation):
78+
* runtime/ArrayPrototype.cpp:
79+
(JSC::ArrayPrototype::finishCreation):
80+
(JSC::arrayProtoFuncPush):
81+
* runtime/ClonedArguments.cpp:
82+
(JSC::ClonedArguments::getOwnPropertySlot):
83+
* runtime/CommonIdentifiers.cpp:
84+
(JSC::CommonIdentifiers::CommonIdentifiers):
85+
* runtime/CommonIdentifiers.h:
86+
* runtime/Error.cpp:
87+
(JSC::addErrorInfo):
88+
(JSC::hasErrorInfo):
89+
* runtime/ExceptionHelpers.cpp:
90+
(JSC::createUndefinedVariableError):
91+
* runtime/GenericArgumentsInlines.h:
92+
(JSC::GenericArguments<Type>::getOwnPropertySlot):
93+
* runtime/Identifier.h:
94+
(JSC::Identifier::isSymbol):
95+
(JSC::Identifier::Identifier):
96+
(JSC::Identifier::from): Deleted.
97+
* runtime/IdentifierInlines.h:
98+
(JSC::Identifier::Identifier):
99+
(JSC::Identifier::fromUid):
100+
(JSC::Identifier::fromString):
101+
* runtime/JSCJSValue.cpp:
102+
(JSC::JSValue::dumpInContextAssumingStructure):
103+
* runtime/JSCJSValueInlines.h:
104+
(JSC::JSValue::toPropertyKey):
105+
* runtime/JSGlobalObject.cpp:
106+
(JSC::JSGlobalObject::init):
107+
* runtime/JSLexicalEnvironment.cpp:
108+
(JSC::JSLexicalEnvironment::getOwnNonIndexPropertyNames):
109+
* runtime/JSObject.cpp:
110+
(JSC::getClassPropertyNames):
111+
(JSC::JSObject::reifyStaticFunctionsForDelete):
112+
* runtime/JSObject.h:
113+
(JSC::makeIdentifier):
114+
* runtime/JSPromiseConstructor.cpp:
115+
(JSC::JSPromiseConstructorFuncRace):
116+
(JSC::JSPromiseConstructorFuncAll):
117+
* runtime/JSString.h:
118+
(JSC::JSString::toIdentifier):
119+
* runtime/JSSymbolTableObject.cpp:
120+
(JSC::JSSymbolTableObject::getOwnNonIndexPropertyNames):
121+
* runtime/LiteralParser.cpp:
122+
(JSC::LiteralParser<CharType>::tryJSONPParse):
123+
(JSC::LiteralParser<CharType>::makeIdentifier):
124+
* runtime/Lookup.h:
125+
(JSC::reifyStaticProperties):
126+
* runtime/MapConstructor.cpp:
127+
(JSC::constructMap):
128+
* runtime/MapIteratorPrototype.cpp:
129+
(JSC::MapIteratorPrototype::finishCreation):
130+
* runtime/MapPrototype.cpp:
131+
(JSC::MapPrototype::finishCreation):
132+
* runtime/MathObject.cpp:
133+
(JSC::MathObject::finishCreation):
134+
* runtime/NumberConstructor.cpp:
135+
(JSC::NumberConstructor::finishCreation):
136+
* runtime/ObjectConstructor.cpp:
137+
(JSC::ObjectConstructor::finishCreation):
138+
* runtime/PrivateName.h:
139+
(JSC::PrivateName::PrivateName):
140+
* runtime/PropertyMapHashTable.h:
141+
(JSC::PropertyTable::find):
142+
(JSC::PropertyTable::get):
143+
* runtime/PropertyName.h:
144+
(JSC::PropertyName::PropertyName):
145+
(JSC::PropertyName::publicName):
146+
(JSC::PropertyName::asIndex):
147+
* runtime/PropertyNameArray.cpp:
148+
(JSC::PropertyNameArray::add):
149+
* runtime/PropertyNameArray.h:
150+
(JSC::PropertyNameArray::addKnownUnique):
151+
* runtime/RegExpConstructor.cpp:
152+
(JSC::RegExpConstructor::finishCreation):
153+
* runtime/SetConstructor.cpp:
154+
(JSC::constructSet):
155+
* runtime/SetIteratorPrototype.cpp:
156+
(JSC::SetIteratorPrototype::finishCreation):
157+
* runtime/SetPrototype.cpp:
158+
(JSC::SetPrototype::finishCreation):
159+
* runtime/StringIteratorPrototype.cpp:
160+
(JSC::StringIteratorPrototype::finishCreation):
161+
* runtime/StringPrototype.cpp:
162+
(JSC::StringPrototype::finishCreation):
163+
* runtime/Structure.cpp:
164+
(JSC::Structure::getPropertyNamesFromStructure):
165+
* runtime/SymbolConstructor.cpp:
166+
* runtime/VM.cpp:
167+
(JSC::VM::throwException):
168+
* runtime/WeakMapConstructor.cpp:
169+
(JSC::constructWeakMap):
170+
1171
2015-03-31 Andreas Kling <akling@apple.com>
2172

3173
Logically empty WeakBlocks should not pin down their MarkedBlocks indefinitely.

‎Source/JavaScriptCore/bindings/ScriptFunctionCall.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ Deprecated::ScriptValue ScriptFunctionCall::call(bool& hadException)
121121

122122
JSLockHolder lock(m_exec);
123123

124-
JSValue function = thisObject->get(m_exec, Identifier(m_exec, m_name));
124+
JSValue function = thisObject->get(m_exec, Identifier::fromString(m_exec, m_name));
125125
if (m_exec->hadException()) {
126126
hadException = true;
127127
return Deprecated::ScriptValue();

‎Source/JavaScriptCore/builtins/BuiltinExecutables.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ UnlinkedFunctionExecutable* BuiltinExecutables::createExecutableInternal(const S
101101

102102
if (closedVariable == m_vm.propertyNames->undefinedKeyword.impl())
103103
continue;
104-
RELEASE_ASSERT(closedVariable->isUnique());
104+
RELEASE_ASSERT(closedVariable->isSymbol());
105105
}
106106
body->overrideName(name);
107107
UnlinkedFunctionExecutable* functionExecutable = UnlinkedFunctionExecutable::create(&m_vm, source, body, kind, WTF::move(sourceOverride));

‎Source/JavaScriptCore/builtins/BuiltinNames.h‎

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,18 @@
3131

3232
namespace JSC {
3333

34-
#define INITIALISE_BUILTIN_NAMES(name) , m_##name(vm, #name), m_##name##PrivateName(Identifier::from(PrivateName(ASCIILiteral("Symbol." #name))))
35-
#define DECLARE_BUILTIN_NAMES(name) const Identifier m_##name; const Identifier m_##name##PrivateName;;
34+
#define INITIALISE_BUILTIN_NAMES(name) , m_##name(Identifier::fromString(vm, #name)), m_##name##PrivateName(Identifier::fromUid(PrivateName()))
35+
#define DECLARE_BUILTIN_NAMES(name) const Identifier m_##name; const Identifier m_##name##PrivateName;
3636
#define DECLARE_BUILTIN_IDENTIFIER_ACCESSOR(name) \
3737
const Identifier& name##PublicName() const { return m_##name; } \
3838
const Identifier& name##PrivateName() const { return m_##name##PrivateName; }
3939

40+
#define INITIALISE_BUILTIN_SYMBOLS(name) INITIALISE_BUILTIN_NAMES(name), m_##name##Symbol(Identifier::fromUid(PrivateName(ASCIILiteral("Symbol." #name))))
41+
#define DECLARE_BUILTIN_SYMBOLS(name) DECLARE_BUILTIN_NAMES(name) const Identifier m_##name##Symbol;
42+
#define DECLARE_BUILTIN_SYMBOL_ACCESSOR(name) \
43+
DECLARE_BUILTIN_IDENTIFIER_ACCESSOR(name) \
44+
const Identifier& name##Symbol() const { return m_##name##Symbol; }
45+
4046
#define INITIALISE_PRIVATE_TO_PUBLIC_ENTRY(name) m_privateToPublicMap.add(m_##name##PrivateName.impl(), &m_##name);
4147
#define INITIALISE_PUBLIC_TO_PRIVATE_ENTRY(name) m_publicToPrivateMap.add(m_##name.impl(), &m_##name##PrivateName);
4248

@@ -48,23 +54,28 @@ class BuiltinNames {
4854
: m_emptyIdentifier(commonIdentifiers->emptyIdentifier)
4955
JSC_FOREACH_BUILTIN_FUNCTION_NAME(INITIALISE_BUILTIN_NAMES)
5056
JSC_COMMON_PRIVATE_IDENTIFIERS_EACH_PROPERTY_NAME(INITIALISE_BUILTIN_NAMES)
57+
JSC_COMMON_PRIVATE_IDENTIFIERS_EACH_WELL_KNOWN_SYMBOL(INITIALISE_BUILTIN_SYMBOLS)
5158
{
5259
JSC_FOREACH_BUILTIN_FUNCTION_NAME(INITIALISE_PRIVATE_TO_PUBLIC_ENTRY)
5360
JSC_COMMON_PRIVATE_IDENTIFIERS_EACH_PROPERTY_NAME(INITIALISE_PRIVATE_TO_PUBLIC_ENTRY)
61+
JSC_COMMON_PRIVATE_IDENTIFIERS_EACH_WELL_KNOWN_SYMBOL(INITIALISE_PRIVATE_TO_PUBLIC_ENTRY)
5462
JSC_FOREACH_BUILTIN_FUNCTION_NAME(INITIALISE_PUBLIC_TO_PRIVATE_ENTRY)
5563
JSC_COMMON_PRIVATE_IDENTIFIERS_EACH_PROPERTY_NAME(INITIALISE_PUBLIC_TO_PRIVATE_ENTRY)
64+
JSC_COMMON_PRIVATE_IDENTIFIERS_EACH_WELL_KNOWN_SYMBOL(INITIALISE_PUBLIC_TO_PRIVATE_ENTRY)
5665
}
5766

5867
const Identifier* getPrivateName(const Identifier&) const;
5968
const Identifier& getPublicName(const Identifier&) const;
6069

6170
JSC_FOREACH_BUILTIN_FUNCTION_NAME(DECLARE_BUILTIN_IDENTIFIER_ACCESSOR)
6271
JSC_COMMON_PRIVATE_IDENTIFIERS_EACH_PROPERTY_NAME(DECLARE_BUILTIN_IDENTIFIER_ACCESSOR)
72+
JSC_COMMON_PRIVATE_IDENTIFIERS_EACH_WELL_KNOWN_SYMBOL(DECLARE_BUILTIN_SYMBOL_ACCESSOR)
6373

6474
private:
6575
Identifier m_emptyIdentifier;
6676
JSC_FOREACH_BUILTIN_FUNCTION_NAME(DECLARE_BUILTIN_NAMES)
6777
JSC_COMMON_PRIVATE_IDENTIFIERS_EACH_PROPERTY_NAME(DECLARE_BUILTIN_NAMES)
78+
JSC_COMMON_PRIVATE_IDENTIFIERS_EACH_WELL_KNOWN_SYMBOL(DECLARE_BUILTIN_SYMBOLS)
6879
typedef HashMap<RefPtr<StringImpl>, const Identifier*, IdentifierRepHash> BuiltinNamesMap;
6980
BuiltinNamesMap m_publicToPrivateMap;
7081
BuiltinNamesMap m_privateToPublicMap;
@@ -73,7 +84,9 @@ class BuiltinNames {
7384
#undef DECLARE_BUILTIN_NAMES
7485
#undef INITIALISE_BUILTIN_NAMES
7586
#undef DECLARE_BUILTIN_IDENTIFIER_ACCESSOR
76-
87+
#undef DECLARE_BUILTIN_SYMBOLS
88+
#undef INITIALISE_BUILTIN_SYMBOLS
89+
#undef DECLARE_BUILTIN_SYMBOL_ACCESSOR
7790

7891
inline const Identifier* BuiltinNames::getPrivateName(const Identifier& ident) const
7992
{
@@ -91,7 +104,7 @@ inline const Identifier& BuiltinNames::getPublicName(const Identifier& ident) co
91104
return m_emptyIdentifier;
92105
}
93106

94-
107+
95108
}
96109

97110
#endif

‎Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -513,7 +513,7 @@ BytecodeGenerator::BytecodeGenerator(VM& vm, EvalNode* evalNode, UnlinkedEvalCod
513513
Vector<Identifier, 0, UnsafeVectorOverflow> variables;
514514
variables.reserveCapacity(numVariables);
515515
for (size_t i = 0; i < numVariables; ++i) {
516-
ASSERT(varStack[i].first.impl()->isAtomic());
516+
ASSERT(varStack[i].first.impl()->isAtomic() || varStack[i].first.impl()->isSymbol());
517517
variables.append(varStack[i].first);
518518
}
519519
codeBlock->adoptVariables(variables);
@@ -2405,14 +2405,14 @@ RegisterID* BytecodeGenerator::popTryAndEmitCatch(TryData* tryData, RegisterID*
24052405
void BytecodeGenerator::emitThrowReferenceError(const String& message)
24062406
{
24072407
emitOpcode(op_throw_static_error);
2408-
instructions().append(addConstantValue(addStringConstant(Identifier(m_vm, message)))->index());
2408+
instructions().append(addConstantValue(addStringConstant(Identifier::fromString(m_vm, message)))->index());
24092409
instructions().append(true);
24102410
}
24112411

24122412
void BytecodeGenerator::emitThrowTypeError(const String& message)
24132413
{
24142414
emitOpcode(op_throw_static_error);
2415-
instructions().append(addConstantValue(addStringConstant(Identifier(m_vm, message)))->index());
2415+
instructions().append(addConstantValue(addStringConstant(Identifier::fromString(m_vm, message)))->index());
24162416
instructions().append(false);
24172417
}
24182418

@@ -2579,7 +2579,7 @@ void BytecodeGenerator::emitReadOnlyExceptionIfNeeded()
25792579
if (!isStrictMode())
25802580
return;
25812581
emitOpcode(op_throw_static_error);
2582-
instructions().append(addConstantValue(addStringConstant(Identifier(m_vm, StrictModeReadonlyPropertyWriteError)))->index());
2582+
instructions().append(addConstantValue(addStringConstant(Identifier::fromString(m_vm, StrictModeReadonlyPropertyWriteError)))->index());
25832583
instructions().append(false);
25842584
}
25852585

@@ -2588,7 +2588,7 @@ void BytecodeGenerator::emitEnumeration(ThrowableExpressionData* node, Expressio
25882588
LabelScopePtr scope = newLabelScope(LabelScope::Loop);
25892589
RefPtr<RegisterID> subject = newTemporary();
25902590
emitNode(subject.get(), subjectNode);
2591-
RefPtr<RegisterID> iterator = emitGetById(newTemporary(), subject.get(), propertyNames().iteratorPrivateName);
2591+
RefPtr<RegisterID> iterator = emitGetById(newTemporary(), subject.get(), propertyNames().iteratorSymbol);
25922592
{
25932593
CallArguments args(*this, nullptr);
25942594
emitMove(args.thisRegister(), subject.get());

‎Source/JavaScriptCore/dfg/DFGDesiredIdentifiers.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ void DesiredIdentifiers::reallyAdd(VM& vm, CommonData* commonData)
7373
for (unsigned i = 0; i < m_addedIdentifiers.size(); ++i) {
7474
StringImpl* rep = m_addedIdentifiers[i];
7575
ASSERT(rep->hasAtLeastOneRef());
76-
commonData->dfgIdentifiers.append(Identifier(&vm, rep));
76+
commonData->dfgIdentifiers.append(Identifier::fromUid(&vm, rep));
7777
}
7878
}
7979

0 commit comments

Comments
 (0)