Skip to content
This repository has been archived by the owner on Oct 15, 2020. It is now read-only.

Commit

Permalink
[Merge chakra-core/ChakraCore@36fc51b58f] [1.6>1.7] [MERGE #3412 @cur…
Browse files Browse the repository at this point in the history
…tisman] Fix Issue #3368:  Symbol.species.toString() shouldn't have bracket around the name

Merge pull request #3412 from curtisman:fix3368
  • Loading branch information
chakrabot committed Jul 22, 2017
1 parent ca69080 commit 79c597e
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 48 deletions.
2 changes: 1 addition & 1 deletion deps/chakrashim/core/lib/Runtime/Base/JnDirectFields.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ ENTRY_SYMBOL(_symbolMatch, _u("Symbol.match"))
ENTRY_SYMBOL(_symbolReplace, _u("Symbol.replace"))
ENTRY_SYMBOL(_symbolSearch, _u("Symbol.search"))
ENTRY_SYMBOL(_symbolSplit, _u("Symbol.split"))
ENTRY_SYMBOL(_symbolSpecies, _u("[Symbol.species]"))
ENTRY_SYMBOL(_symbolSpecies, _u("Symbol.species"))
ENTRY_SYMBOL(_symbolToPrimitive, _u("Symbol.toPrimitive"))
ENTRY_SYMBOL(_symbolToStringTag, _u("Symbol.toStringTag"))
ENTRY_SYMBOL(_symbolUnscopables, _u("Symbol.unscopables"))
Expand Down
51 changes: 16 additions & 35 deletions deps/chakrashim/core/lib/Runtime/Library/JavascriptLibrary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1640,10 +1640,7 @@ namespace Js

library->AddMember(arrayConstructor, PropertyIds::length, TaggedInt::ToVarUnchecked(1), PropertyNone);
library->AddMember(arrayConstructor, PropertyIds::prototype, scriptContext->GetLibrary()->arrayPrototype, PropertyNone);
if (scriptContext->GetConfig()->IsES6SpeciesEnabled())
{
library->AddAccessorsToLibraryObject(arrayConstructor, PropertyIds::_symbolSpecies, &JavascriptArray::EntryInfo::GetterSymbolSpecies, nullptr);
}
library->AddSpeciesAccessorsToLibraryObject(arrayConstructor, &JavascriptArray::EntryInfo::GetterSymbolSpecies);

