| 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 8878 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8889 set_current_block(join_block); | 8889 set_current_block(join_block); |
| 8890 // We did not materialize any value in the predecessor environments, | 8890 // We did not materialize any value in the predecessor environments, |
| 8891 // so there is no need to handle it here. | 8891 // so there is no need to handle it here. |
| 8892 } | 8892 } |
| 8893 } | 8893 } |
| 8894 | 8894 |
| 8895 | 8895 |
| 8896 void HOptimizedGraphBuilder::VisitArithmeticExpression(BinaryOperation* expr) { | 8896 void HOptimizedGraphBuilder::VisitArithmeticExpression(BinaryOperation* expr) { |
| 8897 CHECK_ALIVE(VisitForValue(expr->left())); | 8897 CHECK_ALIVE(VisitForValue(expr->left())); |
| 8898 CHECK_ALIVE(VisitForValue(expr->right())); | 8898 CHECK_ALIVE(VisitForValue(expr->right())); |
| 8899 if (!FLAG_emit_opt_code_positions) SetSourcePosition(expr->position()); | 8899 SetSourcePosition(expr->position()); |
| 8900 HValue* right = Pop(); | 8900 HValue* right = Pop(); |
| 8901 HValue* left = Pop(); | 8901 HValue* left = Pop(); |
| 8902 HInstruction* instr = BuildBinaryOperation(expr, left, right); | 8902 HInstruction* instr = BuildBinaryOperation(expr, left, right); |
| 8903 if (FLAG_emit_opt_code_positions && instr->IsBinaryOperation()) { |
| 8904 HBinaryOperation::cast(instr)->SetOperandPositions( |
| 8905 zone(), expr->left()->position(), expr->right()->position()); |
| 8906 } |
| 8903 return ast_context()->ReturnInstruction(instr, expr->id()); | 8907 return ast_context()->ReturnInstruction(instr, expr->id()); |
| 8904 } | 8908 } |
| 8905 | 8909 |
| 8906 | 8910 |
| 8907 void HOptimizedGraphBuilder::HandleLiteralCompareTypeof(CompareOperation* expr, | 8911 void HOptimizedGraphBuilder::HandleLiteralCompareTypeof(CompareOperation* expr, |
| 8908 Expression* sub_expr, | 8912 Expression* sub_expr, |
| 8909 Handle<String> check) { | 8913 Handle<String> check) { |
| 8910 CHECK_ALIVE(VisitForTypeOf(sub_expr)); | 8914 CHECK_ALIVE(VisitForTypeOf(sub_expr)); |
| 8911 if (!FLAG_emit_opt_code_positions) SetSourcePosition(expr->position()); | 8915 SetSourcePosition(expr->position()); |
| 8912 HValue* value = Pop(); | 8916 HValue* value = Pop(); |
| 8913 HTypeofIsAndBranch* instr = New<HTypeofIsAndBranch>(value, check); | 8917 HTypeofIsAndBranch* instr = New<HTypeofIsAndBranch>(value, check); |
| 8914 return ast_context()->ReturnControl(instr, expr->id()); | 8918 return ast_context()->ReturnControl(instr, expr->id()); |
| 8915 } | 8919 } |
| 8916 | 8920 |
| 8917 | 8921 |
| 8918 static bool IsLiteralCompareBool(Isolate* isolate, | 8922 static bool IsLiteralCompareBool(Isolate* isolate, |
| 8919 HValue* left, | 8923 HValue* left, |
| 8920 Token::Value op, | 8924 Token::Value op, |
| 8921 HValue* right) { | 8925 HValue* right) { |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8963 Handle<Type> left_type = expr->left()->bounds().lower; | 8967 Handle<Type> left_type = expr->left()->bounds().lower; |
| 8964 Handle<Type> right_type = expr->right()->bounds().lower; | 8968 Handle<Type> right_type = expr->right()->bounds().lower; |
| 8965 Handle<Type> combined_type = expr->combined_type(); | 8969 Handle<Type> combined_type = expr->combined_type(); |
| 8966 Representation combined_rep = Representation::FromType(combined_type); | 8970 Representation combined_rep = Representation::FromType(combined_type); |
| 8967 Representation left_rep = Representation::FromType(left_type); | 8971 Representation left_rep = Representation::FromType(left_type); |
| 8968 Representation right_rep = Representation::FromType(right_type); | 8972 Representation right_rep = Representation::FromType(right_type); |
| 8969 | 8973 |
| 8970 CHECK_ALIVE(VisitForValue(expr->left())); | 8974 CHECK_ALIVE(VisitForValue(expr->left())); |
| 8971 CHECK_ALIVE(VisitForValue(expr->right())); | 8975 CHECK_ALIVE(VisitForValue(expr->right())); |
| 8972 | 8976 |
| 8977 if (FLAG_emit_opt_code_positions) SetSourcePosition(expr->position()); |
| 8978 |
| 8973 HValue* right = Pop(); | 8979 HValue* right = Pop(); |
| 8974 HValue* left = Pop(); | 8980 HValue* left = Pop(); |
| 8975 Token::Value op = expr->op(); | 8981 Token::Value op = expr->op(); |
| 8976 | 8982 |
| 8977 if (IsLiteralCompareBool(isolate(), left, op, right)) { | 8983 if (IsLiteralCompareBool(isolate(), left, op, right)) { |
| 8978 HCompareObjectEqAndBranch* result = | 8984 HCompareObjectEqAndBranch* result = |
| 8979 New<HCompareObjectEqAndBranch>(left, right); | 8985 New<HCompareObjectEqAndBranch>(left, right); |
| 8980 return ast_context()->ReturnControl(result, expr->id()); | 8986 return ast_context()->ReturnControl(result, expr->id()); |
| 8981 } | 8987 } |
| 8982 | 8988 |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9041 switch (op) { | 9047 switch (op) { |
| 9042 case Token::EQ: | 9048 case Token::EQ: |
| 9043 case Token::EQ_STRICT: { | 9049 case Token::EQ_STRICT: { |
| 9044 // Can we get away with map check and not instance type check? | 9050 // Can we get away with map check and not instance type check? |
| 9045 if (combined_type->IsClass()) { | 9051 if (combined_type->IsClass()) { |
| 9046 Handle<Map> map = combined_type->AsClass(); | 9052 Handle<Map> map = combined_type->AsClass(); |
| 9047 AddCheckMap(left, map); | 9053 AddCheckMap(left, map); |
| 9048 AddCheckMap(right, map); | 9054 AddCheckMap(right, map); |
| 9049 HCompareObjectEqAndBranch* result = | 9055 HCompareObjectEqAndBranch* result = |
| 9050 New<HCompareObjectEqAndBranch>(left, right); | 9056 New<HCompareObjectEqAndBranch>(left, right); |
| 9057 if (FLAG_emit_opt_code_positions) { |
| 9058 result->set_operand_position(zone(), 0, expr->left()->position()); |
| 9059 result->set_operand_position(zone(), 1, expr->right()->position()); |
| 9060 } |
| 9051 return ast_context()->ReturnControl(result, expr->id()); | 9061 return ast_context()->ReturnControl(result, expr->id()); |
| 9052 } else { | 9062 } else { |
| 9053 BuildCheckHeapObject(left); | 9063 BuildCheckHeapObject(left); |
| 9054 Add<HCheckInstanceType>(left, HCheckInstanceType::IS_SPEC_OBJECT); | 9064 Add<HCheckInstanceType>(left, HCheckInstanceType::IS_SPEC_OBJECT); |
| 9055 BuildCheckHeapObject(right); | 9065 BuildCheckHeapObject(right); |
| 9056 Add<HCheckInstanceType>(right, HCheckInstanceType::IS_SPEC_OBJECT); | 9066 Add<HCheckInstanceType>(right, HCheckInstanceType::IS_SPEC_OBJECT); |
| 9057 HCompareObjectEqAndBranch* result = | 9067 HCompareObjectEqAndBranch* result = |
| 9058 New<HCompareObjectEqAndBranch>(left, right); | 9068 New<HCompareObjectEqAndBranch>(left, right); |
| 9059 return ast_context()->ReturnControl(result, expr->id()); | 9069 return ast_context()->ReturnControl(result, expr->id()); |
| 9060 } | 9070 } |
| (...skipping 21 matching lines...) Expand all Loading... |
| 9082 } else { | 9092 } else { |
| 9083 if (combined_rep.IsTagged() || combined_rep.IsNone()) { | 9093 if (combined_rep.IsTagged() || combined_rep.IsNone()) { |
| 9084 HCompareGeneric* result = New<HCompareGeneric>(left, right, op); | 9094 HCompareGeneric* result = New<HCompareGeneric>(left, right, op); |
| 9085 result->set_observed_input_representation(1, left_rep); | 9095 result->set_observed_input_representation(1, left_rep); |
| 9086 result->set_observed_input_representation(2, right_rep); | 9096 result->set_observed_input_representation(2, right_rep); |
| 9087 return ast_context()->ReturnInstruction(result, expr->id()); | 9097 return ast_context()->ReturnInstruction(result, expr->id()); |
| 9088 } else { | 9098 } else { |
| 9089 HCompareNumericAndBranch* result = | 9099 HCompareNumericAndBranch* result = |
| 9090 New<HCompareNumericAndBranch>(left, right, op); | 9100 New<HCompareNumericAndBranch>(left, right, op); |
| 9091 result->set_observed_input_representation(left_rep, right_rep); | 9101 result->set_observed_input_representation(left_rep, right_rep); |
| 9102 if (FLAG_emit_opt_code_positions) { |
| 9103 result->SetOperandPositions(zone(), |
| 9104 expr->left()->position(), |
| 9105 expr->right()->position()); |
| 9106 } |
| 9092 return ast_context()->ReturnControl(result, expr->id()); | 9107 return ast_context()->ReturnControl(result, expr->id()); |
| 9093 } | 9108 } |
| 9094 } | 9109 } |
| 9095 } | 9110 } |
| 9096 | 9111 |
| 9097 | 9112 |
| 9098 void HOptimizedGraphBuilder::HandleLiteralCompareNil(CompareOperation* expr, | 9113 void HOptimizedGraphBuilder::HandleLiteralCompareNil(CompareOperation* expr, |
| 9099 Expression* sub_expr, | 9114 Expression* sub_expr, |
| 9100 NilValue nil) { | 9115 NilValue nil) { |
| 9101 ASSERT(!HasStackOverflow()); | 9116 ASSERT(!HasStackOverflow()); |
| (...skipping 1296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10398 trace_.Add(" "); | 10413 trace_.Add(" "); |
| 10399 phi->PrintTo(&trace_); | 10414 phi->PrintTo(&trace_); |
| 10400 trace_.Add("\n"); | 10415 trace_.Add("\n"); |
| 10401 } | 10416 } |
| 10402 } | 10417 } |
| 10403 | 10418 |
| 10404 { | 10419 { |
| 10405 Tag HIR_tag(this, "HIR"); | 10420 Tag HIR_tag(this, "HIR"); |
| 10406 for (HInstructionIterator it(current); !it.Done(); it.Advance()) { | 10421 for (HInstructionIterator it(current); !it.Done(); it.Advance()) { |
| 10407 HInstruction* instruction = it.Current(); | 10422 HInstruction* instruction = it.Current(); |
| 10408 int bci = 0; | 10423 int bci = FLAG_emit_opt_code_positions && instruction->has_position() ? |
| 10424 instruction->position() : 0; |
| 10409 int uses = instruction->UseCount(); | 10425 int uses = instruction->UseCount(); |
| 10410 PrintIndent(); | 10426 PrintIndent(); |
| 10411 trace_.Add("%d %d ", bci, uses); | 10427 trace_.Add("%d %d ", bci, uses); |
| 10412 instruction->PrintNameTo(&trace_); | 10428 instruction->PrintNameTo(&trace_); |
| 10413 trace_.Add(" "); | 10429 trace_.Add(" "); |
| 10414 instruction->PrintTo(&trace_); | 10430 instruction->PrintTo(&trace_); |
| 10415 trace_.Add(" <|@\n"); | 10431 trace_.Add(" <|@\n"); |
| 10416 } | 10432 } |
| 10417 } | 10433 } |
| 10418 | 10434 |
| 10419 | 10435 |
| 10420 if (chunk != NULL) { | 10436 if (chunk != NULL) { |
| 10421 Tag LIR_tag(this, "LIR"); | 10437 Tag LIR_tag(this, "LIR"); |
| 10422 int first_index = current->first_instruction_index(); | 10438 int first_index = current->first_instruction_index(); |
| 10423 int last_index = current->last_instruction_index(); | 10439 int last_index = current->last_instruction_index(); |
| 10424 if (first_index != -1 && last_index != -1) { | 10440 if (first_index != -1 && last_index != -1) { |
| 10425 const ZoneList<LInstruction*>* instructions = chunk->instructions(); | 10441 const ZoneList<LInstruction*>* instructions = chunk->instructions(); |
| 10426 for (int i = first_index; i <= last_index; ++i) { | 10442 for (int i = first_index; i <= last_index; ++i) { |
| 10427 LInstruction* linstr = instructions->at(i); | 10443 LInstruction* linstr = instructions->at(i); |
| 10428 if (linstr != NULL) { | 10444 if (linstr != NULL) { |
| 10429 PrintIndent(); | 10445 PrintIndent(); |
| 10430 trace_.Add("%d ", | 10446 trace_.Add("%d ", |
| 10431 LifetimePosition::FromInstructionIndex(i).Value()); | 10447 LifetimePosition::FromInstructionIndex(i).Value()); |
| 10432 linstr->PrintTo(&trace_); | 10448 linstr->PrintTo(&trace_); |
| 10449 trace_.Add(" [hir:"); |
| 10450 linstr->hydrogen_value()->PrintNameTo(&trace_); |
| 10451 trace_.Add("]"); |
| 10433 trace_.Add(" <|@\n"); | 10452 trace_.Add(" <|@\n"); |
| 10434 } | 10453 } |
| 10435 } | 10454 } |
| 10436 } | 10455 } |
| 10437 } | 10456 } |
| 10438 } | 10457 } |
| 10439 } | 10458 } |
| 10440 | 10459 |
| 10441 | 10460 |
| 10442 void HTracer::TraceLiveRanges(const char* name, LAllocator* allocator) { | 10461 void HTracer::TraceLiveRanges(const char* name, LAllocator* allocator) { |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10601 if (ShouldProduceTraceOutput()) { | 10620 if (ShouldProduceTraceOutput()) { |
| 10602 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); | 10621 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); |
| 10603 } | 10622 } |
| 10604 | 10623 |
| 10605 #ifdef DEBUG | 10624 #ifdef DEBUG |
| 10606 graph_->Verify(false); // No full verify. | 10625 graph_->Verify(false); // No full verify. |
| 10607 #endif | 10626 #endif |
| 10608 } | 10627 } |
| 10609 | 10628 |
| 10610 } } // namespace v8::internal | 10629 } } // namespace v8::internal |
| OLD | NEW |