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

Unified Diff: src/interpreter/interpreter-intrinsics.cc

Issue 2645313003: [async-iteration] implement Async-from-Sync Iterator (Closed)
Patch Set: more stuff 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 side-by-side diff with in-line comments
Download patch
Index: src/interpreter/interpreter-intrinsics.cc
diff --git a/src/interpreter/interpreter-intrinsics.cc b/src/interpreter/interpreter-intrinsics.cc
index 3893b027b1a2ae361c0bc63a4d16e4f1bf016926..f29604fdafcab900564ab0f650670048c9eac1c9 100644
--- a/src/interpreter/interpreter-intrinsics.cc
+++ b/src/interpreter/interpreter-intrinsics.cc
@@ -298,6 +298,44 @@ Node* IntrinsicsHelper::ClassOf(Node* args_reg, Node* arg_count,
return __ ClassOf(value);
}
+Node* IntrinsicsHelper::CreateAsyncFromSyncIterator(Node* args_reg,
+ Node* arg_count,
+ Node* context) {
+ InterpreterAssembler::Label not_receiver(
+ assembler_, InterpreterAssembler::Label::kDeferred);
+ InterpreterAssembler::Label done(assembler_);
+ InterpreterAssembler::Variable return_value(assembler_,
+ MachineRepresentation::kTagged);
+
+ Node* sync_iterator = __ LoadRegister(args_reg);
+
+ __ GotoIf(__ TaggedIsSmi(sync_iterator), &not_receiver);
neis 2017/02/20 11:27:59 IsJSReceiver already does this.
caitp 2017/02/20 17:09:35 ``` Node* CodeStubAssembler::IsJSReceiver(Node* ob
neis 2017/02/20 18:26:54 Sorry, I thought you were using the version define
caitp 2017/02/20 20:09:19 Acknowledged.
+ __ GotoUnless(__ IsJSReceiver(sync_iterator), &not_receiver);
+
+ Node* const native_context = __ LoadNativeContext(context);
+ Node* const map = __ LoadContextElement(
+ native_context, Context::ASYNC_FROM_SYNC_ITERATOR_MAP_INDEX);
+ Node* const iterator = __ AllocateJSObjectFromMap(map);
+
+ __ StoreObjectFieldNoWriteBarrier(
+ iterator, JSAsyncFromSyncIterator::kSyncIteratorOffset, sync_iterator);
+
+ return_value.Bind(iterator);
+ __ Goto(&done);
+
+ __ Bind(&not_receiver);
+ {
+ return_value.Bind(
+ __ CallRuntime(Runtime::kThrowSymbolIteratorInvalid, context));
+
+ // Unreachable due to the Throw in runtime call.
+ __ Goto(&done);
+ }
+
+ __ Bind(&done);
+ return return_value.value();
+}
+
void IntrinsicsHelper::AbortIfArgCountMismatch(int expected, Node* actual) {
InterpreterAssembler::Label match(assembler_);
Node* comparison = __ Word32Equal(actual, __ Int32Constant(expected));

Powered by Google App Engine
This is Rietveld 408576698