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 3606 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3617 NONE); | 3617 NONE); |
3618 } | 3618 } |
3619 | 3619 |
3620 void Genesis::InitializeGlobal_harmony_async_iteration() { | 3620 void Genesis::InitializeGlobal_harmony_async_iteration() { |
3621 if (!FLAG_harmony_async_iteration) return; | 3621 if (!FLAG_harmony_async_iteration) return; |
3622 Handle<JSFunction> symbol_fun(native_context()->symbol_function()); | 3622 Handle<JSFunction> symbol_fun(native_context()->symbol_function()); |
3623 InstallConstant(isolate(), symbol_fun, "asyncIterator", | 3623 InstallConstant(isolate(), symbol_fun, "asyncIterator", |
3624 factory()->async_iterator_symbol()); | 3624 factory()->async_iterator_symbol()); |
3625 } | 3625 } |
3626 | 3626 |
| 3627 void Genesis::InitializeGlobal_harmony_promise_finally() { |
| 3628 if (!FLAG_harmony_promise_finally) return; |
| 3629 |
| 3630 Handle<JSFunction> constructor(native_context()->promise_function()); |
| 3631 Handle<JSObject> prototype(JSObject::cast(constructor->instance_prototype())); |
| 3632 SimpleInstallFunction(prototype, "finally", Builtins::kPromiseFinally, 1, |
| 3633 true, DONT_ENUM); |
| 3634 |
| 3635 // The promise prototype map has changed because we added a property |
| 3636 // to prototype, so we update the saved map. |
| 3637 Handle<Map> prototype_map(prototype->map()); |
| 3638 Map::SetShouldBeFastPrototypeMap(prototype_map, true, isolate()); |
| 3639 native_context()->set_promise_prototype_map(*prototype_map); |
| 3640 |
| 3641 Handle<Code> code = handle( |
| 3642 isolate()->builtins()->builtin(Builtins::kPromiseThenFinally), isolate()); |
| 3643 Handle<SharedFunctionInfo> info = |
| 3644 factory()->NewSharedFunctionInfo(factory()->empty_string(), code, false); |
| 3645 info->set_internal_formal_parameter_count(1); |
| 3646 info->set_length(1); |
| 3647 info->set_native(true); |
| 3648 native_context()->set_promise_then_finally_shared_fun(*info); |
| 3649 |
| 3650 code = handle(isolate()->builtins()->builtin(Builtins::kPromiseCatchFinally), |
| 3651 isolate()); |
| 3652 info = |
| 3653 factory()->NewSharedFunctionInfo(factory()->empty_string(), code, false); |
| 3654 info->set_internal_formal_parameter_count(1); |
| 3655 info->set_length(1); |
| 3656 info->set_native(true); |
| 3657 native_context()->set_promise_catch_finally_shared_fun(*info); |
| 3658 |
| 3659 code = handle( |
| 3660 isolate()->builtins()->builtin(Builtins::kPromiseValueThunkFinally), |
| 3661 isolate()); |
| 3662 info = |
| 3663 factory()->NewSharedFunctionInfo(factory()->empty_string(), code, false); |
| 3664 info->set_internal_formal_parameter_count(0); |
| 3665 info->set_length(0); |
| 3666 native_context()->set_promise_value_thunk_finally_shared_fun(*info); |
| 3667 |
| 3668 code = |
| 3669 handle(isolate()->builtins()->builtin(Builtins::kPromiseThrowerFinally), |
| 3670 isolate()); |
| 3671 info = |
| 3672 factory()->NewSharedFunctionInfo(factory()->empty_string(), code, false); |
| 3673 info->set_internal_formal_parameter_count(0); |
| 3674 info->set_length(0); |
| 3675 native_context()->set_promise_thrower_finally_shared_fun(*info); |
| 3676 } |
| 3677 |
3627 Handle<JSFunction> Genesis::InstallArrayBuffer(Handle<JSObject> target, | 3678 Handle<JSFunction> Genesis::InstallArrayBuffer(Handle<JSObject> target, |
3628 const char* name, | 3679 const char* name, |
3629 Builtins::Name call, | 3680 Builtins::Name call, |
3630 BuiltinFunctionId id) { | 3681 BuiltinFunctionId id) { |
3631 // Create the %ArrayBufferPrototype% | 3682 // Create the %ArrayBufferPrototype% |
3632 // Setup the {prototype} with the given {name} for @@toStringTag. | 3683 // Setup the {prototype} with the given {name} for @@toStringTag. |
3633 Handle<JSObject> prototype = | 3684 Handle<JSObject> prototype = |
3634 factory()->NewJSObject(isolate()->object_function(), TENURED); | 3685 factory()->NewJSObject(isolate()->object_function(), TENURED); |
3635 JSObject::AddProperty(prototype, factory()->to_string_tag_symbol(), | 3686 JSObject::AddProperty(prototype, factory()->to_string_tag_symbol(), |
3636 factory()->NewStringFromAsciiChecked(name), | 3687 factory()->NewStringFromAsciiChecked(name), |
(...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4083 nullptr}; | 4134 nullptr}; |
4084 static const char* datetime_format_to_parts_natives[] = { | 4135 static const char* datetime_format_to_parts_natives[] = { |
4085 "native datetime-format-to-parts.js", nullptr}; | 4136 "native datetime-format-to-parts.js", nullptr}; |
4086 #endif | 4137 #endif |
4087 static const char* harmony_restrictive_generators_natives[] = {nullptr}; | 4138 static const char* harmony_restrictive_generators_natives[] = {nullptr}; |
4088 static const char* harmony_trailing_commas_natives[] = {nullptr}; | 4139 static const char* harmony_trailing_commas_natives[] = {nullptr}; |
4089 static const char* harmony_class_fields_natives[] = {nullptr}; | 4140 static const char* harmony_class_fields_natives[] = {nullptr}; |
4090 static const char* harmony_object_rest_spread_natives[] = {nullptr}; | 4141 static const char* harmony_object_rest_spread_natives[] = {nullptr}; |
4091 static const char* harmony_async_iteration_natives[] = {nullptr}; | 4142 static const char* harmony_async_iteration_natives[] = {nullptr}; |
4092 static const char* harmony_dynamic_import_natives[] = {nullptr}; | 4143 static const char* harmony_dynamic_import_natives[] = {nullptr}; |
| 4144 static const char* harmony_promise_finally_natives[] = {nullptr}; |
4093 | 4145 |
4094 for (int i = ExperimentalNatives::GetDebuggerCount(); | 4146 for (int i = ExperimentalNatives::GetDebuggerCount(); |
4095 i < ExperimentalNatives::GetBuiltinsCount(); i++) { | 4147 i < ExperimentalNatives::GetBuiltinsCount(); i++) { |
4096 #define INSTALL_EXPERIMENTAL_NATIVES(id, desc) \ | 4148 #define INSTALL_EXPERIMENTAL_NATIVES(id, desc) \ |
4097 if (FLAG_##id) { \ | 4149 if (FLAG_##id) { \ |
4098 for (size_t j = 0; id##_natives[j] != NULL; j++) { \ | 4150 for (size_t j = 0; id##_natives[j] != NULL; j++) { \ |
4099 Vector<const char> script_name = ExperimentalNatives::GetScriptName(i); \ | 4151 Vector<const char> script_name = ExperimentalNatives::GetScriptName(i); \ |
4100 if (strncmp(script_name.start(), id##_natives[j], \ | 4152 if (strncmp(script_name.start(), id##_natives[j], \ |
4101 script_name.length()) == 0) { \ | 4153 script_name.length()) == 0) { \ |
4102 if (!Bootstrapper::CompileExperimentalBuiltin(isolate(), i)) { \ | 4154 if (!Bootstrapper::CompileExperimentalBuiltin(isolate(), i)) { \ |
(...skipping 736 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4839 } | 4891 } |
4840 | 4892 |
4841 | 4893 |
4842 // Called when the top-level V8 mutex is destroyed. | 4894 // Called when the top-level V8 mutex is destroyed. |
4843 void Bootstrapper::FreeThreadResources() { | 4895 void Bootstrapper::FreeThreadResources() { |
4844 DCHECK(!IsActive()); | 4896 DCHECK(!IsActive()); |
4845 } | 4897 } |
4846 | 4898 |
4847 } // namespace internal | 4899 } // namespace internal |
4848 } // namespace v8 | 4900 } // namespace v8 |
OLD | NEW |