| 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 1808 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1819 to_primitive->shared()->set_length(1); | 1819 to_primitive->shared()->set_length(1); |
| 1820 } | 1820 } |
| 1821 | 1821 |
| 1822 { // -- P r o m i s e | 1822 { // -- P r o m i s e |
| 1823 // Set catch prediction | 1823 // Set catch prediction |
| 1824 Handle<Code> promise_code = isolate->builtins()->PromiseConstructor(); | 1824 Handle<Code> promise_code = isolate->builtins()->PromiseConstructor(); |
| 1825 promise_code->set_is_promise_rejection(true); | 1825 promise_code->set_is_promise_rejection(true); |
| 1826 | 1826 |
| 1827 Handle<JSObject> prototype = | 1827 Handle<JSObject> prototype = |
| 1828 factory->NewJSObject(isolate->object_function(), TENURED); | 1828 factory->NewJSObject(isolate->object_function(), TENURED); |
| 1829 Handle<JSFunction> promise_fun = InstallFunction( | 1829 Handle<JSFunction> promise_fun = |
| 1830 global, "Promise", JS_PROMISE_TYPE, JSObject::kHeaderSize, prototype, | 1830 InstallFunction(global, "Promise", JS_PROMISE_TYPE, JSPromise::kSize, |
| 1831 Builtins::kPromiseConstructor); | 1831 prototype, Builtins::kPromiseConstructor); |
| 1832 InstallWithIntrinsicDefaultProto(isolate, promise_fun, | 1832 InstallWithIntrinsicDefaultProto(isolate, promise_fun, |
| 1833 Context::PROMISE_FUNCTION_INDEX); | 1833 Context::PROMISE_FUNCTION_INDEX); |
| 1834 | 1834 |
| 1835 Handle<SharedFunctionInfo> shared(promise_fun->shared(), isolate); | 1835 Handle<SharedFunctionInfo> shared(promise_fun->shared(), isolate); |
| 1836 shared->SetConstructStub(*isolate->builtins()->JSBuiltinsConstructStub()); | 1836 shared->SetConstructStub(*isolate->builtins()->JSBuiltinsConstructStub()); |
| 1837 shared->set_instance_class_name(isolate->heap()->Object_string()); | 1837 shared->set_instance_class_name(isolate->heap()->Object_string()); |
| 1838 shared->set_internal_formal_parameter_count(1); | 1838 shared->set_internal_formal_parameter_count(1); |
| 1839 shared->set_length(1); | 1839 shared->set_length(1); |
| 1840 | 1840 |
| 1841 // Install the "constructor" property on the {prototype}. | 1841 // Install the "constructor" property on the {prototype}. |
| 1842 JSObject::AddProperty(prototype, factory->constructor_string(), promise_fun, | 1842 JSObject::AddProperty(prototype, factory->constructor_string(), promise_fun, |
| 1843 DONT_ENUM); | 1843 DONT_ENUM); |
| 1844 | 1844 |
| 1845 // Install the @@toStringTag property on the {prototype}. | 1845 // Install the @@toStringTag property on the {prototype}. |
| 1846 JSObject::AddProperty( | 1846 JSObject::AddProperty( |
| 1847 prototype, factory->to_string_tag_symbol(), factory->Promise_string(), | 1847 prototype, factory->to_string_tag_symbol(), factory->Promise_string(), |
| 1848 static_cast<PropertyAttributes>(DONT_ENUM | READ_ONLY)); | 1848 static_cast<PropertyAttributes>(DONT_ENUM | READ_ONLY)); |
| 1849 | 1849 |
| 1850 SimpleInstallFunction(prototype, "then", Builtins::kPromiseThen, 2, true, |
| 1851 DONT_ENUM); |
| 1852 |
| 1850 { // Internal: PromiseInternalConstructor | 1853 { // Internal: PromiseInternalConstructor |
| 1851 Handle<JSFunction> function = | 1854 Handle<JSFunction> function = |
| 1852 SimpleCreateFunction(isolate, factory->empty_string(), | 1855 SimpleCreateFunction(isolate, factory->empty_string(), |
| 1853 Builtins::kPromiseInternalConstructor, 0, false); | 1856 Builtins::kPromiseInternalConstructor, 0, false); |
| 1854 InstallWithIntrinsicDefaultProto( | 1857 InstallWithIntrinsicDefaultProto( |
| 1855 isolate, function, Context::PROMISE_INTERNAL_CONSTRUCTOR_INDEX); | 1858 isolate, function, Context::PROMISE_INTERNAL_CONSTRUCTOR_INDEX); |
| 1856 } | 1859 } |
| 1857 | 1860 |
| 1861 { // Internal: PromiseCreateAndSet |
| 1862 Handle<JSFunction> function = |
| 1863 SimpleCreateFunction(isolate, factory->empty_string(), |
| 1864 Builtins::kPromiseCreateAndSet, 2, false); |
| 1865 InstallWithIntrinsicDefaultProto(isolate, function, |
| 1866 Context::PROMISE_CREATE_AND_SET_INDEX); |
| 1867 } |
| 1868 |
| 1858 { // Internal: IsPromise | 1869 { // Internal: IsPromise |
| 1859 Handle<JSFunction> function = SimpleCreateFunction( | 1870 Handle<JSFunction> function = SimpleCreateFunction( |
| 1860 isolate, factory->empty_string(), Builtins::kIsPromise, 1, false); | 1871 isolate, factory->empty_string(), Builtins::kIsPromise, 1, false); |
| 1861 InstallWithIntrinsicDefaultProto(isolate, function, | 1872 InstallWithIntrinsicDefaultProto(isolate, function, |
| 1862 Context::IS_PROMISE_INDEX); | 1873 Context::IS_PROMISE_INDEX); |
| 1863 } | 1874 } |
| 1864 | 1875 |
| 1876 { // Internal: PerformPromiseThen |
| 1877 Handle<JSFunction> function = |
| 1878 SimpleCreateFunction(isolate, factory->empty_string(), |
| 1879 Builtins::kPerformPromiseThen, 4, false); |
| 1880 InstallWithIntrinsicDefaultProto(isolate, function, |
| 1881 Context::PERFORM_PROMISE_THEN_INDEX); |
| 1882 } |
| 1883 |
| 1865 { | 1884 { |
| 1866 Handle<Code> code = | 1885 Handle<Code> code = |
| 1867 handle(isolate->builtins()->builtin(Builtins::kPromiseResolveClosure), | 1886 handle(isolate->builtins()->builtin(Builtins::kPromiseResolveClosure), |
| 1868 isolate); | 1887 isolate); |
| 1869 Handle<SharedFunctionInfo> info = | 1888 Handle<SharedFunctionInfo> info = |
| 1870 factory->NewSharedFunctionInfo(factory->empty_string(), code, false); | 1889 factory->NewSharedFunctionInfo(factory->empty_string(), code, false); |
| 1871 info->set_internal_formal_parameter_count(1); | 1890 info->set_internal_formal_parameter_count(1); |
| 1872 info->set_length(1); | 1891 info->set_length(1); |
| 1873 native_context()->set_promise_resolve_shared_fun(*info); | 1892 native_context()->set_promise_resolve_shared_fun(*info); |
| 1874 | 1893 |
| (...skipping 2723 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4598 } | 4617 } |
| 4599 | 4618 |
| 4600 | 4619 |
| 4601 // Called when the top-level V8 mutex is destroyed. | 4620 // Called when the top-level V8 mutex is destroyed. |
| 4602 void Bootstrapper::FreeThreadResources() { | 4621 void Bootstrapper::FreeThreadResources() { |
| 4603 DCHECK(!IsActive()); | 4622 DCHECK(!IsActive()); |
| 4604 } | 4623 } |
| 4605 | 4624 |
| 4606 } // namespace internal | 4625 } // namespace internal |
| 4607 } // namespace v8 | 4626 } // namespace v8 |
| OLD | NEW |