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/ast/scopes.h" | 7 #include "src/ast/scopes.h" |
8 #include "src/compiler.h" | 8 #include "src/compiler.h" |
9 #include "src/compiler/ast-loop-assignment-analyzer.h" | 9 #include "src/compiler/ast-loop-assignment-analyzer.h" |
10 #include "src/compiler/control-builders.h" | 10 #include "src/compiler/control-builders.h" |
(...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
409 TryFinallyBuilder* control_; | 409 TryFinallyBuilder* control_; |
410 }; | 410 }; |
411 | 411 |
412 | 412 |
413 // Helper for generating before and after frame states. | 413 // Helper for generating before and after frame states. |
414 class AstGraphBuilder::FrameStateBeforeAndAfter { | 414 class AstGraphBuilder::FrameStateBeforeAndAfter { |
415 public: | 415 public: |
416 FrameStateBeforeAndAfter(AstGraphBuilder* builder, BailoutId id_before) | 416 FrameStateBeforeAndAfter(AstGraphBuilder* builder, BailoutId id_before) |
417 : builder_(builder), frame_state_before_(nullptr) { | 417 : builder_(builder), frame_state_before_(nullptr) { |
418 frame_state_before_ = id_before == BailoutId::None() | 418 frame_state_before_ = id_before == BailoutId::None() |
419 ? builder_->jsgraph()->EmptyFrameState() | 419 ? builder_->GetEmptyFrameState() |
420 : builder_->environment()->Checkpoint(id_before); | 420 : builder_->environment()->Checkpoint(id_before); |
421 } | 421 } |
422 | 422 |
423 void AddToNode( | 423 void AddToNode( |
424 Node* node, BailoutId id_after, | 424 Node* node, BailoutId id_after, |
425 OutputFrameStateCombine combine = OutputFrameStateCombine::Ignore()) { | 425 OutputFrameStateCombine combine = OutputFrameStateCombine::Ignore()) { |
426 int count = OperatorProperties::GetFrameStateInputCount(node->op()); | 426 int count = OperatorProperties::GetFrameStateInputCount(node->op()); |
427 DCHECK_LE(count, 2); | 427 DCHECK_LE(count, 2); |
428 | 428 |
429 if (count >= 1) { | 429 if (count >= 1) { |
430 // Add the frame state for after the operation. | 430 // Add the frame state for after the operation. |
431 DCHECK_EQ(IrOpcode::kDead, | 431 DCHECK_EQ(IrOpcode::kDead, |
432 NodeProperties::GetFrameStateInput(node, 0)->opcode()); | 432 NodeProperties::GetFrameStateInput(node, 0)->opcode()); |
433 | 433 |
434 bool node_has_exception = NodeProperties::IsExceptionalCall(node); | 434 bool node_has_exception = NodeProperties::IsExceptionalCall(node); |
435 | 435 |
436 Node* frame_state_after = | 436 Node* frame_state_after = |
437 id_after == BailoutId::None() | 437 id_after == BailoutId::None() |
438 ? builder_->jsgraph()->EmptyFrameState() | 438 ? builder_->GetEmptyFrameState() |
439 : builder_->environment()->Checkpoint(id_after, combine, | 439 : builder_->environment()->Checkpoint(id_after, combine, |
440 node_has_exception); | 440 node_has_exception); |
441 | 441 |
442 NodeProperties::ReplaceFrameStateInput(node, 0, frame_state_after); | 442 NodeProperties::ReplaceFrameStateInput(node, 0, frame_state_after); |
443 } | 443 } |
444 | 444 |
445 if (count >= 2) { | 445 if (count >= 2) { |
446 // Add the frame state for before the operation. | 446 // Add the frame state for before the operation. |
447 DCHECK_EQ(IrOpcode::kDead, | 447 DCHECK_EQ(IrOpcode::kDead, |
448 NodeProperties::GetFrameStateInput(node, 1)->opcode()); | 448 NodeProperties::GetFrameStateInput(node, 1)->opcode()); |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
532 if (!new_target_.is_set()) { | 532 if (!new_target_.is_set()) { |
533 int params = info()->num_parameters_including_this(); | 533 int params = info()->num_parameters_including_this(); |
534 int index = Linkage::GetJSCallNewTargetParamIndex(params); | 534 int index = Linkage::GetJSCallNewTargetParamIndex(params); |
535 const Operator* op = common()->Parameter(index, "%new.target"); | 535 const Operator* op = common()->Parameter(index, "%new.target"); |
536 Node* node = NewNode(op, graph()->start()); | 536 Node* node = NewNode(op, graph()->start()); |
537 new_target_.set(node); | 537 new_target_.set(node); |
538 } | 538 } |
539 return new_target_.get(); | 539 return new_target_.get(); |
540 } | 540 } |
541 | 541 |
| 542 Node* AstGraphBuilder::GetEmptyFrameState() { |
| 543 if (!empty_frame_state_.is_set()) { |
| 544 const Operator* op = common()->FrameState( |
| 545 BailoutId::None(), OutputFrameStateCombine::Ignore(), nullptr); |
| 546 Node* node = graph()->NewNode( |
| 547 op, jsgraph()->EmptyStateValues(), jsgraph()->EmptyStateValues(), |
| 548 jsgraph()->EmptyStateValues(), jsgraph()->NoContextConstant(), |
| 549 jsgraph()->UndefinedConstant(), graph()->start()); |
| 550 empty_frame_state_.set(node); |
| 551 } |
| 552 return empty_frame_state_.get(); |
| 553 } |
542 | 554 |
543 bool AstGraphBuilder::CreateGraph(bool stack_check) { | 555 bool AstGraphBuilder::CreateGraph(bool stack_check) { |
544 Scope* scope = info()->scope(); | 556 Scope* scope = info()->scope(); |
545 DCHECK_NOT_NULL(graph()); | 557 DCHECK_NOT_NULL(graph()); |
546 | 558 |
547 // Set up the basic structure of the graph. Outputs for {Start} are the formal | 559 // Set up the basic structure of the graph. Outputs for {Start} are the formal |
548 // parameters (including the receiver) plus new target, number of arguments, | 560 // parameters (including the receiver) plus new target, number of arguments, |
549 // context and closure. | 561 // context and closure. |
550 int actual_parameter_count = info()->num_parameters_including_this() + 4; | 562 int actual_parameter_count = info()->num_parameters_including_this() + 4; |
551 graph()->SetStart(graph()->NewNode(common()->Start(actual_parameter_count))); | 563 graph()->SetStart(graph()->NewNode(common()->Start(actual_parameter_count))); |
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
868 Node** state_values, int offset, int count) { | 880 Node** state_values, int offset, int count) { |
869 Node** env_values = (count == 0) ? nullptr : &values()->at(offset); | 881 Node** env_values = (count == 0) ? nullptr : &values()->at(offset); |
870 *state_values = builder_->state_values_cache_.GetNodeForValues( | 882 *state_values = builder_->state_values_cache_.GetNodeForValues( |
871 env_values, static_cast<size_t>(count)); | 883 env_values, static_cast<size_t>(count)); |
872 } | 884 } |
873 | 885 |
874 Node* AstGraphBuilder::Environment::Checkpoint(BailoutId ast_id, | 886 Node* AstGraphBuilder::Environment::Checkpoint(BailoutId ast_id, |
875 OutputFrameStateCombine combine, | 887 OutputFrameStateCombine combine, |
876 bool owner_has_exception) { | 888 bool owner_has_exception) { |
877 if (!builder()->info()->is_deoptimization_enabled()) { | 889 if (!builder()->info()->is_deoptimization_enabled()) { |
878 return builder()->jsgraph()->EmptyFrameState(); | 890 return builder()->GetEmptyFrameState(); |
879 } | 891 } |
880 | 892 |
881 UpdateStateValues(¶meters_node_, 0, parameters_count()); | 893 UpdateStateValues(¶meters_node_, 0, parameters_count()); |
882 UpdateStateValuesWithCache(&locals_node_, parameters_count(), locals_count()); | 894 UpdateStateValuesWithCache(&locals_node_, parameters_count(), locals_count()); |
883 UpdateStateValues(&stack_node_, parameters_count() + locals_count(), | 895 UpdateStateValues(&stack_node_, parameters_count() + locals_count(), |
884 stack_height()); | 896 stack_height()); |
885 | 897 |
886 const Operator* op = common()->FrameState( | 898 const Operator* op = common()->FrameState( |
887 ast_id, combine, builder()->frame_state_function_info()); | 899 ast_id, combine, builder()->frame_state_function_info()); |
888 | 900 |
(...skipping 3469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4358 // Phi does not exist yet, introduce one. | 4370 // Phi does not exist yet, introduce one. |
4359 value = NewPhi(inputs, value, control); | 4371 value = NewPhi(inputs, value, control); |
4360 value->ReplaceInput(inputs - 1, other); | 4372 value->ReplaceInput(inputs - 1, other); |
4361 } | 4373 } |
4362 return value; | 4374 return value; |
4363 } | 4375 } |
4364 | 4376 |
4365 } // namespace compiler | 4377 } // namespace compiler |
4366 } // namespace internal | 4378 } // namespace internal |
4367 } // namespace v8 | 4379 } // namespace v8 |
OLD | NEW |