Add support for private names
https://bugs.webkit.org/show_bug.cgi?id=86509
Reviewed by Oliver Hunt.
The spec isn't final, but we can start adding support to allow property maps
to contain keys that aren't identifiers.
Source/JavaScriptCore:
- API/JSCallbackObjectFunctions.h:
(JSC::::getOwnPropertySlot):
(JSC::::put):
(JSC::::deleteProperty):
(JSC::::getStaticValue):
(JSC::::staticFunctionGetter):
(JSC::::callbackGetter):
- Only expose public named properties over the JSC API.
- CMakeLists.txt:
- DerivedSources.make:
- DerivedSources.pri:
- GNUmakefile.list.am:
- JavaScriptCore.gypi:
- JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj:
- JavaScriptCore.xcodeproj/project.pbxproj:
- Target.pri:
- Added new files to build system.
- dfg/DFGOperations.cpp:
(JSC::DFG::operationPutByValInternal):
- Added support for property access with name objects.
(JSC::ExecState::privateNamePrototypeTable):
- Added hash table for NamePrototype
- interpreter/Interpreter.cpp:
(JSC::Interpreter::privateExecute):
- Added support for property access with name objects.
(JSC::DEFINE_STUB_FUNCTION):
- Added support for property access with name objects.
- llint/LLIntSlowPaths.cpp:
(JSC::LLInt::getByVal):
(JSC::LLInt::LLINT_SLOW_PATH_DECL):
- runtime/CommonSlowPaths.h:
(JSC::CommonSlowPaths::opIn):
- runtime/JSActivation.cpp:
(JSC::JSActivation::symbolTableGet):
(JSC::JSActivation::symbolTablePut):
(JSC::JSActivation::symbolTablePutWithAttributes):
- Added support for property access with name objects.
- runtime/JSGlobalData.cpp:
(JSC):
(JSC::JSGlobalData::JSGlobalData):
(JSC::JSGlobalData::~JSGlobalData):
(JSGlobalData):
- Added hash table for NamePrototype
- runtime/JSGlobalObject.cpp:
(JSC::JSGlobalObject::reset):
- runtime/JSGlobalObject.h:
(JSGlobalObject):
(JSC::JSGlobalObject::privateNameStructure):
(JSC::JSGlobalObject::symbolTableHasProperty):
- Added new global properties.
- runtime/JSType.h:
- runtime/JSTypeInfo.h:
(JSC::TypeInfo::isName):
- Added type for NameInstances, for fast isName check.
- runtime/JSVariableObject.cpp:
(JSC::JSVariableObject::deleteProperty):
(JSC::JSVariableObject::symbolTableGet):
- runtime/JSVariableObject.h:
(JSC::JSVariableObject::symbolTableGet):
(JSC::JSVariableObject::symbolTablePut):
(JSC::JSVariableObject::symbolTablePutWithAttributes):
- symbol table lookup should take a PropertyName.
(JSC::setUpStaticFunctionSlot):
(JSC::HashTable::entry):
- entry lookup should take a PropertyName.
- runtime/NameConstructor.cpp: Added.
(JSC):
(JSC::NameConstructor::NameConstructor):
(JSC::NameConstructor::finishCreation):
(JSC::constructPrivateName):
(JSC::NameConstructor::getConstructData):
(JSC::NameConstructor::getCallData):
- runtime/NameConstructor.h: Added.
(JSC):
(NameConstructor):
(JSC::NameConstructor::create):
(JSC::NameConstructor::createStructure):
- runtime/NameInstance.cpp: Added.
(JSC):
(JSC::NameInstance::NameInstance):
(JSC::NameInstance::destroy):
- runtime/NameInstance.h: Added.
(JSC):
(NameInstance):
(JSC::NameInstance::createStructure):
(JSC::NameInstance::create):
(JSC::NameInstance::privateName):
(JSC::NameInstance::nameString):
(JSC::NameInstance::finishCreation):
(JSC::isName):
- runtime/NamePrototype.cpp: Added.
(JSC):
(JSC::NamePrototype::NamePrototype):
(JSC::NamePrototype::finishCreation):
(JSC::NamePrototype::getOwnPropertySlot):
(JSC::NamePrototype::getOwnPropertyDescriptor):
(JSC::privateNameProtoFuncToString):
- runtime/NamePrototype.h: Added.
(JSC):
(NamePrototype):
(JSC::NamePrototype::create):
(JSC::NamePrototype::createStructure):
- runtime/PrivateName.h: Added.
(JSC):
(PrivateName):
(JSC::PrivateName::PrivateName):
(JSC::PrivateName::uid):
- A private name object holds a StringImpl that can be used as a unique key in a property map.
- runtime/PropertyMapHashTable.h:
(JSC::PropertyTable::find):
(JSC::PropertyTable::findWithString):
- Strings should only match keys in the table that are identifiers.
(JSC::PropertyName::PropertyName):
(PropertyName):
(JSC::PropertyName::uid):
(JSC::PropertyName::publicName):
(JSC::PropertyName::asIndex):
(JSC::operator==):
(JSC::operator!=):
- replaced impl() & ustring() with uid() [to get the raw impl] and publicName() [impl or null, if not an identifier].
(JSC::Structure::despecifyDictionaryFunction):
(JSC::Structure::addPropertyTransitionToExistingStructure):
(JSC::Structure::addPropertyTransition):
(JSC::Structure::attributeChangeTransition):
(JSC::Structure::get):
(JSC::Structure::despecifyFunction):
(JSC::Structure::putSpecificValue):
(JSC::Structure::remove):
(JSC::Structure::getPropertyNamesFromStructure):
(JSC::Structure::get):
- call uid() to get a PropertyName raw impl, for use as a key.
Source/WebCore:
Test: fast/js/names.html
- bindings/js/JSCSSStyleDeclarationCustom.cpp:
(WebCore::cssPropertyIDForJSCSSPropertyName):
- bindings/js/JSDOMBinding.cpp:
(WebCore::findAtomicString):
(WebCore::objectToStringFunctionGetter):
- bindings/js/JSDOMBinding.h:
(WebCore::propertyNameToString):
(WebCore::propertyNameToAtomicString):
- bindings/js/JSDOMWindowCustom.cpp:
(WebCore::nonCachingStaticFunctionGetter):
- bindings/js/JSHistoryCustom.cpp:
(WebCore::nonCachingStaticBackFunctionGetter):
(WebCore::nonCachingStaticForwardFunctionGetter):
(WebCore::nonCachingStaticGoFunctionGetter):
- bindings/js/JSLocationCustom.cpp:
(WebCore::nonCachingStaticReplaceFunctionGetter):
(WebCore::nonCachingStaticReloadFunctionGetter):
(WebCore::nonCachingStaticAssignFunctionGetter):
(JSC::Bindings::CClass::methodsNamed):
(JSC::Bindings::CClass::fieldNamed):
(JSC::Bindings::CInstance::getMethod):
- bridge/jni/jsc/JavaClassJSC.cpp:
(JavaClass::methodsNamed):
(JavaClass::fieldNamed):
- bridge/jni/jsc/JavaInstanceJSC.cpp:
- bridge/objc/objc_class.mm:
(JSC::Bindings::ObjcClass::methodsNamed):
(JSC::Bindings::ObjcClass::fieldNamed):
(JSC::Bindings::ObjcClass::fallbackObject):
- bridge/objc/objc_instance.mm:
(ObjcInstance::setValueOfUndefinedField):
(ObjcInstance::getValueOfUndefinedField):
- Removed PropertyName::impl(), call publicName() to get the string associated with a name.
Source/WebKit/mac:
- Plugins/Hosted/ProxyInstance.mm:
(WebKit::ProxyClass::methodsNamed):
(WebKit::ProxyClass::fieldNamed):
(WebKit::ProxyInstance::getMethod):
(WebKit::ProxyInstance::methodsNamed):
(WebKit::ProxyInstance::fieldNamed):
- Removed PropertyName::impl(), call publicName() to get the string associated with a name.
Source/WebKit2:
- WebProcess/Plugins/Netscape/JSNPObject.cpp:
(WebKit::npIdentifierFromIdentifier):
(WebKit::JSNPObject::methodGetter):
- Removed PropertyName::impl(), call publicName() to get the string associated with a name.
Source/WTF:
(WTF::StringImpl::StringImpl):
(StringImpl):
(WTF::StringImpl::createEmptyUnique):
(WTF::StringImpl::isEmptyUnique):
- Allow empty string impls to be allocated, which can be used as unique keys.
LayoutTests:
- fast/js/names-expected.txt: Added.
- fast/js/names.html: Added.
- fast/js/script-tests/names.js: Added.
|