| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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/compiler/ast-graph-builder.h" | 5 #include "src/compiler/ast-graph-builder.h" |
| 6 | 6 |
| 7 #include "src/compiler.h" | 7 #include "src/compiler.h" |
| 8 #include "src/compiler/ast-loop-assignment-analyzer.h" | 8 #include "src/compiler/ast-loop-assignment-analyzer.h" |
| 9 #include "src/compiler/control-builders.h" | 9 #include "src/compiler/control-builders.h" |
| 10 #include "src/compiler/linkage.h" | 10 #include "src/compiler/linkage.h" |
| 11 #include "src/compiler/machine-operator.h" | 11 #include "src/compiler/machine-operator.h" |
| 12 #include "src/compiler/node-matchers.h" | 12 #include "src/compiler/node-matchers.h" |
| 13 #include "src/compiler/node-properties.h" | 13 #include "src/compiler/node-properties.h" |
| 14 #include "src/compiler/operator-properties.h" | 14 #include "src/compiler/operator-properties.h" |
| 15 #include "src/compiler/state-values-utils.h" |
| 15 #include "src/full-codegen.h" | 16 #include "src/full-codegen.h" |
| 16 #include "src/parser.h" | 17 #include "src/parser.h" |
| 17 #include "src/scopes.h" | 18 #include "src/scopes.h" |
| 18 | 19 |
| 19 namespace v8 { | 20 namespace v8 { |
| 20 namespace internal { | 21 namespace internal { |
| 21 namespace compiler { | 22 namespace compiler { |
| 22 | 23 |
| 23 | 24 |
| 24 // Each expression in the AST is evaluated in a specific context. This context | 25 // Each expression in the AST is evaluated in a specific context. This context |
| (...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 385 jsgraph_(jsgraph), | 386 jsgraph_(jsgraph), |
| 386 environment_(nullptr), | 387 environment_(nullptr), |
| 387 ast_context_(nullptr), | 388 ast_context_(nullptr), |
| 388 globals_(0, local_zone), | 389 globals_(0, local_zone), |
| 389 execution_control_(nullptr), | 390 execution_control_(nullptr), |
| 390 execution_context_(nullptr), | 391 execution_context_(nullptr), |
| 391 try_nesting_level_(0), | 392 try_nesting_level_(0), |
| 392 input_buffer_size_(0), | 393 input_buffer_size_(0), |
| 393 input_buffer_(nullptr), | 394 input_buffer_(nullptr), |
| 394 exit_control_(nullptr), | 395 exit_control_(nullptr), |
| 395 loop_assignment_analysis_(loop) { | 396 loop_assignment_analysis_(loop), |
| 397 state_values_cache_(jsgraph) { |
| 396 InitializeAstVisitor(info->isolate(), local_zone); | 398 InitializeAstVisitor(info->isolate(), local_zone); |
| 397 } | 399 } |
| 398 | 400 |
| 399 | 401 |
| 400 Node* AstGraphBuilder::GetFunctionClosure() { | 402 Node* AstGraphBuilder::GetFunctionClosure() { |
| 401 if (!function_closure_.is_set()) { | 403 if (!function_closure_.is_set()) { |
| 402 const Operator* op = | 404 const Operator* op = |
| 403 common()->Parameter(Linkage::kJSFunctionCallClosureParamIndex); | 405 common()->Parameter(Linkage::kJSFunctionCallClosureParamIndex); |
| 404 Node* node = NewNode(op, graph()->start()); | 406 Node* node = NewNode(op, graph()->start()); |
| 405 function_closure_.set(node); | 407 function_closure_.set(node); |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 595 values_.insert(values_.begin(), copy->values_.begin(), copy->values_.end()); | 597 values_.insert(values_.begin(), copy->values_.begin(), copy->values_.end()); |
| 596 contexts_.reserve(copy->contexts_.size()); | 598 contexts_.reserve(copy->contexts_.size()); |
| 597 contexts_.insert(contexts_.begin(), copy->contexts_.begin(), | 599 contexts_.insert(contexts_.begin(), copy->contexts_.begin(), |
| 598 copy->contexts_.end()); | 600 copy->contexts_.end()); |
| 599 } | 601 } |
| 600 | 602 |
| 601 | 603 |
| 602 void AstGraphBuilder::Environment::UpdateStateValues(Node** state_values, | 604 void AstGraphBuilder::Environment::UpdateStateValues(Node** state_values, |
| 603 int offset, int count) { | 605 int offset, int count) { |
| 604 bool should_update = false; | 606 bool should_update = false; |
| 605 Node** env_values = (count == 0) ? NULL : &values()->at(offset); | 607 Node** env_values = (count == 0) ? nullptr : &values()->at(offset); |
| 606 if (*state_values == NULL || (*state_values)->InputCount() != count) { | 608 if (*state_values == NULL || (*state_values)->InputCount() != count) { |
| 607 should_update = true; | 609 should_update = true; |
| 608 } else { | 610 } else { |
| 609 DCHECK(static_cast<size_t>(offset + count) <= values()->size()); | 611 DCHECK(static_cast<size_t>(offset + count) <= values()->size()); |
| 610 for (int i = 0; i < count; i++) { | 612 for (int i = 0; i < count; i++) { |
| 611 if ((*state_values)->InputAt(i) != env_values[i]) { | 613 if ((*state_values)->InputAt(i) != env_values[i]) { |
| 612 should_update = true; | 614 should_update = true; |
| 613 break; | 615 break; |
| 614 } | 616 } |
| 615 } | 617 } |
| 616 } | 618 } |
| 617 if (should_update) { | 619 if (should_update) { |
| 618 const Operator* op = common()->StateValues(count); | 620 const Operator* op = common()->StateValues(count); |
| 619 (*state_values) = graph()->NewNode(op, count, env_values); | 621 (*state_values) = graph()->NewNode(op, count, env_values); |
| 620 } | 622 } |
| 621 } | 623 } |
| 622 | 624 |
| 623 | 625 |
| 626 void AstGraphBuilder::Environment::UpdateStateValuesWithCache( |
| 627 Node** state_values, int offset, int count) { |
| 628 Node** env_values = (count == 0) ? nullptr : &values()->at(offset); |
| 629 *state_values = builder_->state_values_cache_.GetNodeForValues( |
| 630 env_values, static_cast<size_t>(count)); |
| 631 } |
| 632 |
| 633 |
| 624 Node* AstGraphBuilder::Environment::Checkpoint( | 634 Node* AstGraphBuilder::Environment::Checkpoint( |
| 625 BailoutId ast_id, OutputFrameStateCombine combine) { | 635 BailoutId ast_id, OutputFrameStateCombine combine) { |
| 626 if (!FLAG_turbo_deoptimization) return nullptr; | 636 if (!FLAG_turbo_deoptimization) return nullptr; |
| 627 | 637 |
| 628 UpdateStateValues(¶meters_node_, 0, parameters_count()); | 638 UpdateStateValues(¶meters_node_, 0, parameters_count()); |
| 629 UpdateStateValues(&locals_node_, parameters_count(), locals_count()); | 639 UpdateStateValuesWithCache(&locals_node_, parameters_count(), locals_count()); |
| 630 UpdateStateValues(&stack_node_, parameters_count() + locals_count(), | 640 UpdateStateValues(&stack_node_, parameters_count() + locals_count(), |
| 631 stack_height()); | 641 stack_height()); |
| 632 | 642 |
| 633 const Operator* op = common()->FrameState(JS_FRAME, ast_id, combine); | 643 const Operator* op = common()->FrameState(JS_FRAME, ast_id, combine); |
| 634 | 644 |
| 635 return graph()->NewNode(op, parameters_node_, locals_node_, stack_node_, | 645 return graph()->NewNode(op, parameters_node_, locals_node_, stack_node_, |
| 636 builder()->current_context(), | 646 builder()->current_context(), |
| 637 builder()->jsgraph()->UndefinedConstant()); | 647 builder()->jsgraph()->UndefinedConstant()); |
| 638 } | 648 } |
| 639 | 649 |
| (...skipping 2698 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3338 // Phi does not exist yet, introduce one. | 3348 // Phi does not exist yet, introduce one. |
| 3339 value = NewPhi(inputs, value, control); | 3349 value = NewPhi(inputs, value, control); |
| 3340 value->ReplaceInput(inputs - 1, other); | 3350 value->ReplaceInput(inputs - 1, other); |
| 3341 } | 3351 } |
| 3342 return value; | 3352 return value; |
| 3343 } | 3353 } |
| 3344 | 3354 |
| 3345 } // namespace compiler | 3355 } // namespace compiler |
| 3346 } // namespace internal | 3356 } // namespace internal |
| 3347 } // namespace v8 | 3357 } // namespace v8 |
| OLD | NEW |