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/js-type-feedback.h" | 10 #include "src/compiler/js-type-feedback.h" |
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
328 LoopBuilder* control_; | 328 LoopBuilder* control_; |
329 }; | 329 }; |
330 | 330 |
331 | 331 |
332 // Control scope implementation for a TryCatchStatement. | 332 // Control scope implementation for a TryCatchStatement. |
333 class AstGraphBuilder::ControlScopeForCatch : public ControlScope { | 333 class AstGraphBuilder::ControlScopeForCatch : public ControlScope { |
334 public: | 334 public: |
335 ControlScopeForCatch(AstGraphBuilder* owner, TryCatchBuilder* control) | 335 ControlScopeForCatch(AstGraphBuilder* owner, TryCatchBuilder* control) |
336 : ControlScope(owner), control_(control) { | 336 : ControlScope(owner), control_(control) { |
337 builder()->try_nesting_level_++; // Increment nesting. | 337 builder()->try_nesting_level_++; // Increment nesting. |
| 338 builder()->try_catch_nesting_level_++; |
338 } | 339 } |
339 ~ControlScopeForCatch() { | 340 ~ControlScopeForCatch() { |
340 builder()->try_nesting_level_--; // Decrement nesting. | 341 builder()->try_nesting_level_--; // Decrement nesting. |
| 342 builder()->try_catch_nesting_level_--; |
341 } | 343 } |
342 | 344 |
343 protected: | 345 protected: |
344 virtual bool Execute(Command cmd, Statement* target, Node* value) override { | 346 virtual bool Execute(Command cmd, Statement* target, Node* value) override { |
345 switch (cmd) { | 347 switch (cmd) { |
346 case CMD_THROW: | 348 case CMD_THROW: |
347 control_->Throw(value); | 349 control_->Throw(value); |
348 return true; | 350 return true; |
349 case CMD_BREAK: | 351 case CMD_BREAK: |
350 case CMD_CONTINUE: | 352 case CMD_CONTINUE: |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
430 JSGraph* jsgraph, LoopAssignmentAnalysis* loop, | 432 JSGraph* jsgraph, LoopAssignmentAnalysis* loop, |
431 JSTypeFeedbackTable* js_type_feedback) | 433 JSTypeFeedbackTable* js_type_feedback) |
432 : local_zone_(local_zone), | 434 : local_zone_(local_zone), |
433 info_(info), | 435 info_(info), |
434 jsgraph_(jsgraph), | 436 jsgraph_(jsgraph), |
435 environment_(nullptr), | 437 environment_(nullptr), |
436 ast_context_(nullptr), | 438 ast_context_(nullptr), |
437 globals_(0, local_zone), | 439 globals_(0, local_zone), |
438 execution_control_(nullptr), | 440 execution_control_(nullptr), |
439 execution_context_(nullptr), | 441 execution_context_(nullptr), |
| 442 try_catch_nesting_level_(0), |
440 try_nesting_level_(0), | 443 try_nesting_level_(0), |
441 input_buffer_size_(0), | 444 input_buffer_size_(0), |
442 input_buffer_(nullptr), | 445 input_buffer_(nullptr), |
443 exit_controls_(local_zone), | 446 exit_controls_(local_zone), |
444 loop_assignment_analysis_(loop), | 447 loop_assignment_analysis_(loop), |
445 state_values_cache_(jsgraph), | 448 state_values_cache_(jsgraph), |
446 liveness_analyzer_(static_cast<size_t>(info->scope()->num_stack_slots()), | 449 liveness_analyzer_(static_cast<size_t>(info->scope()->num_stack_slots()), |
447 local_zone), | 450 local_zone), |
448 js_type_feedback_(js_type_feedback) { | 451 js_type_feedback_(js_type_feedback) { |
449 InitializeAstVisitor(info->isolate(), local_zone); | 452 InitializeAstVisitor(info->isolate(), local_zone); |
(...skipping 3105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3555 if (has_effect) { | 3558 if (has_effect) { |
3556 environment_->UpdateEffectDependency(result); | 3559 environment_->UpdateEffectDependency(result); |
3557 } | 3560 } |
3558 if (!environment()->IsMarkedAsUnreachable()) { | 3561 if (!environment()->IsMarkedAsUnreachable()) { |
3559 // Update the current control dependency for control-producing nodes. | 3562 // Update the current control dependency for control-producing nodes. |
3560 if (NodeProperties::IsControl(result)) { | 3563 if (NodeProperties::IsControl(result)) { |
3561 environment_->UpdateControlDependency(result); | 3564 environment_->UpdateControlDependency(result); |
3562 } | 3565 } |
3563 // Add implicit exception continuation for throwing nodes. | 3566 // Add implicit exception continuation for throwing nodes. |
3564 if (!result->op()->HasProperty(Operator::kNoThrow) && inside_try_scope) { | 3567 if (!result->op()->HasProperty(Operator::kNoThrow) && inside_try_scope) { |
| 3568 // Conservative prediction whether caught locally. |
| 3569 IfExceptionHint hint = try_catch_nesting_level_ > 0 |
| 3570 ? IfExceptionHint::kLocallyCaught |
| 3571 : IfExceptionHint::kLocallyUncaught; |
3565 // Copy the environment for the success continuation. | 3572 // Copy the environment for the success continuation. |
3566 Environment* success_env = environment()->CopyForConditional(); | 3573 Environment* success_env = environment()->CopyForConditional(); |
3567 | 3574 const Operator* op = common()->IfException(hint); |
3568 Node* on_exception = graph()->NewNode(common()->IfException(), result); | 3575 Node* on_exception = graph()->NewNode(op, result); |
3569 environment_->UpdateControlDependency(on_exception); | 3576 environment_->UpdateControlDependency(on_exception); |
3570 execution_control()->ThrowValue(on_exception); | 3577 execution_control()->ThrowValue(on_exception); |
3571 set_environment(success_env); | 3578 set_environment(success_env); |
3572 } | 3579 } |
3573 // Add implicit success continuation for throwing nodes. | 3580 // Add implicit success continuation for throwing nodes. |
3574 if (!result->op()->HasProperty(Operator::kNoThrow)) { | 3581 if (!result->op()->HasProperty(Operator::kNoThrow)) { |
3575 Node* on_success = graph()->NewNode(common()->IfSuccess(), result); | 3582 const Operator* op = common()->IfSuccess(); |
| 3583 Node* on_success = graph()->NewNode(op, result); |
3576 environment_->UpdateControlDependency(on_success); | 3584 environment_->UpdateControlDependency(on_success); |
3577 } | 3585 } |
3578 } | 3586 } |
3579 } | 3587 } |
3580 | 3588 |
3581 return result; | 3589 return result; |
3582 } | 3590 } |
3583 | 3591 |
3584 | 3592 |
3585 void AstGraphBuilder::UpdateControlDependencyToLeaveFunction(Node* exit) { | 3593 void AstGraphBuilder::UpdateControlDependencyToLeaveFunction(Node* exit) { |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3795 // Phi does not exist yet, introduce one. | 3803 // Phi does not exist yet, introduce one. |
3796 value = NewPhi(inputs, value, control); | 3804 value = NewPhi(inputs, value, control); |
3797 value->ReplaceInput(inputs - 1, other); | 3805 value->ReplaceInput(inputs - 1, other); |
3798 } | 3806 } |
3799 return value; | 3807 return value; |
3800 } | 3808 } |
3801 | 3809 |
3802 } // namespace compiler | 3810 } // namespace compiler |
3803 } // namespace internal | 3811 } // namespace internal |
3804 } // namespace v8 | 3812 } // namespace v8 |
OLD | NEW |