Chromium Code Reviews| Index: src/hydrogen.cc |
| diff --git a/src/hydrogen.cc b/src/hydrogen.cc |
| index d3d7b5837a0c5e3d9a09ba4a58ce9486773818e8..0af75ce4ae60199623b75b5bcbbe441b4ea9b8d8 100644 |
| --- a/src/hydrogen.cc |
| +++ b/src/hydrogen.cc |
| @@ -4375,7 +4375,7 @@ void HOptimizedGraphBuilder::VisitSwitchStatement(SwitchStatement* stmt) { |
| HControlInstruction* compare = BuildCompareInstruction( |
| Token::EQ_STRICT, tag_value, label_value, tag_type, label_type, |
| combined_type, stmt->tag()->position(), clause->label()->position(), |
| - clause->id()); |
| + PUSH_BEFORE_SIMULATE, clause->id()); |
| HBasicBlock* next_test_block = graph()->CreateBasicBlock(); |
| HBasicBlock* body_block = graph()->CreateBasicBlock(); |
| @@ -9527,9 +9527,13 @@ void HOptimizedGraphBuilder::VisitCompareOperation(CompareOperation* expr) { |
| return ast_context()->ReturnInstruction(result, expr->id()); |
| } |
| + PushBeforeSimulateBehavior push_behavior = |
| + ast_context()->IsEffect() ? NO_PUSH_BEFORE_SIMULATE |
| + : PUSH_BEFORE_SIMULATE; |
| HControlInstruction* compare = BuildCompareInstruction( |
| op, left, right, left_type, right_type, combined_type, |
| - expr->left()->position(), expr->right()->position(), expr->id()); |
| + expr->left()->position(), expr->right()->position(), |
| + push_behavior, expr->id()); |
| if (compare == NULL) return; // Bailed out. |
| return ast_context()->ReturnControl(compare, expr->id()); |
| } |
| @@ -9544,6 +9548,7 @@ HControlInstruction* HOptimizedGraphBuilder::BuildCompareInstruction( |
| Type* combined_type, |
| int left_position, |
| int right_position, |
| + PushBeforeSimulateBehavior push_sim_result, |
| BailoutId bailout_id) { |
| // Cases handled below depend on collected type feedback. They should |
| // soft deoptimize when there is no type feedback. |
| @@ -9608,9 +9613,14 @@ HControlInstruction* HOptimizedGraphBuilder::BuildCompareInstruction( |
| result->set_observed_input_representation(1, left_rep); |
| result->set_observed_input_representation(2, right_rep); |
| if (result->HasObservableSideEffects()) { |
| - Push(result); |
| - AddSimulate(bailout_id, REMOVABLE_SIMULATE); |
| - Drop(1); |
| + if (push_sim_result == NO_PUSH_BEFORE_SIMULATE) { |
|
Jakob Kummerow
2014/02/13 15:55:32
nit: I'd find it slightly more readable to swap th
|
| + AddSimulate(bailout_id, REMOVABLE_SIMULATE); |
| + } else { |
| + ASSERT(push_sim_result == PUSH_BEFORE_SIMULATE); |
| + Push(result); |
| + AddSimulate(bailout_id, REMOVABLE_SIMULATE); |
| + Drop(1); |
| + } |
| } |
| // TODO(jkummerow): Can we make this more efficient? |
| HBranch* branch = New<HBranch>(result); |