| OLD | NEW |
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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/hydrogen.h" | 5 #include "src/hydrogen.h" |
| 6 | 6 |
| 7 #include <sstream> | 7 #include <sstream> |
| 8 | 8 |
| 9 #include "src/v8.h" | 9 #include "src/v8.h" |
| 10 | 10 |
| (...skipping 4800 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4811 | 4811 |
| 4812 // Generate a compare and branch. | 4812 // Generate a compare and branch. |
| 4813 CHECK_ALIVE(VisitForValue(clause->label())); | 4813 CHECK_ALIVE(VisitForValue(clause->label())); |
| 4814 HValue* label_value = Pop(); | 4814 HValue* label_value = Pop(); |
| 4815 | 4815 |
| 4816 Type* label_type = clause->label()->bounds().lower; | 4816 Type* label_type = clause->label()->bounds().lower; |
| 4817 Type* combined_type = clause->compare_type(); | 4817 Type* combined_type = clause->compare_type(); |
| 4818 HControlInstruction* compare = BuildCompareInstruction( | 4818 HControlInstruction* compare = BuildCompareInstruction( |
| 4819 Token::EQ_STRICT, tag_value, label_value, tag_type, label_type, | 4819 Token::EQ_STRICT, tag_value, label_value, tag_type, label_type, |
| 4820 combined_type, | 4820 combined_type, |
| 4821 ScriptPositionToSourcePosition(stmt->tag()->position()), | |
| 4822 ScriptPositionToSourcePosition(clause->label()->position()), | |
| 4823 PUSH_BEFORE_SIMULATE, clause->id()); | 4821 PUSH_BEFORE_SIMULATE, clause->id()); |
| 4824 | 4822 |
| 4823 if (FLAG_hydrogen_track_positions) { |
| 4824 compare->SetOperandPositions( |
| 4825 zone(), ScriptPositionToSourcePosition(stmt->tag()->position()), |
| 4826 ScriptPositionToSourcePosition(clause->label()->position())); |
| 4827 } |
| 4825 HBasicBlock* next_test_block = graph()->CreateBasicBlock(); | 4828 HBasicBlock* next_test_block = graph()->CreateBasicBlock(); |
| 4826 HBasicBlock* body_block = graph()->CreateBasicBlock(); | 4829 HBasicBlock* body_block = graph()->CreateBasicBlock(); |
| 4827 body_blocks.Add(body_block, zone()); | 4830 body_blocks.Add(body_block, zone()); |
| 4828 compare->SetSuccessorAt(0, body_block); | 4831 compare->SetSuccessorAt(0, body_block); |
| 4829 compare->SetSuccessorAt(1, next_test_block); | 4832 compare->SetSuccessorAt(1, next_test_block); |
| 4830 FinishCurrentBlock(compare); | 4833 FinishCurrentBlock(compare); |
| 4831 | 4834 |
| 4832 set_current_block(body_block); | 4835 set_current_block(body_block); |
| 4833 Drop(1); // tag_value | 4836 Drop(1); // tag_value |
| 4834 | 4837 |
| (...skipping 6081 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10916 // even though we are certain to pass the correct number of arguments here. | 10919 // even though we are certain to pass the correct number of arguments here. |
| 10917 HInstruction* result = New<HInvokeFunction>(function, 2); | 10920 HInstruction* result = New<HInvokeFunction>(function, 2); |
| 10918 return ast_context()->ReturnInstruction(result, expr->id()); | 10921 return ast_context()->ReturnInstruction(result, expr->id()); |
| 10919 } | 10922 } |
| 10920 | 10923 |
| 10921 PushBeforeSimulateBehavior push_behavior = | 10924 PushBeforeSimulateBehavior push_behavior = |
| 10922 ast_context()->IsEffect() ? NO_PUSH_BEFORE_SIMULATE | 10925 ast_context()->IsEffect() ? NO_PUSH_BEFORE_SIMULATE |
| 10923 : PUSH_BEFORE_SIMULATE; | 10926 : PUSH_BEFORE_SIMULATE; |
| 10924 HControlInstruction* compare = BuildCompareInstruction( | 10927 HControlInstruction* compare = BuildCompareInstruction( |
| 10925 op, left, right, left_type, right_type, combined_type, | 10928 op, left, right, left_type, right_type, combined_type, |
| 10926 ScriptPositionToSourcePosition(expr->left()->position()), | |
| 10927 ScriptPositionToSourcePosition(expr->right()->position()), | |
| 10928 push_behavior, expr->id()); | 10929 push_behavior, expr->id()); |
| 10929 if (compare == NULL) return; // Bailed out. | 10930 if (compare == NULL) return; // Bailed out. |
| 10931 if (FLAG_hydrogen_track_positions) { |
| 10932 compare->SetOperandPositions( |
| 10933 zone(), ScriptPositionToSourcePosition(expr->left()->position()), |
| 10934 ScriptPositionToSourcePosition(expr->right()->position())); |
| 10935 } |
| 10930 return ast_context()->ReturnControl(compare, expr->id()); | 10936 return ast_context()->ReturnControl(compare, expr->id()); |
| 10931 } | 10937 } |
| 10932 | 10938 |
| 10933 | 10939 |
| 10934 HControlInstruction* HOptimizedGraphBuilder::BuildCompareInstruction( | 10940 HControlInstruction* HOptimizedGraphBuilder::BuildCompareInstruction( |
| 10935 Token::Value op, HValue* left, HValue* right, Type* left_type, | 10941 Token::Value op, HValue* left, HValue* right, Type* left_type, |
| 10936 Type* right_type, Type* combined_type, SourcePosition left_position, | 10942 Type* right_type, Type* combined_type, |
| 10937 SourcePosition right_position, PushBeforeSimulateBehavior push_sim_result, | 10943 PushBeforeSimulateBehavior push_sim_result, BailoutId bailout_id) { |
| 10938 BailoutId bailout_id) { | |
| 10939 // Cases handled below depend on collected type feedback. They should | 10944 // Cases handled below depend on collected type feedback. They should |
| 10940 // soft deoptimize when there is no type feedback. | 10945 // soft deoptimize when there is no type feedback. |
| 10941 if (!combined_type->IsInhabited()) { | 10946 if (!combined_type->IsInhabited()) { |
| 10942 Add<HDeoptimize>( | 10947 Add<HDeoptimize>( |
| 10943 Deoptimizer::kInsufficientTypeFeedbackForCombinedTypeOfBinaryOperation, | 10948 Deoptimizer::kInsufficientTypeFeedbackForCombinedTypeOfBinaryOperation, |
| 10944 Deoptimizer::SOFT); | 10949 Deoptimizer::SOFT); |
| 10945 combined_type = left_type = right_type = Type::Any(zone()); | 10950 combined_type = left_type = right_type = Type::Any(zone()); |
| 10946 } | 10951 } |
| 10947 | 10952 |
| 10948 Representation left_rep = Representation::FromType(left_type); | 10953 Representation left_rep = Representation::FromType(left_type); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 10963 return New<HBranch>(graph()->GetConstantTrue()); | 10968 return New<HBranch>(graph()->GetConstantTrue()); |
| 10964 } | 10969 } |
| 10965 // Can we get away with map check and not instance type check? | 10970 // Can we get away with map check and not instance type check? |
| 10966 HValue* operand_to_check = | 10971 HValue* operand_to_check = |
| 10967 left->block()->block_id() < right->block()->block_id() ? left : right; | 10972 left->block()->block_id() < right->block()->block_id() ? left : right; |
| 10968 if (combined_type->IsClass()) { | 10973 if (combined_type->IsClass()) { |
| 10969 Handle<Map> map = combined_type->AsClass()->Map(); | 10974 Handle<Map> map = combined_type->AsClass()->Map(); |
| 10970 AddCheckMap(operand_to_check, map); | 10975 AddCheckMap(operand_to_check, map); |
| 10971 HCompareObjectEqAndBranch* result = | 10976 HCompareObjectEqAndBranch* result = |
| 10972 New<HCompareObjectEqAndBranch>(left, right); | 10977 New<HCompareObjectEqAndBranch>(left, right); |
| 10973 if (FLAG_hydrogen_track_positions) { | |
| 10974 result->set_operand_position(zone(), 0, left_position); | |
| 10975 result->set_operand_position(zone(), 1, right_position); | |
| 10976 } | |
| 10977 return result; | 10978 return result; |
| 10978 } else { | 10979 } else { |
| 10979 BuildCheckHeapObject(operand_to_check); | 10980 BuildCheckHeapObject(operand_to_check); |
| 10980 Add<HCheckInstanceType>(operand_to_check, | 10981 Add<HCheckInstanceType>(operand_to_check, |
| 10981 HCheckInstanceType::IS_SPEC_OBJECT); | 10982 HCheckInstanceType::IS_SPEC_OBJECT); |
| 10982 HCompareObjectEqAndBranch* result = | 10983 HCompareObjectEqAndBranch* result = |
| 10983 New<HCompareObjectEqAndBranch>(left, right); | 10984 New<HCompareObjectEqAndBranch>(left, right); |
| 10984 return result; | 10985 return result; |
| 10985 } | 10986 } |
| 10986 } else { | 10987 } else { |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11029 AddSimulate(bailout_id, REMOVABLE_SIMULATE); | 11030 AddSimulate(bailout_id, REMOVABLE_SIMULATE); |
| 11030 } | 11031 } |
| 11031 } | 11032 } |
| 11032 // TODO(jkummerow): Can we make this more efficient? | 11033 // TODO(jkummerow): Can we make this more efficient? |
| 11033 HBranch* branch = New<HBranch>(result); | 11034 HBranch* branch = New<HBranch>(result); |
| 11034 return branch; | 11035 return branch; |
| 11035 } else { | 11036 } else { |
| 11036 HCompareNumericAndBranch* result = | 11037 HCompareNumericAndBranch* result = |
| 11037 New<HCompareNumericAndBranch>(left, right, op); | 11038 New<HCompareNumericAndBranch>(left, right, op); |
| 11038 result->set_observed_input_representation(left_rep, right_rep); | 11039 result->set_observed_input_representation(left_rep, right_rep); |
| 11039 if (FLAG_hydrogen_track_positions) { | |
| 11040 result->SetOperandPositions(zone(), left_position, right_position); | |
| 11041 } | |
| 11042 return result; | 11040 return result; |
| 11043 } | 11041 } |
| 11044 } | 11042 } |
| 11045 } | 11043 } |
| 11046 | 11044 |
| 11047 | 11045 |
| 11048 void HOptimizedGraphBuilder::HandleLiteralCompareNil(CompareOperation* expr, | 11046 void HOptimizedGraphBuilder::HandleLiteralCompareNil(CompareOperation* expr, |
| 11049 Expression* sub_expr, | 11047 Expression* sub_expr, |
| 11050 NilValue nil) { | 11048 NilValue nil) { |
| 11051 DCHECK(!HasStackOverflow()); | 11049 DCHECK(!HasStackOverflow()); |
| (...skipping 2387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13439 if (ShouldProduceTraceOutput()) { | 13437 if (ShouldProduceTraceOutput()) { |
| 13440 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); | 13438 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); |
| 13441 } | 13439 } |
| 13442 | 13440 |
| 13443 #ifdef DEBUG | 13441 #ifdef DEBUG |
| 13444 graph_->Verify(false); // No full verify. | 13442 graph_->Verify(false); // No full verify. |
| 13445 #endif | 13443 #endif |
| 13446 } | 13444 } |
| 13447 | 13445 |
| 13448 } } // namespace v8::internal | 13446 } } // namespace v8::internal |
| OLD | NEW |