if (scriptContext->GetConfig()->IsES6FunctionNameEnabled())
{
Expand Down Expand Up @@ -1807,8 +1804,7 @@ namespace Js
JavascriptLibrary* library = sharedArrayBufferConstructor->GetLibrary();
library->AddMember(sharedArrayBufferConstructor, PropertyIds::length, TaggedInt::ToVarUnchecked(1), PropertyNone);
library->AddMember(sharedArrayBufferConstructor, PropertyIds::prototype, scriptContext->GetLibrary()->sharedArrayBufferPrototype, PropertyNone);

library->AddAccessorsToLibraryObject(sharedArrayBufferConstructor, PropertyIds::_symbolSpecies, &SharedArrayBuffer::EntryInfo::GetterSymbolSpecies, nullptr);
library->AddSpeciesAccessorsToLibraryObject(sharedArrayBufferConstructor, &SharedArrayBuffer::EntryInfo::GetterSymbolSpecies);

if (scriptContext->GetConfig()->IsES6FunctionNameEnabled())
{
Expand Down Expand Up @@ -1877,11 +1873,7 @@ namespace Js
JavascriptLibrary* library = arrayBufferConstructor->GetLibrary();
library->AddMember(arrayBufferConstructor, PropertyIds::length, TaggedInt::ToVarUnchecked(1), PropertyNone);
library->AddMember(arrayBufferConstructor, PropertyIds::prototype, scriptContext->GetLibrary()->arrayBufferPrototype, PropertyNone);

if (scriptContext->GetConfig()->IsES6SpeciesEnabled())
{
library->AddAccessorsToLibraryObject(arrayBufferConstructor, PropertyIds::_symbolSpecies, &ArrayBuffer::EntryInfo::GetterSymbolSpecies, nullptr);
}
library->AddSpeciesAccessorsToLibraryObject(arrayBufferConstructor, &ArrayBuffer::EntryInfo::GetterSymbolSpecies);

if (scriptContext->GetConfig()->IsES6FunctionNameEnabled())
{
Expand Down Expand Up @@ -1991,10 +1983,7 @@ namespace Js

library->AddFunctionToLibraryObject(typedArrayConstructor, PropertyIds::from, &TypedArrayBase::EntryInfo::From, 1);
library->AddFunctionToLibraryObject(typedArrayConstructor, PropertyIds::of, &TypedArrayBase::EntryInfo::Of, 0);
if (scriptContext->GetConfig()->IsES6SpeciesEnabled())
{
library->AddAccessorsToLibraryObject(typedArrayConstructor, PropertyIds::_symbolSpecies, &TypedArrayBase::EntryInfo::GetterSymbolSpecies, nullptr);
}
library->AddSpeciesAccessorsToLibraryObject(typedArrayConstructor, &TypedArrayBase::EntryInfo::GetterSymbolSpecies);

typedArrayConstructor->SetHasNoEnumerableProperties(true);

Expand Down Expand Up @@ -2352,11 +2341,7 @@ namespace Js
ScriptContext* scriptContext = promiseConstructor->GetScriptContext();
library->AddMember(promiseConstructor, PropertyIds::length, TaggedInt::ToVarUnchecked(1), PropertyNone);
library->AddMember(promiseConstructor, PropertyIds::prototype, library->promisePrototype, PropertyNone);

if (scriptContext->GetConfig()->IsES6SpeciesEnabled())
{
library->AddAccessorsToLibraryObject(promiseConstructor, PropertyIds::_symbolSpecies, &JavascriptPromise::EntryInfo::GetterSymbolSpecies, nullptr);
}
library->AddSpeciesAccessorsToLibraryObject(promiseConstructor, &JavascriptPromise::EntryInfo::GetterSymbolSpecies);

if (scriptContext->GetConfig()->IsES6FunctionNameEnabled())
{
Expand Down Expand Up @@ -4425,11 +4410,7 @@ namespace Js
// so that the update is in sync with profiler
library->AddMember(regexConstructor, PropertyIds::length, TaggedInt::ToVarUnchecked(2), PropertyNone);
library->AddMember(regexConstructor, PropertyIds::prototype, library->regexPrototype, PropertyNone);

if (scriptContext->GetConfig()->IsES6SpeciesEnabled())
{
library->AddAccessorsToLibraryObject(regexConstructor, PropertyIds::_symbolSpecies, &JavascriptRegExp::EntryInfo::GetterSymbolSpecies, nullptr);
}
library->AddSpeciesAccessorsToLibraryObject(regexConstructor, &JavascriptRegExp::EntryInfo::GetterSymbolSpecies);

if (scriptContext->GetConfig()->IsES6FunctionNameEnabled())
{
Expand Down Expand Up @@ -4657,11 +4638,7 @@ namespace Js
ScriptContext* scriptContext = mapConstructor->GetScriptContext();
library->AddMember(mapConstructor, PropertyIds::length, TaggedInt::ToVarUnchecked(0), PropertyNone);
library->AddMember(mapConstructor, PropertyIds::prototype, library->mapPrototype, PropertyNone);

if (scriptContext->GetConfig()->IsES6SpeciesEnabled())
{
library->AddAccessorsToLibraryObject(mapConstructor, PropertyIds::_symbolSpecies, &JavascriptMap::EntryInfo::GetterSymbolSpecies, nullptr);
}
library->AddSpeciesAccessorsToLibraryObject(mapConstructor, &JavascriptMap::EntryInfo::GetterSymbolSpecies);

if (scriptContext->GetConfig()->IsES6FunctionNameEnabled())
{
Expand Down Expand Up @@ -4716,11 +4693,7 @@ namespace Js
ScriptContext* scriptContext = setConstructor->GetScriptContext();
library->AddMember(setConstructor, PropertyIds::length, TaggedInt::ToVarUnchecked(0), PropertyNone);
library->AddMember(setConstructor, PropertyIds::prototype, library->setPrototype, PropertyNone);

if (scriptContext->GetConfig()->IsES6SpeciesEnabled())
{
library->AddAccessorsToLibraryObject(setConstructor, PropertyIds::_symbolSpecies, &JavascriptSet::EntryInfo::GetterSymbolSpecies, nullptr);
}
library->AddSpeciesAccessorsToLibraryObject(setConstructor, &JavascriptSet::EntryInfo::GetterSymbolSpecies);

if (scriptContext->GetConfig()->IsES6FunctionNameEnabled())
{
Expand Down Expand Up @@ -5145,6 +5118,14 @@ namespace Js
AddAccessorsToLibraryObject(object, propertyId, getterFunction, setterFunction);
}

void JavascriptLibrary::AddSpeciesAccessorsToLibraryObject(DynamicObject* object, FunctionInfo * getterFunctionInfo)
{
if (scriptContext->GetConfig()->IsES6SpeciesEnabled())
{
AddAccessorsToLibraryObjectWithName(object, PropertyIds::_symbolSpecies, PropertyIds::_RuntimeFunctionNameId_species, getterFunctionInfo, nullptr);
}
}

RuntimeFunction* JavascriptLibrary::CreateGetterFunction(PropertyId nameId, FunctionInfo* functionInfo)
{
Var name_withGetPrefix = LiteralString::Concat(LiteralString::NewCopySz(_u("get "), scriptContext), scriptContext->GetPropertyString(nameId));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -574,6 +574,7 @@ namespace Js
void AddAccessorsToLibraryObject(DynamicObject* object, PropertyId propertyId, FunctionInfo * getterFunctionInfo, FunctionInfo * setterFunctionInfo);
void AddAccessorsToLibraryObject(DynamicObject* object, PropertyId propertyId, RecyclableObject * getterFunction, RecyclableObject * setterFunction);
void AddAccessorsToLibraryObjectWithName(DynamicObject* object, PropertyId propertyId, PropertyId nameId, FunctionInfo * getterFunctionInfo, FunctionInfo * setterFunction);
void AddSpeciesAccessorsToLibraryObject(DynamicObject* object, FunctionInfo * getterFunctionInfo);
RuntimeFunction * CreateGetterFunction(PropertyId nameId, FunctionInfo* functionInfo);
RuntimeFunction * CreateSetterFunction(PropertyId nameId, FunctionInfo* functionInfo);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@
"#__proto__": "function <large string>",
"length": "number 1",
"prototype": "Array []",
"[Symbol.species]": "function <large string>",
"Symbol.species": "function <large string>",
"name": "string Array",
"isArray": "function <large string>",
"from": "function <large string>",
Expand Down Expand Up @@ -646,7 +646,7 @@
"#__proto__": "function <large string>",
"length": "number 1",
"prototype": "Array []",
"[Symbol.species]": "function <large string>",
"Symbol.species": "function <large string>",
"name": "string Array",
"isArray": "function <large string>",
"from": "function <large string>",
Expand Down Expand Up @@ -884,4 +884,4 @@
}
}
}
]
]
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
"caller": "object null",
"arguments": "object null"
},
"[Symbol.species]": {
"Symbol.species": {
"#__proto__": "function function() {\n [native code]\n}",
"length": "number 3",
"name": "string Int8Array",
Expand Down Expand Up @@ -348,4 +348,4 @@
}
]
}
]
]
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"#__proto__": "function function() {\n [native code]\n}",
"length": "number 0",
"prototype": "Object {...}",
"[Symbol.species]": "function function Map() { [native code] }",
"Symbol.species": "function function Map() { [native code] }",
"name": "string Map",
"caller": "object null",
"arguments": "object null"
Expand Down Expand Up @@ -131,4 +131,4 @@
}
}
}
]
]
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"#__proto__": "function <large string>",
"length": "number 0",
"prototype": "Object {...}",
"[Symbol.species]": "function <large string>",
"Symbol.species": "function <large string>",
"name": "string Map",
"caller": "object null",
"arguments": "object null"
Expand Down Expand Up @@ -187,7 +187,7 @@
"#__proto__": "function <large string>",
"length": "number 0",
"prototype": "Object {...}",
"[Symbol.species]": "function <large string>",
"Symbol.species": "function <large string>",
"name": "string Map",
"caller": "object null",
"arguments": "object null"
Expand Down Expand Up @@ -291,7 +291,7 @@
"#__proto__": "function <large string>",
"length": "number 0",
"prototype": "Object {...}",
"[Symbol.species]": "function <large string>",
"Symbol.species": "function <large string>",
"name": "string Map",
"caller": "object null",
"arguments": "object null"
Expand Down Expand Up @@ -457,7 +457,7 @@
"#__proto__": "function <large string>",
"length": "number 0",
"prototype": "Object {...}",
"[Symbol.species]": "function <large string>",
"Symbol.species": "function <large string>",
"name": "string Map",
"caller": "object null",
"arguments": "object null"
Expand Down Expand Up @@ -539,4 +539,4 @@
}
}
}
]
]

0 comments on commit 79c597e

Please sign in to comment.