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

Side by Side Diff: src/bootstrapper.cc

Issue 2614623003: Move all Symbol.species setup for builtin constructors to bootstrapper (Closed)
Patch Set: Rebased 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();
518 // TODO(adamk): We should be able to share a SharedFunctionInfo
519 // between all these JSFunctins.
520 SimpleInstallGetter(constructor, factory->symbol_species_string(),
521 factory->species_symbol(), Builtins::kReturnReceiver,
522 true);
523 }
524
516 } // namespace 525 } // namespace
517 526
518 Handle<JSFunction> Genesis::CreateEmptyFunction(Isolate* isolate) { 527 Handle<JSFunction> Genesis::CreateEmptyFunction(Isolate* isolate) {
519 // Allocate the map for function instances. Maps are allocated first and their 528 // Allocate the map for function instances. Maps are allocated first and their
520 // prototypes patched later, once empty function is created. 529 // prototypes patched later, once empty function is created.
521 530
522 // Functions with this map will not have a 'prototype' property, and 531 // Functions with this map will not have a 'prototype' property, and
523 // can not be used as constructors. 532 // can not be used as constructors.
524 Handle<Map> function_without_prototype_map = 533 Handle<Map> function_without_prototype_map =
525 factory()->CreateSloppyFunctionMap(FUNCTION_WITHOUT_PROTOTYPE); 534 factory()->CreateSloppyFunctionMap(FUNCTION_WITHOUT_PROTOTYPE);
(...skipping 777 matching lines...) Expand 10 before | Expand all | Expand 10 after
1303 Accessors::ArrayLengthInfo(isolate, attribs); 1312 Accessors::ArrayLengthInfo(isolate, attribs);
1304 { // Add length. 1313 { // Add length.
1305 Descriptor d = Descriptor::AccessorConstant( 1314 Descriptor d = Descriptor::AccessorConstant(
1306 Handle<Name>(Name::cast(array_length->name())), array_length, 1315 Handle<Name>(Name::cast(array_length->name())), array_length,
1307 attribs); 1316 attribs);
1308 initial_map->AppendDescriptor(&d); 1317 initial_map->AppendDescriptor(&d);
1309 } 1318 }
1310 1319
1311 InstallWithIntrinsicDefaultProto(isolate, array_function, 1320 InstallWithIntrinsicDefaultProto(isolate, array_function,
1312 Context::ARRAY_FUNCTION_INDEX); 1321 Context::ARRAY_FUNCTION_INDEX);
1322 InstallSpeciesGetter(array_function);
1313 1323
1314 // Cache the array maps, needed by ArrayConstructorStub 1324 // Cache the array maps, needed by ArrayConstructorStub
1315 CacheInitialJSArrayMaps(native_context(), initial_map); 1325 CacheInitialJSArrayMaps(native_context(), initial_map);
1316 ArrayConstructorStub array_constructor_stub(isolate); 1326 ArrayConstructorStub array_constructor_stub(isolate);
1317 Handle<Code> code = array_constructor_stub.GetCode(); 1327 Handle<Code> code = array_constructor_stub.GetCode();
1318 array_function->shared()->SetConstructStub(*code); 1328 array_function->shared()->SetConstructStub(*code);
1319 1329
1320 Handle<JSFunction> is_arraylike = SimpleInstallFunction( 1330 Handle<JSFunction> is_arraylike = SimpleInstallFunction(
1321 array_function, isolate->factory()->InternalizeUtf8String("isArray"), 1331 array_function, isolate->factory()->InternalizeUtf8String("isArray"),
1322 Builtins::kArrayIsArray, 1, true); 1332 Builtins::kArrayIsArray, 1, true);
(...skipping 554 matching lines...) Expand 10 before | Expand all | Expand 10 after
1877 SimpleInstallFunction(prototype, isolate->factory()->then_string(), 1887 SimpleInstallFunction(prototype, isolate->factory()->then_string(),
1878 Builtins::kPromiseThen, 2, true); 1888 Builtins::kPromiseThen, 2, true);
1879 InstallWithIntrinsicDefaultProto(isolate, promise_then, 1889 InstallWithIntrinsicDefaultProto(isolate, promise_then,
1880 Context::PROMISE_THEN_INDEX); 1890 Context::PROMISE_THEN_INDEX);
1881 1891
1882 Handle<JSFunction> promise_catch = SimpleInstallFunction( 1892 Handle<JSFunction> promise_catch = SimpleInstallFunction(
1883 prototype, "catch", Builtins::kPromiseCatch, 1, true, DONT_ENUM); 1893 prototype, "catch", Builtins::kPromiseCatch, 1, true, DONT_ENUM);
1884 InstallWithIntrinsicDefaultProto(isolate, promise_catch, 1894 InstallWithIntrinsicDefaultProto(isolate, promise_catch,
1885 Context::PROMISE_CATCH_INDEX); 1895 Context::PROMISE_CATCH_INDEX);
1886 1896
1887 SimpleInstallGetter(promise_fun, factory->symbol_species_string(), 1897 InstallSpeciesGetter(promise_fun);
1888 factory->species_symbol(), Builtins::kReturnReceiver,
1889 true);
1890 1898
1891 SimpleInstallFunction(promise_fun, "resolve", Builtins::kPromiseResolve, 1, 1899 SimpleInstallFunction(promise_fun, "resolve", Builtins::kPromiseResolve, 1,
1892 true, DONT_ENUM); 1900 true, DONT_ENUM);
1893 1901
1894 Handle<Map> prototype_map(prototype->map()); 1902 Handle<Map> prototype_map(prototype->map());
1895 Map::SetShouldBeFastPrototypeMap(prototype_map, true, isolate); 1903 Map::SetShouldBeFastPrototypeMap(prototype_map, true, isolate);
1896 1904
1897 // Store the initial Promise.prototype map. This is used in fast-path 1905 // Store the initial Promise.prototype map. This is used in fast-path
1898 // checks. Do not alter the prototype after this point. 1906 // checks. Do not alter the prototype after this point.
1899 native_context()->set_promise_prototype_map(*prototype_map); 1907 native_context()->set_promise_prototype_map(*prototype_map);
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
2065 Map::SetShouldBeFastPrototypeMap(prototype_map, true, isolate); 2073 Map::SetShouldBeFastPrototypeMap(prototype_map, true, isolate);
2066 2074
2067 // Store the initial RegExp.prototype map. This is used in fast-path 2075 // Store the initial RegExp.prototype map. This is used in fast-path
2068 // checks. Do not alter the prototype after this point. 2076 // checks. Do not alter the prototype after this point.
2069 native_context()->set_regexp_prototype_map(*prototype_map); 2077 native_context()->set_regexp_prototype_map(*prototype_map);
2070 } 2078 }
2071 2079
2072 { 2080 {
2073 // RegExp getters and setters. 2081 // RegExp getters and setters.
2074 2082
2075 SimpleInstallGetter(regexp_fun, factory->symbol_species_string(), 2083 InstallSpeciesGetter(regexp_fun);
2076 factory->species_symbol(), Builtins::kReturnReceiver,
2077 true);
2078 2084
2079 // Static properties set by a successful match. 2085 // Static properties set by a successful match.
2080 2086
2081 const PropertyAttributes no_enum = DONT_ENUM; 2087 const PropertyAttributes no_enum = DONT_ENUM;
2082 SimpleInstallGetterSetter(regexp_fun, factory->input_string(), 2088 SimpleInstallGetterSetter(regexp_fun, factory->input_string(),
2083 Builtins::kRegExpInputGetter, 2089 Builtins::kRegExpInputGetter,
2084 Builtins::kRegExpInputSetter, no_enum); 2090 Builtins::kRegExpInputSetter, no_enum);
2085 SimpleInstallGetterSetter( 2091 SimpleInstallGetterSetter(
2086 regexp_fun, factory->InternalizeUtf8String("$_"), 2092 regexp_fun, factory->InternalizeUtf8String("$_"),
2087 Builtins::kRegExpInputGetter, Builtins::kRegExpInputSetter, no_enum); 2093 Builtins::kRegExpInputGetter, Builtins::kRegExpInputSetter, no_enum);
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
2392 v8_break_iterator_constructor, DONT_ENUM); 2398 v8_break_iterator_constructor, DONT_ENUM);
2393 } 2399 }
2394 #endif // V8_I18N_SUPPORT 2400 #endif // V8_I18N_SUPPORT
2395 2401
2396 { // -- A r r a y B u f f e r 2402 { // -- A r r a y B u f f e r
2397 Handle<JSFunction> array_buffer_fun = InstallArrayBuffer( 2403 Handle<JSFunction> array_buffer_fun = InstallArrayBuffer(
2398 global, "ArrayBuffer", Builtins::kArrayBufferPrototypeGetByteLength, 2404 global, "ArrayBuffer", Builtins::kArrayBufferPrototypeGetByteLength,
2399 BuiltinFunctionId::kArrayBufferByteLength); 2405 BuiltinFunctionId::kArrayBufferByteLength);
2400 InstallWithIntrinsicDefaultProto(isolate, array_buffer_fun, 2406 InstallWithIntrinsicDefaultProto(isolate, array_buffer_fun,
2401 Context::ARRAY_BUFFER_FUN_INDEX); 2407 Context::ARRAY_BUFFER_FUN_INDEX);
2408 InstallSpeciesGetter(array_buffer_fun);
2402 } 2409 }
2403 2410
2404 { // -- T y p e d A r r a y 2411 { // -- T y p e d A r r a y
2405 Handle<JSObject> prototype = 2412 Handle<JSObject> prototype =
2406 factory->NewJSObject(isolate->object_function(), TENURED); 2413 factory->NewJSObject(isolate->object_function(), TENURED);
2407 native_context()->set_typed_array_prototype(*prototype); 2414 native_context()->set_typed_array_prototype(*prototype);
2408 2415
2409 Handle<JSFunction> typed_array_fun = 2416 Handle<JSFunction> typed_array_fun =
2410 CreateFunction(isolate, factory->InternalizeUtf8String("TypedArray"), 2417 CreateFunction(isolate, factory->InternalizeUtf8String("TypedArray"),
2411 JS_TYPED_ARRAY_TYPE, JSTypedArray::kSize, prototype, 2418 JS_TYPED_ARRAY_TYPE, JSTypedArray::kSize, prototype,
2412 Builtins::kIllegal); 2419 Builtins::kIllegal);
2420 InstallSpeciesGetter(typed_array_fun);
2413 2421
2414 // Install the "constructor" property on the {prototype}. 2422 // Install the "constructor" property on the {prototype}.
2415 JSObject::AddProperty(prototype, factory->constructor_string(), 2423 JSObject::AddProperty(prototype, factory->constructor_string(),
2416 typed_array_fun, DONT_ENUM); 2424 typed_array_fun, DONT_ENUM);
2417 native_context()->set_typed_array_function(*typed_array_fun); 2425 native_context()->set_typed_array_function(*typed_array_fun);
2418 2426
2419 // Install the "buffer", "byteOffset", "byteLength" and "length" 2427 // Install the "buffer", "byteOffset", "byteLength" and "length"
2420 // getters on the {prototype}. 2428 // getters on the {prototype}.
2421 SimpleInstallGetter(prototype, factory->buffer_string(), 2429 SimpleInstallGetter(prototype, factory->buffer_string(),
2422 Builtins::kTypedArrayPrototypeBuffer, false); 2430 Builtins::kTypedArrayPrototypeBuffer, false);
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
2530 SimpleInstallFunction(prototype, "setFloat64", 2538 SimpleInstallFunction(prototype, "setFloat64",
2531 Builtins::kDataViewPrototypeSetFloat64, 2, false); 2539 Builtins::kDataViewPrototypeSetFloat64, 2, false);
2532 } 2540 }
2533 2541
2534 { // -- M a p 2542 { // -- M a p
2535 Handle<JSFunction> js_map_fun = InstallFunction( 2543 Handle<JSFunction> js_map_fun = InstallFunction(
2536 global, "Map", JS_MAP_TYPE, JSMap::kSize, 2544 global, "Map", JS_MAP_TYPE, JSMap::kSize,
2537 isolate->initial_object_prototype(), Builtins::kIllegal); 2545 isolate->initial_object_prototype(), Builtins::kIllegal);
2538 InstallWithIntrinsicDefaultProto(isolate, js_map_fun, 2546 InstallWithIntrinsicDefaultProto(isolate, js_map_fun,
2539 Context::JS_MAP_FUN_INDEX); 2547 Context::JS_MAP_FUN_INDEX);
2548 InstallSpeciesGetter(js_map_fun);
2540 } 2549 }
2541 2550
2542 { // -- S e t 2551 { // -- S e t
2543 Handle<JSFunction> js_set_fun = InstallFunction( 2552 Handle<JSFunction> js_set_fun = InstallFunction(
2544 global, "Set", JS_SET_TYPE, JSSet::kSize, 2553 global, "Set", JS_SET_TYPE, JSSet::kSize,
2545 isolate->initial_object_prototype(), Builtins::kIllegal); 2554 isolate->initial_object_prototype(), Builtins::kIllegal);
2546 InstallWithIntrinsicDefaultProto(isolate, js_set_fun, 2555 InstallWithIntrinsicDefaultProto(isolate, js_set_fun,
2547 Context::JS_SET_FUN_INDEX); 2556 Context::JS_SET_FUN_INDEX);
2557 InstallSpeciesGetter(js_set_fun);
2548 } 2558 }
2549 2559
2550 { // -- J S M o d u l e N a m e s p a c e 2560 { // -- J S M o d u l e N a m e s p a c e
2551 Handle<Map> map = 2561 Handle<Map> map =
2552 factory->NewMap(JS_MODULE_NAMESPACE_TYPE, JSModuleNamespace::kSize); 2562 factory->NewMap(JS_MODULE_NAMESPACE_TYPE, JSModuleNamespace::kSize);
2553 Map::SetPrototype(map, isolate->factory()->null_value()); 2563 Map::SetPrototype(map, isolate->factory()->null_value());
2554 Map::EnsureDescriptorSlack(map, 1); 2564 Map::EnsureDescriptorSlack(map, 1);
2555 native_context()->set_js_module_namespace_map(*map); 2565 native_context()->set_js_module_namespace_map(*map);
2556 2566
2557 { // Install @@toStringTag. 2567 { // Install @@toStringTag.
(...skipping 2172 matching lines...) Expand 10 before | Expand all | Expand 10 after
4730 } 4740 }
4731 4741
4732 4742
4733 // Called when the top-level V8 mutex is destroyed. 4743 // Called when the top-level V8 mutex is destroyed.
4734 void Bootstrapper::FreeThreadResources() { 4744 void Bootstrapper::FreeThreadResources() {
4735 DCHECK(!IsActive()); 4745 DCHECK(!IsActive());
4736 } 4746 }
4737 4747
4738 } // namespace internal 4748 } // namespace internal
4739 } // namespace v8 4749 } // 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