| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 4618 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4629 } | 4629 } |
| 4630 | 4630 |
| 4631 | 4631 |
| 4632 void HGraphBuilder::VisitSub(UnaryOperation* expr) { | 4632 void HGraphBuilder::VisitSub(UnaryOperation* expr) { |
| 4633 CHECK_ALIVE(VisitForValue(expr->expression())); | 4633 CHECK_ALIVE(VisitForValue(expr->expression())); |
| 4634 HValue* value = Pop(); | 4634 HValue* value = Pop(); |
| 4635 HInstruction* instr = new(zone()) HMul(value, graph_->GetConstantMinus1()); | 4635 HInstruction* instr = new(zone()) HMul(value, graph_->GetConstantMinus1()); |
| 4636 TypeInfo info = oracle()->UnaryType(expr); | 4636 TypeInfo info = oracle()->UnaryType(expr); |
| 4637 Representation rep = ToRepresentation(info); | 4637 Representation rep = ToRepresentation(info); |
| 4638 TraceRepresentation(expr->op(), info, instr, rep); | 4638 TraceRepresentation(expr->op(), info, instr, rep); |
| 4639 AssumeRepresentation(instr, rep); | 4639 instr->AssumeRepresentation(rep); |
| 4640 ast_context()->ReturnInstruction(instr, expr->id()); | 4640 ast_context()->ReturnInstruction(instr, expr->id()); |
| 4641 } | 4641 } |
| 4642 | 4642 |
| 4643 | 4643 |
| 4644 void HGraphBuilder::VisitBitNot(UnaryOperation* expr) { | 4644 void HGraphBuilder::VisitBitNot(UnaryOperation* expr) { |
| 4645 CHECK_ALIVE(VisitForValue(expr->expression())); | 4645 CHECK_ALIVE(VisitForValue(expr->expression())); |
| 4646 HValue* value = Pop(); | 4646 HValue* value = Pop(); |
| 4647 HInstruction* instr = new(zone()) HBitNot(value); | 4647 HInstruction* instr = new(zone()) HBitNot(value); |
| 4648 ast_context()->ReturnInstruction(instr, expr->id()); | 4648 ast_context()->ReturnInstruction(instr, expr->id()); |
| 4649 } | 4649 } |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4700 HConstant* delta = increment | 4700 HConstant* delta = increment |
| 4701 ? graph_->GetConstant1() | 4701 ? graph_->GetConstant1() |
| 4702 : graph_->GetConstantMinus1(); | 4702 : graph_->GetConstantMinus1(); |
| 4703 HInstruction* instr = new(zone()) HAdd(value, delta); | 4703 HInstruction* instr = new(zone()) HAdd(value, delta); |
| 4704 TypeInfo info = oracle()->IncrementType(expr); | 4704 TypeInfo info = oracle()->IncrementType(expr); |
| 4705 Representation rep = ToRepresentation(info); | 4705 Representation rep = ToRepresentation(info); |
| 4706 if (rep.IsTagged()) { | 4706 if (rep.IsTagged()) { |
| 4707 rep = Representation::Integer32(); | 4707 rep = Representation::Integer32(); |
| 4708 } | 4708 } |
| 4709 TraceRepresentation(expr->op(), info, instr, rep); | 4709 TraceRepresentation(expr->op(), info, instr, rep); |
| 4710 AssumeRepresentation(instr, rep); | 4710 instr->AssumeRepresentation(rep); |
| 4711 return instr; | 4711 return instr; |
| 4712 } | 4712 } |
| 4713 | 4713 |
| 4714 | 4714 |
| 4715 void HGraphBuilder::VisitCountOperation(CountOperation* expr) { | 4715 void HGraphBuilder::VisitCountOperation(CountOperation* expr) { |
| 4716 ASSERT(!HasStackOverflow()); | 4716 ASSERT(!HasStackOverflow()); |
| 4717 ASSERT(current_block() != NULL); | 4717 ASSERT(current_block() != NULL); |
| 4718 ASSERT(current_block()->HasPredecessor()); | 4718 ASSERT(current_block()->HasPredecessor()); |
| 4719 Expression* target = expr->expression(); | 4719 Expression* target = expr->expression(); |
| 4720 VariableProxy* proxy = target->AsVariableProxy(); | 4720 VariableProxy* proxy = target->AsVariableProxy(); |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4878 ((left->IsConstant() && HConstant::cast(left)->HasStringValue()) || | 4878 ((left->IsConstant() && HConstant::cast(left)->HasStringValue()) || |
| 4879 (right->IsConstant() && HConstant::cast(right)->HasStringValue()))) { | 4879 (right->IsConstant() && HConstant::cast(right)->HasStringValue()))) { |
| 4880 return instr; | 4880 return instr; |
| 4881 } | 4881 } |
| 4882 Representation rep = ToRepresentation(info); | 4882 Representation rep = ToRepresentation(info); |
| 4883 // We only generate either int32 or generic tagged bitwise operations. | 4883 // We only generate either int32 or generic tagged bitwise operations. |
| 4884 if (instr->IsBitwiseBinaryOperation() && rep.IsDouble()) { | 4884 if (instr->IsBitwiseBinaryOperation() && rep.IsDouble()) { |
| 4885 rep = Representation::Integer32(); | 4885 rep = Representation::Integer32(); |
| 4886 } | 4886 } |
| 4887 TraceRepresentation(expr->op(), info, instr, rep); | 4887 TraceRepresentation(expr->op(), info, instr, rep); |
| 4888 AssumeRepresentation(instr, rep); | 4888 instr->AssumeRepresentation(rep); |
| 4889 return instr; | 4889 return instr; |
| 4890 } | 4890 } |
| 4891 | 4891 |
| 4892 | 4892 |
| 4893 HInstruction* HGraphBuilder::BuildBinaryOperation( | 4893 HInstruction* HGraphBuilder::BuildBinaryOperation( |
| 4894 Token::Value op, HValue* left, HValue* right, TypeInfo info) { | 4894 Token::Value op, HValue* left, HValue* right, TypeInfo info) { |
| 4895 switch (op) { | 4895 switch (op) { |
| 4896 case Token::ADD: | 4896 case Token::ADD: |
| 4897 if (info.IsString()) { | 4897 if (info.IsString()) { |
| 4898 AddInstruction(new(zone()) HCheckNonSmi(left)); | 4898 AddInstruction(new(zone()) HCheckNonSmi(left)); |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5066 Token::Name(op), | 5066 Token::Name(op), |
| 5067 info.ToString(), | 5067 info.ToString(), |
| 5068 flexible ? "" : " DO NOT ", | 5068 flexible ? "" : " DO NOT ", |
| 5069 value->Mnemonic(), | 5069 value->Mnemonic(), |
| 5070 graph_->GetMaximumValueID(), | 5070 graph_->GetMaximumValueID(), |
| 5071 value->representation().Mnemonic(), | 5071 value->representation().Mnemonic(), |
| 5072 rep.Mnemonic()); | 5072 rep.Mnemonic()); |
| 5073 } | 5073 } |
| 5074 | 5074 |
| 5075 | 5075 |
| 5076 void HGraphBuilder::AssumeRepresentation(HValue* value, Representation rep) { | |
| 5077 if (value->CheckFlag(HValue::kFlexibleRepresentation)) { | |
| 5078 value->ChangeRepresentation(rep); | |
| 5079 // The representation of the value is dictated by type feedback and | |
| 5080 // will not be changed later. | |
| 5081 value->ClearFlag(HValue::kFlexibleRepresentation); | |
| 5082 } | |
| 5083 } | |
| 5084 | |
| 5085 | |
| 5086 Representation HGraphBuilder::ToRepresentation(TypeInfo info) { | 5076 Representation HGraphBuilder::ToRepresentation(TypeInfo info) { |
| 5087 if (info.IsSmi()) return Representation::Integer32(); | 5077 if (info.IsSmi()) return Representation::Integer32(); |
| 5088 if (info.IsInteger32()) return Representation::Integer32(); | 5078 if (info.IsInteger32()) return Representation::Integer32(); |
| 5089 if (info.IsDouble()) return Representation::Double(); | 5079 if (info.IsDouble()) return Representation::Double(); |
| 5090 if (info.IsNumber()) return Representation::Double(); | 5080 if (info.IsNumber()) return Representation::Double(); |
| 5091 return Representation::Tagged(); | 5081 return Representation::Tagged(); |
| 5092 } | 5082 } |
| 5093 | 5083 |
| 5094 | 5084 |
| 5095 void HGraphBuilder::VisitCompareOperation(CompareOperation* expr) { | 5085 void HGraphBuilder::VisitCompareOperation(CompareOperation* expr) { |
| (...skipping 1043 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6139 } | 6129 } |
| 6140 } | 6130 } |
| 6141 | 6131 |
| 6142 #ifdef DEBUG | 6132 #ifdef DEBUG |
| 6143 if (graph_ != NULL) graph_->Verify(); | 6133 if (graph_ != NULL) graph_->Verify(); |
| 6144 if (allocator_ != NULL) allocator_->Verify(); | 6134 if (allocator_ != NULL) allocator_->Verify(); |
| 6145 #endif | 6135 #endif |
| 6146 } | 6136 } |
| 6147 | 6137 |
| 6148 } } // namespace v8::internal | 6138 } } // namespace v8::internal |
| OLD | NEW |