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

Side by Side Diff: src/interpreter/bytecode-generator.cc

Issue 2637403008: [async-iteration] add support for for-await-of loops in Async Functions (Closed)
Patch Set: remove that comment 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 | « src/interpreter/bytecode-array-builder.cc ('k') | src/interpreter/constant-array-builder.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 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/interpreter/bytecode-generator.h" 5 #include "src/interpreter/bytecode-generator.h"
6 6
7 #include "src/ast/compile-time-value.h" 7 #include "src/ast/compile-time-value.h"
8 #include "src/ast/scopes.h" 8 #include "src/ast/scopes.h"
9 #include "src/builtins/builtins-constructor.h" 9 #include "src/builtins/builtins-constructor.h"
10 #include "src/code-stubs.h" 10 #include "src/code-stubs.h"
(...skipping 2955 matching lines...) Expand 10 before | Expand all | Expand 10 after
2966 void BytecodeGenerator::VisitGetIterator(GetIterator* expr) { 2966 void BytecodeGenerator::VisitGetIterator(GetIterator* expr) {
2967 FeedbackSlot load_slot = expr->IteratorPropertyFeedbackSlot(); 2967 FeedbackSlot load_slot = expr->IteratorPropertyFeedbackSlot();
2968 FeedbackSlot call_slot = expr->IteratorCallFeedbackSlot(); 2968 FeedbackSlot call_slot = expr->IteratorCallFeedbackSlot();
2969 2969
2970 RegisterList args = register_allocator()->NewRegisterList(1); 2970 RegisterList args = register_allocator()->NewRegisterList(1);
2971 Register method = register_allocator()->NewRegister(); 2971 Register method = register_allocator()->NewRegister();
2972 Register obj = args[0]; 2972 Register obj = args[0];
2973 2973
2974 VisitForAccumulatorValue(expr->iterable()); 2974 VisitForAccumulatorValue(expr->iterable());
2975 2975
2976 // Let method be GetMethod(obj, @@iterator). 2976 if (expr->hint() == IteratorType::kAsync) {
2977 builder() 2977 FeedbackSlot async_load_slot = expr->AsyncIteratorPropertyFeedbackSlot();
2978 ->StoreAccumulatorInRegister(obj) 2978 FeedbackSlot async_call_slot = expr->AsyncIteratorCallFeedbackSlot();
2979 .LoadIteratorProperty(obj, feedback_index(load_slot))
2980 .StoreAccumulatorInRegister(method);
2981 2979
2982 // Let iterator be Call(method, obj). 2980 // Set method to GetMethod(obj, @@asyncIterator)
2983 builder()->Call(method, args, feedback_index(call_slot), 2981 builder()->StoreAccumulatorInRegister(obj).LoadAsyncIteratorProperty(
2984 Call::NAMED_PROPERTY_CALL); 2982 obj, feedback_index(async_load_slot));
2985 2983
2986 // If Type(iterator) is not Object, throw a TypeError exception. 2984 BytecodeLabel async_iterator_undefined, async_iterator_null, done;
2987 BytecodeLabel no_type_error; 2985 // TODO(ignition): Add a single opcode for JumpIfNullOrUndefined
2988 builder()->JumpIfJSReceiver(&no_type_error); 2986 builder()->JumpIfUndefined(&async_iterator_undefined);
2989 builder()->CallRuntime(Runtime::kThrowSymbolIteratorInvalid); 2987 builder()->JumpIfNull(&async_iterator_null);
2990 builder()->Bind(&no_type_error); 2988
2989 // Let iterator be Call(method, obj)
2990 builder()->StoreAccumulatorInRegister(method).Call(
2991 method, args, feedback_index(async_call_slot),
2992 Call::NAMED_PROPERTY_CALL);
2993
2994 // If Type(iterator) is not Object, throw a TypeError exception.
2995 builder()->JumpIfJSReceiver(&done);
2996 builder()->CallRuntime(Runtime::kThrowSymbolAsyncIteratorInvalid);
2997
2998 builder()->Bind(&async_iterator_undefined);
2999 builder()->Bind(&async_iterator_null);
3000 // If method is undefined,
3001 // Let syncMethod be GetMethod(obj, @@iterator)
3002 builder()
3003 ->LoadIteratorProperty(obj, feedback_index(load_slot))
3004 .StoreAccumulatorInRegister(method);
3005
3006 // Let syncIterator be Call(syncMethod, obj)
3007 builder()->Call(method, args, feedback_index(call_slot),
3008 Call::NAMED_PROPERTY_CALL);
3009
3010 // Return CreateAsyncFromSyncIterator(syncIterator)
3011 // alias `method` register as it's no longer used
3012 Register sync_iter = method;
3013 builder()->StoreAccumulatorInRegister(sync_iter).CallRuntime(
3014 Runtime::kInlineCreateAsyncFromSyncIterator, sync_iter);
3015
3016 builder()->Bind(&done);
3017 } else {
3018 // Let method be GetMethod(obj, @@iterator).
3019 builder()
3020 ->StoreAccumulatorInRegister(obj)
3021 .LoadIteratorProperty(obj, feedback_index(load_slot))
3022 .StoreAccumulatorInRegister(method);
3023
3024 // Let iterator be Call(method, obj).
3025 builder()->Call(method, args, feedback_index(call_slot),
3026 Call::NAMED_PROPERTY_CALL);
3027
3028 // If Type(iterator) is not Object, throw a TypeError exception.
3029 BytecodeLabel no_type_error;
3030 builder()->JumpIfJSReceiver(&no_type_error);
3031 builder()->CallRuntime(Runtime::kThrowSymbolIteratorInvalid);
3032 builder()->Bind(&no_type_error);
3033 }
2991 } 3034 }
2992 3035
2993 void BytecodeGenerator::VisitThisFunction(ThisFunction* expr) { 3036 void BytecodeGenerator::VisitThisFunction(ThisFunction* expr) {
2994 builder()->LoadAccumulatorWithRegister(Register::function_closure()); 3037 builder()->LoadAccumulatorWithRegister(Register::function_closure());
2995 } 3038 }
2996 3039
2997 void BytecodeGenerator::VisitSuperCallReference(SuperCallReference* expr) { 3040 void BytecodeGenerator::VisitSuperCallReference(SuperCallReference* expr) {
2998 // Handled by VisitCall(). 3041 // Handled by VisitCall().
2999 UNREACHABLE(); 3042 UNREACHABLE();
3000 } 3043 }
(...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after
3406 } 3449 }
3407 3450
3408 Runtime::FunctionId BytecodeGenerator::StoreKeyedToSuperRuntimeId() { 3451 Runtime::FunctionId BytecodeGenerator::StoreKeyedToSuperRuntimeId() {
3409 return is_strict(language_mode()) ? Runtime::kStoreKeyedToSuper_Strict 3452 return is_strict(language_mode()) ? Runtime::kStoreKeyedToSuper_Strict
3410 : Runtime::kStoreKeyedToSuper_Sloppy; 3453 : Runtime::kStoreKeyedToSuper_Sloppy;
3411 } 3454 }
3412 3455
3413 } // namespace interpreter 3456 } // namespace interpreter
3414 } // namespace internal 3457 } // namespace internal
3415 } // namespace v8 3458 } // namespace v8
OLDNEW
« no previous file with comments | « src/interpreter/bytecode-array-builder.cc ('k') | src/interpreter/constant-array-builder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698