OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 4357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4368 | 4368 |
4369 // Generate a compare and branch. | 4369 // Generate a compare and branch. |
4370 CHECK_ALIVE(VisitForValue(clause->label())); | 4370 CHECK_ALIVE(VisitForValue(clause->label())); |
4371 HValue* label_value = Pop(); | 4371 HValue* label_value = Pop(); |
4372 | 4372 |
4373 Type* label_type = clause->label()->bounds().lower; | 4373 Type* label_type = clause->label()->bounds().lower; |
4374 Type* combined_type = clause->compare_type(); | 4374 Type* combined_type = clause->compare_type(); |
4375 HControlInstruction* compare = BuildCompareInstruction( | 4375 HControlInstruction* compare = BuildCompareInstruction( |
4376 Token::EQ_STRICT, tag_value, label_value, tag_type, label_type, | 4376 Token::EQ_STRICT, tag_value, label_value, tag_type, label_type, |
4377 combined_type, stmt->tag()->position(), clause->label()->position(), | 4377 combined_type, stmt->tag()->position(), clause->label()->position(), |
4378 clause->id()); | 4378 PUSH_BEFORE_SIMULATE, clause->id()); |
4379 | 4379 |
4380 HBasicBlock* next_test_block = graph()->CreateBasicBlock(); | 4380 HBasicBlock* next_test_block = graph()->CreateBasicBlock(); |
4381 HBasicBlock* body_block = graph()->CreateBasicBlock(); | 4381 HBasicBlock* body_block = graph()->CreateBasicBlock(); |
4382 body_blocks.Add(body_block, zone()); | 4382 body_blocks.Add(body_block, zone()); |
4383 compare->SetSuccessorAt(0, body_block); | 4383 compare->SetSuccessorAt(0, body_block); |
4384 compare->SetSuccessorAt(1, next_test_block); | 4384 compare->SetSuccessorAt(1, next_test_block); |
4385 FinishCurrentBlock(compare); | 4385 FinishCurrentBlock(compare); |
4386 | 4386 |
4387 set_current_block(body_block); | 4387 set_current_block(body_block); |
4388 Drop(1); // tag_value | 4388 Drop(1); // tag_value |
(...skipping 4609 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8998 : HAllocationMode(allocation_site)) | 8998 : HAllocationMode(allocation_site)) |
8999 : HAllocationMode(pretenure_flag); | 8999 : HAllocationMode(pretenure_flag); |
9000 | 9000 |
9001 HValue* result = HGraphBuilder::BuildBinaryOperation( | 9001 HValue* result = HGraphBuilder::BuildBinaryOperation( |
9002 expr->op(), left, right, left_type, right_type, result_type, | 9002 expr->op(), left, right, left_type, right_type, result_type, |
9003 fixed_right_arg, allocation_mode); | 9003 fixed_right_arg, allocation_mode); |
9004 // Add a simulate after instructions with observable side effects, and | 9004 // Add a simulate after instructions with observable side effects, and |
9005 // after phis, which are the result of BuildBinaryOperation when we | 9005 // after phis, which are the result of BuildBinaryOperation when we |
9006 // inlined some complex subgraph. | 9006 // inlined some complex subgraph. |
9007 if (result->HasObservableSideEffects() || result->IsPhi()) { | 9007 if (result->HasObservableSideEffects() || result->IsPhi()) { |
9008 if (push_sim_result == NO_PUSH_BEFORE_SIMULATE) { | 9008 if (push_sim_result == PUSH_BEFORE_SIMULATE) { |
9009 Add<HSimulate>(expr->id(), REMOVABLE_SIMULATE); | |
9010 } else { | |
9011 ASSERT(push_sim_result == PUSH_BEFORE_SIMULATE); | |
9012 Push(result); | 9009 Push(result); |
9013 Add<HSimulate>(expr->id(), REMOVABLE_SIMULATE); | 9010 Add<HSimulate>(expr->id(), REMOVABLE_SIMULATE); |
9014 Drop(1); | 9011 Drop(1); |
| 9012 } else { |
| 9013 Add<HSimulate>(expr->id(), REMOVABLE_SIMULATE); |
9015 } | 9014 } |
9016 } | 9015 } |
9017 return result; | 9016 return result; |
9018 } | 9017 } |
9019 | 9018 |
9020 | 9019 |
9021 HValue* HGraphBuilder::BuildBinaryOperation( | 9020 HValue* HGraphBuilder::BuildBinaryOperation( |
9022 Token::Value op, | 9021 Token::Value op, |
9023 HValue* left, | 9022 HValue* left, |
9024 HValue* right, | 9023 HValue* right, |
(...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9520 } else if (op == Token::IN) { | 9519 } else if (op == Token::IN) { |
9521 HValue* function = AddLoadJSBuiltin(Builtins::IN); | 9520 HValue* function = AddLoadJSBuiltin(Builtins::IN); |
9522 Add<HPushArgument>(left); | 9521 Add<HPushArgument>(left); |
9523 Add<HPushArgument>(right); | 9522 Add<HPushArgument>(right); |
9524 // TODO(olivf) InvokeFunction produces a check for the parameter count, | 9523 // TODO(olivf) InvokeFunction produces a check for the parameter count, |
9525 // even though we are certain to pass the correct number of arguments here. | 9524 // even though we are certain to pass the correct number of arguments here. |
9526 HInstruction* result = New<HInvokeFunction>(function, 2); | 9525 HInstruction* result = New<HInvokeFunction>(function, 2); |
9527 return ast_context()->ReturnInstruction(result, expr->id()); | 9526 return ast_context()->ReturnInstruction(result, expr->id()); |
9528 } | 9527 } |
9529 | 9528 |
| 9529 PushBeforeSimulateBehavior push_behavior = |
| 9530 ast_context()->IsEffect() ? NO_PUSH_BEFORE_SIMULATE |
| 9531 : PUSH_BEFORE_SIMULATE; |
9530 HControlInstruction* compare = BuildCompareInstruction( | 9532 HControlInstruction* compare = BuildCompareInstruction( |
9531 op, left, right, left_type, right_type, combined_type, | 9533 op, left, right, left_type, right_type, combined_type, |
9532 expr->left()->position(), expr->right()->position(), expr->id()); | 9534 expr->left()->position(), expr->right()->position(), |
| 9535 push_behavior, expr->id()); |
9533 if (compare == NULL) return; // Bailed out. | 9536 if (compare == NULL) return; // Bailed out. |
9534 return ast_context()->ReturnControl(compare, expr->id()); | 9537 return ast_context()->ReturnControl(compare, expr->id()); |
9535 } | 9538 } |
9536 | 9539 |
9537 | 9540 |
9538 HControlInstruction* HOptimizedGraphBuilder::BuildCompareInstruction( | 9541 HControlInstruction* HOptimizedGraphBuilder::BuildCompareInstruction( |
9539 Token::Value op, | 9542 Token::Value op, |
9540 HValue* left, | 9543 HValue* left, |
9541 HValue* right, | 9544 HValue* right, |
9542 Type* left_type, | 9545 Type* left_type, |
9543 Type* right_type, | 9546 Type* right_type, |
9544 Type* combined_type, | 9547 Type* combined_type, |
9545 int left_position, | 9548 int left_position, |
9546 int right_position, | 9549 int right_position, |
| 9550 PushBeforeSimulateBehavior push_sim_result, |
9547 BailoutId bailout_id) { | 9551 BailoutId bailout_id) { |
9548 // Cases handled below depend on collected type feedback. They should | 9552 // Cases handled below depend on collected type feedback. They should |
9549 // soft deoptimize when there is no type feedback. | 9553 // soft deoptimize when there is no type feedback. |
9550 if (combined_type->Is(Type::None())) { | 9554 if (combined_type->Is(Type::None())) { |
9551 Add<HDeoptimize>("Insufficient type feedback for combined type " | 9555 Add<HDeoptimize>("Insufficient type feedback for combined type " |
9552 "of binary operation", | 9556 "of binary operation", |
9553 Deoptimizer::SOFT); | 9557 Deoptimizer::SOFT); |
9554 combined_type = left_type = right_type = Type::Any(zone()); | 9558 combined_type = left_type = right_type = Type::Any(zone()); |
9555 } | 9559 } |
9556 | 9560 |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9601 Add<HCheckInstanceType>(right, HCheckInstanceType::IS_STRING); | 9605 Add<HCheckInstanceType>(right, HCheckInstanceType::IS_STRING); |
9602 HStringCompareAndBranch* result = | 9606 HStringCompareAndBranch* result = |
9603 New<HStringCompareAndBranch>(left, right, op); | 9607 New<HStringCompareAndBranch>(left, right, op); |
9604 return result; | 9608 return result; |
9605 } else { | 9609 } else { |
9606 if (combined_rep.IsTagged() || combined_rep.IsNone()) { | 9610 if (combined_rep.IsTagged() || combined_rep.IsNone()) { |
9607 HCompareGeneric* result = Add<HCompareGeneric>(left, right, op); | 9611 HCompareGeneric* result = Add<HCompareGeneric>(left, right, op); |
9608 result->set_observed_input_representation(1, left_rep); | 9612 result->set_observed_input_representation(1, left_rep); |
9609 result->set_observed_input_representation(2, right_rep); | 9613 result->set_observed_input_representation(2, right_rep); |
9610 if (result->HasObservableSideEffects()) { | 9614 if (result->HasObservableSideEffects()) { |
9611 Push(result); | 9615 if (push_sim_result == PUSH_BEFORE_SIMULATE) { |
9612 AddSimulate(bailout_id, REMOVABLE_SIMULATE); | 9616 Push(result); |
9613 Drop(1); | 9617 AddSimulate(bailout_id, REMOVABLE_SIMULATE); |
| 9618 Drop(1); |
| 9619 } else { |
| 9620 AddSimulate(bailout_id, REMOVABLE_SIMULATE); |
| 9621 } |
9614 } | 9622 } |
9615 // TODO(jkummerow): Can we make this more efficient? | 9623 // TODO(jkummerow): Can we make this more efficient? |
9616 HBranch* branch = New<HBranch>(result); | 9624 HBranch* branch = New<HBranch>(result); |
9617 return branch; | 9625 return branch; |
9618 } else { | 9626 } else { |
9619 HCompareNumericAndBranch* result = | 9627 HCompareNumericAndBranch* result = |
9620 New<HCompareNumericAndBranch>(left, right, op); | 9628 New<HCompareNumericAndBranch>(left, right, op); |
9621 result->set_observed_input_representation(left_rep, right_rep); | 9629 result->set_observed_input_representation(left_rep, right_rep); |
9622 if (FLAG_emit_opt_code_positions) { | 9630 if (FLAG_emit_opt_code_positions) { |
9623 result->SetOperandPositions(zone(), left_position, right_position); | 9631 result->SetOperandPositions(zone(), left_position, right_position); |
(...skipping 1563 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11187 if (ShouldProduceTraceOutput()) { | 11195 if (ShouldProduceTraceOutput()) { |
11188 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); | 11196 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); |
11189 } | 11197 } |
11190 | 11198 |
11191 #ifdef DEBUG | 11199 #ifdef DEBUG |
11192 graph_->Verify(false); // No full verify. | 11200 graph_->Verify(false); // No full verify. |
11193 #endif | 11201 #endif |
11194 } | 11202 } |
11195 | 11203 |
11196 } } // namespace v8::internal | 11204 } } // namespace v8::internal |
OLD | NEW |