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

Side by Side Diff: src/bootstrapper.cc

Issue 2667993005: [bootstrapper] Refactor CreateFunction and InstallFunction. (Closed)
Patch Set: Fix. Created 3 years, 10 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 | no next file » | 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 345 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 356
357 namespace { 357 namespace {
358 358
359 void InstallFunction(Handle<JSObject> target, Handle<Name> property_name, 359 void InstallFunction(Handle<JSObject> target, Handle<Name> property_name,
360 Handle<JSFunction> function, Handle<String> function_name, 360 Handle<JSFunction> function, Handle<String> function_name,
361 PropertyAttributes attributes = DONT_ENUM) { 361 PropertyAttributes attributes = DONT_ENUM) {
362 JSObject::AddProperty(target, property_name, function, attributes); 362 JSObject::AddProperty(target, property_name, function, attributes);
363 if (target->IsJSGlobalObject()) { 363 if (target->IsJSGlobalObject()) {
364 function->shared()->set_instance_class_name(*function_name); 364 function->shared()->set_instance_class_name(*function_name);
365 } 365 }
366 function->shared()->set_native(true);
367 } 366 }
368 367
369 void InstallFunction(Handle<JSObject> target, Handle<JSFunction> function, 368 void InstallFunction(Handle<JSObject> target, Handle<JSFunction> function,
370 Handle<Name> name, 369 Handle<Name> name,
371 PropertyAttributes attributes = DONT_ENUM) { 370 PropertyAttributes attributes = DONT_ENUM) {
372 Handle<String> name_string = Name::ToFunctionName(name).ToHandleChecked(); 371 Handle<String> name_string = Name::ToFunctionName(name).ToHandleChecked();
373 InstallFunction(target, name, function, name_string, attributes); 372 InstallFunction(target, name, function, name_string, attributes);
374 } 373 }
375 374
376 Handle<JSFunction> CreateFunction(Isolate* isolate, Handle<String> name, 375 Handle<JSFunction> CreateFunction(Isolate* isolate, Handle<String> name,
377 InstanceType type, int instance_size, 376 InstanceType type, int instance_size,
378 MaybeHandle<JSObject> maybe_prototype, 377 MaybeHandle<JSObject> maybe_prototype,
379 Builtins::Name call, 378 Builtins::Name call,
380 bool strict_function_map = false) { 379 bool strict_function_map = false) {
381 Factory* factory = isolate->factory(); 380 Factory* factory = isolate->factory();
382 Handle<Code> call_code(isolate->builtins()->builtin(call)); 381 Handle<Code> call_code(isolate->builtins()->builtin(call));
383 Handle<JSObject> prototype; 382 Handle<JSObject> prototype;
384 return maybe_prototype.ToHandle(&prototype) 383 Handle<JSFunction> result =
385 ? factory->NewFunction(name, call_code, prototype, type, 384 maybe_prototype.ToHandle(&prototype)
386 instance_size, strict_function_map) 385 ? factory->NewFunction(name, call_code, prototype, type,
387 : factory->NewFunctionWithoutPrototype(name, call_code, 386 instance_size, strict_function_map)
388 strict_function_map); 387 : factory->NewFunctionWithoutPrototype(name, call_code,
388 strict_function_map);
389 result->shared()->set_native(true);
390 return result;
389 } 391 }
390 392
391 Handle<JSFunction> InstallFunction(Handle<JSObject> target, Handle<Name> name, 393 Handle<JSFunction> InstallFunction(Handle<JSObject> target, Handle<Name> name,
392 InstanceType type, int instance_size, 394 InstanceType type, int instance_size,
393 MaybeHandle<JSObject> maybe_prototype, 395 MaybeHandle<JSObject> maybe_prototype,
394 Builtins::Name call, 396 Builtins::Name call,
395 PropertyAttributes attributes, 397 PropertyAttributes attributes,
396 bool strict_function_map = false) { 398 bool strict_function_map = false) {
397 Handle<String> name_string = Name::ToFunctionName(name).ToHandleChecked(); 399 Handle<String> name_string = Name::ToFunctionName(name).ToHandleChecked();
398 Handle<JSFunction> function = 400 Handle<JSFunction> function =
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
462 Builtins::Name call_getter, 464 Builtins::Name call_getter,
463 Builtins::Name call_setter, 465 Builtins::Name call_setter,
464 PropertyAttributes attribs) { 466 PropertyAttributes attribs) {
465 Isolate* const isolate = base->GetIsolate(); 467 Isolate* const isolate = base->GetIsolate();
466 468
467 Handle<String> getter_name = 469 Handle<String> getter_name =
468 Name::ToFunctionName(name, isolate->factory()->get_string()) 470 Name::ToFunctionName(name, isolate->factory()->get_string())
469 .ToHandleChecked(); 471 .ToHandleChecked();
470 Handle<JSFunction> getter = 472 Handle<JSFunction> getter =
471 SimpleCreateFunction(isolate, getter_name, call_getter, 0, true); 473 SimpleCreateFunction(isolate, getter_name, call_getter, 0, true);
472 getter->shared()->set_native(true);
473 474
474 Handle<String> setter_name = 475 Handle<String> setter_name =
475 Name::ToFunctionName(name, isolate->factory()->set_string()) 476 Name::ToFunctionName(name, isolate->factory()->set_string())
476 .ToHandleChecked(); 477 .ToHandleChecked();
477 Handle<JSFunction> setter = 478 Handle<JSFunction> setter =
478 SimpleCreateFunction(isolate, setter_name, call_setter, 1, true); 479 SimpleCreateFunction(isolate, setter_name, call_setter, 1, true);
479 setter->shared()->set_native(true);
480 480
481 JSObject::DefineAccessor(base, name, getter, setter, attribs).Check(); 481 JSObject::DefineAccessor(base, name, getter, setter, attribs).Check();
482 } 482 }
483 483
484 Handle<JSFunction> SimpleInstallGetter(Handle<JSObject> base, 484 Handle<JSFunction> SimpleInstallGetter(Handle<JSObject> base,
485 Handle<String> name, 485 Handle<String> name,
486 Handle<Name> property_name, 486 Handle<Name> property_name,
487 Builtins::Name call, bool adapt) { 487 Builtins::Name call, bool adapt) {
488 Isolate* const isolate = base->GetIsolate(); 488 Isolate* const isolate = base->GetIsolate();
489 489
490 Handle<String> getter_name = 490 Handle<String> getter_name =
491 Name::ToFunctionName(name, isolate->factory()->get_string()) 491 Name::ToFunctionName(name, isolate->factory()->get_string())
492 .ToHandleChecked(); 492 .ToHandleChecked();
493 Handle<JSFunction> getter = 493 Handle<JSFunction> getter =
494 SimpleCreateFunction(isolate, getter_name, call, 0, adapt); 494 SimpleCreateFunction(isolate, getter_name, call, 0, adapt);
495 getter->shared()->set_native(true);
496 495
497 Handle<Object> setter = isolate->factory()->undefined_value(); 496 Handle<Object> setter = isolate->factory()->undefined_value();
498 497
499 JSObject::DefineAccessor(base, property_name, getter, setter, DONT_ENUM) 498 JSObject::DefineAccessor(base, property_name, getter, setter, DONT_ENUM)
500 .Check(); 499 .Check();
501 500
502 return getter; 501 return getter;
503 } 502 }
504 503
505 Handle<JSFunction> SimpleInstallGetter(Handle<JSObject> base, 504 Handle<JSFunction> SimpleInstallGetter(Handle<JSObject> base,
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
715 } 714 }
716 715
717 void Genesis::CreateIteratorMaps(Handle<JSFunction> empty) { 716 void Genesis::CreateIteratorMaps(Handle<JSFunction> empty) {
718 // Create iterator-related meta-objects. 717 // Create iterator-related meta-objects.
719 Handle<JSObject> iterator_prototype = 718 Handle<JSObject> iterator_prototype =
720 factory()->NewJSObject(isolate()->object_function(), TENURED); 719 factory()->NewJSObject(isolate()->object_function(), TENURED);
721 720
722 Handle<JSFunction> iterator_prototype_iterator = SimpleCreateFunction( 721 Handle<JSFunction> iterator_prototype_iterator = SimpleCreateFunction(
723 isolate(), factory()->NewStringFromAsciiChecked("[Symbol.iterator]"), 722 isolate(), factory()->NewStringFromAsciiChecked("[Symbol.iterator]"),
724 Builtins::kReturnReceiver, 0, true); 723 Builtins::kReturnReceiver, 0, true);
725 iterator_prototype_iterator->shared()->set_native(true);
726 724
727 JSObject::AddProperty(iterator_prototype, factory()->iterator_symbol(), 725 JSObject::AddProperty(iterator_prototype, factory()->iterator_symbol(),
728 iterator_prototype_iterator, DONT_ENUM); 726 iterator_prototype_iterator, DONT_ENUM);
729 native_context()->set_initial_iterator_prototype(*iterator_prototype); 727 native_context()->set_initial_iterator_prototype(*iterator_prototype);
730 728
731 Handle<JSObject> generator_object_prototype = 729 Handle<JSObject> generator_object_prototype =
732 factory()->NewJSObject(isolate()->object_function(), TENURED); 730 factory()->NewJSObject(isolate()->object_function(), TENURED);
733 native_context()->set_initial_generator_prototype( 731 native_context()->set_initial_generator_prototype(
734 *generator_object_prototype); 732 *generator_object_prototype);
735 JSObject::ForceSetPrototype(generator_object_prototype, iterator_prototype); 733 JSObject::ForceSetPrototype(generator_object_prototype, iterator_prototype);
(...skipping 18 matching lines...) Expand all
754 factory()->to_string_tag_symbol(), 752 factory()->to_string_tag_symbol(),
755 factory()->NewStringFromAsciiChecked("Generator"), 753 factory()->NewStringFromAsciiChecked("Generator"),
756 static_cast<PropertyAttributes>(DONT_ENUM | READ_ONLY)); 754 static_cast<PropertyAttributes>(DONT_ENUM | READ_ONLY));
757 SimpleInstallFunction(generator_object_prototype, "next", 755 SimpleInstallFunction(generator_object_prototype, "next",
758 Builtins::kGeneratorPrototypeNext, 1, true); 756 Builtins::kGeneratorPrototypeNext, 1, true);
759 SimpleInstallFunction(generator_object_prototype, "return", 757 SimpleInstallFunction(generator_object_prototype, "return",
760 Builtins::kGeneratorPrototypeReturn, 1, true); 758 Builtins::kGeneratorPrototypeReturn, 1, true);
761 SimpleInstallFunction(generator_object_prototype, "throw", 759 SimpleInstallFunction(generator_object_prototype, "throw",
762 Builtins::kGeneratorPrototypeThrow, 1, true); 760 Builtins::kGeneratorPrototypeThrow, 1, true);
763 761
764 // Internal version of generator_prototype_next, flagged as non-native. 762 // Internal version of generator_prototype_next, flagged as non-native such
763 // that it doesn't show up in Error traces.
765 Handle<JSFunction> generator_next_internal = 764 Handle<JSFunction> generator_next_internal =
766 SimpleCreateFunction(isolate(), factory()->next_string(), 765 SimpleCreateFunction(isolate(), factory()->next_string(),
767 Builtins::kGeneratorPrototypeNext, 1, true); 766 Builtins::kGeneratorPrototypeNext, 1, true);
767 generator_next_internal->shared()->set_native(false);
768 native_context()->set_generator_next_internal(*generator_next_internal); 768 native_context()->set_generator_next_internal(*generator_next_internal);
769 769
770 // Create maps for generator functions and their prototypes. Store those 770 // Create maps for generator functions and their prototypes. Store those
771 // maps in the native context. The "prototype" property descriptor is 771 // maps in the native context. The "prototype" property descriptor is
772 // writable, non-enumerable, and non-configurable (as per ES6 draft 772 // writable, non-enumerable, and non-configurable (as per ES6 draft
773 // 04-14-15, section 25.2.4.3). 773 // 04-14-15, section 25.2.4.3).
774 Handle<Map> strict_function_map(strict_function_map_writable_prototype_); 774 Handle<Map> strict_function_map(strict_function_map_writable_prototype_);
775 // Generator functions do not have "caller" or "arguments" accessors. 775 // Generator functions do not have "caller" or "arguments" accessors.
776 Handle<Map> generator_function_map = 776 Handle<Map> generator_function_map =
777 Map::Copy(strict_function_map, "GeneratorFunction"); 777 Map::Copy(strict_function_map, "GeneratorFunction");
(...skipping 587 matching lines...) Expand 10 before | Expand all | Expand 10 after
1365 // including the receiver), as required by the builtin. 1365 // including the receiver), as required by the builtin.
1366 next->shared()->set_internal_formal_parameter_count(0); 1366 next->shared()->set_internal_formal_parameter_count(0);
1367 1367
1368 // Set the length for the function to satisfy ECMA-262. 1368 // Set the length for the function to satisfy ECMA-262.
1369 next->shared()->set_length(0); 1369 next->shared()->set_length(0);
1370 1370
1371 Handle<JSFunction> array_iterator_function = CreateFunction( 1371 Handle<JSFunction> array_iterator_function = CreateFunction(
1372 isolate, factory->ArrayIterator_string(), 1372 isolate, factory->ArrayIterator_string(),
1373 JS_FAST_ARRAY_VALUE_ITERATOR_TYPE, JSArrayIterator::kSize, 1373 JS_FAST_ARRAY_VALUE_ITERATOR_TYPE, JSArrayIterator::kSize,
1374 array_iterator_prototype, Builtins::kIllegal); 1374 array_iterator_prototype, Builtins::kIllegal);
1375 array_iterator_function->shared()->set_native(false);
1375 array_iterator_function->shared()->set_instance_class_name( 1376 array_iterator_function->shared()->set_instance_class_name(
1376 isolate->heap()->ArrayIterator_string()); 1377 isolate->heap()->ArrayIterator_string());
1377 1378
1378 native_context()->set_initial_array_iterator_prototype( 1379 native_context()->set_initial_array_iterator_prototype(
1379 *array_iterator_prototype); 1380 *array_iterator_prototype);
1380 native_context()->set_initial_array_iterator_prototype_map( 1381 native_context()->set_initial_array_iterator_prototype_map(
1381 array_iterator_prototype->map()); 1382 array_iterator_prototype->map());
1382 1383
1383 Handle<Map> initial_map(array_iterator_function->initial_map(), isolate); 1384 Handle<Map> initial_map(array_iterator_function->initial_map(), isolate);
1384 1385
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
1599 SimpleInstallFunction(prototype, "trimLeft", 1600 SimpleInstallFunction(prototype, "trimLeft",
1600 Builtins::kStringPrototypeTrimLeft, 0, false); 1601 Builtins::kStringPrototypeTrimLeft, 0, false);
1601 SimpleInstallFunction(prototype, "trimRight", 1602 SimpleInstallFunction(prototype, "trimRight",
1602 Builtins::kStringPrototypeTrimRight, 0, false); 1603 Builtins::kStringPrototypeTrimRight, 0, false);
1603 SimpleInstallFunction(prototype, "valueOf", 1604 SimpleInstallFunction(prototype, "valueOf",
1604 Builtins::kStringPrototypeValueOf, 0, true); 1605 Builtins::kStringPrototypeValueOf, 0, true);
1605 1606
1606 Handle<JSFunction> iterator = SimpleCreateFunction( 1607 Handle<JSFunction> iterator = SimpleCreateFunction(
1607 isolate, factory->NewStringFromAsciiChecked("[Symbol.iterator]"), 1608 isolate, factory->NewStringFromAsciiChecked("[Symbol.iterator]"),
1608 Builtins::kStringPrototypeIterator, 0, true); 1609 Builtins::kStringPrototypeIterator, 0, true);
1609 iterator->shared()->set_native(true);
1610 iterator->shared()->set_builtin_function_id(kStringIterator); 1610 iterator->shared()->set_builtin_function_id(kStringIterator);
1611 JSObject::AddProperty(prototype, factory->iterator_symbol(), iterator, 1611 JSObject::AddProperty(prototype, factory->iterator_symbol(), iterator,
1612 static_cast<PropertyAttributes>(DONT_ENUM)); 1612 static_cast<PropertyAttributes>(DONT_ENUM));
1613 } 1613 }
1614 1614
1615 { // --- S t r i n g I t e r a t o r --- 1615 { // --- S t r i n g I t e r a t o r ---
1616 Handle<JSObject> iterator_prototype( 1616 Handle<JSObject> iterator_prototype(
1617 native_context()->initial_iterator_prototype()); 1617 native_context()->initial_iterator_prototype());
1618 1618
1619 Handle<JSObject> string_iterator_prototype = 1619 Handle<JSObject> string_iterator_prototype =
(...skipping 15 matching lines...) Expand all
1635 // including the receiver), as required by the builtin. 1635 // including the receiver), as required by the builtin.
1636 next->shared()->set_internal_formal_parameter_count(0); 1636 next->shared()->set_internal_formal_parameter_count(0);
1637 1637
1638 // Set the length for the function to satisfy ECMA-262. 1638 // Set the length for the function to satisfy ECMA-262.
1639 next->shared()->set_length(0); 1639 next->shared()->set_length(0);
1640 1640
1641 Handle<JSFunction> string_iterator_function = CreateFunction( 1641 Handle<JSFunction> string_iterator_function = CreateFunction(
1642 isolate, factory->NewStringFromAsciiChecked("StringIterator"), 1642 isolate, factory->NewStringFromAsciiChecked("StringIterator"),
1643 JS_STRING_ITERATOR_TYPE, JSStringIterator::kSize, 1643 JS_STRING_ITERATOR_TYPE, JSStringIterator::kSize,
1644 string_iterator_prototype, Builtins::kIllegal); 1644 string_iterator_prototype, Builtins::kIllegal);
1645 string_iterator_function->shared()->set_native(false);
1645 native_context()->set_string_iterator_map( 1646 native_context()->set_string_iterator_map(
1646 string_iterator_function->initial_map()); 1647 string_iterator_function->initial_map());
1647 } 1648 }
1648 1649
1649 { 1650 {
1650 // --- S y m b o l --- 1651 // --- S y m b o l ---
1651 Handle<JSObject> prototype = 1652 Handle<JSObject> prototype =
1652 factory->NewJSObject(isolate->object_function(), TENURED); 1653 factory->NewJSObject(isolate->object_function(), TENURED);
1653 Handle<JSFunction> symbol_fun = 1654 Handle<JSFunction> symbol_fun =
1654 InstallFunction(global, "Symbol", JS_VALUE_TYPE, JSValue::kSize, 1655 InstallFunction(global, "Symbol", JS_VALUE_TYPE, JSValue::kSize,
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
1854 info->SetConstructStub(*isolate->builtins()->JSBuiltinsConstructStub()); 1855 info->SetConstructStub(*isolate->builtins()->JSBuiltinsConstructStub());
1855 info->set_instance_class_name(isolate->heap()->Object_string()); 1856 info->set_instance_class_name(isolate->heap()->Object_string());
1856 info->set_internal_formal_parameter_count(2); 1857 info->set_internal_formal_parameter_count(2);
1857 info->set_length(2); 1858 info->set_length(2);
1858 native_context()->set_promise_get_capabilities_executor_shared_fun(*info); 1859 native_context()->set_promise_get_capabilities_executor_shared_fun(*info);
1859 1860
1860 // %new_promise_capability(C, debugEvent) 1861 // %new_promise_capability(C, debugEvent)
1861 Handle<JSFunction> new_promise_capability = 1862 Handle<JSFunction> new_promise_capability =
1862 SimpleCreateFunction(isolate, factory->empty_string(), 1863 SimpleCreateFunction(isolate, factory->empty_string(),
1863 Builtins::kNewPromiseCapability, 2, false); 1864 Builtins::kNewPromiseCapability, 2, false);
1865 new_promise_capability->shared()->set_native(false);
1864 InstallWithIntrinsicDefaultProto(isolate, new_promise_capability, 1866 InstallWithIntrinsicDefaultProto(isolate, new_promise_capability,
1865 Context::NEW_PROMISE_CAPABILITY_INDEX); 1867 Context::NEW_PROMISE_CAPABILITY_INDEX);
1866 } 1868 }
1867 1869
1868 { // -- P r o m i s e 1870 { // -- P r o m i s e
1869 // Set catch prediction 1871 // Set catch prediction
1870 Handle<Code> promise_code = isolate->builtins()->PromiseConstructor(); 1872 Handle<Code> promise_code = isolate->builtins()->PromiseConstructor();
1871 promise_code->set_is_promise_rejection(true); 1873 promise_code->set_is_promise_rejection(true);
1872 1874
1873 Handle<JSObject> prototype = 1875 Handle<JSObject> prototype =
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
1917 1919
1918 // Store the initial Promise.prototype map. This is used in fast-path 1920 // Store the initial Promise.prototype map. This is used in fast-path
1919 // checks. Do not alter the prototype after this point. 1921 // checks. Do not alter the prototype after this point.
1920 native_context()->set_promise_prototype_map(*prototype_map); 1922 native_context()->set_promise_prototype_map(*prototype_map);
1921 1923
1922 { // Internal: PromiseInternalConstructor 1924 { // Internal: PromiseInternalConstructor
1923 // Also exposed as extrasUtils.createPromise. 1925 // Also exposed as extrasUtils.createPromise.
1924 Handle<JSFunction> function = 1926 Handle<JSFunction> function =
1925 SimpleCreateFunction(isolate, factory->empty_string(), 1927 SimpleCreateFunction(isolate, factory->empty_string(),
1926 Builtins::kPromiseInternalConstructor, 1, true); 1928 Builtins::kPromiseInternalConstructor, 1, true);
1929 function->shared()->set_native(false);
1927 InstallWithIntrinsicDefaultProto( 1930 InstallWithIntrinsicDefaultProto(
1928 isolate, function, Context::PROMISE_INTERNAL_CONSTRUCTOR_INDEX); 1931 isolate, function, Context::PROMISE_INTERNAL_CONSTRUCTOR_INDEX);
1929 } 1932 }
1930 1933
1931 { // Internal: IsPromise 1934 { // Internal: IsPromise
1932 Handle<JSFunction> function = SimpleCreateFunction( 1935 Handle<JSFunction> function = SimpleCreateFunction(
1933 isolate, factory->empty_string(), Builtins::kIsPromise, 1, false); 1936 isolate, factory->empty_string(), Builtins::kIsPromise, 1, false);
1937 function->shared()->set_native(false);
1934 InstallWithIntrinsicDefaultProto(isolate, function, 1938 InstallWithIntrinsicDefaultProto(isolate, function,
1935 Context::IS_PROMISE_INDEX); 1939 Context::IS_PROMISE_INDEX);
1936 } 1940 }
1937 1941
1938 { // Internal: ResolvePromise 1942 { // Internal: ResolvePromise
1939 // Also exposed as extrasUtils.resolvePromise. 1943 // Also exposed as extrasUtils.resolvePromise.
1940 Handle<JSFunction> function = SimpleCreateFunction( 1944 Handle<JSFunction> function = SimpleCreateFunction(
1941 isolate, factory->empty_string(), Builtins::kResolvePromise, 2, true); 1945 isolate, factory->empty_string(), Builtins::kResolvePromise, 2, true);
1946 function->shared()->set_native(false);
1942 InstallWithIntrinsicDefaultProto(isolate, function, 1947 InstallWithIntrinsicDefaultProto(isolate, function,
1943 Context::PROMISE_RESOLVE_INDEX); 1948 Context::PROMISE_RESOLVE_INDEX);
1944 } 1949 }
1945 1950
1946 { // Internal: PromiseHandle 1951 { // Internal: PromiseHandle
1947 Handle<JSFunction> function = SimpleCreateFunction( 1952 Handle<JSFunction> function = SimpleCreateFunction(
1948 isolate, factory->empty_string(), Builtins::kPromiseHandle, 5, false); 1953 isolate, factory->empty_string(), Builtins::kPromiseHandle, 5, false);
1954 function->shared()->set_native(false);
1949 InstallWithIntrinsicDefaultProto(isolate, function, 1955 InstallWithIntrinsicDefaultProto(isolate, function,
1950 Context::PROMISE_HANDLE_INDEX); 1956 Context::PROMISE_HANDLE_INDEX);
1951 // Set up catch prediction 1957 // Set up catch prediction
1952 Handle<Code> promise_handle = isolate->builtins()->PromiseHandle(); 1958 Handle<Code> promise_handle = isolate->builtins()->PromiseHandle();
1953 promise_handle->set_is_promise_rejection(true); 1959 promise_handle->set_is_promise_rejection(true);
1954 } 1960 }
1955 1961
1956 { // Internal: PromiseHandleReject 1962 { // Internal: PromiseHandleReject
1957 Handle<JSFunction> function = 1963 Handle<JSFunction> function =
1958 SimpleCreateFunction(isolate, factory->empty_string(), 1964 SimpleCreateFunction(isolate, factory->empty_string(),
1959 Builtins::kPromiseHandleReject, 3, false); 1965 Builtins::kPromiseHandleReject, 3, false);
1966 function->shared()->set_native(false);
1960 InstallWithIntrinsicDefaultProto(isolate, function, 1967 InstallWithIntrinsicDefaultProto(isolate, function,
1961 Context::PROMISE_HANDLE_REJECT_INDEX); 1968 Context::PROMISE_HANDLE_REJECT_INDEX);
1962 // Set up catch prediction 1969 // Set up catch prediction
1963 Handle<Code> promise_handle = isolate->builtins()->PromiseHandleReject(); 1970 Handle<Code> promise_handle = isolate->builtins()->PromiseHandleReject();
1964 promise_handle->set_is_exception_caught(true); 1971 promise_handle->set_is_exception_caught(true);
1965 } 1972 }
1966 1973
1967 { // Internal: InternalPromiseReject 1974 { // Internal: InternalPromiseReject
1968 Handle<JSFunction> function = 1975 Handle<JSFunction> function =
1969 SimpleCreateFunction(isolate, factory->empty_string(), 1976 SimpleCreateFunction(isolate, factory->empty_string(),
1970 Builtins::kInternalPromiseReject, 3, true); 1977 Builtins::kInternalPromiseReject, 3, true);
1978 function->shared()->set_native(false);
1971 InstallWithIntrinsicDefaultProto(isolate, function, 1979 InstallWithIntrinsicDefaultProto(isolate, function,
1972 Context::PROMISE_INTERNAL_REJECT_INDEX); 1980 Context::PROMISE_INTERNAL_REJECT_INDEX);
1973 } 1981 }
1974 1982
1975 { 1983 {
1976 Handle<Code> code = 1984 Handle<Code> code =
1977 handle(isolate->builtins()->builtin(Builtins::kPromiseResolveClosure), 1985 handle(isolate->builtins()->builtin(Builtins::kPromiseResolveClosure),
1978 isolate); 1986 isolate);
1979 Handle<SharedFunctionInfo> info = 1987 Handle<SharedFunctionInfo> info =
1980 factory->NewSharedFunctionInfo(factory->empty_string(), code, false); 1988 factory->NewSharedFunctionInfo(factory->empty_string(), code, false);
(...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after
2427 2435
2428 { // -- T y p e d A r r a y 2436 { // -- T y p e d A r r a y
2429 Handle<JSObject> prototype = 2437 Handle<JSObject> prototype =
2430 factory->NewJSObject(isolate->object_function(), TENURED); 2438 factory->NewJSObject(isolate->object_function(), TENURED);
2431 native_context()->set_typed_array_prototype(*prototype); 2439 native_context()->set_typed_array_prototype(*prototype);
2432 2440
2433 Handle<JSFunction> typed_array_fun = 2441 Handle<JSFunction> typed_array_fun =
2434 CreateFunction(isolate, factory->InternalizeUtf8String("TypedArray"), 2442 CreateFunction(isolate, factory->InternalizeUtf8String("TypedArray"),
2435 JS_TYPED_ARRAY_TYPE, JSTypedArray::kSize, prototype, 2443 JS_TYPED_ARRAY_TYPE, JSTypedArray::kSize, prototype,
2436 Builtins::kIllegal); 2444 Builtins::kIllegal);
2445 typed_array_fun->shared()->set_native(false);
2437 InstallSpeciesGetter(typed_array_fun); 2446 InstallSpeciesGetter(typed_array_fun);
2438 2447
2439 // Install the "constructor" property on the {prototype}. 2448 // Install the "constructor" property on the {prototype}.
2440 JSObject::AddProperty(prototype, factory->constructor_string(), 2449 JSObject::AddProperty(prototype, factory->constructor_string(),
2441 typed_array_fun, DONT_ENUM); 2450 typed_array_fun, DONT_ENUM);
2442 native_context()->set_typed_array_function(*typed_array_fun); 2451 native_context()->set_typed_array_function(*typed_array_fun);
2443 2452
2444 // Install the "buffer", "byteOffset", "byteLength" and "length" 2453 // Install the "buffer", "byteOffset", "byteLength" and "length"
2445 // getters on the {prototype}. 2454 // getters on the {prototype}.
2446 SimpleInstallGetter(prototype, factory->buffer_string(), 2455 SimpleInstallGetter(prototype, factory->buffer_string(),
(...skipping 921 matching lines...) Expand 10 before | Expand all | Expand 10 after
3368 async_function_constructor, 3377 async_function_constructor,
3369 static_cast<PropertyAttributes>(DONT_ENUM | READ_ONLY)); 3378 static_cast<PropertyAttributes>(DONT_ENUM | READ_ONLY));
3370 3379
3371 JSFunction::SetPrototype(async_function_constructor, 3380 JSFunction::SetPrototype(async_function_constructor,
3372 async_function_prototype); 3381 async_function_prototype);
3373 3382
3374 { 3383 {
3375 Handle<JSFunction> function = 3384 Handle<JSFunction> function =
3376 SimpleCreateFunction(isolate, factory->empty_string(), 3385 SimpleCreateFunction(isolate, factory->empty_string(),
3377 Builtins::kAsyncFunctionAwaitCaught, 3, false); 3386 Builtins::kAsyncFunctionAwaitCaught, 3, false);
3387 function->shared()->set_native(false);
3378 InstallWithIntrinsicDefaultProto( 3388 InstallWithIntrinsicDefaultProto(
3379 isolate, function, Context::ASYNC_FUNCTION_AWAIT_CAUGHT_INDEX); 3389 isolate, function, Context::ASYNC_FUNCTION_AWAIT_CAUGHT_INDEX);
3380 } 3390 }
3381 3391
3382 { 3392 {
3383 Handle<JSFunction> function = 3393 Handle<JSFunction> function =
3384 SimpleCreateFunction(isolate, factory->empty_string(), 3394 SimpleCreateFunction(isolate, factory->empty_string(),
3385 Builtins::kAsyncFunctionAwaitUncaught, 3, false); 3395 Builtins::kAsyncFunctionAwaitUncaught, 3, false);
3396 function->shared()->set_native(false);
3386 InstallWithIntrinsicDefaultProto( 3397 InstallWithIntrinsicDefaultProto(
3387 isolate, function, Context::ASYNC_FUNCTION_AWAIT_UNCAUGHT_INDEX); 3398 isolate, function, Context::ASYNC_FUNCTION_AWAIT_UNCAUGHT_INDEX);
3388 } 3399 }
3389 3400
3390 { 3401 {
3391 Handle<Code> code = 3402 Handle<Code> code =
3392 isolate->builtins()->AsyncFunctionAwaitRejectClosure(); 3403 isolate->builtins()->AsyncFunctionAwaitRejectClosure();
3393 Handle<SharedFunctionInfo> info = 3404 Handle<SharedFunctionInfo> info =
3394 factory->NewSharedFunctionInfo(factory->empty_string(), code, false); 3405 factory->NewSharedFunctionInfo(factory->empty_string(), code, false);
3395 info->set_internal_formal_parameter_count(1); 3406 info->set_internal_formal_parameter_count(1);
3396 info->set_length(1); 3407 info->set_length(1);
3397 native_context->set_async_function_await_reject_shared_fun(*info); 3408 native_context->set_async_function_await_reject_shared_fun(*info);
3398 } 3409 }
3399 3410
3400 { 3411 {
3401 Handle<Code> code = 3412 Handle<Code> code =
3402 isolate->builtins()->AsyncFunctionAwaitResolveClosure(); 3413 isolate->builtins()->AsyncFunctionAwaitResolveClosure();
3403 Handle<SharedFunctionInfo> info = 3414 Handle<SharedFunctionInfo> info =
3404 factory->NewSharedFunctionInfo(factory->empty_string(), code, false); 3415 factory->NewSharedFunctionInfo(factory->empty_string(), code, false);
3405 info->set_internal_formal_parameter_count(1); 3416 info->set_internal_formal_parameter_count(1);
3406 info->set_length(1); 3417 info->set_length(1);
3407 native_context->set_async_function_await_resolve_shared_fun(*info); 3418 native_context->set_async_function_await_resolve_shared_fun(*info);
3408 } 3419 }
3409 3420
3410 { 3421 {
3411 Handle<JSFunction> function = 3422 Handle<JSFunction> function =
3412 SimpleCreateFunction(isolate, factory->empty_string(), 3423 SimpleCreateFunction(isolate, factory->empty_string(),
3413 Builtins::kAsyncFunctionPromiseCreate, 0, false); 3424 Builtins::kAsyncFunctionPromiseCreate, 0, false);
3425 function->shared()->set_native(false);
3414 InstallWithIntrinsicDefaultProto( 3426 InstallWithIntrinsicDefaultProto(
3415 isolate, function, Context::ASYNC_FUNCTION_PROMISE_CREATE_INDEX); 3427 isolate, function, Context::ASYNC_FUNCTION_PROMISE_CREATE_INDEX);
3416 } 3428 }
3417 3429
3418 { 3430 {
3419 Handle<JSFunction> function = SimpleCreateFunction( 3431 Handle<JSFunction> function = SimpleCreateFunction(
3420 isolate, factory->empty_string(), 3432 isolate, factory->empty_string(),
3421 Builtins::kAsyncFunctionPromiseRelease, 1, false); 3433 Builtins::kAsyncFunctionPromiseRelease, 1, false);
3434 function->shared()->set_native(false);
3422 InstallWithIntrinsicDefaultProto( 3435 InstallWithIntrinsicDefaultProto(
3423 isolate, function, Context::ASYNC_FUNCTION_PROMISE_RELEASE_INDEX); 3436 isolate, function, Context::ASYNC_FUNCTION_PROMISE_RELEASE_INDEX);
3424 } 3437 }
3425 } 3438 }
3426 3439
3427 { // -- C a l l S i t e 3440 { // -- C a l l S i t e
3428 // Builtin functions for CallSite. 3441 // Builtin functions for CallSite.
3429 3442
3430 // CallSites are a special case; the constructor is for our private use 3443 // CallSites are a special case; the constructor is for our private use
3431 // only, therefore we set it up as a builtin that throws. Internally, we use 3444 // only, therefore we set it up as a builtin that throws. Internally, we use
(...skipping 1403 matching lines...) Expand 10 before | Expand all | Expand 10 after
4835 } 4848 }
4836 4849
4837 4850
4838 // Called when the top-level V8 mutex is destroyed. 4851 // Called when the top-level V8 mutex is destroyed.
4839 void Bootstrapper::FreeThreadResources() { 4852 void Bootstrapper::FreeThreadResources() {
4840 DCHECK(!IsActive()); 4853 DCHECK(!IsActive());
4841 } 4854 }
4842 4855
4843 } // namespace internal 4856 } // namespace internal
4844 } // namespace v8 4857 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698