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 1844 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1855 info->SetConstructStub(*isolate->builtins()->JSBuiltinsConstructStub()); | 1855 info->SetConstructStub(*isolate->builtins()->JSBuiltinsConstructStub()); |
1856 info->set_instance_class_name(isolate->heap()->Object_string()); | 1856 info->set_instance_class_name(isolate->heap()->Object_string()); |
1857 info->set_internal_formal_parameter_count(2); | 1857 info->set_internal_formal_parameter_count(2); |
1858 info->set_length(2); | 1858 info->set_length(2); |
1859 native_context()->set_promise_get_capabilities_executor_shared_fun(*info); | 1859 native_context()->set_promise_get_capabilities_executor_shared_fun(*info); |
1860 | 1860 |
1861 // %new_promise_capability(C, debugEvent) | 1861 // %new_promise_capability(C, debugEvent) |
1862 Handle<JSFunction> new_promise_capability = | 1862 Handle<JSFunction> new_promise_capability = |
1863 SimpleCreateFunction(isolate, factory->empty_string(), | 1863 SimpleCreateFunction(isolate, factory->empty_string(), |
1864 Builtins::kNewPromiseCapability, 2, false); | 1864 Builtins::kNewPromiseCapability, 2, false); |
1865 new_promise_capability->shared()->set_native(false); | |
1866 InstallWithIntrinsicDefaultProto(isolate, new_promise_capability, | 1865 InstallWithIntrinsicDefaultProto(isolate, new_promise_capability, |
1867 Context::NEW_PROMISE_CAPABILITY_INDEX); | 1866 Context::NEW_PROMISE_CAPABILITY_INDEX); |
1868 } | 1867 } |
1869 | 1868 |
1870 { // -- P r o m i s e | 1869 { // -- P r o m i s e |
1871 // Set catch prediction | 1870 // Set catch prediction |
1872 Handle<Code> promise_code = isolate->builtins()->PromiseConstructor(); | 1871 Handle<Code> promise_code = isolate->builtins()->PromiseConstructor(); |
1873 promise_code->set_is_promise_rejection(true); | 1872 promise_code->set_is_promise_rejection(true); |
1874 | 1873 |
1875 Handle<JSObject> prototype = | 1874 Handle<JSObject> prototype = |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1927 SimpleCreateFunction(isolate, factory->empty_string(), | 1926 SimpleCreateFunction(isolate, factory->empty_string(), |
1928 Builtins::kPromiseInternalConstructor, 1, true); | 1927 Builtins::kPromiseInternalConstructor, 1, true); |
1929 function->shared()->set_native(false); | 1928 function->shared()->set_native(false); |
1930 InstallWithIntrinsicDefaultProto( | 1929 InstallWithIntrinsicDefaultProto( |
1931 isolate, function, Context::PROMISE_INTERNAL_CONSTRUCTOR_INDEX); | 1930 isolate, function, Context::PROMISE_INTERNAL_CONSTRUCTOR_INDEX); |
1932 } | 1931 } |
1933 | 1932 |
1934 { // Internal: IsPromise | 1933 { // Internal: IsPromise |
1935 Handle<JSFunction> function = SimpleCreateFunction( | 1934 Handle<JSFunction> function = SimpleCreateFunction( |
1936 isolate, factory->empty_string(), Builtins::kIsPromise, 1, false); | 1935 isolate, factory->empty_string(), Builtins::kIsPromise, 1, false); |
1937 function->shared()->set_native(false); | |
1938 InstallWithIntrinsicDefaultProto(isolate, function, | 1936 InstallWithIntrinsicDefaultProto(isolate, function, |
1939 Context::IS_PROMISE_INDEX); | 1937 Context::IS_PROMISE_INDEX); |
1940 } | 1938 } |
1941 | 1939 |
1942 { // Internal: ResolvePromise | 1940 { // Internal: ResolvePromise |
1943 // Also exposed as extrasUtils.resolvePromise. | 1941 // Also exposed as extrasUtils.resolvePromise. |
1944 Handle<JSFunction> function = SimpleCreateFunction( | 1942 Handle<JSFunction> function = SimpleCreateFunction( |
1945 isolate, factory->empty_string(), Builtins::kResolvePromise, 2, true); | 1943 isolate, factory->empty_string(), Builtins::kResolvePromise, 2, true); |
1946 function->shared()->set_native(false); | 1944 function->shared()->set_native(false); |
1947 InstallWithIntrinsicDefaultProto(isolate, function, | 1945 InstallWithIntrinsicDefaultProto(isolate, function, |
1948 Context::PROMISE_RESOLVE_INDEX); | 1946 Context::PROMISE_RESOLVE_INDEX); |
1949 } | 1947 } |
1950 | 1948 |
1951 { // Internal: PromiseHandle | 1949 { // Internal: PromiseHandle |
1952 Handle<JSFunction> function = SimpleCreateFunction( | 1950 Handle<JSFunction> function = SimpleCreateFunction( |
1953 isolate, factory->empty_string(), Builtins::kPromiseHandle, 5, false); | 1951 isolate, factory->empty_string(), Builtins::kPromiseHandle, 5, false); |
1954 function->shared()->set_native(false); | |
1955 InstallWithIntrinsicDefaultProto(isolate, function, | 1952 InstallWithIntrinsicDefaultProto(isolate, function, |
1956 Context::PROMISE_HANDLE_INDEX); | 1953 Context::PROMISE_HANDLE_INDEX); |
1957 // Set up catch prediction | 1954 // Set up catch prediction |
1958 Handle<Code> promise_handle = isolate->builtins()->PromiseHandle(); | 1955 Handle<Code> promise_handle = isolate->builtins()->PromiseHandle(); |
1959 promise_handle->set_is_promise_rejection(true); | 1956 promise_handle->set_is_promise_rejection(true); |
1960 } | 1957 } |
1961 | 1958 |
1962 { // Internal: PromiseHandleReject | 1959 { // Internal: PromiseHandleReject |
1963 Handle<JSFunction> function = | 1960 Handle<JSFunction> function = |
1964 SimpleCreateFunction(isolate, factory->empty_string(), | 1961 SimpleCreateFunction(isolate, factory->empty_string(), |
1965 Builtins::kPromiseHandleReject, 3, false); | 1962 Builtins::kPromiseHandleReject, 3, false); |
1966 function->shared()->set_native(false); | |
1967 InstallWithIntrinsicDefaultProto(isolate, function, | 1963 InstallWithIntrinsicDefaultProto(isolate, function, |
1968 Context::PROMISE_HANDLE_REJECT_INDEX); | 1964 Context::PROMISE_HANDLE_REJECT_INDEX); |
1969 // Set up catch prediction | 1965 // Set up catch prediction |
1970 Handle<Code> promise_handle = isolate->builtins()->PromiseHandleReject(); | 1966 Handle<Code> promise_handle = isolate->builtins()->PromiseHandleReject(); |
1971 promise_handle->set_is_exception_caught(true); | 1967 promise_handle->set_is_exception_caught(true); |
1972 } | 1968 } |
1973 | 1969 |
1974 { // Internal: InternalPromiseReject | 1970 { // Internal: InternalPromiseReject |
1975 Handle<JSFunction> function = | 1971 Handle<JSFunction> function = |
1976 SimpleCreateFunction(isolate, factory->empty_string(), | 1972 SimpleCreateFunction(isolate, factory->empty_string(), |
(...skipping 1400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3377 async_function_constructor, | 3373 async_function_constructor, |
3378 static_cast<PropertyAttributes>(DONT_ENUM | READ_ONLY)); | 3374 static_cast<PropertyAttributes>(DONT_ENUM | READ_ONLY)); |
3379 | 3375 |
3380 JSFunction::SetPrototype(async_function_constructor, | 3376 JSFunction::SetPrototype(async_function_constructor, |
3381 async_function_prototype); | 3377 async_function_prototype); |
3382 | 3378 |
3383 { | 3379 { |
3384 Handle<JSFunction> function = | 3380 Handle<JSFunction> function = |
3385 SimpleCreateFunction(isolate, factory->empty_string(), | 3381 SimpleCreateFunction(isolate, factory->empty_string(), |
3386 Builtins::kAsyncFunctionAwaitCaught, 3, false); | 3382 Builtins::kAsyncFunctionAwaitCaught, 3, false); |
3387 function->shared()->set_native(false); | |
3388 InstallWithIntrinsicDefaultProto( | 3383 InstallWithIntrinsicDefaultProto( |
3389 isolate, function, Context::ASYNC_FUNCTION_AWAIT_CAUGHT_INDEX); | 3384 isolate, function, Context::ASYNC_FUNCTION_AWAIT_CAUGHT_INDEX); |
3390 } | 3385 } |
3391 | 3386 |
3392 { | 3387 { |
3393 Handle<JSFunction> function = | 3388 Handle<JSFunction> function = |
3394 SimpleCreateFunction(isolate, factory->empty_string(), | 3389 SimpleCreateFunction(isolate, factory->empty_string(), |
3395 Builtins::kAsyncFunctionAwaitUncaught, 3, false); | 3390 Builtins::kAsyncFunctionAwaitUncaught, 3, false); |
3396 function->shared()->set_native(false); | |
3397 InstallWithIntrinsicDefaultProto( | 3391 InstallWithIntrinsicDefaultProto( |
3398 isolate, function, Context::ASYNC_FUNCTION_AWAIT_UNCAUGHT_INDEX); | 3392 isolate, function, Context::ASYNC_FUNCTION_AWAIT_UNCAUGHT_INDEX); |
3399 } | 3393 } |
3400 | 3394 |
3401 { | 3395 { |
3402 Handle<Code> code = | 3396 Handle<Code> code = |
3403 isolate->builtins()->AsyncFunctionAwaitRejectClosure(); | 3397 isolate->builtins()->AsyncFunctionAwaitRejectClosure(); |
3404 Handle<SharedFunctionInfo> info = | 3398 Handle<SharedFunctionInfo> info = |
3405 factory->NewSharedFunctionInfo(factory->empty_string(), code, false); | 3399 factory->NewSharedFunctionInfo(factory->empty_string(), code, false); |
3406 info->set_internal_formal_parameter_count(1); | 3400 info->set_internal_formal_parameter_count(1); |
3407 info->set_length(1); | 3401 info->set_length(1); |
3408 native_context->set_async_function_await_reject_shared_fun(*info); | 3402 native_context->set_async_function_await_reject_shared_fun(*info); |
3409 } | 3403 } |
3410 | 3404 |
3411 { | 3405 { |
3412 Handle<Code> code = | 3406 Handle<Code> code = |
3413 isolate->builtins()->AsyncFunctionAwaitResolveClosure(); | 3407 isolate->builtins()->AsyncFunctionAwaitResolveClosure(); |
3414 Handle<SharedFunctionInfo> info = | 3408 Handle<SharedFunctionInfo> info = |
3415 factory->NewSharedFunctionInfo(factory->empty_string(), code, false); | 3409 factory->NewSharedFunctionInfo(factory->empty_string(), code, false); |
3416 info->set_internal_formal_parameter_count(1); | 3410 info->set_internal_formal_parameter_count(1); |
3417 info->set_length(1); | 3411 info->set_length(1); |
3418 native_context->set_async_function_await_resolve_shared_fun(*info); | 3412 native_context->set_async_function_await_resolve_shared_fun(*info); |
3419 } | 3413 } |
3420 | 3414 |
3421 { | 3415 { |
3422 Handle<JSFunction> function = | 3416 Handle<JSFunction> function = |
3423 SimpleCreateFunction(isolate, factory->empty_string(), | 3417 SimpleCreateFunction(isolate, factory->empty_string(), |
3424 Builtins::kAsyncFunctionPromiseCreate, 0, false); | 3418 Builtins::kAsyncFunctionPromiseCreate, 0, false); |
3425 function->shared()->set_native(false); | |
3426 InstallWithIntrinsicDefaultProto( | 3419 InstallWithIntrinsicDefaultProto( |
3427 isolate, function, Context::ASYNC_FUNCTION_PROMISE_CREATE_INDEX); | 3420 isolate, function, Context::ASYNC_FUNCTION_PROMISE_CREATE_INDEX); |
3428 } | 3421 } |
3429 | 3422 |
3430 { | 3423 { |
3431 Handle<JSFunction> function = SimpleCreateFunction( | 3424 Handle<JSFunction> function = SimpleCreateFunction( |
3432 isolate, factory->empty_string(), | 3425 isolate, factory->empty_string(), |
3433 Builtins::kAsyncFunctionPromiseRelease, 1, false); | 3426 Builtins::kAsyncFunctionPromiseRelease, 1, false); |
3434 function->shared()->set_native(false); | |
3435 InstallWithIntrinsicDefaultProto( | 3427 InstallWithIntrinsicDefaultProto( |
3436 isolate, function, Context::ASYNC_FUNCTION_PROMISE_RELEASE_INDEX); | 3428 isolate, function, Context::ASYNC_FUNCTION_PROMISE_RELEASE_INDEX); |
3437 } | 3429 } |
3438 } | 3430 } |
3439 | 3431 |
3440 { // -- C a l l S i t e | 3432 { // -- C a l l S i t e |
3441 // Builtin functions for CallSite. | 3433 // Builtin functions for CallSite. |
3442 | 3434 |
3443 // CallSites are a special case; the constructor is for our private use | 3435 // CallSites are a special case; the constructor is for our private use |
3444 // only, therefore we set it up as a builtin that throws. Internally, we use | 3436 // 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 Loading... |
4848 } | 4840 } |
4849 | 4841 |
4850 | 4842 |
4851 // Called when the top-level V8 mutex is destroyed. | 4843 // Called when the top-level V8 mutex is destroyed. |
4852 void Bootstrapper::FreeThreadResources() { | 4844 void Bootstrapper::FreeThreadResources() { |
4853 DCHECK(!IsActive()); | 4845 DCHECK(!IsActive()); |
4854 } | 4846 } |
4855 | 4847 |
4856 } // namespace internal | 4848 } // namespace internal |
4857 } // namespace v8 | 4849 } // namespace v8 |
OLD | NEW |