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

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

Issue 2557593004: [ignition] desugar GetIterator() via bytecode rather than via AST (Closed)
Patch Set: georg's comments 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 unified diff | Download patch
« no previous file with comments | « src/interpreter/bytecode-generator.h ('k') | src/interpreter/bytecodes.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/code-stubs.h" 9 #include "src/code-stubs.h"
10 #include "src/compilation-info.h" 10 #include "src/compilation-info.h"
(...skipping 565 matching lines...) Expand 10 before | Expand all | Expand 10 after
576 global_declarations_(0, info->zone()), 576 global_declarations_(0, info->zone()),
577 function_literals_(0, info->zone()), 577 function_literals_(0, info->zone()),
578 native_function_literals_(0, info->zone()), 578 native_function_literals_(0, info->zone()),
579 execution_control_(nullptr), 579 execution_control_(nullptr),
580 execution_context_(nullptr), 580 execution_context_(nullptr),
581 execution_result_(nullptr), 581 execution_result_(nullptr),
582 generator_resume_points_(info->literal()->yield_count(), info->zone()), 582 generator_resume_points_(info->literal()->yield_count(), info->zone()),
583 generator_state_(), 583 generator_state_(),
584 loop_depth_(0), 584 loop_depth_(0),
585 home_object_symbol_(info->isolate()->factory()->home_object_symbol()), 585 home_object_symbol_(info->isolate()->factory()->home_object_symbol()),
586 iterator_symbol_(info->isolate()->factory()->iterator_symbol()),
586 empty_fixed_array_(info->isolate()->factory()->empty_fixed_array()) { 587 empty_fixed_array_(info->isolate()->factory()->empty_fixed_array()) {
587 AstValueFactory* ast_value_factory = info->parse_info()->ast_value_factory(); 588 AstValueFactory* ast_value_factory = info->parse_info()->ast_value_factory();
588 const AstRawString* prototype_string = ast_value_factory->prototype_string(); 589 const AstRawString* prototype_string = ast_value_factory->prototype_string();
589 ast_value_factory->Internalize(info->isolate()); 590 ast_value_factory->Internalize(info->isolate());
590 prototype_string_ = prototype_string->string(); 591 prototype_string_ = prototype_string->string();
591 undefined_string_ = ast_value_factory->undefined_string(); 592 undefined_string_ = ast_value_factory->undefined_string();
592 } 593 }
593 594
594 Handle<BytecodeArray> BytecodeGenerator::FinalizeBytecode(Isolate* isolate) { 595 Handle<BytecodeArray> BytecodeGenerator::FinalizeBytecode(Isolate* isolate) {
595 AllocateDeferredConstants(); 596 AllocateDeferredConstants();
(...skipping 2249 matching lines...) Expand 10 before | Expand all | Expand 10 after
2845 FeedbackVectorSlot slot = expr->BinaryOperationFeedbackSlot(); 2846 FeedbackVectorSlot slot = expr->BinaryOperationFeedbackSlot();
2846 builder()->BinaryOperation(expr->op(), lhs, feedback_index(slot)); 2847 builder()->BinaryOperation(expr->op(), lhs, feedback_index(slot));
2847 } 2848 }
2848 2849
2849 void BytecodeGenerator::VisitSpread(Spread* expr) { Visit(expr->expression()); } 2850 void BytecodeGenerator::VisitSpread(Spread* expr) { Visit(expr->expression()); }
2850 2851
2851 void BytecodeGenerator::VisitEmptyParentheses(EmptyParentheses* expr) { 2852 void BytecodeGenerator::VisitEmptyParentheses(EmptyParentheses* expr) {
2852 UNREACHABLE(); 2853 UNREACHABLE();
2853 } 2854 }
2854 2855
2856 void BytecodeGenerator::VisitGetIterator(GetIterator* expr) {
2857 FeedbackVectorSlot load_slot = expr->IteratorPropertyFeedbackSlot();
2858 FeedbackVectorSlot call_slot = expr->IteratorCallFeedbackSlot();
2859
2860 RegisterList args = register_allocator()->NewRegisterList(1);
2861 Register method = register_allocator()->NewRegister();
2862 Register obj = args[0];
2863
2864 VisitForAccumulatorValue(expr->iterable());
2865
2866 // Let method be GetMethod(obj, @@iterator).
2867 builder()
2868 ->StoreAccumulatorInRegister(obj)
2869 .LoadNamedProperty(obj, iterator_symbol(), feedback_index(load_slot))
2870 .StoreAccumulatorInRegister(method);
2871
2872 // Let iterator be Call(method, obj).
2873 builder()->Call(method, args, feedback_index(call_slot),
2874 Call::NAMED_PROPERTY_CALL);
2875
2876 // If Type(iterator) is not Object, throw a TypeError exception.
2877 BytecodeLabel no_type_error;
2878 builder()->JumpIfJSReceiver(&no_type_error);
2879 builder()->CallRuntime(Runtime::kThrowSymbolIteratorInvalid);
2880 builder()->Bind(&no_type_error);
2881 }
2882
2855 void BytecodeGenerator::VisitThisFunction(ThisFunction* expr) { 2883 void BytecodeGenerator::VisitThisFunction(ThisFunction* expr) {
2856 builder()->LoadAccumulatorWithRegister(Register::function_closure()); 2884 builder()->LoadAccumulatorWithRegister(Register::function_closure());
2857 } 2885 }
2858 2886
2859 void BytecodeGenerator::VisitSuperCallReference(SuperCallReference* expr) { 2887 void BytecodeGenerator::VisitSuperCallReference(SuperCallReference* expr) {
2860 // Handled by VisitCall(). 2888 // Handled by VisitCall().
2861 UNREACHABLE(); 2889 UNREACHABLE();
2862 } 2890 }
2863 2891
2864 void BytecodeGenerator::VisitSuperPropertyReference( 2892 void BytecodeGenerator::VisitSuperPropertyReference(
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after
3231 } 3259 }
3232 3260
3233 Runtime::FunctionId BytecodeGenerator::StoreKeyedToSuperRuntimeId() { 3261 Runtime::FunctionId BytecodeGenerator::StoreKeyedToSuperRuntimeId() {
3234 return is_strict(language_mode()) ? Runtime::kStoreKeyedToSuper_Strict 3262 return is_strict(language_mode()) ? Runtime::kStoreKeyedToSuper_Strict
3235 : Runtime::kStoreKeyedToSuper_Sloppy; 3263 : Runtime::kStoreKeyedToSuper_Sloppy;
3236 } 3264 }
3237 3265
3238 } // namespace interpreter 3266 } // namespace interpreter
3239 } // namespace internal 3267 } // namespace internal
3240 } // namespace v8 3268 } // namespace v8
OLDNEW
« no previous file with comments | « src/interpreter/bytecode-generator.h ('k') | src/interpreter/bytecodes.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698