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 1897 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1908 true, DONT_ENUM); | 1908 true, DONT_ENUM); |
1909 | 1909 |
1910 Handle<Map> prototype_map(prototype->map()); | 1910 Handle<Map> prototype_map(prototype->map()); |
1911 Map::SetShouldBeFastPrototypeMap(prototype_map, true, isolate); | 1911 Map::SetShouldBeFastPrototypeMap(prototype_map, true, isolate); |
1912 | 1912 |
1913 // Store the initial Promise.prototype map. This is used in fast-path | 1913 // Store the initial Promise.prototype map. This is used in fast-path |
1914 // checks. Do not alter the prototype after this point. | 1914 // checks. Do not alter the prototype after this point. |
1915 native_context()->set_promise_prototype_map(*prototype_map); | 1915 native_context()->set_promise_prototype_map(*prototype_map); |
1916 | 1916 |
1917 { // Internal: PromiseInternalConstructor | 1917 { // Internal: PromiseInternalConstructor |
| 1918 // Also exposed as extrasUtils.createPromise. |
1918 Handle<JSFunction> function = | 1919 Handle<JSFunction> function = |
1919 SimpleCreateFunction(isolate, factory->empty_string(), | 1920 SimpleCreateFunction(isolate, factory->empty_string(), |
1920 Builtins::kPromiseInternalConstructor, 1, false); | 1921 Builtins::kPromiseInternalConstructor, 1, true); |
1921 InstallWithIntrinsicDefaultProto( | 1922 InstallWithIntrinsicDefaultProto( |
1922 isolate, function, Context::PROMISE_INTERNAL_CONSTRUCTOR_INDEX); | 1923 isolate, function, Context::PROMISE_INTERNAL_CONSTRUCTOR_INDEX); |
1923 } | 1924 } |
1924 | 1925 |
1925 { // Internal: IsPromise | 1926 { // Internal: IsPromise |
1926 Handle<JSFunction> function = SimpleCreateFunction( | 1927 Handle<JSFunction> function = SimpleCreateFunction( |
1927 isolate, factory->empty_string(), Builtins::kIsPromise, 1, false); | 1928 isolate, factory->empty_string(), Builtins::kIsPromise, 1, false); |
1928 InstallWithIntrinsicDefaultProto(isolate, function, | 1929 InstallWithIntrinsicDefaultProto(isolate, function, |
1929 Context::IS_PROMISE_INDEX); | 1930 Context::IS_PROMISE_INDEX); |
1930 } | 1931 } |
1931 | 1932 |
1932 { // Internal: PerformPromiseThen | 1933 { // Internal: PerformPromiseThen |
1933 Handle<JSFunction> function = | 1934 Handle<JSFunction> function = |
1934 SimpleCreateFunction(isolate, factory->empty_string(), | 1935 SimpleCreateFunction(isolate, factory->empty_string(), |
1935 Builtins::kPerformPromiseThen, 4, false); | 1936 Builtins::kPerformPromiseThen, 4, false); |
1936 InstallWithIntrinsicDefaultProto(isolate, function, | 1937 InstallWithIntrinsicDefaultProto(isolate, function, |
1937 Context::PERFORM_PROMISE_THEN_INDEX); | 1938 Context::PERFORM_PROMISE_THEN_INDEX); |
1938 } | 1939 } |
1939 | 1940 |
1940 { // Internal: ResolvePromise | 1941 { // Internal: ResolvePromise |
1941 Handle<JSFunction> function = | 1942 // Also exposed as extrasUtils.resolvePromise. |
1942 SimpleCreateFunction(isolate, factory->empty_string(), | 1943 Handle<JSFunction> function = SimpleCreateFunction( |
1943 Builtins::kResolvePromise, 2, false); | 1944 isolate, factory->empty_string(), Builtins::kResolvePromise, 2, true); |
1944 InstallWithIntrinsicDefaultProto(isolate, function, | 1945 InstallWithIntrinsicDefaultProto(isolate, function, |
1945 Context::PROMISE_RESOLVE_INDEX); | 1946 Context::PROMISE_RESOLVE_INDEX); |
1946 } | 1947 } |
1947 | 1948 |
1948 { // Internal: PromiseHandle | 1949 { // Internal: PromiseHandle |
1949 Handle<JSFunction> function = SimpleCreateFunction( | 1950 Handle<JSFunction> function = SimpleCreateFunction( |
1950 isolate, factory->empty_string(), Builtins::kPromiseHandle, 6, true); | 1951 isolate, factory->empty_string(), Builtins::kPromiseHandle, 6, true); |
1951 InstallWithIntrinsicDefaultProto(isolate, function, | 1952 InstallWithIntrinsicDefaultProto(isolate, function, |
1952 Context::PROMISE_HANDLE_INDEX); | 1953 Context::PROMISE_HANDLE_INDEX); |
1953 // Set up catch prediction | 1954 // Set up catch prediction |
(...skipping 1677 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3631 native_context()->set_natives_utils_object(*utils); | 3632 native_context()->set_natives_utils_object(*utils); |
3632 | 3633 |
3633 // Set up the extras utils object as a shared container between native | 3634 // Set up the extras utils object as a shared container between native |
3634 // scripts and extras. (Extras consume things added there by native scripts.) | 3635 // scripts and extras. (Extras consume things added there by native scripts.) |
3635 Handle<JSObject> extras_utils = | 3636 Handle<JSObject> extras_utils = |
3636 factory()->NewJSObject(isolate()->object_function()); | 3637 factory()->NewJSObject(isolate()->object_function()); |
3637 native_context()->set_extras_utils_object(*extras_utils); | 3638 native_context()->set_extras_utils_object(*extras_utils); |
3638 | 3639 |
3639 InstallInternalArray(extras_utils, "InternalPackedArray", FAST_ELEMENTS); | 3640 InstallInternalArray(extras_utils, "InternalPackedArray", FAST_ELEMENTS); |
3640 | 3641 |
| 3642 InstallFunction(extras_utils, isolate()->promise_internal_constructor(), |
| 3643 factory()->NewStringFromAsciiChecked("createPromise")); |
3641 InstallFunction(extras_utils, isolate()->promise_resolve(), | 3644 InstallFunction(extras_utils, isolate()->promise_resolve(), |
3642 factory()->NewStringFromAsciiChecked("resolvePromise")); | 3645 factory()->NewStringFromAsciiChecked("resolvePromise")); |
3643 | 3646 |
3644 int builtin_index = Natives::GetDebuggerCount(); | 3647 int builtin_index = Natives::GetDebuggerCount(); |
3645 // Only run prologue.js and runtime.js at this point. | 3648 // Only run prologue.js and runtime.js at this point. |
3646 DCHECK_EQ(builtin_index, Natives::GetIndex("prologue")); | 3649 DCHECK_EQ(builtin_index, Natives::GetIndex("prologue")); |
3647 if (!Bootstrapper::CompileBuiltin(isolate(), builtin_index++)) return false; | 3650 if (!Bootstrapper::CompileBuiltin(isolate(), builtin_index++)) return false; |
3648 DCHECK_EQ(builtin_index, Natives::GetIndex("runtime")); | 3651 DCHECK_EQ(builtin_index, Natives::GetIndex("runtime")); |
3649 if (!Bootstrapper::CompileBuiltin(isolate(), builtin_index++)) return false; | 3652 if (!Bootstrapper::CompileBuiltin(isolate(), builtin_index++)) return false; |
3650 | 3653 |
(...skipping 1091 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4742 } | 4745 } |
4743 | 4746 |
4744 | 4747 |
4745 // Called when the top-level V8 mutex is destroyed. | 4748 // Called when the top-level V8 mutex is destroyed. |
4746 void Bootstrapper::FreeThreadResources() { | 4749 void Bootstrapper::FreeThreadResources() { |
4747 DCHECK(!IsActive()); | 4750 DCHECK(!IsActive()); |
4748 } | 4751 } |
4749 | 4752 |
4750 } // namespace internal | 4753 } // namespace internal |
4751 } // namespace v8 | 4754 } // namespace v8 |
OLD | NEW |