Changeset 179429 in webkit


Ignore:
Timestamp:
Jan 30, 2015 5:23:56 PM (9 years ago)
Author:
Yusuke Suzuki
Message:

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 executingSymbol::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*.

(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.
Location:
trunk
Files:
18 added
2 deleted
52 edited
7 copied
7 moved

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r179425 r179429  
     12015-01-30  Yusuke Suzuki  <utatane.tea@gmail.com>
     2
     3        Implement ES6 Symbol
     4        https://bugs.webkit.org/show_bug.cgi?id=140435
     5
     6        Reviewed by Geoffrey Garen.
     7
     8        * js/script-tests/symbol-abstract-equality-comparison.js: Added.
     9        (Pair):
     10        (relationalOperators.forEach):
     11        * js/script-tests/symbol-abstract-relational-comparison.js: Added.
     12        (relationalOperators.forEach):
     13        * js/script-tests/symbol-in-map.js: Added.
     14        (set shouldBe):
     15        * js/script-tests/symbol-object.js: Added.
     16        * js/script-tests/symbol-prototype-is-ordinary-object.js: Added.
     17        * js/script-tests/symbol-strict-equality-comparison.js: Added.
     18        (Pair):
     19        (relationalOperators.forEach):
     20        * js/script-tests/symbol-tostring.js: Added.
     21        * js/script-tests/symbols.js: Renamed from LayoutTests/js/script-tests/names.js.
     22        (forIn):
     23        * js/symbol-abstract-equality-comparison-expected.txt: Added.
     24        * js/symbol-abstract-equality-comparison.html: Copied from LayoutTests/js/names.html.
     25        * js/symbol-abstract-relational-comparison-expected.txt: Added.
     26        * js/symbol-abstract-relational-comparison.html: Copied from LayoutTests/js/names.html.
     27        * js/symbol-in-map-expected.txt: Added.
     28        * js/symbol-in-map.html: Copied from LayoutTests/js/names.html.
     29        * js/symbol-object-expected.txt: Added.
     30        * js/symbol-object.html: Copied from LayoutTests/js/names.html.
     31        * js/symbol-prototype-is-ordinary-object-expected.txt: Added.
     32        * js/symbol-prototype-is-ordinary-object.html: Copied from LayoutTests/js/names.html.
     33        * js/symbol-strict-equality-comparison-expected.txt: Added.
     34        * js/symbol-strict-equality-comparison.html: Copied from LayoutTests/js/names.html.
     35        * js/symbol-tostring-expected.txt: Added.
     36        * js/symbol-tostring.html: Copied from LayoutTests/js/names.html.
     37        * js/symbols-expected.txt: Renamed from LayoutTests/js/names-expected.txt.
     38        * js/symbols.html: Renamed from LayoutTests/js/names.html.
     39
    1402015-01-30  Dariusz Frankiewicz  <d.frankiewic@samsung.com>
    241
  • trunk/LayoutTests/js/script-tests/symbols.js

    r179427 r179429  
    11description(
    2 "This tests an early experimental implementation of ES6-esque private names."
     2"This tests an early experimental implementation of ES6-esque Symbols."
    33);
    44
     
    1111}
    1212
    13 var prop = Name("prop");
     13var prop = Symbol("prop");
    1414var o = {};
    1515
  • trunk/LayoutTests/js/symbol-abstract-equality-comparison.html

    r179427 r179429  
    55</head>
    66<body>
    7 <script src="script-tests/names.js"></script>
     7<script src="script-tests/symbol-abstract-equality-comparison.js"></script>
    88<script src="../resources/js-test-post.js"></script>
    99</body>
  • trunk/LayoutTests/js/symbol-abstract-relational-comparison.html

    r179427 r179429  
    55</head>
    66<body>
    7 <script src="script-tests/names.js"></script>
     7<script src="script-tests/symbol-abstract-relational-comparison.js"></script>
    88<script src="../resources/js-test-post.js"></script>
    99</body>
  • trunk/LayoutTests/js/symbol-in-map.html

    r179427 r179429  
    55</head>
    66<body>
    7 <script src="script-tests/names.js"></script>
     7<script src="script-tests/symbol-in-map.js"></script>
    88<script src="../resources/js-test-post.js"></script>
    99</body>
  • trunk/LayoutTests/js/symbol-object.html

    r179427 r179429  
    55</head>
    66<body>
    7 <script src="script-tests/names.js"></script>
     7<script src="script-tests/symbol-object.js"></script>
    88<script src="../resources/js-test-post.js"></script>
    99</body>
  • trunk/LayoutTests/js/symbol-prototype-is-ordinary-object.html

    r179427 r179429  
    55</head>
    66<body>
    7 <script src="script-tests/names.js"></script>
     7<script src="script-tests/symbol-prototype-is-ordinary-object.js"></script>
    88<script src="../resources/js-test-post.js"></script>
    99</body>
  • trunk/LayoutTests/js/symbol-strict-equality-comparison.html

    r179427 r179429  
    55</head>
    66<body>
    7 <script src="script-tests/names.js"></script>
     7<script src="script-tests/symbol-strict-equality-comparison.js"></script>
    88<script src="../resources/js-test-post.js"></script>
    99</body>
  • trunk/LayoutTests/js/symbol-tostring.html

    r179427 r179429  
    55</head>
    66<body>
    7 <script src="script-tests/names.js"></script>
     7<script src="script-tests/symbol-tostring.js"></script>
    88<script src="../resources/js-test-post.js"></script>
    99</body>
  • trunk/LayoutTests/js/symbols-expected.txt

    r179427 r179429  
    1 This tests an early experimental implementation of ES6-esque private names.
     1This tests an early experimental implementation of ES6-esque Symbols.
    22
    33On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
  • trunk/LayoutTests/js/symbols.html

    r179427 r179429  
    55</head>
    66<body>
    7 <script src="script-tests/names.js"></script>
     7<script src="script-tests/symbols.js"></script>
    88<script src="../resources/js-test-post.js"></script>
    99</body>
  • trunk/Source/JavaScriptCore/CMakeLists.txt

    r179392 r179429  
    509509    runtime/MathObject.cpp
    510510    runtime/MemoryStatistics.cpp
    511     runtime/NameConstructor.cpp
    512     runtime/NameInstance.cpp
    513     runtime/NamePrototype.cpp
    514511    runtime/NativeErrorConstructor.cpp
    515512    runtime/NativeErrorPrototype.cpp
     
    552549    runtime/StructureIDTable.cpp
    553550    runtime/StructureRareData.cpp
     551    runtime/Symbol.cpp
     552    runtime/SymbolObject.cpp
     553    runtime/SymbolPrototype.cpp
     554    runtime/SymbolConstructor.cpp
    554555    runtime/SymbolTable.cpp
    555556    runtime/TestRunnerUtils.cpp
     
    585586    runtime/JSPromiseConstructor.cpp
    586587    runtime/JSPromisePrototype.cpp
    587     runtime/NamePrototype.cpp
    588588    runtime/NumberConstructor.cpp
    589589    runtime/NumberPrototype.cpp
     
    593593    runtime/RegExpPrototype.cpp
    594594    runtime/StringConstructor.cpp
     595    runtime/SymbolPrototype.cpp
    595596)
    596597
  • trunk/Source/JavaScriptCore/ChangeLog

    r179426 r179429  
     12015-01-30  Yusuke Suzuki  <utatane.tea@gmail.com>
     2
     3        Implement ES6 Symbol
     4        https://bugs.webkit.org/show_bug.cgi?id=140435
     5
     6        Reviewed by Geoffrey Garen.
     7
     8        This patch implements ES6 Symbol. In this patch, we don't support
     9        Symbol.keyFor, Symbol.for, Object.getOwnPropertySymbols. They will be
     10        supported in the subsequent patches.
     11
     12        Since ES6 Symbol is introduced as new primitive value, we implement
     13        Symbol as a derived class from JSCell. And now JSValue accepts Symbol*
     14        as a new primitive value.
     15
     16        Symbol has a *unique* flagged StringImpl* as an `uid`. Which pointer
     17        value represents the Symbol's identity. So don't compare Symbol's
     18        JSCell pointer value for comparison.
     19        This enables re-producing Symbol primitive value from StringImpl* uid
     20        by executing`Symbol::create(vm, uid)`. This is needed to produce
     21        Symbol primitive values from stored StringImpl* in `Object.getOwnPropertySymbols`.
     22
     23        And Symbol.[[Description]] is folded into the string value of Symbol's uid.
     24        By doing so, we can represent ES6 Symbol without extending current PropertyTable key; StringImpl*.
     25
     26        * CMakeLists.txt:
     27        * DerivedSources.make:
     28        * JavaScriptCore.order:
     29        * JavaScriptCore.vcxproj/JavaScriptCore.vcxproj:
     30        * JavaScriptCore.vcxproj/JavaScriptCore.vcxproj.filters:
     31        * JavaScriptCore.xcodeproj/project.pbxproj:
     32        * builtins/BuiltinExecutables.cpp:
     33        (JSC::BuiltinExecutables::createBuiltinExecutable):
     34        * builtins/BuiltinNames.h:
     35        * dfg/DFGOperations.cpp:
     36        (JSC::DFG::operationPutByValInternal):
     37        * inspector/JSInjectedScriptHost.cpp:
     38        (Inspector::JSInjectedScriptHost::subtype):
     39        * interpreter/Interpreter.cpp:
     40        * jit/JITOperations.cpp:
     41        (JSC::getByVal):
     42        * llint/LLIntData.cpp:
     43        (JSC::LLInt::Data::performAssertions):
     44        * llint/LLIntSlowPaths.cpp:
     45        (JSC::LLInt::getByVal):
     46        (JSC::LLInt::LLINT_SLOW_PATH_DECL):
     47        * llint/LowLevelInterpreter.asm:
     48        * runtime/CommonIdentifiers.h:
     49        * runtime/CommonSlowPaths.cpp:
     50        (JSC::SLOW_PATH_DECL):
     51        * runtime/CommonSlowPaths.h:
     52        (JSC::CommonSlowPaths::opIn):
     53        * runtime/ExceptionHelpers.cpp:
     54        (JSC::createUndefinedVariableError):
     55        * runtime/JSCJSValue.cpp:
     56        (JSC::JSValue::synthesizePrototype):
     57        (JSC::JSValue::dumpInContextAssumingStructure):
     58        (JSC::JSValue::toStringSlowCase):
     59        * runtime/JSCJSValue.h:
     60        * runtime/JSCJSValueInlines.h:
     61        (JSC::JSValue::isSymbol):
     62        (JSC::JSValue::isPrimitive):
     63        (JSC::JSValue::toPropertyKey):
     64
     65        It represents ToPropertyKey abstract operation in the ES6 spec.
     66        It cleans up the old implementation's `isName` checks.
     67        And to prevent performance regressions in
     68            js/regress/fold-get-by-id-to-multi-get-by-offset-rare-int.html
     69            js/regress/fold-get-by-id-to-multi-get-by-offset.html
     70        we annnotate this function as ALWAYS_INLINE.
     71
     72        (JSC::JSValue::getPropertySlot):
     73        (JSC::JSValue::get):
     74        (JSC::JSValue::equalSlowCaseInline):
     75        (JSC::JSValue::strictEqualSlowCaseInline):
     76        * runtime/JSCell.cpp:
     77        (JSC::JSCell::put):
     78        (JSC::JSCell::putByIndex):
     79        (JSC::JSCell::toPrimitive):
     80        (JSC::JSCell::getPrimitiveNumber):
     81        (JSC::JSCell::toNumber):
     82        (JSC::JSCell::toObject):
     83        * runtime/JSCell.h:
     84        * runtime/JSCellInlines.h:
     85        (JSC::JSCell::isSymbol):
     86        (JSC::JSCell::toBoolean):
     87        (JSC::JSCell::pureToBoolean):
     88        * runtime/JSGlobalObject.cpp:
     89        (JSC::JSGlobalObject::init):
     90        (JSC::JSGlobalObject::visitChildren):
     91        * runtime/JSGlobalObject.h:
     92        (JSC::JSGlobalObject::symbolPrototype):
     93        (JSC::JSGlobalObject::symbolObjectStructure):
     94        * runtime/JSONObject.cpp:
     95        (JSC::Stringifier::Stringifier):
     96        * runtime/JSSymbolTableObject.cpp:
     97        (JSC::JSSymbolTableObject::getOwnNonIndexPropertyNames):
     98        * runtime/JSType.h:
     99        * runtime/JSTypeInfo.h:
     100        (JSC::TypeInfo::isName): Deleted.
     101        * runtime/MapData.cpp:
     102        (JSC::MapData::find):
     103        (JSC::MapData::add):
     104        (JSC::MapData::remove):
     105        (JSC::MapData::replaceAndPackBackingStore):
     106        * runtime/MapData.h:
     107        (JSC::MapData::clear):
     108        * runtime/NameInstance.h: Removed.
     109        * runtime/NamePrototype.cpp: Removed.
     110        * runtime/ObjectConstructor.cpp:
     111        (JSC::objectConstructorGetOwnPropertyDescriptor):
     112        (JSC::objectConstructorDefineProperty):
     113        * runtime/ObjectPrototype.cpp:
     114        (JSC::objectProtoFuncHasOwnProperty):
     115        (JSC::objectProtoFuncDefineGetter):
     116        (JSC::objectProtoFuncDefineSetter):
     117        (JSC::objectProtoFuncLookupGetter):
     118        (JSC::objectProtoFuncLookupSetter):
     119        (JSC::objectProtoFuncPropertyIsEnumerable):
     120        * runtime/Operations.cpp:
     121        (JSC::jsTypeStringForValue):
     122        (JSC::jsIsObjectType):
     123        * runtime/PrivateName.h:
     124        (JSC::PrivateName::PrivateName):
     125        (JSC::PrivateName::operator==):
     126        (JSC::PrivateName::operator!=):
     127        * runtime/PropertyMapHashTable.h:
     128        (JSC::PropertyTable::find):
     129        (JSC::PropertyTable::get):
     130        * runtime/PropertyName.h:
     131        (JSC::PropertyName::PropertyName):
     132        (JSC::PropertyName::publicName):
     133        * runtime/SmallStrings.h:
     134        * runtime/StringConstructor.cpp:
     135        (JSC::callStringConstructor):
     136
     137        In ES6, String constructor accepts Symbol to execute `String(symbol)`.
     138
     139        * runtime/Structure.cpp:
     140        (JSC::Structure::getPropertyNamesFromStructure):
     141        * runtime/StructureInlines.h:
     142        (JSC::Structure::prototypeForLookup):
     143        * runtime/Symbol.cpp: Added.
     144        (JSC::Symbol::Symbol):
     145        (JSC::SymbolObject::create):
     146        (JSC::Symbol::toPrimitive):
     147        (JSC::Symbol::toBoolean):
     148        (JSC::Symbol::getPrimitiveNumber):
     149        (JSC::Symbol::toObject):
     150        (JSC::Symbol::toNumber):
     151        (JSC::Symbol::destroy):
     152        (JSC::Symbol::descriptiveString):
     153        * runtime/Symbol.h: Added.
     154        (JSC::Symbol::createStructure):
     155        (JSC::Symbol::create):
     156        (JSC::Symbol::privateName):
     157        (JSC::Symbol::finishCreation):
     158        (JSC::asSymbol):
     159        * runtime/SymbolConstructor.cpp: Renamed from Source/JavaScriptCore/runtime/NameConstructor.cpp.
     160        (JSC::SymbolConstructor::SymbolConstructor):
     161        (JSC::SymbolConstructor::finishCreation):
     162        (JSC::callSymbol):
     163        (JSC::SymbolConstructor::getConstructData):
     164        (JSC::SymbolConstructor::getCallData):
     165        * runtime/SymbolConstructor.h: Renamed from Source/JavaScriptCore/runtime/NameConstructor.h.
     166        (JSC::SymbolConstructor::create):
     167        (JSC::SymbolConstructor::createStructure):
     168        * runtime/SymbolObject.cpp: Renamed from Source/JavaScriptCore/runtime/NameInstance.cpp.
     169        (JSC::SymbolObject::SymbolObject):
     170        (JSC::SymbolObject::finishCreation):
     171        (JSC::SymbolObject::defaultValue):
     172
     173        Now JSC doesn't support @@toPrimitive. So instead of it, we implement
     174        Symbol.prototype[@@toPrimitive] as ES5 Symbol.[[DefaultValue]].
     175
     176        * runtime/SymbolObject.h: Added.
     177        (JSC::SymbolObject::create):
     178        (JSC::SymbolObject::internalValue):
     179        (JSC::SymbolObject::createStructure):
     180        * runtime/SymbolPrototype.cpp: Added.
     181        (JSC::SymbolPrototype::SymbolPrototype):
     182        (JSC::SymbolPrototype::finishCreation):
     183        (JSC::SymbolPrototype::getOwnPropertySlot):
     184        (JSC::symbolProtoFuncToString):
     185        (JSC::symbolProtoFuncValueOf):
     186        * runtime/SymbolPrototype.h: Renamed from Source/JavaScriptCore/runtime/NamePrototype.h.
     187        (JSC::SymbolPrototype::create):
     188        (JSC::SymbolPrototype::createStructure):
     189
     190        SymbolPrototype object is ordinary JS object. Not wrapper object of Symbol.
     191        It is tested in js/symbol-prototype-is-ordinary-object.html.
     192
     193        * runtime/VM.cpp:
     194        (JSC::VM::VM):
     195        * runtime/VM.h:
     196
    11972015-01-30  Geoffrey Garen  <ggaren@apple.com>
    2198
  • trunk/Source/JavaScriptCore/DerivedSources.make

    r178631 r179429  
    4949    KeywordLookup.h \
    5050    Lexer.lut.h \
    51     NamePrototype.lut.h \
    5251    NumberConstructor.lut.h \
    5352    NumberPrototype.lut.h \
     
    5857    RegExpObject.lut.h \
    5958    StringConstructor.lut.h \
     59    SymbolPrototype.lut.h \
    6060    udis86_itab.h \
    6161    Bytecodes.h \
  • trunk/Source/JavaScriptCore/JavaScriptCore.order

    r175078 r179429  
    46004600__ZN3JSC4Yarr13YarrGeneratorILNS0_18YarrJITCompileModeE1EE33generatePatternCharacterNonGreedyEm
    46014601__ZN3JSC4Yarr13YarrGeneratorILNS0_18YarrJITCompileModeE1EE34backtrackPatternCharacterNonGreedyEm
    4602 __ZN3JSC13NamePrototypeC1EPNS_9ExecStateEPNS_9StructureE
    4603 __ZN3JSC12NameInstanceC2ERNS_2VMEPNS_9StructureEPNS_8JSStringE
    4604 __ZN3JSC13NamePrototype14finishCreationEPNS_9ExecStateE
    4605 __ZN3JSC15NameConstructorC1EPNS_14JSGlobalObjectEPNS_9StructureE
    4606 __ZN3JSC15NameConstructor14finishCreationEPNS_9ExecStateEPNS_13NamePrototypeE
    46074602_JSStringIsEqualToUTF8CString
    46084603_JSStringIsEqual
    4609 __ZN3JSC12NameInstance7destroyEPNS_6JSCellE
    46104604__ZN3WTF3MD5C1Ev
    46114605__ZN3WTF3MD58addBytesEPKhm
     
    47574751__ZN3JSC11JSNameScope3putEPNS_6JSCellEPNS_9ExecStateENS_12PropertyNameENS_7JSValueERNS_15PutPropertySlotE
    47584752__ZN3JSC14symbolTablePutINS_11JSNameScopeEEEbPT_PNS_9ExecStateENS_12PropertyNameENS_7JSValueEb
    4759 __ZN3JSC15NameConstructor11getCallDataEPNS_6JSCellERNS_8CallDataE
    47604753__ZN3JSCL20constructPrivateNameEPNS_9ExecStateE
    4761 __ZN3JSC12NameInstanceC1ERNS_2VMEPNS_9StructureEPNS_8JSStringE
    47624754__ZN3JSCL29objectProtoFuncToLocaleStringEPNS_9ExecStateE
    47634755__ZN3JSC13JSNotAnObject24getOwnPropertyDescriptorEPNS_8JSObjectEPNS_9ExecStateENS_12PropertyNameERNS_18PropertyDescriptorE
  • trunk/Source/JavaScriptCore/JavaScriptCore.vcxproj/JavaScriptCore.vcxproj

    r179392 r179429  
    774774    <ClCompile Include="..\runtime\MathObject.cpp" />
    775775    <ClCompile Include="..\runtime\MemoryStatistics.cpp" />
    776     <ClCompile Include="..\runtime\NameConstructor.cpp" />
    777     <ClCompile Include="..\runtime\NameInstance.cpp" />
    778     <ClCompile Include="..\runtime\NamePrototype.cpp" />
    779776    <ClCompile Include="..\runtime\NativeErrorConstructor.cpp" />
    780777    <ClCompile Include="..\runtime\NativeErrorPrototype.cpp" />
     
    817814    <ClCompile Include="..\runtime\StructureIDTable.cpp" />
    818815    <ClCompile Include="..\runtime\StructureRareData.cpp" />
     816    <ClCompile Include="..\runtime\Symbol.cpp" />
     817    <ClCompile Include="..\runtime\SymbolConstructor.cpp" />
     818    <ClCompile Include="..\runtime\SymbolObject.cpp" />
     819    <ClCompile Include="..\runtime\SymbolPrototype.cpp" />
    819820    <ClCompile Include="..\runtime\SymbolTable.cpp" />
    820821    <ClCompile Include="..\runtime\TestRunnerUtils.cpp" />
     
    864865    <ClInclude Include="$(ConfigurationBuildDir)\obj$(PlatformArchitecture)\$(ProjectName)\DerivedSources\KeywordLookup.lut.h" />
    865866    <ClInclude Include="$(ConfigurationBuildDir)\obj$(PlatformArchitecture)\$(ProjectName)\DerivedSources\Lexer.lut.h" />
    866     <ClInclude Include="$(ConfigurationBuildDir)\obj$(PlatformArchitecture)\$(ProjectName)\DerivedSources\NamePrototype.lut.h" />
    867867    <ClInclude Include="$(ConfigurationBuildDir)\obj$(PlatformArchitecture)\$(ProjectName)\DerivedSources\NumberConstructor.lut.h" />
    868868    <ClInclude Include="$(ConfigurationBuildDir)\obj$(PlatformArchitecture)\$(ProjectName)\DerivedSources\NumberPrototype.lut.h" />
     
    873873    <ClInclude Include="$(ConfigurationBuildDir)\obj$(PlatformArchitecture)\$(ProjectName)\DerivedSources\RegExpPrototype.lut.h" />
    874874    <ClInclude Include="$(ConfigurationBuildDir)\obj$(PlatformArchitecture)\$(ProjectName)\DerivedSources\StringConstructor.lut.h" />
     875    <ClInclude Include="$(ConfigurationBuildDir)\obj$(PlatformArchitecture)\$(ProjectName)\DerivedSources\SymbolPrototype.lut.h" />
    875876    <ClInclude Include="$(ConfigurationBuildDir)\obj$(PlatformArchitecture)\$(ProjectName)\DerivedSources\JSCBuiltins.h" />
    876877  </ItemGroup>
     
    15691570    <ClInclude Include="..\runtime\MemoryStatistics.h" />
    15701571    <ClInclude Include="..\runtime\Microtask.h" />
    1571     <ClInclude Include="..\runtime\NameConstructor.h" />
    1572     <ClInclude Include="..\runtime\NameInstance.h" />
    1573     <ClInclude Include="..\runtime\NamePrototype.h" />
    15741572    <ClInclude Include="..\runtime\NativeErrorConstructor.h" />
    15751573    <ClInclude Include="..\runtime\NativeErrorPrototype.h" />
     
    16261624    <ClInclude Include="..\runtime\StructureRareDataInlines.h" />
    16271625    <ClInclude Include="..\runtime\StructureTransitionTable.h" />
     1626    <ClInclude Include="..\runtime\Symbol.h" />
     1627    <ClInclude Include="..\runtime\SymbolConstructor.h" />
     1628    <ClInclude Include="..\runtime\SymbolObject.h" />
     1629    <ClInclude Include="..\runtime\SymbolPrototype.h" />
    16281630    <ClInclude Include="..\runtime\SymbolTable.h" />
    16291631    <ClInclude Include="..\runtime\TestRunnerUtils.h" />
  • trunk/Source/JavaScriptCore/JavaScriptCore.vcxproj/JavaScriptCore.vcxproj.filters

    r179211 r179429  
    742742      <Filter>runtime</Filter>
    743743    </ClCompile>
    744     <ClCompile Include="..\runtime\NameConstructor.cpp">
    745       <Filter>runtime</Filter>
    746     </ClCompile>
    747     <ClCompile Include="..\runtime\NameInstance.cpp">
    748       <Filter>runtime</Filter>
    749     </ClCompile>
    750     <ClCompile Include="..\runtime\NamePrototype.cpp">
    751       <Filter>runtime</Filter>
    752     </ClCompile>
    753744    <ClCompile Include="..\runtime\NativeErrorConstructor.cpp">
    754745      <Filter>runtime</Filter>
     
    860851    </ClCompile>
    861852    <ClCompile Include="..\runtime\StructureIDTable.cpp">
     853      <Filter>runtime</Filter>
     854    </ClCompile>
     855    <ClCompile Include="..\runtime\Symbol.cpp">
     856      <Filter>runtime</Filter>
     857    </ClInclude>
     858    <ClCompile Include="..\runtime\SymbolConstructor.cpp">
     859      <Filter>runtime</Filter>
     860    </ClCompile>
     861    <ClCompile Include="..\runtime\SymbolObject.cpp">
     862      <Filter>runtime</Filter>
     863    </ClCompile>
     864    <ClCompile Include="..\runtime\SymbolPrototype.cpp">
    862865      <Filter>runtime</Filter>
    863866    </ClCompile>
     
    27602763      <Filter>runtime</Filter>
    27612764    </ClInclude>
    2762     <ClInclude Include="..\runtime\NameConstructor.h">
    2763       <Filter>runtime</Filter>
    2764     </ClInclude>
    2765     <ClInclude Include="..\runtime\NameInstance.h">
    2766       <Filter>runtime</Filter>
    2767     </ClInclude>
    2768     <ClInclude Include="..\runtime\NamePrototype.h">
    2769       <Filter>runtime</Filter>
    2770     </ClInclude>
    27712765    <ClInclude Include="..\runtime\NativeErrorConstructor.h">
    27722766      <Filter>runtime</Filter>
     
    29022896    </ClInclude>
    29032897    <ClInclude Include="..\runtime\StructureTransitionTable.h">
     2898      <Filter>runtime</Filter>
     2899    </ClInclude>
     2900    <ClInclude Include="..\runtime\Symbol.h">
     2901      <Filter>runtime</Filter>
     2902    </ClInclude>
     2903    <ClInclude Include="..\runtime\SymbolConstructor.h">
     2904      <Filter>runtime</Filter>
     2905    </ClInclude>
     2906    <ClInclude Include="..\runtime\SymbolObject.h">
     2907      <Filter>runtime</Filter>
     2908    </ClInclude>
     2909    <ClInclude Include="..\runtime\SymbolPrototype.h">
    29042910      <Filter>runtime</Filter>
    29052911    </ClInclude>
     
    32503256      <Filter>Derived Sources</Filter>
    32513257    </ClInclude>
    3252     <ClInclude Include="$(ConfigurationBuildDir)\obj$(PlatformArchitecture)\$(ProjectName)\DerivedSources\NamePrototype.lut.h">
     3258    <ClInclude Include="$(ConfigurationBuildDir)\obj$(PlatformArchitecture)\$(ProjectName)\DerivedSources\SymbolPrototype.lut.h">
    32533259      <Filter>Derived Sources</Filter>
    32543260    </ClInclude>
  • trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj

    r179392 r179429  
    933933                65FB5117184EEE7000C12B70 /* ProtoCallFrame.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 65FB5116184EE9BC00C12B70 /* ProtoCallFrame.cpp */; };
    934934                6AD2CB4D19B9140100065719 /* DebuggerEvalEnabler.h in Headers */ = {isa = PBXBuildFile; fileRef = 6AD2CB4C19B9140100065719 /* DebuggerEvalEnabler.h */; settings = {ATTRIBUTES = (Private, ); }; };
     935                705B41AB1A6E501E00716757 /* Symbol.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 705B41A31A6E501E00716757 /* Symbol.cpp */; };
     936                705B41AC1A6E501E00716757 /* Symbol.h in Headers */ = {isa = PBXBuildFile; fileRef = 705B41A41A6E501E00716757 /* Symbol.h */; settings = {ATTRIBUTES = (Private, ); }; };
     937                705B41AD1A6E501E00716757 /* SymbolConstructor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 705B41A51A6E501E00716757 /* SymbolConstructor.cpp */; };
     938                705B41AE1A6E501E00716757 /* SymbolConstructor.h in Headers */ = {isa = PBXBuildFile; fileRef = 705B41A61A6E501E00716757 /* SymbolConstructor.h */; settings = {ATTRIBUTES = (Private, ); }; };
     939                705B41AF1A6E501E00716757 /* SymbolObject.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 705B41A71A6E501E00716757 /* SymbolObject.cpp */; };
     940                705B41B01A6E501E00716757 /* SymbolObject.h in Headers */ = {isa = PBXBuildFile; fileRef = 705B41A81A6E501E00716757 /* SymbolObject.h */; settings = {ATTRIBUTES = (Private, ); }; };
     941                705B41B11A6E501E00716757 /* SymbolPrototype.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 705B41A91A6E501E00716757 /* SymbolPrototype.cpp */; };
     942                705B41B21A6E501E00716757 /* SymbolPrototype.h in Headers */ = {isa = PBXBuildFile; fileRef = 705B41AA1A6E501E00716757 /* SymbolPrototype.h */; settings = {ATTRIBUTES = (Private, ); }; };
    935943                7C008CD2186F8A9300955C24 /* JSPromiseFunctions.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C008CD0186F8A9300955C24 /* JSPromiseFunctions.cpp */; };
    936944                7C008CD3186F8A9300955C24 /* JSPromiseFunctions.h in Headers */ = {isa = PBXBuildFile; fileRef = 7C008CD1186F8A9300955C24 /* JSPromiseFunctions.h */; settings = {ATTRIBUTES = (Private, ); }; };
     
    10181026                86E3C61D167BABEE006D760A /* JSVirtualMachineInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 86E3C611167BAB87006D760A /* JSVirtualMachineInternal.h */; settings = {ATTRIBUTES = (Private, ); }; };
    10191027                86E85539111B9968001AF51E /* JSStringBuilder.h in Headers */ = {isa = PBXBuildFile; fileRef = 86E85538111B9968001AF51E /* JSStringBuilder.h */; };
    1020                 86EBF2FF1560F06A008E9222 /* NameConstructor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 86EBF2F91560F036008E9222 /* NameConstructor.cpp */; };
    1021                 86EBF3001560F06A008E9222 /* NameConstructor.h in Headers */ = {isa = PBXBuildFile; fileRef = 86EBF2FA1560F036008E9222 /* NameConstructor.h */; };
    1022                 86EBF3011560F06A008E9222 /* NameInstance.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 86EBF2FB1560F036008E9222 /* NameInstance.cpp */; };
    1023                 86EBF3021560F06A008E9222 /* NameInstance.h in Headers */ = {isa = PBXBuildFile; fileRef = 86EBF2FC1560F036008E9222 /* NameInstance.h */; };
    1024                 86EBF3031560F06A008E9222 /* NamePrototype.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 86EBF2FD1560F036008E9222 /* NamePrototype.cpp */; };
    1025                 86EBF3041560F06A008E9222 /* NamePrototype.h in Headers */ = {isa = PBXBuildFile; fileRef = 86EBF2FE1560F036008E9222 /* NamePrototype.h */; };
    10261028                86EC9DC41328DF82002B2AD7 /* DFGByteCodeParser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 86EC9DB41328DF82002B2AD7 /* DFGByteCodeParser.cpp */; };
    10271029                86EC9DC51328DF82002B2AD7 /* DFGByteCodeParser.h in Headers */ = {isa = PBXBuildFile; fileRef = 86EC9DB51328DF82002B2AD7 /* DFGByteCodeParser.h */; settings = {ATTRIBUTES = (Private, ); }; };
     
    26002602                6AD2CB4C19B9140100065719 /* DebuggerEvalEnabler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DebuggerEvalEnabler.h; sourceTree = "<group>"; };
    26012603                704FD35305697E6D003DBED9 /* BooleanObject.h */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = BooleanObject.h; sourceTree = "<group>"; tabWidth = 8; };
     2604                705B41A31A6E501E00716757 /* Symbol.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Symbol.cpp; sourceTree = "<group>"; };
     2605                705B41A41A6E501E00716757 /* Symbol.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Symbol.h; sourceTree = "<group>"; };
     2606                705B41A51A6E501E00716757 /* SymbolConstructor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SymbolConstructor.cpp; sourceTree = "<group>"; };
     2607                705B41A61A6E501E00716757 /* SymbolConstructor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SymbolConstructor.h; sourceTree = "<group>"; };
     2608                705B41A71A6E501E00716757 /* SymbolObject.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SymbolObject.cpp; sourceTree = "<group>"; };
     2609                705B41A81A6E501E00716757 /* SymbolObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SymbolObject.h; sourceTree = "<group>"; };
     2610                705B41A91A6E501E00716757 /* SymbolPrototype.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SymbolPrototype.cpp; sourceTree = "<group>"; };
     2611                705B41AA1A6E501E00716757 /* SymbolPrototype.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SymbolPrototype.h; sourceTree = "<group>"; };
    26022612                7C008CD0186F8A9300955C24 /* JSPromiseFunctions.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; path = JSPromiseFunctions.cpp; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.cpp; };
    26032613                7C008CD1186F8A9300955C24 /* JSPromiseFunctions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSPromiseFunctions.h; sourceTree = "<group>"; };
     
    26972707                86E3C611167BAB87006D760A /* JSVirtualMachineInternal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSVirtualMachineInternal.h; sourceTree = "<group>"; };
    26982708                86E85538111B9968001AF51E /* JSStringBuilder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSStringBuilder.h; sourceTree = "<group>"; };
    2699                 86EBF2F91560F036008E9222 /* NameConstructor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NameConstructor.cpp; sourceTree = "<group>"; };
    2700                 86EBF2FA1560F036008E9222 /* NameConstructor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NameConstructor.h; sourceTree = "<group>"; };
    2701                 86EBF2FB1560F036008E9222 /* NameInstance.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NameInstance.cpp; sourceTree = "<group>"; };
    2702                 86EBF2FC1560F036008E9222 /* NameInstance.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NameInstance.h; sourceTree = "<group>"; };
    2703                 86EBF2FD1560F036008E9222 /* NamePrototype.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NamePrototype.cpp; sourceTree = "<group>"; };
    2704                 86EBF2FE1560F036008E9222 /* NamePrototype.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NamePrototype.h; sourceTree = "<group>"; };
    27052709                86EC9DB41328DF82002B2AD7 /* DFGByteCodeParser.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = DFGByteCodeParser.cpp; path = dfg/DFGByteCodeParser.cpp; sourceTree = "<group>"; };
    27062710                86EC9DB51328DF82002B2AD7 /* DFGByteCodeParser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DFGByteCodeParser.h; path = dfg/DFGByteCodeParser.h; sourceTree = "<group>"; };
     
    44414445                                90213E3C123A40C200D422F3 /* MemoryStatistics.h */,
    44424446                                7C008CE5187631B600955C24 /* Microtask.h */,
    4443                                 86EBF2F91560F036008E9222 /* NameConstructor.cpp */,
    4444                                 86EBF2FA1560F036008E9222 /* NameConstructor.h */,
    4445                                 86EBF2FB1560F036008E9222 /* NameInstance.cpp */,
    4446                                 86EBF2FC1560F036008E9222 /* NameInstance.h */,
    4447                                 86EBF2FD1560F036008E9222 /* NamePrototype.cpp */,
    4448                                 86EBF2FE1560F036008E9222 /* NamePrototype.h */,
    44494447                                BC02E9080E1839DB000F9297 /* NativeErrorConstructor.cpp */,
    44504448                                BC02E9090E1839DB000F9297 /* NativeErrorConstructor.h */,
     
    45444542                                C20BA92C16BB1C1500B3AEA2 /* StructureRareDataInlines.h */,
    45454543                                BC9041470EB9250900FE26FA /* StructureTransitionTable.h */,
     4544                                705B41A31A6E501E00716757 /* Symbol.cpp */,
     4545                                705B41A41A6E501E00716757 /* Symbol.h */,
     4546                                705B41A51A6E501E00716757 /* SymbolConstructor.cpp */,
     4547                                705B41A61A6E501E00716757 /* SymbolConstructor.h */,
     4548                                705B41A71A6E501E00716757 /* SymbolObject.cpp */,
     4549                                705B41A81A6E501E00716757 /* SymbolObject.h */,
     4550                                705B41A91A6E501E00716757 /* SymbolPrototype.cpp */,
     4551                                705B41AA1A6E501E00716757 /* SymbolPrototype.h */,
    45464552                                0F919D2715856770004A4E7D /* SymbolTable.cpp */,
    45474553                                14A396A60CD2933100B5B4FF /* SymbolTable.h */,
     
    60546060                                7C008CE7187631B600955C24 /* Microtask.h in Headers */,
    60556061                                86C568E211A213EE0007F7F0 /* MIPSAssembler.h in Headers */,
    6056                                 86EBF3001560F06A008E9222 /* NameConstructor.h in Headers */,
    6057                                 86EBF3021560F06A008E9222 /* NameInstance.h in Headers */,
    6058                                 86EBF3041560F06A008E9222 /* NamePrototype.h in Headers */,
    60596062                                BC02E9110E1839DB000F9297 /* NativeErrorConstructor.h in Headers */,
    60606063                                BC02E9130E1839DB000F9297 /* NativeErrorPrototype.h in Headers */,
     
    62156218                                BC9041480EB9250900FE26FA /* StructureTransitionTable.h in Headers */,
    62166219                                C2DF44301707AC0100A5CA96 /* SuperRegion.h in Headers */,
     6220                                705B41AC1A6E501E00716757 /* Symbol.h in Headers */,
     6221                                705B41AE1A6E501E00716757 /* SymbolConstructor.h in Headers */,
     6222                                705B41B01A6E501E00716757 /* SymbolObject.h in Headers */,
     6223                                705B41B21A6E501E00716757 /* SymbolPrototype.h in Headers */,
    62176224                                BC18C46B0E16F5CD00B34460 /* SymbolTable.h in Headers */,
    62186225                                A784A26411D16622005776AC /* SyntaxChecker.h in Headers */,
     
    71817188                                90213E3D123A40C200D422F3 /* MemoryStatistics.cpp in Sources */,
    71827189                                0FB5467D14F5CFD6002C2989 /* MethodOfGettingAValueProfile.cpp in Sources */,
    7183                                 86EBF2FF1560F06A008E9222 /* NameConstructor.cpp in Sources */,
    7184                                 86EBF3011560F06A008E9222 /* NameInstance.cpp in Sources */,
    7185                                 86EBF3031560F06A008E9222 /* NamePrototype.cpp in Sources */,
    71867190                                14469DE0107EC7E700650446 /* NativeErrorConstructor.cpp in Sources */,
    71877191                                14469DE1107EC7E700650446 /* NativeErrorPrototype.cpp in Sources */,
     
    72847288                                BCCF0D0C0EF0B8A500413C8F /* StructureStubInfo.cpp in Sources */,
    72857289                                C2DF442F1707AC0100A5CA96 /* SuperRegion.cpp in Sources */,
     7290                                705B41AB1A6E501E00716757 /* Symbol.cpp in Sources */,
     7291                                705B41AD1A6E501E00716757 /* SymbolConstructor.cpp in Sources */,
     7292                                705B41AF1A6E501E00716757 /* SymbolObject.cpp in Sources */,
     7293                                705B41B11A6E501E00716757 /* SymbolPrototype.cpp in Sources */,
    72867294                                0F919D2815856773004A4E7D /* SymbolTable.cpp in Sources */,
    72877295                                0FC314131814559100033232 /* TempRegisterSet.cpp in Sources */,
  • trunk/Source/JavaScriptCore/builtins/BuiltinExecutables.cpp

    r176825 r179429  
    7676        if (closedVariable == m_vm.propertyNames->undefinedKeyword.impl())
    7777            continue;
    78         RELEASE_ASSERT(closedVariable->isEmptyUnique());
     78        RELEASE_ASSERT(closedVariable->isUnique());
    7979    }
    8080    body->overrideName(name);
  • trunk/Source/JavaScriptCore/builtins/BuiltinNames.h

    r164346 r179429  
    3232namespace JSC {
    3333   
    34 #define INITIALISE_BUILTIN_NAMES(name) , m_##name(vm, #name), m_##name##PrivateName(Identifier::from(PrivateName()))
     34#define INITIALISE_BUILTIN_NAMES(name) , m_##name(vm, #name), m_##name##PrivateName(Identifier::from(PrivateName(ASCIILiteral("Symbol." #name))))
    3535#define DECLARE_BUILTIN_NAMES(name) const Identifier m_##name; const Identifier m_##name##PrivateName;;
    3636#define DECLARE_BUILTIN_IDENTIFIER_ACCESSOR(name) \
  • trunk/Source/JavaScriptCore/dfg/DFGOperations.cpp

    r179392 r179429  
    4949#include "VM.h"
    5050#include "JSNameScope.h"
    51 #include "NameInstance.h"
    5251#include "ObjectConstructor.h"
    5352#include "JSCInlines.h"
    5453#include "Repatch.h"
    5554#include "StringConstructor.h"
     55#include "Symbol.h"
    5656#include "TypeProfilerLog.h"
    5757#include "TypedArrayInlines.h"
     
    111111    }
    112112
    113     if (isName(property)) {
    114         PutPropertySlot slot(baseValue, strict);
    115         if (direct) {
    116             RELEASE_ASSERT(baseValue.isObject());
    117             asObject(baseValue)->putDirect(*vm, jsCast<NameInstance*>(property.asCell())->privateName(), value, slot);
    118         } else
    119             baseValue.put(exec, jsCast<NameInstance*>(property.asCell())->privateName(), value, slot);
    120         return;
    121     }
    122 
    123113    // Don't put to an object if toString throws an exception.
    124     Identifier ident = property.toString(exec)->toIdentifier(exec);
     114    PropertyName propertyName = property.toPropertyKey(exec);
    125115    if (!vm->exception()) {
    126116        PutPropertySlot slot(baseValue, strict);
    127117        if (direct) {
    128118            RELEASE_ASSERT(baseValue.isObject());
    129             asObject(baseValue)->putDirect(*vm, ident, value, slot);
     119            asObject(baseValue)->putDirect(*vm, propertyName, value, slot);
    130120        } else
    131             baseValue.put(exec, ident, value, slot);
     121            baseValue.put(exec, propertyName, value, slot);
    132122    }
    133123}
     
    307297    }
    308298
    309     if (isName(property))
    310         return JSValue::encode(baseValue.get(exec, jsCast<NameInstance*>(property.asCell())->privateName()));
    311 
    312     Identifier ident = property.toString(exec)->toIdentifier(exec);
    313     return JSValue::encode(baseValue.get(exec, ident));
     299    PropertyName propertyName = property.toPropertyKey(exec);
     300    return JSValue::encode(baseValue.get(exec, propertyName));
    314301}
    315302
     
    338325    }
    339326
    340     if (isName(property))
    341         return JSValue::encode(JSValue(base).get(exec, jsCast<NameInstance*>(property.asCell())->privateName()));
    342 
    343     Identifier ident = property.toString(exec)->toIdentifier(exec);
    344     return JSValue::encode(JSValue(base).get(exec, ident));
     327    PropertyName propertyName = property.toPropertyKey(exec);
     328    return JSValue::encode(JSValue(base).get(exec, propertyName));
    345329}
    346330
  • trunk/Source/JavaScriptCore/inspector/JSInjectedScriptHost.cpp

    r179349 r179429  
    123123    if (value.isNumber())
    124124        return exec->vm().smallStrings.numberString();
     125    if (value.isSymbol())
     126        return exec->vm().smallStrings.symbolString();
    125127
    126128    JSObject* object = asObject(value);
  • trunk/Source/JavaScriptCore/interpreter/Interpreter.cpp

    r178856 r179429  
    5555#include "LegacyProfiler.h"
    5656#include "LiteralParser.h"
    57 #include "NameInstance.h"
    5857#include "ObjectPrototype.h"
    5958#include "JSCInlines.h"
     
    6867#include "StrictEvalActivation.h"
    6968#include "StrongInlines.h"
     69#include "Symbol.h"
    7070#include "VMEntryScope.h"
    7171#include "VirtualRegister.h"
  • trunk/Source/JavaScriptCore/jit/JITOperations.cpp

    r179392 r179429  
    160160    VM* vm = &exec->vm();
    161161    NativeCallFrameTracer tracer(vm, exec);
    162     Identifier ident = uid->isEmptyUnique() ? Identifier::from(PrivateName(uid)) : Identifier(vm, uid);
     162    Identifier ident = uid->isUnique() ? Identifier::from(PrivateName(uid)) : Identifier(vm, uid);
    163163
    164164    JSValue baseValue = JSValue::decode(base);
     
    467467        } else
    468468            baseValue.putByIndex(callFrame, i, value, callFrame->codeBlock()->isStrictMode());
    469     } else if (isName(subscript)) {
    470         PutPropertySlot slot(baseValue, callFrame->codeBlock()->isStrictMode());
    471         baseValue.put(callFrame, jsCast<NameInstance*>(subscript.asCell())->privateName(), value, slot);
    472469    } else {
    473         Identifier property = subscript.toString(callFrame)->toIdentifier(callFrame);
     470        PropertyName property = subscript.toPropertyKey(callFrame);
    474471        if (!callFrame->vm().exception()) { // Don't put to an object if toString threw an exception.
    475472            PutPropertySlot slot(baseValue, callFrame->codeBlock()->isStrictMode());
     
    484481        uint32_t i = subscript.asUInt32();
    485482        baseObject->putDirectIndex(callFrame, i, value);
    486     } else if (isName(subscript)) {
    487         PutPropertySlot slot(baseObject, callFrame->codeBlock()->isStrictMode());
    488         baseObject->putDirect(callFrame->vm(), jsCast<NameInstance*>(subscript.asCell())->privateName(), value, slot);
    489483    } else {
    490         Identifier property = subscript.toString(callFrame)->toIdentifier(callFrame);
     484        PropertyName property = subscript.toPropertyKey(callFrame);
    491485        if (!callFrame->vm().exception()) { // Don't put to an object if toString threw an exception.
    492486            PutPropertySlot slot(baseObject, callFrame->codeBlock()->isStrictMode());
     
    14681462    }
    14691463
    1470     if (isName(subscript))
    1471         return baseValue.get(exec, jsCast<NameInstance*>(subscript.asCell())->privateName());
    1472 
    1473     Identifier property = subscript.toString(exec)->toIdentifier(exec);
     1464    PropertyName property = subscript.toPropertyKey(exec);
    14741465    return baseValue.get(exec, property);
    14751466}
     
    16061597                ctiPatchCallByReturnAddress(exec->codeBlock(), ReturnAddressPtr(OUR_RETURN_ADDRESS), FunctionPtr(operationGetByValDefault));
    16071598        }
    1608     } else if (isName(subscript))
    1609         result = baseValue.get(exec, jsCast<NameInstance*>(subscript.asCell())->privateName());
    1610     else {
    1611         Identifier property = subscript.toString(exec)->toIdentifier(exec);
     1599    } else {
     1600        PropertyName property = subscript.toPropertyKey(exec);
    16121601        result = baseValue.get(exec, property);
    16131602    }
  • trunk/Source/JavaScriptCore/llint/LLIntData.cpp

    r178856 r179429  
    133133#endif
    134134    ASSERT(StringType == 6);
    135     ASSERT(ObjectType == 17);
    136     ASSERT(FinalObjectType == 18);
     135    ASSERT(ObjectType == 18);
     136    ASSERT(FinalObjectType == 19);
    137137    ASSERT(MasqueradesAsUndefined == 1);
    138138    ASSERT(ImplementsHasInstance == 2);
  • trunk/Source/JavaScriptCore/llint/LLIntSlowPaths.cpp

    r179392 r179429  
    745745    }
    746746
    747     if (isName(subscript))
    748         return baseValue.get(exec, jsCast<NameInstance*>(subscript.asCell())->privateName());
    749    
    750     Identifier property = subscript.toString(exec)->toIdentifier(exec);
     747    PropertyName property = subscript.toPropertyKey(exec);
    751748    return baseValue.get(exec, property);
    752749}
     
    798795    }
    799796
    800     if (isName(subscript)) {
    801         PutPropertySlot slot(baseValue, exec->codeBlock()->isStrictMode());
    802         baseValue.put(exec, jsCast<NameInstance*>(subscript.asCell())->privateName(), value, slot);
    803         LLINT_END();
    804     }
    805 
    806     Identifier property = subscript.toString(exec)->toIdentifier(exec);
     797    PropertyName property = subscript.toPropertyKey(exec);
    807798    LLINT_CHECK_EXCEPTION();
    808799    PutPropertySlot slot(baseValue, exec->codeBlock()->isStrictMode());
     
    823814        uint32_t i = subscript.asUInt32();
    824815        baseObject->putDirectIndex(exec, i, value);
    825     } else if (isName(subscript)) {
    826         PutPropertySlot slot(baseObject, exec->codeBlock()->isStrictMode());
    827         baseObject->putDirect(exec->vm(), jsCast<NameInstance*>(subscript.asCell())->privateName(), value, slot);
    828816    } else {
    829         Identifier property = subscript.toString(exec)->toIdentifier(exec);
     817        PropertyName property = subscript.toPropertyKey(exec);
    830818        if (!exec->vm().exception()) { // Don't put to an object if toString threw an exception.
    831819            PutPropertySlot slot(baseObject, exec->codeBlock()->isStrictMode());
     
    849837    if (subscript.getUInt32(i))
    850838        couldDelete = baseObject->methodTable()->deletePropertyByIndex(baseObject, exec, i);
    851     else if (isName(subscript))
    852         couldDelete = baseObject->methodTable()->deleteProperty(baseObject, exec, jsCast<NameInstance*>(subscript.asCell())->privateName());
    853839    else {
    854840        LLINT_CHECK_EXCEPTION();
    855         Identifier property = subscript.toString(exec)->toIdentifier(exec);
     841        PropertyName property = subscript.toPropertyKey(exec);
    856842        LLINT_CHECK_EXCEPTION();
    857843        couldDelete = baseObject->methodTable()->deleteProperty(baseObject, exec, property);
  • trunk/Source/JavaScriptCore/llint/LowLevelInterpreter.asm

    r178856 r179429  
    154154# Type constants.
    155155const StringType = 6
    156 const ObjectType = 17
    157 const FinalObjectType = 18
     156const ObjectType = 18
     157const FinalObjectType = 19
    158158
    159159# Type flags constants.
  • trunk/Source/JavaScriptCore/runtime/CommonIdentifiers.h

    r174066 r179429  
    5353    macro(SetIterator)\
    5454    macro(String) \
     55    macro(Symbol) \
    5556    macro(SyntaxError) \
    5657    macro(TypeError) \
     
    220221    macro(yield)
    221222
     223#define JSC_COMMON_PRIVATE_IDENTIFIERS_EACH_WELL_KNOWN_SYMBOL(macro) \
     224    macro(hasInstance) \
     225    macro(isConcatSpreadable) \
     226    macro(iterator) \
     227    macro(match) \
     228    macro(replace) \
     229    macro(search) \
     230    macro(species) \
     231    macro(split) \
     232    macro(toPrimitive) \
     233    macro(toStringTag) \
     234    macro(unscopable)
     235
    222236#define JSC_COMMON_PRIVATE_IDENTIFIERS_EACH_PROPERTY_NAME(macro) \
    223     macro(iterator) \
     237    JSC_COMMON_PRIVATE_IDENTIFIERS_EACH_WELL_KNOWN_SYMBOL(macro) \
    224238    macro(iteratorNext) \
    225239    macro(resolve) \
  • trunk/Source/JavaScriptCore/runtime/CommonSlowPaths.cpp

    r178143 r179429  
    487487    if (subscript.getUInt32(i))
    488488        couldDelete = baseObject->methodTable()->deletePropertyByIndex(baseObject, exec, i);
    489     else if (isName(subscript))
    490         couldDelete = baseObject->methodTable()->deleteProperty(baseObject, exec, jsCast<NameInstance*>(subscript.asCell())->privateName());
    491489    else {
    492490        CHECK_EXCEPTION();
    493         Identifier property = subscript.toString(exec)->toIdentifier(exec);
     491        PropertyName property = subscript.toPropertyKey(exec);
    494492        CHECK_EXCEPTION();
    495493        couldDelete = baseObject->methodTable()->deleteProperty(baseObject, exec, property);
     
    576574    JSValue property = OP(3).jsValue();
    577575    ASSERT(property.isString());
    578     RETURN(baseValue.get(exec, property.toString(exec)->toIdentifier(exec)));
     576    RETURN(baseValue.get(exec, property.toPropertyKey(exec)));
    579577}
    580578
  • trunk/Source/JavaScriptCore/runtime/CommonSlowPaths.h

    r178073 r179429  
    3131#include "ExceptionHelpers.h"
    3232#include "JSStackInlines.h"
    33 #include "NameInstance.h"
    3433#include "StackAlignment.h"
     34#include "Symbol.h"
    3535#include "VM.h"
    3636#include <wtf/StdLibExtras.h>
     
    8383        return baseObj->hasProperty(exec, i);
    8484
    85     if (isName(propName))
    86         return baseObj->hasProperty(exec, jsCast<NameInstance*>(propName.asCell())->privateName());
    87 
    88     Identifier property = propName.toString(exec)->toIdentifier(exec);
     85    PropertyName property = propName.toPropertyKey(exec);
    8986    if (exec->vm().exception())
    9087        return false;
  • trunk/Source/JavaScriptCore/runtime/ExceptionHelpers.cpp

    r173120 r179429  
    8383{
    8484   
    85     if (ident.impl()->isEmptyUnique()) {
     85    if (ident.impl()->isUnique()) {
    8686        String message(makeString("Can't find private variable: @", exec->propertyNames().getPublicName(ident).string()));
    8787        return createReferenceError(exec, message);
  • trunk/Source/JavaScriptCore/runtime/JSCJSValue.cpp

    r178928 r179429  
    100100{
    101101    if (isCell()) {
    102         ASSERT(isString());
    103         return exec->lexicalGlobalObject()->stringPrototype();
     102        if (isString())
     103            return exec->lexicalGlobalObject()->stringPrototype();
     104        ASSERT(isSymbol());
     105        return exec->lexicalGlobalObject()->symbolPrototype();
    104106    }
    105107
     
    232234                if (impl->isAtomic())
    233235                    out.print(" (identifier)");
    234                 if (impl->isEmptyUnique())
     236                if (impl->isUnique())
    235237                    out.print(" (unique)");
    236238            } else
     
    365367    if (isUndefined())
    366368        return vm.smallStrings.undefinedString();
     369    if (isSymbol()) {
     370        throwTypeError(exec);
     371        return jsEmptyString(exec);
     372    }
    367373
    368374    ASSERT(isCell());
  • trunk/Source/JavaScriptCore/runtime/JSCJSValue.h

    r176676 r179429  
    218218    bool isNumber() const;
    219219    bool isString() const;
     220    bool isSymbol() const;
    220221    bool isPrimitive() const;
    221222    bool isGetterSetter() const;
     
    243244    double toNumber(ExecState*) const;
    244245    JSString* toString(ExecState*) const;
     246    PropertyName toPropertyKey(ExecState*) const;
    245247    WTF::String toWTFString(ExecState*) const;
    246248    WTF::String toWTFStringInline(ExecState*) const;
  • trunk/Source/JavaScriptCore/runtime/JSCJSValueInlines.h

    r176676 r179429  
    2727#define JSValueInlines_h
    2828
     29#include "Identifier.h"
    2930#include "InternalFunction.h"
    3031#include "JSCJSValue.h"
     
    550551}
    551552
     553inline bool JSValue::isSymbol() const
     554{
     555    return isCell() && asCell()->isSymbol();
     556}
     557
    552558inline bool JSValue::isPrimitive() const
    553559{
    554     return !isCell() || asCell()->isString();
     560    return !isCell() || asCell()->isString() || asCell()->isSymbol();
    555561}
    556562
     
    603609    }
    604610    return false;
     611}
     612
     613ALWAYS_INLINE PropertyName JSValue::toPropertyKey(ExecState* exec) const
     614{
     615    if (isString())
     616        return asString(*this)->toIdentifier(exec);
     617
     618    JSValue primitive = toPrimitive(exec, PreferString);
     619    if (primitive.isSymbol())
     620        return asSymbol(primitive)->privateName();
     621    return primitive.toString(exec)->toIdentifier(exec);
    605622}
    606623
     
    693710    JSObject* object;
    694711    if (UNLIKELY(!isObject())) {
    695         if (isCell() && asString(*this)->getStringPropertySlot(exec, propertyName, slot))
     712        if (isString() && asString(*this)->getStringPropertySlot(exec, propertyName, slot))
    696713            return true;
    697714        object = synthesizePrototype(exec);
     
    714731    JSObject* object;
    715732    if (UNLIKELY(!isObject())) {
    716         if (isCell() && asString(*this)->getStringPropertySlot(exec, propertyName, slot))
     733        if (isString() && asString(*this)->getStringPropertySlot(exec, propertyName, slot))
    717734            return slot.getValue(exec, propertyName);
    718735        object = synthesizePrototype(exec);
     
    807824        }
    808825
     826        bool sym1 = v1.isSymbol();
     827        bool sym2 = v2.isSymbol();
     828        if (sym1 || sym2) {
     829            if (sym1 && sym2)
     830                return asSymbol(v1)->privateName() == asSymbol(v2)->privateName();
     831            return false;
     832        }
     833
    809834        if (s1 || s2) {
    810835            double d1 = v1.toNumber(exec);
     
    832857    if (v1.asCell()->isString() && v2.asCell()->isString())
    833858        return WTF::equal(*asString(v1)->value(exec).impl(), *asString(v2)->value(exec).impl());
     859    if (v1.asCell()->isSymbol() && v2.asCell()->isSymbol())
     860        return asSymbol(v1)->privateName() == asSymbol(v2)->privateName();
    834861
    835862    return v1 == v2;
  • trunk/Source/JavaScriptCore/runtime/JSCell.cpp

    r172196 r179429  
    9797void JSCell::put(JSCell* cell, ExecState* exec, PropertyName identifier, JSValue value, PutPropertySlot& slot)
    9898{
    99     if (cell->isString()) {
     99    if (cell->isString() || cell->isSymbol()) {
    100100        JSValue(cell).putToPrimitive(exec, identifier, value, slot);
    101101        return;
     
    107107void JSCell::putByIndex(JSCell* cell, ExecState* exec, unsigned identifier, JSValue value, bool shouldThrow)
    108108{
    109     if (cell->isString()) {
     109    if (cell->isString() || cell->isSymbol()) {
    110110        PutPropertySlot slot(cell, shouldThrow);
    111111        JSValue(cell).putToPrimitive(exec, Identifier::from(exec, identifier), value, slot);
     
    139139    if (isString())
    140140        return static_cast<const JSString*>(this)->toPrimitive(exec, preferredType);
     141    if (isSymbol())
     142        return static_cast<const Symbol*>(this)->toPrimitive(exec, preferredType);
    141143    return static_cast<const JSObject*>(this)->toPrimitive(exec, preferredType);
    142144}
     
    146148    if (isString())
    147149        return static_cast<const JSString*>(this)->getPrimitiveNumber(exec, number, value);
     150    if (isSymbol())
     151        return static_cast<const Symbol*>(this)->getPrimitiveNumber(exec, number, value);
    148152    return static_cast<const JSObject*>(this)->getPrimitiveNumber(exec, number, value);
    149153}
     
    153157    if (isString())
    154158        return static_cast<const JSString*>(this)->toNumber(exec);
     159    if (isSymbol())
     160        return static_cast<const Symbol*>(this)->toNumber(exec);
    155161    return static_cast<const JSObject*>(this)->toNumber(exec);
    156162}
     
    160166    if (isString())
    161167        return static_cast<const JSString*>(this)->toObject(exec, globalObject);
     168    if (isSymbol())
     169        return static_cast<const Symbol*>(this)->toObject(exec, globalObject);
    162170    ASSERT(isObject());
    163171    return jsCast<JSObject*>(const_cast<JSCell*>(this));
  • trunk/Source/JavaScriptCore/runtime/JSCell.h

    r175593 r179429  
    8686    // Querying the type.
    8787    bool isString() const;
     88    bool isSymbol() const;
    8889    bool isObject() const;
    8990    bool isGetterSetter() const;
  • trunk/Source/JavaScriptCore/runtime/JSCellInlines.h

    r173706 r179429  
    3636#include "MarkedBlock.h"
    3737#include "Structure.h"
     38#include "Symbol.h"
    3839#include <wtf/CompilationThread.h>
    3940
     
    165166}
    166167
     168inline bool JSCell::isSymbol() const
     169{
     170    return m_type == SymbolType;
     171}
     172
    167173inline bool JSCell::isGetterSetter() const
    168174{
     
    248254inline bool JSCell::toBoolean(ExecState* exec) const
    249255{
    250     if (isString()) 
     256    if (isString())
    251257        return static_cast<const JSString*>(this)->toBoolean();
     258    if (isSymbol())
     259        return static_cast<const Symbol*>(this)->toBoolean();
    252260    return !structure()->masqueradesAsUndefined(exec->lexicalGlobalObject());
    253261}
     
    255263inline TriState JSCell::pureToBoolean() const
    256264{
    257     if (isString()) 
     265    if (isString())
    258266        return static_cast<const JSString*>(this)->toBoolean() ? TrueTriState : FalseTriState;
     267    if (isSymbol())
     268        return static_cast<const Symbol*>(this)->toBoolean() ? TrueTriState : FalseTriState;
    259269    return MixedTriState;
    260270}
  • trunk/Source/JavaScriptCore/runtime/JSGlobalObject.cpp

    r178728 r179429  
    9595#include "MathObject.h"
    9696#include "Microtask.h"
    97 #include "NameConstructor.h"
    98 #include "NameInstance.h"
    99 #include "NamePrototype.h"
    10097#include "NativeErrorConstructor.h"
    10198#include "NativeErrorPrototype.h"
     
    119116#include "StringConstructor.h"
    120117#include "StringPrototype.h"
     118#include "Symbol.h"
     119#include "SymbolConstructor.h"
     120#include "SymbolPrototype.h"
    121121#include "VariableWatchpointSetInlines.h"
    122122#include "WeakMapConstructor.h"
     
    426426    putDirectWithoutTransition(vm, Identifier(exec, "console"), consoleObject, DontEnum);
    427427   
    428     if (m_experimentsEnabled) {
    429         NamePrototype* privateNamePrototype = NamePrototype::create(exec, NamePrototype::createStructure(vm, this, m_objectPrototype.get()));
    430         m_privateNameStructure.set(vm, this, NameInstance::createStructure(vm, this, privateNamePrototype));
    431        
    432         JSCell* privateNameConstructor = NameConstructor::create(vm, NameConstructor::createStructure(vm, this, m_functionPrototype.get()), privateNamePrototype);
    433         privateNamePrototype->putDirectWithoutTransition(vm, vm.propertyNames->constructor, privateNameConstructor, DontEnum);
    434         putDirectWithoutTransition(vm, Identifier(exec, "Name"), privateNameConstructor, DontEnum);
    435     }
    436    
    437428    resetPrototype(vm, prototype());
    438429}
     
    696687    visitor.append(&thisObject->m_boundFunctionStructure);
    697688    visitor.append(&thisObject->m_namedFunctionStructure);
    698     visitor.append(&thisObject->m_privateNameStructure);
     689    visitor.append(&thisObject->m_symbolObjectStructure);
    699690    visitor.append(&thisObject->m_regExpMatchesArrayStructure);
    700691    visitor.append(&thisObject->m_regExpStructure);
  • trunk/Source/JavaScriptCore/runtime/JSGlobalObject.h

    r178696 r179429  
    3636#include "StructureChain.h"
    3737#include "StructureRareDataInlines.h"
     38#include "SymbolPrototype.h"
    3839#include "VM.h"
    3940#include "Watchpoint.h"
     
    9293    macro(Date, date, date, DateInstance, Date) \
    9394    macro(String, string, stringObject, StringObject, String) \
     95    macro(Symbol, symbol, symbolObject, SymbolObject, Symbol) \
    9496    macro(Boolean, boolean, booleanObject, BooleanObject, Boolean) \
    9597    macro(Number, number, numberObject, NumberObject, Number) \
     
    394396    BooleanPrototype* booleanPrototype() const { return m_booleanPrototype.get(); }
    395397    StringPrototype* stringPrototype() const { return m_stringPrototype.get(); }
     398    SymbolPrototype* symbolPrototype() const { return m_symbolPrototype.get(); }
    396399    NumberPrototype* numberPrototype() const { return m_numberPrototype.get(); }
    397400    DatePrototype* datePrototype() const { return m_datePrototype.get(); }
     
    452455    Structure* setStructure() const { return m_setStructure.get(); }
    453456    Structure* stringObjectStructure() const { return m_stringObjectStructure.get(); }
     457    Structure* symbolObjectStructure() const { return m_symbolObjectStructure.get(); }
    454458    Structure* iteratorResultStructure() const { return m_iteratorResultStructure.get(); }
    455459    static ptrdiff_t iteratorResultStructureOffset() { return OBJECT_OFFSETOF(JSGlobalObject, m_iteratorResultStructure); }
  • trunk/Source/JavaScriptCore/runtime/JSONObject.cpp

    r173082 r179429  
    227227                if (!asObject(name)->inherits(NumberObject::info()) && !asObject(name)->inherits(StringObject::info()))
    228228                    continue;
    229             }
     229            } else if (!name.isNumber() && !name.isString())
     230                continue;
    230231
    231232            m_arrayReplacerPropertyNames.add(name.toString(exec)->toIdentifier(exec));
  • trunk/Source/JavaScriptCore/runtime/JSSymbolTableObject.cpp

    r173517 r179429  
    6262        SymbolTable::Map::iterator end = thisObject->symbolTable()->end(locker);
    6363        for (SymbolTable::Map::iterator it = thisObject->symbolTable()->begin(locker); it != end; ++it) {
    64             if (it->key->isEmptyUnique())
     64            if (it->key->isUnique())
    6565                continue;
    6666            if (!(it->value.getAttributes() & DontEnum) || shouldIncludeDontEnumProperties(mode))
  • trunk/Source/JavaScriptCore/runtime/JSType.h

    r173541 r179429  
    3434    CellType,
    3535    StringType,
     36    SymbolType,
    3637
    3738    GetterSetterType,
     
    5354    JSCalleeType,
    5455    JSFunctionType,
    55     NameInstanceType,
    5656    NumberObjectType,
    5757    ErrorInstanceType,
  • trunk/Source/JavaScriptCore/runtime/JSTypeInfo.h

    r173269 r179429  
    7878    bool isFinalObject() const { return type() == FinalObjectType; }
    7979    bool isNumberObject() const { return type() == NumberObjectType; }
    80     bool isName() const { return type() == NameInstanceType; }
    8180
    8281    unsigned flags() const { return (static_cast<unsigned>(m_flags2) << 8) | static_cast<unsigned>(m_flags); }
  • trunk/Source/JavaScriptCore/runtime/MapData.cpp

    r178224 r179429  
    6161        return &m_entries[iter->value];
    6262    }
     63    if (key.value.isSymbol()) {
     64        auto iter = m_symbolKeyedTable.find(asSymbol(key.value)->privateName().uid());
     65        if (iter == m_symbolKeyedTable.end())
     66            return 0;
     67        return &m_entries[iter->value];
     68    }
    6369    if (key.value.isCell()) {
    6470        auto iter = m_cellKeyedTable.find(key.value.asCell());
     
    108114    if (key.value.isString())
    109115        return add(callFrame, m_stringKeyedTable, asString(key.value)->value(callFrame).impl(), key);
     116    if (key.value.isSymbol())
     117        return add(callFrame, m_symbolKeyedTable, asSymbol(key.value)->privateName().uid(), key);
    110118    if (key.value.isCell())
    111119        return add(callFrame, m_cellKeyedTable, key.value.asCell(), key);
     
    129137        location = iter->value;
    130138        m_stringKeyedTable.remove(iter);
     139    }  else if (key.value.isSymbol()) {
     140        auto iter = m_symbolKeyedTable.find(asSymbol(key.value)->privateName().uid());
     141        if (iter == m_symbolKeyedTable.end())
     142            return false;
     143        location = iter->value;
     144        m_symbolKeyedTable.remove(iter);
    131145    } else if (key.value.isCell()) {
    132146        auto iter = m_cellKeyedTable.find(key.value.asCell());
     
    173187        ptr->value = m_entries[ptr->value].value.get().asInt32();
    174188    for (auto ptr = m_stringKeyedTable.begin(); ptr != m_stringKeyedTable.end(); ++ptr)
     189        ptr->value = m_entries[ptr->value].value.get().asInt32();
     190    for (auto ptr = m_symbolKeyedTable.begin(); ptr != m_symbolKeyedTable.end(); ++ptr)
    175191        ptr->value = m_entries[ptr->value].value.get().asInt32();
    176192
  • trunk/Source/JavaScriptCore/runtime/MapData.h

    r176803 r179429  
    113113    typedef HashMap<EncodedJSValue, int32_t, EncodedJSValueHash, EncodedJSValueHashTraits, IndexTraits> ValueKeyedMap;
    114114    typedef HashMap<StringImpl*, int32_t, typename WTF::DefaultHash<StringImpl*>::Hash, WTF::HashTraits<StringImpl*>, IndexTraits> StringKeyedMap;
     115    typedef HashMap<AtomicStringImpl*, int32_t, typename WTF::DefaultHash<AtomicStringImpl*>::Hash, WTF::HashTraits<AtomicStringImpl*>, IndexTraits> SymbolKeyedMap;
    115116
    116117    size_t capacityInBytes() { return m_capacity * sizeof(Entry); }
     
    135136    ValueKeyedMap m_valueKeyedTable;
    136137    StringKeyedMap m_stringKeyedTable;
     138    SymbolKeyedMap m_symbolKeyedTable;
    137139    int32_t m_capacity;
    138140    int32_t m_size;
     
    147149    m_valueKeyedTable.clear();
    148150    m_stringKeyedTable.clear();
     151    m_symbolKeyedTable.clear();
    149152    m_capacity = 0;
    150153    m_size = 0;
  • trunk/Source/JavaScriptCore/runtime/ObjectConstructor.cpp

    r173082 r179429  
    174174    if (!exec->argument(0).isObject())
    175175        return throwVMError(exec, createTypeError(exec, ASCIILiteral("Requested property descriptor of a value that is not an object.")));
    176     Identifier propertyName = exec->argument(1).toString(exec)->toIdentifier(exec);
     176    PropertyName propertyName = exec->argument(1).toPropertyKey(exec);
    177177    if (exec->hadException())
    178178        return JSValue::encode(jsNull());
     
    317317        return throwVMError(exec, createTypeError(exec, ASCIILiteral("Properties can only be defined on Objects.")));
    318318    JSObject* O = asObject(exec->argument(0));
    319     Identifier propertyName = exec->argument(1).toString(exec)->toIdentifier(exec);
     319    PropertyName propertyName = exec->argument(1).toPropertyKey(exec);
    320320    if (exec->hadException())
    321321        return JSValue::encode(jsNull());
  • trunk/Source/JavaScriptCore/runtime/ObjectPrototype.cpp

    r177030 r179429  
    8686{
    8787    JSValue thisValue = exec->thisValue().toThis(exec, StrictMode);
    88     return JSValue::encode(jsBoolean(thisValue.toObject(exec)->hasOwnProperty(exec, exec->argument(0).toString(exec)->toIdentifier(exec))));
     88    return JSValue::encode(jsBoolean(thisValue.toObject(exec)->hasOwnProperty(exec, exec->argument(0).toPropertyKey(exec))));
    8989}
    9090
     
    123123    descriptor.setEnumerable(true);
    124124    descriptor.setConfigurable(true);
    125     thisObject->methodTable(exec->vm())->defineOwnProperty(thisObject, exec, exec->argument(0).toString(exec)->toIdentifier(exec), descriptor, false);
     125    thisObject->methodTable(exec->vm())->defineOwnProperty(thisObject, exec, exec->argument(0).toPropertyKey(exec), descriptor, false);
    126126
    127127    return JSValue::encode(jsUndefined());
     
    143143    descriptor.setEnumerable(true);
    144144    descriptor.setConfigurable(true);
    145     thisObject->methodTable(exec->vm())->defineOwnProperty(thisObject, exec, exec->argument(0).toString(exec)->toIdentifier(exec), descriptor, false);
     145    thisObject->methodTable(exec->vm())->defineOwnProperty(thisObject, exec, exec->argument(0).toPropertyKey(exec), descriptor, false);
    146146
    147147    return JSValue::encode(jsUndefined());
     
    155155
    156156    PropertySlot slot(thisObject);
    157     if (thisObject->getPropertySlot(exec, exec->argument(0).toString(exec)->toIdentifier(exec), slot)
     157    if (thisObject->getPropertySlot(exec, exec->argument(0).toPropertyKey(exec), slot)
    158158        && slot.isAccessor()) {
    159159        GetterSetter* getterSetter = slot.getterSetter();
     
    171171
    172172    PropertySlot slot(thisObject);
    173     if (thisObject->getPropertySlot(exec, exec->argument(0).toString(exec)->toIdentifier(exec), slot)
     173    if (thisObject->getPropertySlot(exec, exec->argument(0).toPropertyKey(exec), slot)
    174174        && slot.isAccessor()) {
    175175        GetterSetter* getterSetter = slot.getterSetter();
     
    183183{
    184184    JSObject* thisObject = exec->thisValue().toThis(exec, StrictMode).toObject(exec);
    185     Identifier propertyName = exec->argument(0).toString(exec)->toIdentifier(exec);
     185    PropertyName propertyName = exec->argument(0).toPropertyKey(exec);
    186186
    187187    PropertyDescriptor descriptor;
  • trunk/Source/JavaScriptCore/runtime/Operations.cpp

    r164764 r179429  
    6666    if (v.isString())
    6767        return vm.smallStrings.stringString();
     68    if (v.isSymbol())
     69        return vm.smallStrings.symbolString();
    6870    if (v.isObject()) {
    6971        // Return "undefined" for objects that should be treated
     
    9092
    9193    JSType type = v.asCell()->type();
    92     if (type == StringType)
     94    if (type == StringType || type == SymbolType)
    9395        return false;
    9496    if (type >= ObjectType) {
  • trunk/Source/JavaScriptCore/runtime/PrivateName.h

    r176622 r179429  
    3434public:
    3535    PrivateName()
    36         : m_impl(StringImpl::createEmptyUnique())
     36        : m_impl(StringImpl::createUniqueEmpty())
    3737    {
     38        ASSERT(m_impl->isUnique());
     39    }
     40    PrivateName(const String& description)
     41        : m_impl(StringImpl::createUnique(description.impl()))
     42    {
     43        ASSERT(m_impl->isUnique());
    3844    }
    3945    explicit PrivateName(StringImpl* uid)
    4046        : m_impl(uid)
    4147    {
    42         ASSERT(m_impl->isEmptyUnique());
     48        ASSERT(m_impl->isUnique());
    4349    }
    4450
    4551    AtomicStringImpl* uid() const { return static_cast<AtomicStringImpl*>(m_impl.get()); }
     52
     53    bool operator==(const PrivateName& other) const { return uid() == other.uid(); }
     54    bool operator!=(const PrivateName& other) const { return uid() != other.uid(); }
    4655
    4756private:
  • trunk/Source/JavaScriptCore/runtime/PropertyMapHashTable.h

    r177222 r179429  
    272272{
    273273    ASSERT(key);
    274     ASSERT(key->isAtomic() || key->isEmptyUnique());
     274    ASSERT(key->isAtomic() || key->isUnique());
    275275    unsigned hash = key->existingHash();
    276276    unsigned step = 0;
     
    306306{
    307307    ASSERT(key);
    308     ASSERT(key->isAtomic() || key->isEmptyUnique());
     308    ASSERT(key->isAtomic() || key->isUnique());
    309309
    310310    if (!m_keyCount)
  • trunk/Source/JavaScriptCore/runtime/PropertyName.h

    r178928 r179429  
    9494    {
    9595        ASSERT(m_impl);
    96         ASSERT(m_impl->isEmptyUnique());
     96        ASSERT(m_impl->isUnique());
    9797        ASSERT(m_impl->isAtomic());
    9898    }
     
    105105    AtomicStringImpl* publicName() const
    106106    {
    107         return m_impl->isEmptyUnique() ? nullptr : m_impl;
     107        return m_impl->isUnique() ? nullptr : m_impl;
    108108    }
    109109
  • trunk/Source/JavaScriptCore/runtime/SmallStrings.h

    r178984 r179429  
    3939    macro(undefined) \
    4040    macro(string) \
     41    macro(symbol) \
    4142    macro(true)
    4243
  • trunk/Source/JavaScriptCore/runtime/StringConstructor.cpp

    r171824 r179429  
    111111    if (!exec->argumentCount())
    112112        return JSValue::encode(jsEmptyString(exec));
    113     return JSValue::encode(exec->uncheckedArgument(0).toString(exec));
     113    JSValue argument = exec->uncheckedArgument(0);
     114    if (argument.isSymbol())
     115        return JSValue::encode(jsString(exec, asSymbol(argument)->descriptiveString()));
     116    return JSValue::encode(argument.toString(exec));
    114117}
    115118
  • trunk/Source/JavaScriptCore/runtime/Structure.cpp

    r178928 r179429  
    948948    for (PropertyTable::iterator iter = propertyTable()->begin(); iter != end; ++iter) {
    949949        ASSERT(hasNonEnumerableProperties() || !(iter->attributes & DontEnum));
    950         if (!iter->key->isEmptyUnique() && (!(iter->attributes & DontEnum) || shouldIncludeDontEnumProperties(mode))) {
     950        if (!iter->key->isUnique() && (!(iter->attributes & DontEnum) || shouldIncludeDontEnumProperties(mode))) {
    951951            if (knownUnique)
    952952                propertyNames.addKnownUnique(iter->key);
  • trunk/Source/JavaScriptCore/runtime/StructureInlines.h

    r176583 r179429  
    169169    if (isObject())
    170170        return m_prototype.get();
     171    if (typeInfo().type() == SymbolType)
     172        return globalObject->symbolPrototype();
    171173
    172174    ASSERT(typeInfo().type() == StringType);
  • trunk/Source/JavaScriptCore/runtime/SymbolConstructor.cpp

    r179427 r179429  
    11/*
    22 * Copyright (C) 2012 Apple Inc. All rights reserved.
     3 * Copyright (C) 2015 Yusuke Suzuki <utatane.tea@gmail.com>.
    34 *
    45 * Redistribution and use in source and binary forms, with or without
     
    2526
    2627#include "config.h"
    27 #include "NameConstructor.h"
     28#include "SymbolConstructor.h"
    2829
     30#include "Error.h"
     31#include "JSCInlines.h"
    2932#include "JSGlobalObject.h"
    30 #include "NamePrototype.h"
    31 #include "JSCInlines.h"
     33#include "SymbolPrototype.h"
    3234
    3335namespace JSC {
    3436
    35 STATIC_ASSERT_IS_TRIVIALLY_DESTRUCTIBLE(NameConstructor);
     37STATIC_ASSERT_IS_TRIVIALLY_DESTRUCTIBLE(SymbolConstructor);
    3638
    37 const ClassInfo NameConstructor::s_info = { "Function", &Base::s_info, 0, CREATE_METHOD_TABLE(NameConstructor) };
     39const ClassInfo SymbolConstructor::s_info = { "Function", &Base::s_info, 0, CREATE_METHOD_TABLE(SymbolConstructor) };
    3840
    39 NameConstructor::NameConstructor(VM& vm, Structure* structure)
     41SymbolConstructor::SymbolConstructor(VM& vm, Structure* structure)
    4042    : InternalFunction(vm, structure)
    4143{
    4244}
    4345
    44 void NameConstructor::finishCreation(VM& vm, NamePrototype* prototype)
     46#define INITIALIZE_WELL_KNOWN_SYMBOLS(name) \
     47    putDirectWithoutTransition(vm, Identifier(&vm, #name), Symbol::create(vm, vm.propertyNames->name##PrivateName.impl()), DontEnum | DontDelete | ReadOnly);
     48
     49void SymbolConstructor::finishCreation(VM& vm, SymbolPrototype* prototype)
    4550{
    4651    Base::finishCreation(vm, prototype->classInfo()->className);
    4752    putDirectWithoutTransition(vm, vm.propertyNames->prototype, prototype, DontEnum | DontDelete | ReadOnly);
    48     putDirectWithoutTransition(vm, vm.propertyNames->length, jsNumber(1), DontDelete | ReadOnly | DontEnum);
     53    putDirectWithoutTransition(vm, vm.propertyNames->length, jsNumber(0), DontDelete | ReadOnly | DontEnum);
     54
     55    JSC_COMMON_PRIVATE_IDENTIFIERS_EACH_WELL_KNOWN_SYMBOL(INITIALIZE_WELL_KNOWN_SYMBOLS)
    4956}
    5057
    51 static EncodedJSValue JSC_HOST_CALL constructPrivateName(ExecState* exec)
     58static EncodedJSValue JSC_HOST_CALL callSymbol(ExecState* exec)
    5259{
    53     JSValue publicName = exec->argument(0);
    54     return JSValue::encode(NameInstance::create(exec->vm(), exec->lexicalGlobalObject()->privateNameStructure(), publicName.toString(exec)));
     60    JSValue description = exec->argument(0);
     61    if (description.isUndefined())
     62        return JSValue::encode(Symbol::create(exec->vm()));
     63    return JSValue::encode(Symbol::create(exec, description.toString(exec)));
    5564}
    5665
    57 ConstructType NameConstructor::getConstructData(JSCell*, ConstructData& constructData)
     66ConstructType SymbolConstructor::getConstructData(JSCell*, ConstructData&)
    5867{
    59     constructData.native.function = constructPrivateName;
    60     return ConstructTypeHost;
     68    return ConstructTypeNone;
    6169}
    6270
    63 CallType NameConstructor::getCallData(JSCell*, CallData& callData)
     71CallType SymbolConstructor::getCallData(JSCell*, CallData& callData)
    6472{
    65     callData.native.function = constructPrivateName;
     73    callData.native.function = callSymbol;
    6674    return CallTypeHost;
    6775}
  • trunk/Source/JavaScriptCore/runtime/SymbolConstructor.h

    r179427 r179429  
    11/*
    22 * Copyright (C) 2012 Apple Inc. All rights reserved.
     3 * Copyright (C) 2015 Yusuke Suzuki <utatane.tea@gmail.com>.
    34 *
    45 * Redistribution and use in source and binary forms, with or without
     
    2425 */
    2526
    26 #ifndef NameConstructor_h
    27 #define NameConstructor_h
     27#ifndef SymbolConstructor_h
     28#define SymbolConstructor_h
    2829
    2930#include "InternalFunction.h"
    30 #include "NameInstance.h"
     31#include "Symbol.h"
    3132
    3233namespace JSC {
    3334
    34 class NamePrototype;
     35class SymbolPrototype;
    3536
    36 class NameConstructor : public InternalFunction {
     37class SymbolConstructor : public InternalFunction {
    3738public:
    3839    typedef InternalFunction Base;
    3940
    40     static NameConstructor* create(VM& vm, Structure* structure, NamePrototype* prototype)
     41    static SymbolConstructor* create(VM& vm, Structure* structure, SymbolPrototype* prototype)
    4142    {
    42         NameConstructor* constructor = new (NotNull, allocateCell<NameConstructor>(vm.heap)) NameConstructor(vm, structure);
     43        SymbolConstructor* constructor = new (NotNull, allocateCell<SymbolConstructor>(vm.heap)) SymbolConstructor(vm, structure);
    4344        constructor->finishCreation(vm, prototype);
    4445        return constructor;
     
    4748    DECLARE_INFO;
    4849
    49     static Structure* createStructure(VM& vm, JSGlobalObject* globalObject, JSValue prototype) 
    50     { 
    51         return Structure::create(vm, globalObject, prototype, TypeInfo(ObjectType, StructureFlags), info()); 
     50    static Structure* createStructure(VM& vm, JSGlobalObject* globalObject, JSValue prototype)
     51    {
     52        return Structure::create(vm, globalObject, prototype, TypeInfo(ObjectType, StructureFlags), info());
    5253    }
    5354
    5455protected:
    55     void finishCreation(VM&, NamePrototype*);
    56    
     56    void finishCreation(VM&, SymbolPrototype*);
     57
    5758private:
    58     NameConstructor(VM&, Structure*);
     59    SymbolConstructor(VM&, Structure*);
    5960    static ConstructType getConstructData(JSCell*, ConstructData&);
    6061    static CallType getCallData(JSCell*, CallData&);
     
    6364} // namespace JSC
    6465
    65 #endif // NameConstructor_h
     66#endif // SymbolConstructor_h
  • trunk/Source/JavaScriptCore/runtime/SymbolObject.cpp

    r179427 r179429  
    11/*
    22 * Copyright (C) 2012 Apple Inc. All rights reserved.
     3 * Copyright (C) 2015 Yusuke Suzuki <utatane.tea@gmail.com>.
    34 *
    45 * Redistribution and use in source and binary forms, with or without
     
    2526
    2627#include "config.h"
    27 #include "NameInstance.h"
     28#include "SymbolObject.h"
    2829
    29 #include "JSScope.h"
    3030#include "JSCInlines.h"
    3131
    3232namespace JSC {
    3333
    34 const ClassInfo NameInstance::s_info = { "Name", &Base::s_info, 0, CREATE_METHOD_TABLE(NameInstance) };
     34STATIC_ASSERT_IS_TRIVIALLY_DESTRUCTIBLE(SymbolObject);
    3535
    36 NameInstance::NameInstance(VM& vm, Structure* structure, JSString* nameString)
    37     : Base(vm, structure)
     36const ClassInfo SymbolObject::s_info = { "Symbol", &JSWrapperObject::s_info, nullptr, CREATE_METHOD_TABLE(SymbolObject) };
     37
     38SymbolObject::SymbolObject(VM& vm, Structure* structure)
     39    : JSWrapperObject(vm, structure)
    3840{
    39     m_nameString.set(vm, this, nameString);
    4041}
    4142
    42 void NameInstance::destroy(JSCell* cell)
     43void SymbolObject::finishCreation(VM& vm, Symbol* symbol)
    4344{
    44     static_cast<NameInstance*>(cell)->NameInstance::~NameInstance();
     45    Base::finishCreation(vm);
     46    ASSERT(inherits(info()));
     47    setInternalValue(vm, symbol);
     48}
     49
     50JSValue SymbolObject::defaultValue(const JSObject* object, ExecState*, PreferredPrimitiveType)
     51{
     52    const SymbolObject* symbolObject = jsCast<const SymbolObject*>(object);
     53    return symbolObject->internalValue();
    4554}
    4655
  • trunk/Source/JavaScriptCore/runtime/SymbolPrototype.h

    r179427 r179429  
    11/*
    22 * Copyright (C) 2012 Apple Inc. All rights reserved.
     3 * Copyright (C) 2015 Yusuke Suzuki <utatane.tea@gmail.com>.
    34 *
    45 * Redistribution and use in source and binary forms, with or without
     
    2425 */
    2526
    26 #ifndef NamePrototype_h
    27 #define NamePrototype_h
     27#ifndef SymbolPrototype_h
     28#define SymbolPrototype_h
    2829
    29 #include "NameInstance.h"
     30#include "Symbol.h"
     31#include "SymbolObject.h"
    3032
    3133namespace JSC {
    3234
    33 class NamePrototype : public NameInstance {
     35// In the ES6 spec, Symbol.prototype object is an ordinary JS object, not one of the symbol wrapper object instance.
     36class SymbolPrototype : public JSDestructibleObject {
    3437public:
    35     typedef NameInstance Base;
     38    typedef JSDestructibleObject Base;
    3639
    37     static NamePrototype* create(ExecState* exec, Structure* structure)
     40    static SymbolPrototype* create(VM& vm, JSGlobalObject*, Structure* structure)
    3841    {
    39         VM& vm = exec->vm();
    40         NamePrototype* prototype = new (NotNull, allocateCell<NamePrototype>(vm.heap)) NamePrototype(exec, structure);
     42        SymbolPrototype* prototype = new (NotNull, allocateCell<SymbolPrototype>(vm.heap)) SymbolPrototype(vm, structure);
    4143        prototype->finishCreation(vm);
    4244        return prototype;
    4345    }
    44    
     46
    4547    DECLARE_INFO;
    4648
    4749    static Structure* createStructure(VM& vm, JSGlobalObject* globalObject, JSValue prototype)
    4850    {
    49         return Structure::create(vm, globalObject, prototype, TypeInfo(NameInstanceType, StructureFlags), info());
     51        return Structure::create(vm, globalObject, prototype, TypeInfo(ObjectType, StructureFlags), info());
    5052    }
    5153
    5254protected:
    53     NamePrototype(ExecState*, Structure*);
     55    SymbolPrototype(VM&, Structure*);
    5456    void finishCreation(VM&);
    5557
    56     static const unsigned StructureFlags = OverridesGetOwnPropertySlot | NameInstance::StructureFlags;
     58    static const unsigned StructureFlags = OverridesGetOwnPropertySlot | Base::StructureFlags;
    5759
    5860private:
     
    6264} // namespace JSC
    6365
    64 #endif // NamePrototype_h
     66#endif // SymbolPrototype_h
  • trunk/Source/JavaScriptCore/runtime/VM.cpp

    r179392 r179429  
    221221    functionExecutableStructure.set(*this, FunctionExecutable::createStructure(*this, 0, jsNull()));
    222222    regExpStructure.set(*this, RegExp::createStructure(*this, 0, jsNull()));
     223    symbolStructure.set(*this, Symbol::createStructure(*this, 0, jsNull()));
    223224    symbolTableStructure.set(*this, SymbolTable::createStructure(*this, 0, jsNull()));
    224225    structureChainStructure.set(*this, StructureChain::createStructure(*this, 0, jsNull()));
  • trunk/Source/JavaScriptCore/runtime/VM.h

    r179392 r179429  
    265265    Strong<Structure> functionExecutableStructure;
    266266    Strong<Structure> regExpStructure;
     267    Strong<Structure> symbolStructure;
    267268    Strong<Structure> symbolTableStructure;
    268269    Strong<Structure> structureChainStructure;
  • trunk/Source/WTF/ChangeLog

    r179426 r179429  
     12015-01-30  Yusuke Suzuki  <utatane.tea@gmail.com>
     2
     3        Implement ES6 Symbol
     4        https://bugs.webkit.org/show_bug.cgi?id=140435
     5
     6        Reviewed by Geoffrey Garen.
     7
     8        Introduce new unique string mechanizm into StringImpl.
     9        It is used for implementing Symbol which holds a [[Description]] value.
     10
     11        * wtf/text/AtomicString.h:
     12        (WTF::AtomicString::add):
     13        (WTF::AtomicString::addWithStringTableProvider):
     14
     15        Previously, we checked `isAtomic()` or `!length()`. This guard can filter out EmptyUnique.
     16        But now, we introduced new unique StringImpl. Since it has an actual string value, we need to check `isUnique()`.
     17
     18        * wtf/text/StringImpl.cpp:
     19        (WTF::StringImpl::~StringImpl):
     20        (WTF::StringImpl::createUnique):
     21
     22        In createUnique, we leverage Substring mechanizm to produce a new unique
     23        string from an existing string.
     24
     25        * wtf/text/StringImpl.h:
     26        (WTF::StringImpl::StringImpl):
     27        (WTF::StringImpl::createUniqueEmpty):
     28        (WTF::StringImpl::flagIsUnique):
     29        (WTF::StringImpl::isUnique):
     30        (WTF::StringImpl::setIsAtomic):
     31        (WTF::StringImpl::createEmptyUnique): Deleted.
     32        (WTF::StringImpl::isEmptyUnique): Deleted.
     33
     34        Instead of EmptyUnique, we introduced new flag to StringImpl, `isUnique`.
     35        While EmptyUnique cannot hold any string values except for empty string,
     36        the unique StringImpl can hold any String values.
     37        We fold the Symbol's descriptiveString value here.
     38
     39        * wtf/text/StringStatics.cpp:
     40        (WTF::StringImpl::hashAndFlagsForUnique):
     41        (WTF::StringImpl::hashAndFlagsForEmptyUnique): Deleted.
     42
    1432015-01-30  Geoffrey Garen  <ggaren@apple.com>
    244
  • trunk/Source/WTF/wtf/text/AtomicString.h

    r177259 r179429  
    185185    {
    186186        if (!string || string->isAtomic()) {
    187             ASSERT_WITH_MESSAGE(!string || !string->length() || isInAtomicStringTable(string), "The atomic string comes from an other thread!");
     187            ASSERT_WITH_MESSAGE(!string || !string->length() || string->isUnique() || isInAtomicStringTable(string), "The atomic string comes from an other thread!");
    188188            return string;
    189189        }
     
    199199    {
    200200        if (!string || string->isAtomic()) {
    201             ASSERT_WITH_MESSAGE(!string || !string->length() || isInAtomicStringTable(string), "The atomic string comes from an other thread!");
     201            ASSERT_WITH_MESSAGE(!string || !string->length() || string->isUnique() || isInAtomicStringTable(string), "The atomic string comes from an other thread!");
    202202            return string;
    203203        }
  • trunk/Source/WTF/wtf/text/StringImpl.cpp

    r177860 r179429  
    110110    STRING_STATS_REMOVE_STRING(*this);
    111111
    112     if (isAtomic() && m_length)
     112    if (isAtomic() && length() && !isUnique())
    113113        AtomicString::remove(this);
    114114
     
    285285        CRASH();
    286286    return create(string, length);
     287}
     288
     289Ref<StringImpl> StringImpl::createUnique(PassRefPtr<StringImpl> rep)
     290{
     291    unsigned length = rep->length();
     292    if (!length)
     293        return createUniqueEmpty();
     294    Ref<StringImpl> string = createSubstringSharingImpl(rep, 0, length);
     295    string->m_hashAndFlags = hashAndFlagsForUnique(string->m_hashAndFlags);
     296    return string;
    287297}
    288298
  • trunk/Source/WTF/wtf/text/StringImpl.h

    r177860 r179429  
    281281        // to represent a null terminated buffer.
    282282        , m_data8(reinterpret_cast<const LChar*>(&m_length))
    283         , m_hashAndFlags(hashAndFlagsForEmptyUnique())
     283        , m_hashAndFlags(hashAndFlagsForUnique(s_hashFlag8BitBuffer | BufferInternal))
    284284    {
    285285        ASSERT(m_data8);
     
    379379    }
    380380
    381     static Ref<StringImpl> createEmptyUnique()
     381    ALWAYS_INLINE static Ref<StringImpl> createUniqueEmpty()
    382382    {
    383383        return adoptRef(*new StringImpl(CreateEmptyUnique));
    384384    }
     385
     386    WTF_EXPORT_STRING_API static Ref<StringImpl> createUnique(PassRefPtr<StringImpl> rep);
    385387
    386388    // Reallocate the StringImpl. The originalString must be only owned by the PassRefPtr,
     
    393395    static unsigned flagIs8Bit() { return s_hashFlag8BitBuffer; }
    394396    static unsigned flagIsAtomic() { return s_hashFlagIsAtomic; }
     397    static unsigned flagIsUnique() { return s_hashFlagIsUnique; }
    395398    static unsigned dataOffset() { return OBJECT_OFFSETOF(StringImpl, m_data8); }
    396399
     
    452455    WTF_EXPORT_STRING_API size_t sizeInBytes() const;
    453456
    454     bool isEmptyUnique() const
    455     {
    456         return !length() && !isStatic();
    457     }
     457    bool isUnique() const { return m_hashAndFlags & s_hashFlagIsUnique; }
    458458
    459459    bool isAtomic() const { return m_hashAndFlags & s_hashFlagIsAtomic; }
     
    461461    {
    462462        ASSERT(!isStatic());
    463         ASSERT(!isEmptyUnique());
     463        ASSERT(!isUnique());
    464464        if (isAtomic)
    465465            m_hashAndFlags |= s_hashFlagIsAtomic;
     
    773773    template <typename CharType> static Ref<StringImpl> createInternal(const CharType*, unsigned);
    774774    WTF_EXPORT_PRIVATE NEVER_INLINE unsigned hashSlowCase() const;
    775     WTF_EXPORT_PRIVATE unsigned hashAndFlagsForEmptyUnique();
     775    WTF_EXPORT_PRIVATE static unsigned hashAndFlagsForUnique(unsigned flags);
    776776
    777777    // The bottom bit in the ref count indicates a static (immortal) string.
     
    779779    static const unsigned s_refCountIncrement = 0x2; // This allows us to ref / deref without disturbing the static string flag.
    780780
    781     // The bottom 6 bits in the hash are flags.
    782     static const unsigned s_flagCount = 6;
     781    // The bottom 7 bits in the hash are flags.
     782    static const unsigned s_flagCount = 7;
    783783    static const unsigned s_flagMask = (1u << s_flagCount) - 1;
    784784    COMPILE_ASSERT(s_flagCount <= StringHasher::flagCount, StringHasher_reserves_enough_bits_for_StringImpl_flags);
    785785
     786    static const unsigned s_hashFlagIsUnique = 1u << 6;
    786787    static const unsigned s_hashFlag8BitBuffer = 1u << 5;
    787788    static const unsigned s_hashFlagIsAtomic = 1u << 4;
  • trunk/Source/WTF/wtf/text/StringStatics.cpp

    r167508 r179429  
    4848}
    4949
    50 // Set the hash early, so that all empty unique StringImpls have a hash,
     50// Set the hash early, so that all unique StringImpls have a hash,
    5151// and don't use the normal hashing algorithm - the unique nature of these
    5252// keys means that we don't need them to match any other string (in fact,
    5353// that's exactly the oposite of what we want!), and the normal hash would
    5454// lead to lots of conflicts.
    55 unsigned StringImpl::hashAndFlagsForEmptyUnique()
     55unsigned StringImpl::hashAndFlagsForUnique(unsigned flags)
    5656{
    57     static unsigned s_nextHashAndFlagsForEmptyUnique = BufferInternal | s_hashFlag8BitBuffer | s_hashFlagIsAtomic;
    58     s_nextHashAndFlagsForEmptyUnique += 1 << s_flagCount;
    59     s_nextHashAndFlagsForEmptyUnique |= 1 << 31;
    60     return s_nextHashAndFlagsForEmptyUnique;
     57    static unsigned s_nextHashAndFlagsForUnique = 0;
     58    s_nextHashAndFlagsForUnique += 1 << s_flagCount;
     59    s_nextHashAndFlagsForUnique |= 1 << 31;
     60    unsigned flagsForUnique = (flags & s_flagMask) | s_hashFlagIsAtomic | s_hashFlagIsUnique;
     61    return s_nextHashAndFlagsForUnique | flagsForUnique;
    6162}
    6263
Note: See TracChangeset for help on using the changeset viewer.