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

Unified Diff: src/builtins/builtins-promise.cc

Issue 2567033003: [promises] Port CreateResolvingFunctions to TF (Closed)
Patch Set: add tests Created 4 years 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 side-by-side diff with in-line comments
Download patch
Index: src/builtins/builtins-promise.cc
diff --git a/src/builtins/builtins-promise.cc b/src/builtins/builtins-promise.cc
index 8acd509ccbf9a2f1c6c2662065439a04e69615b2..9a2fe2c298bd026f2ce3695bff6e8416216dfc60 100644
--- a/src/builtins/builtins-promise.cc
+++ b/src/builtins/builtins-promise.cc
@@ -38,23 +38,35 @@ BUILTIN(PromiseRejectClosure) {
// ES#sec-createresolvingfunctions
// CreateResolvingFunctions ( promise )
-BUILTIN(CreateResolvingFunctions) {
- HandleScope scope(isolate);
- DCHECK_EQ(3, args.length());
+void Builtins::Generate_CreateResolvingFunctions(
+ compiler::CodeAssemblerState* state) {
+ CodeStubAssembler a(state);
+ typedef compiler::Node Node;
+
+ Node* const promise = a.Parameter(1);
+ Node* const debug_event = a.Parameter(2);
+ Node* const context = a.Parameter(5);
+ Node* const native_context = a.LoadNativeContext(context);
+
+ Node* resolve = nullptr;
+ Node* reject = nullptr;
- Handle<JSObject> promise = args.at<JSObject>(1);
- Handle<Object> debug_event = args.at<Object>(2);
- Handle<JSFunction> resolve, reject;
+ std::tie(resolve, reject) =
+ a.CreatePromiseResolvingFunctions(promise, debug_event, native_context);
- PromiseUtils::CreateResolvingFunctions(isolate, promise, debug_event,
- &resolve, &reject);
+ Node* const kSize = a.Int32Constant(2);
+ Node* const arr = a.AllocateFixedArray(FAST_ELEMENTS, kSize);
+ a.StoreFixedArrayElement(arr, 0, resolve);
jgruber 2016/12/13 10:44:04 We can skip write barriers when arr is guaranteed
gsathya 2016/12/13 13:01:46 Done.
+ a.StoreFixedArrayElement(arr, 1, reject);
- Handle<FixedArray> result = isolate->factory()->NewFixedArray(2);
- result->set(0, *resolve);
- result->set(1, *reject);
+ const ElementsKind kind = FAST_ELEMENTS;
jgruber 2016/12/13 10:44:04 If you pull this up you could use it in AllocateFi
gsathya 2016/12/13 13:01:46 Done.
+ Node* const array_map = a.LoadJSArrayElementsMap(kind, native_context);
+ Node* const length = a.SmiTag(kSize);
+ Node* const result = a.AllocateUninitializedJSArrayWithoutElements(
+ kind, array_map, length, nullptr);
- return *isolate->factory()->NewJSArrayWithElements(result, FAST_ELEMENTS, 2,
- NOT_TENURED);
+ a.StoreObjectField(result, JSObject::kElementsOffset, arr);
+ a.Return(result);
}
void Builtins::Generate_PromiseConstructor(
@@ -127,13 +139,12 @@ void Builtins::Generate_PromiseConstructor(
{
Label out(&a), if_rejectpromise(&a), debug_pop(&a, Label::kDeferred);
- // TODO(gsathya): Move this to TF.
- Node* const resolving_functions = a.CallRuntime(
- Runtime::kCreateResolvingFunctions, context, var_result.value());
- Node* const resolve =
- a.LoadFixedArrayElement(resolving_functions, a.IntPtrConstant(0));
- Node* const reject =
- a.LoadFixedArrayElement(resolving_functions, a.IntPtrConstant(1));
+ Node* resolve = nullptr;
+ Node* reject = nullptr;
+
+ std::tie(resolve, reject) = a.CreatePromiseResolvingFunctions(
+ var_result.value(), a.BooleanConstant(true), native_context);
jgruber 2016/12/13 10:44:04 a.TrueConstant()
gsathya 2016/12/13 13:01:46 Done.
+
Callable call_callable = CodeFactory::Call(isolate);
Node* const maybe_exception =
« no previous file with comments | « src/builtins/builtins.h ('k') | src/code-stub-assembler.h » ('j') | src/code-stub-assembler.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698