haikuwebkit/LayoutTests/js/symbols-expected.txt

26 lines
673 B
Plaintext
Raw Permalink Normal View History

Implement ES6 Symbol https://bugs.webkit.org/show_bug.cgi?id=140435 Reviewed by Geoffrey Garen. Source/JavaScriptCore: This patch implements ES6 Symbol. In this patch, we don't support Symbol.keyFor, Symbol.for, Object.getOwnPropertySymbols. They will be supported in the subsequent patches. Since ES6 Symbol is introduced as new primitive value, we implement Symbol as a derived class from JSCell. And now JSValue accepts Symbol* as a new primitive value. Symbol has a *unique* flagged StringImpl* as an `uid`. Which pointer value represents the Symbol's identity. So don't compare Symbol's JSCell pointer value for comparison. This enables re-producing Symbol primitive value from StringImpl* uid by executing`Symbol::create(vm, uid)`. This is needed to produce Symbol primitive values from stored StringImpl* in `Object.getOwnPropertySymbols`. And Symbol.[[Description]] is folded into the string value of Symbol's uid. By doing so, we can represent ES6 Symbol without extending current PropertyTable key; StringImpl*. * CMakeLists.txt: * DerivedSources.make: * JavaScriptCore.order: * JavaScriptCore.vcxproj/JavaScriptCore.vcxproj: * JavaScriptCore.vcxproj/JavaScriptCore.vcxproj.filters: * JavaScriptCore.xcodeproj/project.pbxproj: * builtins/BuiltinExecutables.cpp: (JSC::BuiltinExecutables::createBuiltinExecutable): * builtins/BuiltinNames.h: * dfg/DFGOperations.cpp: (JSC::DFG::operationPutByValInternal): * inspector/JSInjectedScriptHost.cpp: (Inspector::JSInjectedScriptHost::subtype): * interpreter/Interpreter.cpp: * jit/JITOperations.cpp: (JSC::getByVal): * llint/LLIntData.cpp: (JSC::LLInt::Data::performAssertions): * llint/LLIntSlowPaths.cpp: (JSC::LLInt::getByVal): (JSC::LLInt::LLINT_SLOW_PATH_DECL): * llint/LowLevelInterpreter.asm: * runtime/CommonIdentifiers.h: * runtime/CommonSlowPaths.cpp: (JSC::SLOW_PATH_DECL): * runtime/CommonSlowPaths.h: (JSC::CommonSlowPaths::opIn): * runtime/ExceptionHelpers.cpp: (JSC::createUndefinedVariableError): * runtime/JSCJSValue.cpp: (JSC::JSValue::synthesizePrototype): (JSC::JSValue::dumpInContextAssumingStructure): (JSC::JSValue::toStringSlowCase): * runtime/JSCJSValue.h: * runtime/JSCJSValueInlines.h: (JSC::JSValue::isSymbol): (JSC::JSValue::isPrimitive): (JSC::JSValue::toPropertyKey): It represents ToPropertyKey abstract operation in the ES6 spec. It cleans up the old implementation's `isName` checks. And to prevent performance regressions in js/regress/fold-get-by-id-to-multi-get-by-offset-rare-int.html js/regress/fold-get-by-id-to-multi-get-by-offset.html we annnotate this function as ALWAYS_INLINE. (JSC::JSValue::getPropertySlot): (JSC::JSValue::get): (JSC::JSValue::equalSlowCaseInline): (JSC::JSValue::strictEqualSlowCaseInline): * runtime/JSCell.cpp: (JSC::JSCell::put): (JSC::JSCell::putByIndex): (JSC::JSCell::toPrimitive): (JSC::JSCell::getPrimitiveNumber): (JSC::JSCell::toNumber): (JSC::JSCell::toObject): * runtime/JSCell.h: * runtime/JSCellInlines.h: (JSC::JSCell::isSymbol): (JSC::JSCell::toBoolean): (JSC::JSCell::pureToBoolean): * runtime/JSGlobalObject.cpp: (JSC::JSGlobalObject::init): (JSC::JSGlobalObject::visitChildren): * runtime/JSGlobalObject.h: (JSC::JSGlobalObject::symbolPrototype): (JSC::JSGlobalObject::symbolObjectStructure): * runtime/JSONObject.cpp: (JSC::Stringifier::Stringifier): * runtime/JSSymbolTableObject.cpp: (JSC::JSSymbolTableObject::getOwnNonIndexPropertyNames): * runtime/JSType.h: * runtime/JSTypeInfo.h: (JSC::TypeInfo::isName): Deleted. * runtime/MapData.cpp: (JSC::MapData::find): (JSC::MapData::add): (JSC::MapData::remove): (JSC::MapData::replaceAndPackBackingStore): * runtime/MapData.h: (JSC::MapData::clear): * runtime/NameInstance.h: Removed. * runtime/NamePrototype.cpp: Removed. * runtime/ObjectConstructor.cpp: (JSC::objectConstructorGetOwnPropertyDescriptor): (JSC::objectConstructorDefineProperty): * runtime/ObjectPrototype.cpp: (JSC::objectProtoFuncHasOwnProperty): (JSC::objectProtoFuncDefineGetter): (JSC::objectProtoFuncDefineSetter): (JSC::objectProtoFuncLookupGetter): (JSC::objectProtoFuncLookupSetter): (JSC::objectProtoFuncPropertyIsEnumerable): * runtime/Operations.cpp: (JSC::jsTypeStringForValue): (JSC::jsIsObjectType): * runtime/PrivateName.h: (JSC::PrivateName::PrivateName): (JSC::PrivateName::operator==): (JSC::PrivateName::operator!=): * runtime/PropertyMapHashTable.h: (JSC::PropertyTable::find): (JSC::PropertyTable::get): * runtime/PropertyName.h: (JSC::PropertyName::PropertyName): (JSC::PropertyName::publicName): * runtime/SmallStrings.h: * runtime/StringConstructor.cpp: (JSC::callStringConstructor): In ES6, String constructor accepts Symbol to execute `String(symbol)`. * runtime/Structure.cpp: (JSC::Structure::getPropertyNamesFromStructure): * runtime/StructureInlines.h: (JSC::Structure::prototypeForLookup): * runtime/Symbol.cpp: Added. (JSC::Symbol::Symbol): (JSC::SymbolObject::create): (JSC::Symbol::toPrimitive): (JSC::Symbol::toBoolean): (JSC::Symbol::getPrimitiveNumber): (JSC::Symbol::toObject): (JSC::Symbol::toNumber): (JSC::Symbol::destroy): (JSC::Symbol::descriptiveString): * runtime/Symbol.h: Added. (JSC::Symbol::createStructure): (JSC::Symbol::create): (JSC::Symbol::privateName): (JSC::Symbol::finishCreation): (JSC::asSymbol): * runtime/SymbolConstructor.cpp: Renamed from Source/JavaScriptCore/runtime/NameConstructor.cpp. (JSC::SymbolConstructor::SymbolConstructor): (JSC::SymbolConstructor::finishCreation): (JSC::callSymbol): (JSC::SymbolConstructor::getConstructData): (JSC::SymbolConstructor::getCallData): * runtime/SymbolConstructor.h: Renamed from Source/JavaScriptCore/runtime/NameConstructor.h. (JSC::SymbolConstructor::create): (JSC::SymbolConstructor::createStructure): * runtime/SymbolObject.cpp: Renamed from Source/JavaScriptCore/runtime/NameInstance.cpp. (JSC::SymbolObject::SymbolObject): (JSC::SymbolObject::finishCreation): (JSC::SymbolObject::defaultValue): Now JSC doesn't support @@toPrimitive. So instead of it, we implement Symbol.prototype[@@toPrimitive] as ES5 Symbol.[[DefaultValue]]. * runtime/SymbolObject.h: Added. (JSC::SymbolObject::create): (JSC::SymbolObject::internalValue): (JSC::SymbolObject::createStructure): * runtime/SymbolPrototype.cpp: Added. (JSC::SymbolPrototype::SymbolPrototype): (JSC::SymbolPrototype::finishCreation): (JSC::SymbolPrototype::getOwnPropertySlot): (JSC::symbolProtoFuncToString): (JSC::symbolProtoFuncValueOf): * runtime/SymbolPrototype.h: Renamed from Source/JavaScriptCore/runtime/NamePrototype.h. (JSC::SymbolPrototype::create): (JSC::SymbolPrototype::createStructure): SymbolPrototype object is ordinary JS object. Not wrapper object of Symbol. It is tested in js/symbol-prototype-is-ordinary-object.html. * runtime/VM.cpp: (JSC::VM::VM): * runtime/VM.h: Source/WTF: Introduce new unique string mechanizm into StringImpl. It is used for implementing Symbol which holds a [[Description]] value. * wtf/text/AtomicString.h: (WTF::AtomicString::add): (WTF::AtomicString::addWithStringTableProvider): Previously, we checked `isAtomic()` or `!length()`. This guard can filter out EmptyUnique. But now, we introduced new unique StringImpl. Since it has an actual string value, we need to check `isUnique()`. * wtf/text/StringImpl.cpp: (WTF::StringImpl::~StringImpl): (WTF::StringImpl::createUnique): In createUnique, we leverage Substring mechanizm to produce a new unique string from an existing string. * wtf/text/StringImpl.h: (WTF::StringImpl::StringImpl): (WTF::StringImpl::createUniqueEmpty): (WTF::StringImpl::flagIsUnique): (WTF::StringImpl::isUnique): (WTF::StringImpl::setIsAtomic): (WTF::StringImpl::createEmptyUnique): Deleted. (WTF::StringImpl::isEmptyUnique): Deleted. Instead of EmptyUnique, we introduced new flag to StringImpl, `isUnique`. While EmptyUnique cannot hold any string values except for empty string, the unique StringImpl can hold any String values. We fold the Symbol's descriptiveString value here. * wtf/text/StringStatics.cpp: (WTF::StringImpl::hashAndFlagsForUnique): (WTF::StringImpl::hashAndFlagsForEmptyUnique): Deleted. LayoutTests: * js/script-tests/symbol-abstract-equality-comparison.js: Added. (Pair): (relationalOperators.forEach): * js/script-tests/symbol-abstract-relational-comparison.js: Added. (relationalOperators.forEach): * js/script-tests/symbol-in-map.js: Added. (set shouldBe): * js/script-tests/symbol-object.js: Added. * js/script-tests/symbol-prototype-is-ordinary-object.js: Added. * js/script-tests/symbol-strict-equality-comparison.js: Added. (Pair): (relationalOperators.forEach): * js/script-tests/symbol-tostring.js: Added. * js/script-tests/symbols.js: Renamed from LayoutTests/js/script-tests/names.js. (forIn): * js/symbol-abstract-equality-comparison-expected.txt: Added. * js/symbol-abstract-equality-comparison.html: Copied from LayoutTests/js/names.html. * js/symbol-abstract-relational-comparison-expected.txt: Added. * js/symbol-abstract-relational-comparison.html: Copied from LayoutTests/js/names.html. * js/symbol-in-map-expected.txt: Added. * js/symbol-in-map.html: Copied from LayoutTests/js/names.html. * js/symbol-object-expected.txt: Added. * js/symbol-object.html: Copied from LayoutTests/js/names.html. * js/symbol-prototype-is-ordinary-object-expected.txt: Added. * js/symbol-prototype-is-ordinary-object.html: Copied from LayoutTests/js/names.html. * js/symbol-strict-equality-comparison-expected.txt: Added. * js/symbol-strict-equality-comparison.html: Copied from LayoutTests/js/names.html. * js/symbol-tostring-expected.txt: Added. * js/symbol-tostring.html: Copied from LayoutTests/js/names.html. * js/symbols-expected.txt: Renamed from LayoutTests/js/names-expected.txt. * js/symbols.html: Renamed from LayoutTests/js/names.html. Canonical link: https://commits.webkit.org/159106@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@179429 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2015-01-31 01:23:56 +00:00
This tests an early experimental implementation of ES6-esque Symbols.
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. * interpreter/CallFrame.h: (JSC::ExecState::privateNamePrototypeTable): - Added hash table for NamePrototype * interpreter/Interpreter.cpp: (JSC::Interpreter::privateExecute): - Added support for property access with name objects. * jit/JITStubs.cpp: (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): * runtime/JSGlobalData.h: (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. * runtime/Lookup.cpp: (JSC::setUpStaticFunctionSlot): * runtime/Lookup.h: (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): - Added constructor. * 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): - Added instance. * 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): - Added prototype. * 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. * runtime/PropertyName.h: (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]. * runtime/Structure.cpp: (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): * runtime/Structure.h: (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): * bridge/c/c_class.cpp: (JSC::Bindings::CClass::methodsNamed): (JSC::Bindings::CClass::fieldNamed): * bridge/c/c_instance.cpp: (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/text/StringImpl.h: (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. - Added test cases. Canonical link: https://commits.webkit.org/104724@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@117859 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2012-05-22 00:37:09 +00:00
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS prop in o is false
PASS 'prop' in o is false
PASS Object.getOwnPropertyNames(o).length is 0
PASS forIn(o) is []
PASS prop in o is true
PASS 'prop' in o is false
PASS Object.getOwnPropertyNames(o).length is 0
PASS forIn(o) is []
PASS o[prop] is 42
PASS o['prop'] is 101
PASS Object.getOwnPropertyNames(o).length is 1
PASS forIn(o) is ["prop"]
PASS prop in o is false
PASS 'prop' in o is true
PASS Object.getOwnPropertyNames(o).length is 1
PASS forIn(o) is ["prop"]
PASS successfullyParsed is true
TEST COMPLETE