| 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 1798 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1809 | 1809 |
| 1810 // Install the "constructor" property on the {prototype}. | 1810 // Install the "constructor" property on the {prototype}. |
| 1811 JSObject::AddProperty(prototype, factory->constructor_string(), promise_fun, | 1811 JSObject::AddProperty(prototype, factory->constructor_string(), promise_fun, |
| 1812 DONT_ENUM); | 1812 DONT_ENUM); |
| 1813 | 1813 |
| 1814 // Install the @@toStringTag property on the {prototype}. | 1814 // Install the @@toStringTag property on the {prototype}. |
| 1815 JSObject::AddProperty( | 1815 JSObject::AddProperty( |
| 1816 prototype, factory->to_string_tag_symbol(), factory->Promise_string(), | 1816 prototype, factory->to_string_tag_symbol(), factory->Promise_string(), |
| 1817 static_cast<PropertyAttributes>(DONT_ENUM | READ_ONLY)); | 1817 static_cast<PropertyAttributes>(DONT_ENUM | READ_ONLY)); |
| 1818 | 1818 |
| 1819 SimpleInstallFunction(prototype, "then", Builtins::kPromiseThen, 2, true, | 1819 Handle<JSFunction> promise_then = |
| 1820 SimpleCreateFunction(isolate, isolate->factory()->then_string(), |
| 1821 Builtins::kPromiseThen, 2, true); |
| 1822 JSObject::AddProperty(prototype, isolate->factory()->then_string(), |
| 1823 promise_then, DONT_ENUM); |
| 1824 InstallWithIntrinsicDefaultProto(isolate, promise_then, |
| 1825 Context::PROMISE_THEN_INDEX); |
| 1826 |
| 1827 // TODO(gsathya): Move to TF |
| 1828 SimpleInstallFunction(prototype, "catch", Builtins::kIllegal, 1, true, |
| 1820 DONT_ENUM); | 1829 DONT_ENUM); |
| 1821 | 1830 |
| 1831 Handle<Map> prototype_map(prototype->map()); |
| 1832 Map::SetShouldBeFastPrototypeMap(prototype_map, true, isolate); |
| 1833 |
| 1834 // Store the initial Promise.prototype map. This is used in fast-path |
| 1835 // checks. Do not alter the prototype after this point. |
| 1836 native_context()->set_promise_prototype_map(*prototype_map); |
| 1837 |
| 1822 { // Internal: PromiseInternalConstructor | 1838 { // Internal: PromiseInternalConstructor |
| 1823 Handle<JSFunction> function = | 1839 Handle<JSFunction> function = |
| 1824 SimpleCreateFunction(isolate, factory->empty_string(), | 1840 SimpleCreateFunction(isolate, factory->empty_string(), |
| 1825 Builtins::kPromiseInternalConstructor, 0, false); | 1841 Builtins::kPromiseInternalConstructor, 0, false); |
| 1826 InstallWithIntrinsicDefaultProto( | 1842 InstallWithIntrinsicDefaultProto( |
| 1827 isolate, function, Context::PROMISE_INTERNAL_CONSTRUCTOR_INDEX); | 1843 isolate, function, Context::PROMISE_INTERNAL_CONSTRUCTOR_INDEX); |
| 1828 } | 1844 } |
| 1829 | 1845 |
| 1830 { // Internal: PromiseCreateAndSet | 1846 { // Internal: PromiseCreateAndSet |
| 1831 Handle<JSFunction> function = | 1847 Handle<JSFunction> function = |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1843 } | 1859 } |
| 1844 | 1860 |
| 1845 { // Internal: PerformPromiseThen | 1861 { // Internal: PerformPromiseThen |
| 1846 Handle<JSFunction> function = | 1862 Handle<JSFunction> function = |
| 1847 SimpleCreateFunction(isolate, factory->empty_string(), | 1863 SimpleCreateFunction(isolate, factory->empty_string(), |
| 1848 Builtins::kPerformPromiseThen, 4, false); | 1864 Builtins::kPerformPromiseThen, 4, false); |
| 1849 InstallWithIntrinsicDefaultProto(isolate, function, | 1865 InstallWithIntrinsicDefaultProto(isolate, function, |
| 1850 Context::PERFORM_PROMISE_THEN_INDEX); | 1866 Context::PERFORM_PROMISE_THEN_INDEX); |
| 1851 } | 1867 } |
| 1852 | 1868 |
| 1869 { // Internal: ResolvePromise |
| 1870 Handle<JSFunction> function = |
| 1871 SimpleCreateFunction(isolate, factory->empty_string(), |
| 1872 Builtins::kResolvePromise, 2, false); |
| 1873 InstallWithIntrinsicDefaultProto(isolate, function, |
| 1874 Context::RESOLVE_PROMISE_INDEX); |
| 1875 } |
| 1876 |
| 1853 { | 1877 { |
| 1854 Handle<Code> code = | 1878 Handle<Code> code = |
| 1855 handle(isolate->builtins()->builtin(Builtins::kPromiseResolveClosure), | 1879 handle(isolate->builtins()->builtin(Builtins::kPromiseResolveClosure), |
| 1856 isolate); | 1880 isolate); |
| 1857 Handle<SharedFunctionInfo> info = | 1881 Handle<SharedFunctionInfo> info = |
| 1858 factory->NewSharedFunctionInfo(factory->empty_string(), code, false); | 1882 factory->NewSharedFunctionInfo(factory->empty_string(), code, false); |
| 1859 info->set_internal_formal_parameter_count(1); | 1883 info->set_internal_formal_parameter_count(1); |
| 1860 info->set_length(1); | 1884 info->set_length(1); |
| 1861 native_context()->set_promise_resolve_shared_fun(*info); | 1885 native_context()->set_promise_resolve_shared_fun(*info); |
| 1862 | 1886 |
| (...skipping 2735 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4598 } | 4622 } |
| 4599 | 4623 |
| 4600 | 4624 |
| 4601 // Called when the top-level V8 mutex is destroyed. | 4625 // Called when the top-level V8 mutex is destroyed. |
| 4602 void Bootstrapper::FreeThreadResources() { | 4626 void Bootstrapper::FreeThreadResources() { |
| 4603 DCHECK(!IsActive()); | 4627 DCHECK(!IsActive()); |
| 4604 } | 4628 } |
| 4605 | 4629 |
| 4606 } // namespace internal | 4630 } // namespace internal |
| 4607 } // namespace v8 | 4631 } // namespace v8 |
| OLD | NEW |