Commit e968595b authored by adamk's avatar adamk Committed by Commit bot

Move all Symbol.species setup for builtin constructors to bootstrapper

This lets us share Builtins::kReturnReceiver, so should
every-so-slightly reduce the size of the context snapshot.

R=gsathya@chromium.org

Review-Url: https://codereview.chromium.org/2614623003
Cr-Commit-Position: refs/heads/master@{#42076}
parent 79ae8f17
......@@ -513,6 +513,15 @@ void InstallConstant(Isolate* isolate, Handle<JSObject> holder,
static_cast<PropertyAttributes>(DONT_DELETE | DONT_ENUM | READ_ONLY));
}
void InstallSpeciesGetter(Handle<JSFunction> constructor) {
Factory* factory = constructor->GetIsolate()->factory();
// TODO(adamk): We should be able to share a SharedFunctionInfo
// between all these JSFunctins.
SimpleInstallGetter(constructor, factory->symbol_species_string(),
factory->species_symbol(), Builtins::kReturnReceiver,
true);
}
} // namespace
Handle<JSFunction> Genesis::CreateEmptyFunction(Isolate* isolate) {
......@@ -1310,6 +1319,7 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
InstallWithIntrinsicDefaultProto(isolate, array_function,
Context::ARRAY_FUNCTION_INDEX);
InstallSpeciesGetter(array_function);
// Cache the array maps, needed by ArrayConstructorStub
CacheInitialJSArrayMaps(native_context(), initial_map);
......@@ -1884,9 +1894,7 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
InstallWithIntrinsicDefaultProto(isolate, promise_catch,
Context::PROMISE_CATCH_INDEX);
SimpleInstallGetter(promise_fun, factory->symbol_species_string(),
factory->species_symbol(), Builtins::kReturnReceiver,
true);
InstallSpeciesGetter(promise_fun);
SimpleInstallFunction(promise_fun, "resolve", Builtins::kPromiseResolve, 1,
true, DONT_ENUM);
......@@ -2072,9 +2080,7 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
{
// RegExp getters and setters.
SimpleInstallGetter(regexp_fun, factory->symbol_species_string(),
factory->species_symbol(), Builtins::kReturnReceiver,
true);
InstallSpeciesGetter(regexp_fun);
// Static properties set by a successful match.
......@@ -2399,6 +2405,7 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
BuiltinFunctionId::kArrayBufferByteLength);
InstallWithIntrinsicDefaultProto(isolate, array_buffer_fun,
Context::ARRAY_BUFFER_FUN_INDEX);
InstallSpeciesGetter(array_buffer_fun);
}
{ // -- T y p e d A r r a y
......@@ -2410,6 +2417,7 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
CreateFunction(isolate, factory->InternalizeUtf8String("TypedArray"),
JS_TYPED_ARRAY_TYPE, JSTypedArray::kSize, prototype,
Builtins::kIllegal);
InstallSpeciesGetter(typed_array_fun);
// Install the "constructor" property on the {prototype}.
JSObject::AddProperty(prototype, factory->constructor_string(),
......@@ -2537,6 +2545,7 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
isolate->initial_object_prototype(), Builtins::kIllegal);
InstallWithIntrinsicDefaultProto(isolate, js_map_fun,
Context::JS_MAP_FUN_INDEX);
InstallSpeciesGetter(js_map_fun);
}
{ // -- S e t
......@@ -2545,6 +2554,7 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
isolate->initial_object_prototype(), Builtins::kIllegal);
InstallWithIntrinsicDefaultProto(isolate, js_set_fun,
Context::JS_SET_FUN_INDEX);
InstallSpeciesGetter(js_set_fun);
}
{ // -- J S M o d u l e N a m e s p a c e
......
......@@ -21,7 +21,6 @@ var MinSimple;
var ObjectHasOwnProperty;
var ObjectToString = utils.ImportNow("object_to_string");
var iteratorSymbol = utils.ImportNow("iterator_symbol");
var speciesSymbol = utils.ImportNow("species_symbol");
var unscopablesSymbol = utils.ImportNow("unscopables_symbol");
utils.Import(function(from) {
......@@ -1490,12 +1489,6 @@ function ArrayOf(...args) {
return array;
}
function ArraySpecies() {
return this;
}
// -------------------------------------------------------------------
// Set up non-enumerable constructor property on the Array.prototype
......@@ -1578,8 +1571,6 @@ utils.InstallFunctions(GlobalArray.prototype, DONT_ENUM, [
%FunctionSetName(ArrayValues, "values");
utils.InstallGetter(GlobalArray, speciesSymbol, ArraySpecies);
%FinishArrayPrototypeSetup(GlobalArray.prototype);
// The internal Array prototype doesn't need to be fancy, since it's never
......
......@@ -15,7 +15,6 @@ var GlobalArrayBuffer = global.ArrayBuffer;
var MaxSimple;
var MinSimple;
var SpeciesConstructor;
var speciesSymbol = utils.ImportNow("species_symbol");
utils.Import(function(from) {
MaxSimple = from.MaxSimple;
......@@ -75,13 +74,6 @@ function ArrayBufferSlice(start, end) {
return result;
}
function ArrayBufferSpecies() {
return this;
}
utils.InstallGetter(GlobalArrayBuffer, speciesSymbol, ArrayBufferSpecies);
utils.InstallFunctions(GlobalArrayBuffer.prototype, DONT_ENUM, [
"slice", ArrayBufferSlice
]);
......
......@@ -17,7 +17,6 @@ var hashCodeSymbol = utils.ImportNow("hash_code_symbol");
var MathRandom = global.Math.random;
var MapIterator;
var SetIterator;
var speciesSymbol = utils.ImportNow("species_symbol");
var toStringTagSymbol = utils.ImportNow("to_string_tag_symbol");
utils.Import(function(from) {
......@@ -251,12 +250,6 @@ function SetForEach(f, receiver) {
}
}
function SetSpecies() {
return this;
}
// -------------------------------------------------------------------
%SetCode(GlobalSet, SetConstructor);
......@@ -268,8 +261,6 @@ function SetSpecies() {
%FunctionSetLength(SetForEach, 1);
utils.InstallGetter(GlobalSet, speciesSymbol, SetSpecies);
// Set up the non-enumerable functions on the Set prototype object.
utils.InstallGetter(GlobalSet.prototype, "size", SetGetSize);
utils.InstallFunctions(GlobalSet.prototype, DONT_ENUM, [
......@@ -439,11 +430,6 @@ function MapForEach(f, receiver) {
}
}
function MapSpecies() {
return this;
}
// -------------------------------------------------------------------
%SetCode(GlobalMap, MapConstructor);
......@@ -455,8 +441,6 @@ function MapSpecies() {
%FunctionSetLength(MapForEach, 1);
utils.InstallGetter(GlobalMap, speciesSymbol, MapSpecies);
// Set up the non-enumerable functions on the Map prototype object.
utils.InstallGetter(GlobalMap.prototype, "size", MapGetSize);
utils.InstallFunctions(GlobalMap.prototype, DONT_ENUM, [
......
......@@ -41,7 +41,6 @@ var SpeciesConstructor;
var ToPositiveInteger;
var ToIndex;
var iteratorSymbol = utils.ImportNow("iterator_symbol");
var speciesSymbol = utils.ImportNow("species_symbol");
var toStringTagSymbol = utils.ImportNow("to_string_tag_symbol");
macro TYPED_ARRAYS(FUNCTION)
......@@ -847,10 +846,6 @@ function TypedArrayConstructor() {
throw %make_type_error(kConstructAbstractClass, "TypedArray");
}
function TypedArraySpecies() {
return this;
}
// -------------------------------------------------------------------
%SetCode(GlobalTypedArray, TypedArrayConstructor);
......@@ -858,7 +853,6 @@ utils.InstallFunctions(GlobalTypedArray, DONT_ENUM, [
"from", TypedArrayFrom,
"of", TypedArrayOf
]);
utils.InstallGetter(GlobalTypedArray, speciesSymbol, TypedArraySpecies);
utils.InstallGetter(GlobalTypedArray.prototype, toStringTagSymbol,
TypedArrayGetToStringTag);
utils.InstallFunctions(GlobalTypedArray.prototype, DONT_ENUM, [
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment