Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: src/bootstrapper.cc

Issue 2695753002: [ESnext] Implement Promise.prototype.finally (Closed)
Patch Set: add comments Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | src/builtins/builtins.h » ('j') | src/builtins/builtins-promise.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 native_context()->set_promise_then_finally_shared_fun(*info);
neis 2017/02/15 12:40:39 Nit: put this block in { }. Same below. Should w
gsathya 2017/02/16 15:05:29 Why?
neis 2017/02/17 10:22:54 I find it easier to read if it's immediately clear
gsathya 2017/02/17 11:26:15 Ok. I made each SFI creation its own block
3648
3649 code = handle(isolate()->builtins()->builtin(Builtins::kPromiseCatchFinally),
3650 isolate());
3651 info =
3652 factory()->NewSharedFunctionInfo(factory()->empty_string(), code, false);
3653 info->set_internal_formal_parameter_count(1);
3654 info->set_length(1);
3655 native_context()->set_promise_catch_finally_shared_fun(*info);
3656
3657 code = handle(
3658 isolate()->builtins()->builtin(Builtins::kPromiseValueThunkFinally),
3659 isolate());
3660 info =
3661 factory()->NewSharedFunctionInfo(factory()->empty_string(), code, false);
3662 info->set_internal_formal_parameter_count(0);
3663 info->set_length(0);
3664 native_context()->set_promise_value_thunk_finally_shared_fun(*info);
3665
3666 code =
3667 handle(isolate()->builtins()->builtin(Builtins::kPromiseThrowerFinally),
3668 isolate());
3669 info =
3670 factory()->NewSharedFunctionInfo(factory()->empty_string(), code, false);
3671 info->set_internal_formal_parameter_count(0);
3672 info->set_length(0);
3673 native_context()->set_promise_thrower_finally_shared_fun(*info);
3674 }
3675
3627 Handle<JSFunction> Genesis::InstallArrayBuffer(Handle<JSObject> target, 3676 Handle<JSFunction> Genesis::InstallArrayBuffer(Handle<JSObject> target,
3628 const char* name, 3677 const char* name,
3629 Builtins::Name call, 3678 Builtins::Name call,
3630 BuiltinFunctionId id) { 3679 BuiltinFunctionId id) {
3631 // Create the %ArrayBufferPrototype% 3680 // Create the %ArrayBufferPrototype%
3632 // Setup the {prototype} with the given {name} for @@toStringTag. 3681 // Setup the {prototype} with the given {name} for @@toStringTag.
3633 Handle<JSObject> prototype = 3682 Handle<JSObject> prototype =
3634 factory()->NewJSObject(isolate()->object_function(), TENURED); 3683 factory()->NewJSObject(isolate()->object_function(), TENURED);
3635 JSObject::AddProperty(prototype, factory()->to_string_tag_symbol(), 3684 JSObject::AddProperty(prototype, factory()->to_string_tag_symbol(),
3636 factory()->NewStringFromAsciiChecked(name), 3685 factory()->NewStringFromAsciiChecked(name),
(...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after
4083 nullptr}; 4132 nullptr};
4084 static const char* datetime_format_to_parts_natives[] = { 4133 static const char* datetime_format_to_parts_natives[] = {
4085 "native datetime-format-to-parts.js", nullptr}; 4134 "native datetime-format-to-parts.js", nullptr};
4086 #endif 4135 #endif
4087 static const char* harmony_restrictive_generators_natives[] = {nullptr}; 4136 static const char* harmony_restrictive_generators_natives[] = {nullptr};
4088 static const char* harmony_trailing_commas_natives[] = {nullptr}; 4137 static const char* harmony_trailing_commas_natives[] = {nullptr};
4089 static const char* harmony_class_fields_natives[] = {nullptr}; 4138 static const char* harmony_class_fields_natives[] = {nullptr};
4090 static const char* harmony_object_rest_spread_natives[] = {nullptr}; 4139 static const char* harmony_object_rest_spread_natives[] = {nullptr};
4091 static const char* harmony_async_iteration_natives[] = {nullptr}; 4140 static const char* harmony_async_iteration_natives[] = {nullptr};
4092 static const char* harmony_dynamic_import_natives[] = {nullptr}; 4141 static const char* harmony_dynamic_import_natives[] = {nullptr};
4142 static const char* harmony_promise_finally_natives[] = {nullptr};
4093 4143
4094 for (int i = ExperimentalNatives::GetDebuggerCount(); 4144 for (int i = ExperimentalNatives::GetDebuggerCount();
4095 i < ExperimentalNatives::GetBuiltinsCount(); i++) { 4145 i < ExperimentalNatives::GetBuiltinsCount(); i++) {
4096 #define INSTALL_EXPERIMENTAL_NATIVES(id, desc) \ 4146 #define INSTALL_EXPERIMENTAL_NATIVES(id, desc) \
4097 if (FLAG_##id) { \ 4147 if (FLAG_##id) { \
4098 for (size_t j = 0; id##_natives[j] != NULL; j++) { \ 4148 for (size_t j = 0; id##_natives[j] != NULL; j++) { \
4099 Vector<const char> script_name = ExperimentalNatives::GetScriptName(i); \ 4149 Vector<const char> script_name = ExperimentalNatives::GetScriptName(i); \
4100 if (strncmp(script_name.start(), id##_natives[j], \ 4150 if (strncmp(script_name.start(), id##_natives[j], \
4101 script_name.length()) == 0) { \ 4151 script_name.length()) == 0) { \
4102 if (!Bootstrapper::CompileExperimentalBuiltin(isolate(), i)) { \ 4152 if (!Bootstrapper::CompileExperimentalBuiltin(isolate(), i)) { \
(...skipping 736 matching lines...) Expand 10 before | Expand all | Expand 10 after
4839 } 4889 }
4840 4890
4841 4891
4842 // Called when the top-level V8 mutex is destroyed. 4892 // Called when the top-level V8 mutex is destroyed.
4843 void Bootstrapper::FreeThreadResources() { 4893 void Bootstrapper::FreeThreadResources() {
4844 DCHECK(!IsActive()); 4894 DCHECK(!IsActive());
4845 } 4895 }
4846 4896
4847 } // namespace internal 4897 } // namespace internal
4848 } // namespace v8 4898 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | src/builtins/builtins.h » ('j') | src/builtins/builtins-promise.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698