Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(391)

Side by Side Diff: src/bootstrapper.cc

Issue 2614623003: Move all Symbol.species setup for builtin constructors to bootstrapper (Closed)
Patch Set: Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | src/js/array.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/bootstrapper.h" 5 #include "src/bootstrapper.h"
6 6
7 #include "src/accessors.h" 7 #include "src/accessors.h"
8 #include "src/api-natives.h" 8 #include "src/api-natives.h"
9 #include "src/base/ieee754.h" 9 #include "src/base/ieee754.h"
10 #include "src/code-stubs.h" 10 #include "src/code-stubs.h"
(...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after
506 return fun; 506 return fun;
507 } 507 }
508 508
509 void InstallConstant(Isolate* isolate, Handle<JSObject> holder, 509 void InstallConstant(Isolate* isolate, Handle<JSObject> holder,
510 const char* name, Handle<Object> value) { 510 const char* name, Handle<Object> value) {
511 JSObject::AddProperty( 511 JSObject::AddProperty(
512 holder, isolate->factory()->NewStringFromAsciiChecked(name), value, 512 holder, isolate->factory()->NewStringFromAsciiChecked(name), value,
513 static_cast<PropertyAttributes>(DONT_DELETE | DONT_ENUM | READ_ONLY)); 513 static_cast<PropertyAttributes>(DONT_DELETE | DONT_ENUM | READ_ONLY));
514 } 514 }
515 515
516 void InstallSpeciesGetter(Handle<JSFunction> constructor) {
517 Factory* factory = constructor->GetIsolate()->factory();
gsathya 2017/01/04 22:11:30 Why not just pass the isolate to this function? Th
adamk 2017/01/04 22:14:28 SimpleInstallGetter doesn't take an Isolate, so we
518 SimpleInstallGetter(constructor, factory->symbol_species_string(),
adamk 2017/01/04 22:14:28 But speaking of micro-opts, it seems like I could
519 factory->species_symbol(), Builtins::kReturnReceiver,
520 true);
521 }
522
516 } // namespace 523 } // namespace
517 524
518 Handle<JSFunction> Genesis::CreateEmptyFunction(Isolate* isolate) { 525 Handle<JSFunction> Genesis::CreateEmptyFunction(Isolate* isolate) {
519 // Allocate the map for function instances. Maps are allocated first and their 526 // Allocate the map for function instances. Maps are allocated first and their
520 // prototypes patched later, once empty function is created. 527 // prototypes patched later, once empty function is created.
521 528
522 // Functions with this map will not have a 'prototype' property, and 529 // Functions with this map will not have a 'prototype' property, and
523 // can not be used as constructors. 530 // can not be used as constructors.
524 Handle<Map> function_without_prototype_map = 531 Handle<Map> function_without_prototype_map =
525 factory()->CreateSloppyFunctionMap(FUNCTION_WITHOUT_PROTOTYPE); 532 factory()->CreateSloppyFunctionMap(FUNCTION_WITHOUT_PROTOTYPE);
(...skipping 777 matching lines...) Expand 10 before | Expand all | Expand 10 after
1303 Accessors::ArrayLengthInfo(isolate, attribs); 1310 Accessors::ArrayLengthInfo(isolate, attribs);
1304 { // Add length. 1311 { // Add length.
1305 Descriptor d = Descriptor::AccessorConstant( 1312 Descriptor d = Descriptor::AccessorConstant(
1306 Handle<Name>(Name::cast(array_length->name())), array_length, 1313 Handle<Name>(Name::cast(array_length->name())), array_length,
1307 attribs); 1314 attribs);
1308 initial_map->AppendDescriptor(&d); 1315 initial_map->AppendDescriptor(&d);
1309 } 1316 }
1310 1317
1311 InstallWithIntrinsicDefaultProto(isolate, array_function, 1318 InstallWithIntrinsicDefaultProto(isolate, array_function,
1312 Context::ARRAY_FUNCTION_INDEX); 1319 Context::ARRAY_FUNCTION_INDEX);
1320 InstallSpeciesGetter(array_function);
1313 1321
1314 // Cache the array maps, needed by ArrayConstructorStub 1322 // Cache the array maps, needed by ArrayConstructorStub
1315 CacheInitialJSArrayMaps(native_context(), initial_map); 1323 CacheInitialJSArrayMaps(native_context(), initial_map);
1316 ArrayConstructorStub array_constructor_stub(isolate); 1324 ArrayConstructorStub array_constructor_stub(isolate);
1317 Handle<Code> code = array_constructor_stub.GetCode(); 1325 Handle<Code> code = array_constructor_stub.GetCode();
1318 array_function->shared()->SetConstructStub(*code); 1326 array_function->shared()->SetConstructStub(*code);
1319 1327
1320 Handle<JSFunction> is_arraylike = SimpleInstallFunction( 1328 Handle<JSFunction> is_arraylike = SimpleInstallFunction(
1321 array_function, isolate->factory()->InternalizeUtf8String("isArray"), 1329 array_function, isolate->factory()->InternalizeUtf8String("isArray"),
1322 Builtins::kArrayIsArray, 1, true); 1330 Builtins::kArrayIsArray, 1, true);
(...skipping 554 matching lines...) Expand 10 before | Expand all | Expand 10 after
1877 SimpleInstallFunction(prototype, isolate->factory()->then_string(), 1885 SimpleInstallFunction(prototype, isolate->factory()->then_string(),
1878 Builtins::kPromiseThen, 2, true); 1886 Builtins::kPromiseThen, 2, true);
1879 InstallWithIntrinsicDefaultProto(isolate, promise_then, 1887 InstallWithIntrinsicDefaultProto(isolate, promise_then,
1880 Context::PROMISE_THEN_INDEX); 1888 Context::PROMISE_THEN_INDEX);
1881 1889
1882 Handle<JSFunction> promise_catch = SimpleInstallFunction( 1890 Handle<JSFunction> promise_catch = SimpleInstallFunction(
1883 prototype, "catch", Builtins::kPromiseCatch, 1, true, DONT_ENUM); 1891 prototype, "catch", Builtins::kPromiseCatch, 1, true, DONT_ENUM);
1884 InstallWithIntrinsicDefaultProto(isolate, promise_catch, 1892 InstallWithIntrinsicDefaultProto(isolate, promise_catch,
1885 Context::PROMISE_CATCH_INDEX); 1893 Context::PROMISE_CATCH_INDEX);
1886 1894
1887 SimpleInstallGetter(promise_fun, factory->symbol_species_string(), 1895 InstallSpeciesGetter(promise_fun);
1888 factory->species_symbol(), Builtins::kReturnReceiver,
1889 true);
1890 1896
1891 Handle<Map> prototype_map(prototype->map()); 1897 Handle<Map> prototype_map(prototype->map());
1892 Map::SetShouldBeFastPrototypeMap(prototype_map, true, isolate); 1898 Map::SetShouldBeFastPrototypeMap(prototype_map, true, isolate);
1893 1899
1894 // Store the initial Promise.prototype map. This is used in fast-path 1900 // Store the initial Promise.prototype map. This is used in fast-path
1895 // checks. Do not alter the prototype after this point. 1901 // checks. Do not alter the prototype after this point.
1896 native_context()->set_promise_prototype_map(*prototype_map); 1902 native_context()->set_promise_prototype_map(*prototype_map);
1897 1903
1898 { // Internal: PromiseInternalConstructor 1904 { // Internal: PromiseInternalConstructor
1899 Handle<JSFunction> function = 1905 Handle<JSFunction> function =
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
2062 Map::SetShouldBeFastPrototypeMap(prototype_map, true, isolate); 2068 Map::SetShouldBeFastPrototypeMap(prototype_map, true, isolate);
2063 2069
2064 // Store the initial RegExp.prototype map. This is used in fast-path 2070 // Store the initial RegExp.prototype map. This is used in fast-path
2065 // checks. Do not alter the prototype after this point. 2071 // checks. Do not alter the prototype after this point.
2066 native_context()->set_regexp_prototype_map(*prototype_map); 2072 native_context()->set_regexp_prototype_map(*prototype_map);
2067 } 2073 }
2068 2074
2069 { 2075 {
2070 // RegExp getters and setters. 2076 // RegExp getters and setters.
2071 2077
2072 SimpleInstallGetter(regexp_fun, factory->symbol_species_string(), 2078 InstallSpeciesGetter(regexp_fun);
2073 factory->species_symbol(), Builtins::kReturnReceiver,
2074 true);
2075 2079
2076 // Static properties set by a successful match. 2080 // Static properties set by a successful match.
2077 2081
2078 const PropertyAttributes no_enum = DONT_ENUM; 2082 const PropertyAttributes no_enum = DONT_ENUM;
2079 SimpleInstallGetterSetter(regexp_fun, factory->input_string(), 2083 SimpleInstallGetterSetter(regexp_fun, factory->input_string(),
2080 Builtins::kRegExpInputGetter, 2084 Builtins::kRegExpInputGetter,
2081 Builtins::kRegExpInputSetter, no_enum); 2085 Builtins::kRegExpInputSetter, no_enum);
2082 SimpleInstallGetterSetter( 2086 SimpleInstallGetterSetter(
2083 regexp_fun, factory->InternalizeUtf8String("$_"), 2087 regexp_fun, factory->InternalizeUtf8String("$_"),
2084 Builtins::kRegExpInputGetter, Builtins::kRegExpInputSetter, no_enum); 2088 Builtins::kRegExpInputGetter, Builtins::kRegExpInputSetter, no_enum);
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
2389 v8_break_iterator_constructor, DONT_ENUM); 2393 v8_break_iterator_constructor, DONT_ENUM);
2390 } 2394 }
2391 #endif // V8_I18N_SUPPORT 2395 #endif // V8_I18N_SUPPORT
2392 2396
2393 { // -- A r r a y B u f f e r 2397 { // -- A r r a y B u f f e r
2394 Handle<JSFunction> array_buffer_fun = InstallArrayBuffer( 2398 Handle<JSFunction> array_buffer_fun = InstallArrayBuffer(
2395 global, "ArrayBuffer", Builtins::kArrayBufferPrototypeGetByteLength, 2399 global, "ArrayBuffer", Builtins::kArrayBufferPrototypeGetByteLength,
2396 BuiltinFunctionId::kArrayBufferByteLength); 2400 BuiltinFunctionId::kArrayBufferByteLength);
2397 InstallWithIntrinsicDefaultProto(isolate, array_buffer_fun, 2401 InstallWithIntrinsicDefaultProto(isolate, array_buffer_fun,
2398 Context::ARRAY_BUFFER_FUN_INDEX); 2402 Context::ARRAY_BUFFER_FUN_INDEX);
2403 InstallSpeciesGetter(array_buffer_fun);
2399 } 2404 }
2400 2405
2401 { // -- T y p e d A r r a y 2406 { // -- T y p e d A r r a y
2402 Handle<JSObject> prototype = 2407 Handle<JSObject> prototype =
2403 factory->NewJSObject(isolate->object_function(), TENURED); 2408 factory->NewJSObject(isolate->object_function(), TENURED);
2404 native_context()->set_typed_array_prototype(*prototype); 2409 native_context()->set_typed_array_prototype(*prototype);
2405 2410
2406 Handle<JSFunction> typed_array_fun = 2411 Handle<JSFunction> typed_array_fun =
2407 CreateFunction(isolate, factory->InternalizeUtf8String("TypedArray"), 2412 CreateFunction(isolate, factory->InternalizeUtf8String("TypedArray"),
2408 JS_TYPED_ARRAY_TYPE, JSTypedArray::kSize, prototype, 2413 JS_TYPED_ARRAY_TYPE, JSTypedArray::kSize, prototype,
2409 Builtins::kIllegal); 2414 Builtins::kIllegal);
2415 InstallSpeciesGetter(typed_array_fun);
2410 2416
2411 // Install the "constructor" property on the {prototype}. 2417 // Install the "constructor" property on the {prototype}.
2412 JSObject::AddProperty(prototype, factory->constructor_string(), 2418 JSObject::AddProperty(prototype, factory->constructor_string(),
2413 typed_array_fun, DONT_ENUM); 2419 typed_array_fun, DONT_ENUM);
2414 native_context()->set_typed_array_function(*typed_array_fun); 2420 native_context()->set_typed_array_function(*typed_array_fun);
2415 2421
2416 // Install the "buffer", "byteOffset", "byteLength" and "length" 2422 // Install the "buffer", "byteOffset", "byteLength" and "length"
2417 // getters on the {prototype}. 2423 // getters on the {prototype}.
2418 SimpleInstallGetter(prototype, factory->buffer_string(), 2424 SimpleInstallGetter(prototype, factory->buffer_string(),
2419 Builtins::kTypedArrayPrototypeBuffer, false); 2425 Builtins::kTypedArrayPrototypeBuffer, false);
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
2527 SimpleInstallFunction(prototype, "setFloat64", 2533 SimpleInstallFunction(prototype, "setFloat64",
2528 Builtins::kDataViewPrototypeSetFloat64, 2, false); 2534 Builtins::kDataViewPrototypeSetFloat64, 2, false);
2529 } 2535 }
2530 2536
2531 { // -- M a p 2537 { // -- M a p
2532 Handle<JSFunction> js_map_fun = InstallFunction( 2538 Handle<JSFunction> js_map_fun = InstallFunction(
2533 global, "Map", JS_MAP_TYPE, JSMap::kSize, 2539 global, "Map", JS_MAP_TYPE, JSMap::kSize,
2534 isolate->initial_object_prototype(), Builtins::kIllegal); 2540 isolate->initial_object_prototype(), Builtins::kIllegal);
2535 InstallWithIntrinsicDefaultProto(isolate, js_map_fun, 2541 InstallWithIntrinsicDefaultProto(isolate, js_map_fun,
2536 Context::JS_MAP_FUN_INDEX); 2542 Context::JS_MAP_FUN_INDEX);
2543 InstallSpeciesGetter(js_map_fun);
2537 } 2544 }
2538 2545
2539 { // -- S e t 2546 { // -- S e t
2540 Handle<JSFunction> js_set_fun = InstallFunction( 2547 Handle<JSFunction> js_set_fun = InstallFunction(
2541 global, "Set", JS_SET_TYPE, JSSet::kSize, 2548 global, "Set", JS_SET_TYPE, JSSet::kSize,
2542 isolate->initial_object_prototype(), Builtins::kIllegal); 2549 isolate->initial_object_prototype(), Builtins::kIllegal);
2543 InstallWithIntrinsicDefaultProto(isolate, js_set_fun, 2550 InstallWithIntrinsicDefaultProto(isolate, js_set_fun,
2544 Context::JS_SET_FUN_INDEX); 2551 Context::JS_SET_FUN_INDEX);
2552 InstallSpeciesGetter(js_set_fun);
2545 } 2553 }
2546 2554
2547 { // -- J S M o d u l e N a m e s p a c e 2555 { // -- J S M o d u l e N a m e s p a c e
2548 Handle<Map> map = 2556 Handle<Map> map =
2549 factory->NewMap(JS_MODULE_NAMESPACE_TYPE, JSModuleNamespace::kSize); 2557 factory->NewMap(JS_MODULE_NAMESPACE_TYPE, JSModuleNamespace::kSize);
2550 Map::SetPrototype(map, isolate->factory()->null_value()); 2558 Map::SetPrototype(map, isolate->factory()->null_value());
2551 Map::EnsureDescriptorSlack(map, 1); 2559 Map::EnsureDescriptorSlack(map, 1);
2552 native_context()->set_js_module_namespace_map(*map); 2560 native_context()->set_js_module_namespace_map(*map);
2553 2561
2554 { // Install @@toStringTag. 2562 { // Install @@toStringTag.
(...skipping 2172 matching lines...) Expand 10 before | Expand all | Expand 10 after
4727 } 4735 }
4728 4736
4729 4737
4730 // Called when the top-level V8 mutex is destroyed. 4738 // Called when the top-level V8 mutex is destroyed.
4731 void Bootstrapper::FreeThreadResources() { 4739 void Bootstrapper::FreeThreadResources() {
4732 DCHECK(!IsActive()); 4740 DCHECK(!IsActive());
4733 } 4741 }
4734 4742
4735 } // namespace internal 4743 } // namespace internal
4736 } // namespace v8 4744 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | src/js/array.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698