| 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 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 405 control_->LeaveTry(token, *value); | 405 control_->LeaveTry(token, *value); |
| 406 return true; | 406 return true; |
| 407 } | 407 } |
| 408 | 408 |
| 409 private: | 409 private: |
| 410 DeferredCommands* commands_; | 410 DeferredCommands* commands_; |
| 411 TryFinallyBuilder* control_; | 411 TryFinallyBuilder* control_; |
| 412 }; | 412 }; |
| 413 | 413 |
| 414 | 414 |
| 415 // Helper for generating before and after frame states. | |
| 416 class AstGraphBuilder::FrameStateBeforeAndAfter { | |
| 417 public: | |
| 418 FrameStateBeforeAndAfter(AstGraphBuilder* builder, BailoutId id_before) | |
| 419 : builder_(builder), frame_state_before_(nullptr) { | |
| 420 frame_state_before_ = id_before == BailoutId::None() | |
| 421 ? builder_->GetEmptyFrameState() | |
| 422 : builder_->environment()->Checkpoint(id_before); | |
| 423 if (id_before != BailoutId::None()) { | |
| 424 // Create an explicit checkpoint node for before the operation. | |
| 425 Node* node = builder_->NewNode(builder_->common()->Checkpoint()); | |
| 426 DCHECK_EQ(IrOpcode::kDead, | |
| 427 NodeProperties::GetFrameStateInput(node)->opcode()); | |
| 428 NodeProperties::ReplaceFrameStateInput(node, frame_state_before_); | |
| 429 } | |
| 430 } | |
| 431 | |
| 432 void AddToNode( | |
| 433 Node* node, BailoutId id_after, | |
| 434 OutputFrameStateCombine combine = OutputFrameStateCombine::Ignore()) { | |
| 435 if (OperatorProperties::HasFrameStateInput(node->op())) { | |
| 436 // Add the frame state for after the operation. | |
| 437 DCHECK_EQ(IrOpcode::kDead, | |
| 438 NodeProperties::GetFrameStateInput(node)->opcode()); | |
| 439 | |
| 440 bool node_has_exception = NodeProperties::IsExceptionalCall(node); | |
| 441 | |
| 442 Node* frame_state_after = | |
| 443 id_after == BailoutId::None() | |
| 444 ? builder_->GetEmptyFrameState() | |
| 445 : builder_->environment()->Checkpoint(id_after, combine, | |
| 446 node_has_exception); | |
| 447 | |
| 448 NodeProperties::ReplaceFrameStateInput(node, frame_state_after); | |
| 449 } | |
| 450 } | |
| 451 | |
| 452 private: | |
| 453 AstGraphBuilder* builder_; | |
| 454 Node* frame_state_before_; | |
| 455 }; | |
| 456 | |
| 457 AstGraphBuilder::AstGraphBuilder(Zone* local_zone, CompilationInfo* info, | 415 AstGraphBuilder::AstGraphBuilder(Zone* local_zone, CompilationInfo* info, |
| 458 JSGraph* jsgraph, LoopAssignmentAnalysis* loop, | 416 JSGraph* jsgraph, LoopAssignmentAnalysis* loop, |
| 459 TypeHintAnalysis* type_hint_analysis) | 417 TypeHintAnalysis* type_hint_analysis) |
| 460 : isolate_(info->isolate()), | 418 : isolate_(info->isolate()), |
| 461 local_zone_(local_zone), | 419 local_zone_(local_zone), |
| 462 info_(info), | 420 info_(info), |
| 463 jsgraph_(jsgraph), | 421 jsgraph_(jsgraph), |
| 464 environment_(nullptr), | 422 environment_(nullptr), |
| 465 ast_context_(nullptr), | 423 ast_context_(nullptr), |
| 466 globals_(0, local_zone), | 424 globals_(0, local_zone), |
| (...skipping 1710 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2177 VectorSlotPair pair = | 2135 VectorSlotPair pair = |
| 2178 CreateVectorSlotPair(property->PropertyFeedbackSlot()); | 2136 CreateVectorSlotPair(property->PropertyFeedbackSlot()); |
| 2179 old_value = BuildKeyedSuperLoad(receiver, home_object, key, pair); | 2137 old_value = BuildKeyedSuperLoad(receiver, home_object, key, pair); |
| 2180 PrepareFrameState(old_value, property->LoadId(), | 2138 PrepareFrameState(old_value, property->LoadId(), |
| 2181 OutputFrameStateCombine::Push()); | 2139 OutputFrameStateCombine::Push()); |
| 2182 break; | 2140 break; |
| 2183 } | 2141 } |
| 2184 } | 2142 } |
| 2185 environment()->Push(old_value); | 2143 environment()->Push(old_value); |
| 2186 VisitForValue(expr->value()); | 2144 VisitForValue(expr->value()); |
| 2187 Node* value; | 2145 Node* right = environment()->Pop(); |
| 2188 { | 2146 Node* left = environment()->Pop(); |
| 2189 FrameStateBeforeAndAfter states(this, expr->value()->id()); | 2147 Node* value = |
| 2190 Node* right = environment()->Pop(); | 2148 BuildBinaryOp(left, right, expr->binary_op(), |
| 2191 Node* left = environment()->Pop(); | 2149 expr->binary_operation()->BinaryOperationFeedbackId()); |
| 2192 value = | 2150 PrepareFrameState(value, expr->binary_operation()->id(), |
| 2193 BuildBinaryOp(left, right, expr->binary_op(), | 2151 OutputFrameStateCombine::Push()); |
| 2194 expr->binary_operation()->BinaryOperationFeedbackId()); | |
| 2195 states.AddToNode(value, expr->binary_operation()->id(), | |
| 2196 OutputFrameStateCombine::Push()); | |
| 2197 } | |
| 2198 environment()->Push(value); | 2152 environment()->Push(value); |
| 2199 if (needs_frame_state_before) { | 2153 if (needs_frame_state_before) { |
| 2200 PrepareEagerCheckpoint(expr->binary_operation()->id()); | 2154 PrepareEagerCheckpoint(expr->binary_operation()->id()); |
| 2201 } | 2155 } |
| 2202 } else { | 2156 } else { |
| 2203 VisitForValue(expr->value()); | 2157 VisitForValue(expr->value()); |
| 2204 } | 2158 } |
| 2205 | 2159 |
| 2206 // Store the value. | 2160 // Store the value. |
| 2207 Node* value = environment()->Pop(); | 2161 Node* value = environment()->Pop(); |
| (...skipping 567 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2775 void AstGraphBuilder::VisitBinaryOperation(BinaryOperation* expr) { | 2729 void AstGraphBuilder::VisitBinaryOperation(BinaryOperation* expr) { |
| 2776 switch (expr->op()) { | 2730 switch (expr->op()) { |
| 2777 case Token::COMMA: | 2731 case Token::COMMA: |
| 2778 return VisitComma(expr); | 2732 return VisitComma(expr); |
| 2779 case Token::OR: | 2733 case Token::OR: |
| 2780 case Token::AND: | 2734 case Token::AND: |
| 2781 return VisitLogicalExpression(expr); | 2735 return VisitLogicalExpression(expr); |
| 2782 default: { | 2736 default: { |
| 2783 VisitForValue(expr->left()); | 2737 VisitForValue(expr->left()); |
| 2784 VisitForValue(expr->right()); | 2738 VisitForValue(expr->right()); |
| 2785 FrameStateBeforeAndAfter states(this, expr->right()->id()); | |
| 2786 Node* right = environment()->Pop(); | 2739 Node* right = environment()->Pop(); |
| 2787 Node* left = environment()->Pop(); | 2740 Node* left = environment()->Pop(); |
| 2788 Node* value = BuildBinaryOp(left, right, expr->op(), | 2741 Node* value = BuildBinaryOp(left, right, expr->op(), |
| 2789 expr->BinaryOperationFeedbackId()); | 2742 expr->BinaryOperationFeedbackId()); |
| 2790 states.AddToNode(value, expr->id(), ast_context()->GetStateCombine()); | 2743 PrepareFrameState(value, expr->id(), ast_context()->GetStateCombine()); |
| 2791 ast_context()->ProduceValue(expr, value); | 2744 ast_context()->ProduceValue(expr, value); |
| 2792 } | 2745 } |
| 2793 } | 2746 } |
| 2794 } | 2747 } |
| 2795 | 2748 |
| 2796 void AstGraphBuilder::VisitLiteralCompareNil(CompareOperation* expr, | 2749 void AstGraphBuilder::VisitLiteralCompareNil(CompareOperation* expr, |
| 2797 Expression* sub_expr, | 2750 Expression* sub_expr, |
| 2798 Node* nil_value) { | 2751 Node* nil_value) { |
| 2799 const Operator* op = nullptr; | 2752 const Operator* op = nullptr; |
| 2800 switch (expr->op()) { | 2753 switch (expr->op()) { |
| (...skipping 1563 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4364 // Phi does not exist yet, introduce one. | 4317 // Phi does not exist yet, introduce one. |
| 4365 value = NewPhi(inputs, value, control); | 4318 value = NewPhi(inputs, value, control); |
| 4366 value->ReplaceInput(inputs - 1, other); | 4319 value->ReplaceInput(inputs - 1, other); |
| 4367 } | 4320 } |
| 4368 return value; | 4321 return value; |
| 4369 } | 4322 } |
| 4370 | 4323 |
| 4371 } // namespace compiler | 4324 } // namespace compiler |
| 4372 } // namespace internal | 4325 } // namespace internal |
| 4373 } // namespace v8 | 4326 } // namespace v8 |
| OLD | NEW |