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

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

Issue 2557593004: [ignition] desugar GetIterator() via bytecode rather than via AST (Closed)
Patch Set: get tests passing 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
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 } 592 }
592 593
593 Handle<BytecodeArray> BytecodeGenerator::FinalizeBytecode(Isolate* isolate) { 594 Handle<BytecodeArray> BytecodeGenerator::FinalizeBytecode(Isolate* isolate) {
594 AllocateDeferredConstants(); 595 AllocateDeferredConstants();
595 if (HasStackOverflow()) return Handle<BytecodeArray>(); 596 if (HasStackOverflow()) return Handle<BytecodeArray>();
(...skipping 2241 matching lines...) Expand 10 before | Expand all | Expand 10 after
2837 FeedbackVectorSlot slot = expr->BinaryOperationFeedbackSlot(); 2838 FeedbackVectorSlot slot = expr->BinaryOperationFeedbackSlot();
2838 builder()->BinaryOperation(expr->op(), lhs, feedback_index(slot)); 2839 builder()->BinaryOperation(expr->op(), lhs, feedback_index(slot));
2839 } 2840 }
2840 2841
2841 void BytecodeGenerator::VisitSpread(Spread* expr) { Visit(expr->expression()); } 2842 void BytecodeGenerator::VisitSpread(Spread* expr) { Visit(expr->expression()); }
2842 2843
2843 void BytecodeGenerator::VisitEmptyParentheses(EmptyParentheses* expr) { 2844 void BytecodeGenerator::VisitEmptyParentheses(EmptyParentheses* expr) {
2844 UNREACHABLE(); 2845 UNREACHABLE();
2845 } 2846 }
2846 2847
2848 void BytecodeGenerator::VisitGetIterator(GetIterator* expr) {
2849 FeedbackVectorSlot load_slot = expr->IteratorPropertyFeedbackSlot();
2850 FeedbackVectorSlot call_slot = expr->IteratorCallFeedbackSlot();
2851
2852 RegisterList args = register_allocator()->NewRegisterList(1);
2853 Register method = register_allocator()->NewRegister();
2854 Register obj = args[0];
2855
2856 VisitForAccumulatorValue(expr->iterable());
2857
2858 // Let method be ? GetMethod(obj, @@iterator).
rmcilroy 2016/12/06 15:02:28 Not sure what the "?" means here. Can we just remo
caitp 2016/12/06 15:14:58 It's the spec's short form for "ReturnIfAbrupt(<co
rmcilroy 2016/12/07 10:50:41 Yeah I would rather we remove it (and add the comm
2859 builder()
neis 2016/12/07 10:17:27 Please change the comment to reflect that the resu
2860 ->StoreAccumulatorInRegister(obj)
2861 .LoadNamedProperty(obj, iterator_symbol(), feedback_index(load_slot))
2862 .StoreAccumulatorInRegister(method)
2863 .Call(method, args, feedback_index(call_slot), Call::NAMED_PROPERTY_CALL);
2864
2865 // If Type(iterator) is not Object, throw a TypeError exception.
2866 BytecodeLabel no_type_error;
2867 builder()->JumpIfJSReceiver(&no_type_error);
2868 builder()->CallRuntime(Runtime::kThrowSymbolIteratorInvalid);
2869 builder()->Bind(&no_type_error);
2870 }
2871
2847 void BytecodeGenerator::VisitThisFunction(ThisFunction* expr) { 2872 void BytecodeGenerator::VisitThisFunction(ThisFunction* expr) {
2848 builder()->LoadAccumulatorWithRegister(Register::function_closure()); 2873 builder()->LoadAccumulatorWithRegister(Register::function_closure());
2849 } 2874 }
2850 2875
2851 void BytecodeGenerator::VisitSuperCallReference(SuperCallReference* expr) { 2876 void BytecodeGenerator::VisitSuperCallReference(SuperCallReference* expr) {
2852 // Handled by VisitCall(). 2877 // Handled by VisitCall().
2853 UNREACHABLE(); 2878 UNREACHABLE();
2854 } 2879 }
2855 2880
2856 void BytecodeGenerator::VisitSuperPropertyReference( 2881 void BytecodeGenerator::VisitSuperPropertyReference(
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after
3223 } 3248 }
3224 3249
3225 Runtime::FunctionId BytecodeGenerator::StoreKeyedToSuperRuntimeId() { 3250 Runtime::FunctionId BytecodeGenerator::StoreKeyedToSuperRuntimeId() {
3226 return is_strict(language_mode()) ? Runtime::kStoreKeyedToSuper_Strict 3251 return is_strict(language_mode()) ? Runtime::kStoreKeyedToSuper_Strict
3227 : Runtime::kStoreKeyedToSuper_Sloppy; 3252 : Runtime::kStoreKeyedToSuper_Sloppy;
3228 } 3253 }
3229 3254
3230 } // namespace interpreter 3255 } // namespace interpreter
3231 } // namespace internal 3256 } // namespace internal
3232 } // namespace v8 3257 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698