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

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

Issue 1664593003: [Interpreter] Adds support for rest parameters to interpreter. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fixes comments. Created 4 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-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/scopes.h" 7 #include "src/ast/scopes.h"
8 #include "src/compiler.h" 8 #include "src/compiler.h"
9 #include "src/interpreter/bytecode-register-allocator.h" 9 #include "src/interpreter/bytecode-register-allocator.h"
10 #include "src/interpreter/control-flow-builders.h" 10 #include "src/interpreter/control-flow-builders.h"
(...skipping 565 matching lines...) Expand 10 before | Expand all | Expand 10 after
576 set_scope(nullptr); 576 set_scope(nullptr);
577 set_info(nullptr); 577 set_info(nullptr);
578 return builder_.ToBytecodeArray(); 578 return builder_.ToBytecodeArray();
579 } 579 }
580 580
581 581
582 void BytecodeGenerator::MakeBytecodeBody() { 582 void BytecodeGenerator::MakeBytecodeBody() {
583 // Build the arguments object if it is used. 583 // Build the arguments object if it is used.
584 VisitArgumentsObject(scope()->arguments()); 584 VisitArgumentsObject(scope()->arguments());
585 585
586 // TODO(mythria): Build rest arguments array if it is used. 586 // Build rest arguments array if it is used.
587 int rest_index; 587 int rest_index;
588 if (scope()->rest_parameter(&rest_index)) { 588 Variable* rest_parameter = scope()->rest_parameter(&rest_index);
589 UNIMPLEMENTED(); 589 VisitRestArgumentsArray(rest_parameter, rest_index);
590 }
591 590
592 // Build assignment to {.this_function} variable if it is used. 591 // Build assignment to {.this_function} variable if it is used.
593 VisitThisFunctionVariable(scope()->this_function_var()); 592 VisitThisFunctionVariable(scope()->this_function_var());
594 593
595 // Build assignment to {new.target} variable if it is used. 594 // Build assignment to {new.target} variable if it is used.
596 VisitNewTargetVariable(scope()->new_target_var()); 595 VisitNewTargetVariable(scope()->new_target_var());
597 596
598 // TODO(rmcilroy): Emit tracing call if requested to do so. 597 // TODO(rmcilroy): Emit tracing call if requested to do so.
599 if (FLAG_trace) { 598 if (FLAG_trace) {
600 UNIMPLEMENTED(); 599 UNIMPLEMENTED();
(...skipping 1815 matching lines...) Expand 10 before | Expand all | Expand 10 after
2416 // Allocate and initialize a new arguments object and assign to the 2415 // Allocate and initialize a new arguments object and assign to the
2417 // {arguments} variable. 2416 // {arguments} variable.
2418 CreateArgumentsType type = 2417 CreateArgumentsType type =
2419 is_strict(language_mode()) || !info()->has_simple_parameters() 2418 is_strict(language_mode()) || !info()->has_simple_parameters()
2420 ? CreateArgumentsType::kUnmappedArguments 2419 ? CreateArgumentsType::kUnmappedArguments
2421 : CreateArgumentsType::kMappedArguments; 2420 : CreateArgumentsType::kMappedArguments;
2422 builder()->CreateArguments(type); 2421 builder()->CreateArguments(type);
2423 VisitVariableAssignment(variable, FeedbackVectorSlot::Invalid()); 2422 VisitVariableAssignment(variable, FeedbackVectorSlot::Invalid());
2424 } 2423 }
2425 2424
2425 void BytecodeGenerator::VisitRestArgumentsArray(Variable* rest, int index) {
2426 if (rest == nullptr) return;
2427
2428 // Allocate and initialize a new arguments object and assign to the {rest}
2429 // variable.
2430 builder()->CreateRestArguments(index);
2431 DCHECK(rest->IsContextSlot() || rest->IsStackAllocated());
2432 VisitVariableAssignment(rest, FeedbackVectorSlot::Invalid());
2433 }
2426 2434
2427 void BytecodeGenerator::VisitThisFunctionVariable(Variable* variable) { 2435 void BytecodeGenerator::VisitThisFunctionVariable(Variable* variable) {
2428 if (variable == nullptr) return; 2436 if (variable == nullptr) return;
2429 2437
2430 // TODO(rmcilroy): Remove once we have tests which exercise this code path. 2438 // TODO(rmcilroy): Remove once we have tests which exercise this code path.
2431 UNIMPLEMENTED(); 2439 UNIMPLEMENTED();
2432 2440
2433 // Store the closure we were called with in the given variable. 2441 // Store the closure we were called with in the given variable.
2434 builder()->LoadAccumulatorWithRegister(Register::function_closure()); 2442 builder()->LoadAccumulatorWithRegister(Register::function_closure());
2435 VisitVariableAssignment(variable, FeedbackVectorSlot::Invalid()); 2443 VisitVariableAssignment(variable, FeedbackVectorSlot::Invalid());
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
2506 } 2514 }
2507 2515
2508 2516
2509 int BytecodeGenerator::feedback_index(FeedbackVectorSlot slot) const { 2517 int BytecodeGenerator::feedback_index(FeedbackVectorSlot slot) const {
2510 return info()->feedback_vector()->GetIndex(slot); 2518 return info()->feedback_vector()->GetIndex(slot);
2511 } 2519 }
2512 2520
2513 } // namespace interpreter 2521 } // namespace interpreter
2514 } // namespace internal 2522 } // namespace internal
2515 } // namespace v8 2523 } // 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