| OLD | NEW |
| 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 1782 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1793 Builtins::kDatePrototypeToPrimitive, | 1793 Builtins::kDatePrototypeToPrimitive, |
| 1794 static_cast<PropertyAttributes>(DONT_ENUM | READ_ONLY)); | 1794 static_cast<PropertyAttributes>(DONT_ENUM | READ_ONLY)); |
| 1795 | 1795 |
| 1796 // Set the expected parameters for @@toPrimitive to 1; required by builtin. | 1796 // Set the expected parameters for @@toPrimitive to 1; required by builtin. |
| 1797 to_primitive->shared()->set_internal_formal_parameter_count(1); | 1797 to_primitive->shared()->set_internal_formal_parameter_count(1); |
| 1798 | 1798 |
| 1799 // Set the length for the function to satisfy ECMA-262. | 1799 // Set the length for the function to satisfy ECMA-262. |
| 1800 to_primitive->shared()->set_length(1); | 1800 to_primitive->shared()->set_length(1); |
| 1801 } | 1801 } |
| 1802 | 1802 |
| 1803 { // -- P r o m i s e |
| 1804 // Set catch prediction |
| 1805 Handle<Code> promise_code = isolate->builtins()->PromiseConstructor(); |
| 1806 promise_code->set_is_promise_rejection(true); |
| 1807 |
| 1808 Handle<JSObject> prototype = |
| 1809 factory->NewJSObject(isolate->object_function(), TENURED); |
| 1810 Handle<JSFunction> promise_fun = InstallFunction( |
| 1811 global, "Promise", JS_PROMISE_TYPE, JSObject::kHeaderSize, prototype, |
| 1812 Builtins::kPromiseConstructor); |
| 1813 InstallWithIntrinsicDefaultProto(isolate, promise_fun, |
| 1814 Context::PROMISE_FUNCTION_INDEX); |
| 1815 |
| 1816 Handle<SharedFunctionInfo> shared(promise_fun->shared(), isolate); |
| 1817 shared->SetConstructStub(*isolate->builtins()->JSBuiltinsConstructStub()); |
| 1818 shared->set_instance_class_name(isolate->heap()->Object_string()); |
| 1819 shared->set_internal_formal_parameter_count(1); |
| 1820 shared->set_length(1); |
| 1821 |
| 1822 // Install the "constructor" property on the {prototype}. |
| 1823 JSObject::AddProperty(prototype, factory->constructor_string(), promise_fun, |
| 1824 DONT_ENUM); |
| 1825 |
| 1826 // Install the @@toStringTag property on the {prototype}. |
| 1827 JSObject::AddProperty( |
| 1828 prototype, factory->to_string_tag_symbol(), factory->Promise_string(), |
| 1829 static_cast<PropertyAttributes>(DONT_ENUM | READ_ONLY)); |
| 1830 |
| 1831 { // Internal: PromiseInternalConstructor |
| 1832 Handle<JSFunction> function = |
| 1833 SimpleCreateFunction(isolate, factory->empty_string(), |
| 1834 Builtins::kPromiseInternalConstructor, 0, false); |
| 1835 InstallWithIntrinsicDefaultProto( |
| 1836 isolate, function, Context::PROMISE_INTERNAL_CONSTRUCTOR_INDEX); |
| 1837 } |
| 1838 |
| 1839 { // Internal: IsPromise |
| 1840 Handle<JSFunction> function = SimpleCreateFunction( |
| 1841 isolate, factory->empty_string(), Builtins::kIsPromise, 1, false); |
| 1842 InstallWithIntrinsicDefaultProto(isolate, function, |
| 1843 Context::IS_PROMISE_INDEX); |
| 1844 } |
| 1845 |
| 1846 { |
| 1847 Handle<Code> code = |
| 1848 handle(isolate->builtins()->builtin(Builtins::kPromiseResolveClosure), |
| 1849 isolate); |
| 1850 Handle<SharedFunctionInfo> info = |
| 1851 factory->NewSharedFunctionInfo(factory->empty_string(), code, false); |
| 1852 info->set_internal_formal_parameter_count(1); |
| 1853 info->set_length(1); |
| 1854 native_context()->set_promise_resolve_shared_fun(*info); |
| 1855 |
| 1856 code = |
| 1857 handle(isolate->builtins()->builtin(Builtins::kPromiseRejectClosure), |
| 1858 isolate); |
| 1859 info = |
| 1860 factory->NewSharedFunctionInfo(factory->empty_string(), code, false); |
| 1861 info->set_internal_formal_parameter_count(2); |
| 1862 info->set_length(1); |
| 1863 native_context()->set_promise_reject_shared_fun(*info); |
| 1864 } |
| 1865 |
| 1866 Handle<JSFunction> create_resolving_functions = |
| 1867 SimpleCreateFunction(isolate, factory->empty_string(), |
| 1868 Builtins::kCreateResolvingFunctions, 2, false); |
| 1869 native_context()->set_create_resolving_functions( |
| 1870 *create_resolving_functions); |
| 1871 } |
| 1872 |
| 1803 { // -- R e g E x p | 1873 { // -- R e g E x p |
| 1804 // Builtin functions for RegExp.prototype. | 1874 // Builtin functions for RegExp.prototype. |
| 1805 Handle<JSObject> prototype = | 1875 Handle<JSObject> prototype = |
| 1806 factory->NewJSObject(isolate->object_function(), TENURED); | 1876 factory->NewJSObject(isolate->object_function(), TENURED); |
| 1807 Handle<JSFunction> regexp_fun = | 1877 Handle<JSFunction> regexp_fun = |
| 1808 InstallFunction(global, "RegExp", JS_REGEXP_TYPE, JSRegExp::kSize, | 1878 InstallFunction(global, "RegExp", JS_REGEXP_TYPE, JSRegExp::kSize, |
| 1809 prototype, Builtins::kRegExpConstructor); | 1879 prototype, Builtins::kRegExpConstructor); |
| 1810 InstallWithIntrinsicDefaultProto(isolate, regexp_fun, | 1880 InstallWithIntrinsicDefaultProto(isolate, regexp_fun, |
| 1811 Context::REGEXP_FUNCTION_INDEX); | 1881 Context::REGEXP_FUNCTION_INDEX); |
| 1812 | 1882 |
| (...skipping 1760 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3573 | 3643 |
| 3574 // Make sure that InternalArray.prototype.concat appears to be compiled. | 3644 // Make sure that InternalArray.prototype.concat appears to be compiled. |
| 3575 // The code will never be called, but inline caching for call will | 3645 // The code will never be called, but inline caching for call will |
| 3576 // only work if it appears to be compiled. | 3646 // only work if it appears to be compiled. |
| 3577 concat->shared()->DontAdaptArguments(); | 3647 concat->shared()->DontAdaptArguments(); |
| 3578 DCHECK(concat->is_compiled()); | 3648 DCHECK(concat->is_compiled()); |
| 3579 // Set the lengths for the functions to satisfy ECMA-262. | 3649 // Set the lengths for the functions to satisfy ECMA-262. |
| 3580 concat->shared()->set_length(1); | 3650 concat->shared()->set_length(1); |
| 3581 } | 3651 } |
| 3582 | 3652 |
| 3583 // Set up the Promise constructor. | |
| 3584 { | |
| 3585 Handle<String> key = factory()->Promise_string(); | |
| 3586 Handle<JSFunction> function = Handle<JSFunction>::cast( | |
| 3587 JSReceiver::GetProperty(global_object, key).ToHandleChecked()); | |
| 3588 JSFunction::EnsureHasInitialMap(function); | |
| 3589 function->initial_map()->set_instance_type(JS_PROMISE_TYPE); | |
| 3590 function->shared()->SetConstructStub( | |
| 3591 *isolate()->builtins()->JSBuiltinsConstructStub()); | |
| 3592 InstallWithIntrinsicDefaultProto(isolate(), function, | |
| 3593 Context::PROMISE_FUNCTION_INDEX); | |
| 3594 | |
| 3595 { | |
| 3596 Handle<Code> code = handle( | |
| 3597 isolate()->builtins()->builtin(Builtins::kPromiseResolveClosure), | |
| 3598 isolate()); | |
| 3599 Handle<SharedFunctionInfo> info = | |
| 3600 isolate()->factory()->NewSharedFunctionInfo(factory()->empty_string(), | |
| 3601 code, false); | |
| 3602 info->set_internal_formal_parameter_count(1); | |
| 3603 info->set_length(1); | |
| 3604 native_context()->set_promise_resolve_shared_fun(*info); | |
| 3605 | |
| 3606 code = handle( | |
| 3607 isolate()->builtins()->builtin(Builtins::kPromiseRejectClosure), | |
| 3608 isolate()); | |
| 3609 info = isolate()->factory()->NewSharedFunctionInfo( | |
| 3610 factory()->empty_string(), code, false); | |
| 3611 info->set_internal_formal_parameter_count(2); | |
| 3612 info->set_length(1); | |
| 3613 native_context()->set_promise_reject_shared_fun(*info); | |
| 3614 } | |
| 3615 | |
| 3616 Handle<JSFunction> create_resolving_functions = | |
| 3617 SimpleCreateFunction(isolate(), factory()->empty_string(), | |
| 3618 Builtins::kCreateResolvingFunctions, 2, false); | |
| 3619 native_context()->set_create_resolving_functions( | |
| 3620 *create_resolving_functions); | |
| 3621 } | |
| 3622 | |
| 3623 InstallBuiltinFunctionIds(); | 3653 InstallBuiltinFunctionIds(); |
| 3624 | 3654 |
| 3625 // Create a map for accessor property descriptors (a variant of JSObject | 3655 // Create a map for accessor property descriptors (a variant of JSObject |
| 3626 // that predefines four properties get, set, configurable and enumerable). | 3656 // that predefines four properties get, set, configurable and enumerable). |
| 3627 { | 3657 { |
| 3628 // AccessorPropertyDescriptor initial map. | 3658 // AccessorPropertyDescriptor initial map. |
| 3629 Handle<Map> map = | 3659 Handle<Map> map = |
| 3630 factory()->NewMap(JS_OBJECT_TYPE, JSAccessorPropertyDescriptor::kSize); | 3660 factory()->NewMap(JS_OBJECT_TYPE, JSAccessorPropertyDescriptor::kSize); |
| 3631 // Create the descriptor array for the property descriptor object. | 3661 // Create the descriptor array for the property descriptor object. |
| 3632 Map::EnsureDescriptorSlack(map, 4); | 3662 Map::EnsureDescriptorSlack(map, 4); |
| (...skipping 928 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4561 } | 4591 } |
| 4562 | 4592 |
| 4563 | 4593 |
| 4564 // Called when the top-level V8 mutex is destroyed. | 4594 // Called when the top-level V8 mutex is destroyed. |
| 4565 void Bootstrapper::FreeThreadResources() { | 4595 void Bootstrapper::FreeThreadResources() { |
| 4566 DCHECK(!IsActive()); | 4596 DCHECK(!IsActive()); |
| 4567 } | 4597 } |
| 4568 | 4598 |
| 4569 } // namespace internal | 4599 } // namespace internal |
| 4570 } // namespace v8 | 4600 } // namespace v8 |
| OLD | NEW |