OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 "v8.h" | 5 #include "v8.h" |
6 | 6 |
7 #include "double.h" | 7 #include "double.h" |
8 #include "factory.h" | 8 #include "factory.h" |
9 #include "hydrogen-infer-representation.h" | 9 #include "hydrogen-infer-representation.h" |
10 #include "property-details-inl.h" | 10 #include "property-details-inl.h" |
(...skipping 3680 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3691 } | 3691 } |
3692 | 3692 |
3693 | 3693 |
3694 HType HChange::CalculateInferredType() { | 3694 HType HChange::CalculateInferredType() { |
3695 if (from().IsDouble() && to().IsTagged()) return HType::HeapNumber(); | 3695 if (from().IsDouble() && to().IsTagged()) return HType::HeapNumber(); |
3696 return type(); | 3696 return type(); |
3697 } | 3697 } |
3698 | 3698 |
3699 | 3699 |
3700 Representation HUnaryMathOperation::RepresentationFromInputs() { | 3700 Representation HUnaryMathOperation::RepresentationFromInputs() { |
| 3701 if (SupportsFlexibleFloorAndRound() && |
| 3702 (op_ == kMathFloor || op_ == kMathRound)) { |
| 3703 // Floor and Round always take a double input. The integral result can be |
| 3704 // used as an integer or a double. Infer the representation from the uses. |
| 3705 return Representation::None(); |
| 3706 } |
3701 Representation rep = representation(); | 3707 Representation rep = representation(); |
3702 // If any of the actual input representation is more general than what we | 3708 // If any of the actual input representation is more general than what we |
3703 // have so far but not Tagged, use that representation instead. | 3709 // have so far but not Tagged, use that representation instead. |
3704 Representation input_rep = value()->representation(); | 3710 Representation input_rep = value()->representation(); |
3705 if (!input_rep.IsTagged()) { | 3711 if (!input_rep.IsTagged()) { |
3706 rep = rep.generalize(input_rep); | 3712 rep = rep.generalize(input_rep); |
3707 } | 3713 } |
3708 return rep; | 3714 return rep; |
3709 } | 3715 } |
3710 | 3716 |
(...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4159 } | 4165 } |
4160 default: | 4166 default: |
4161 UNREACHABLE(); | 4167 UNREACHABLE(); |
4162 break; | 4168 break; |
4163 } | 4169 } |
4164 } while (false); | 4170 } while (false); |
4165 return new(zone) HUnaryMathOperation(context, value, op); | 4171 return new(zone) HUnaryMathOperation(context, value, op); |
4166 } | 4172 } |
4167 | 4173 |
4168 | 4174 |
| 4175 Representation HUnaryMathOperation::RepresentationFromUses() { |
| 4176 if (op_ != kMathFloor && op_ != kMathRound) { |
| 4177 return HValue::RepresentationFromUses(); |
| 4178 } |
| 4179 |
| 4180 // The instruction can have an int32 or double output. Prefer a double |
| 4181 // representation if there are double uses. |
| 4182 bool use_double = false; |
| 4183 |
| 4184 for (HUseIterator it(uses()); !it.Done(); it.Advance()) { |
| 4185 HValue* use = it.value(); |
| 4186 int use_index = it.index(); |
| 4187 Representation rep_observed = use->observed_input_representation(use_index); |
| 4188 Representation rep_required = use->RequiredInputRepresentation(use_index); |
| 4189 use_double |= (rep_observed.IsDouble() || rep_required.IsDouble()); |
| 4190 if (use_double && !FLAG_trace_representation) { |
| 4191 // Having seen one double is enough. |
| 4192 break; |
| 4193 } |
| 4194 if (FLAG_trace_representation) { |
| 4195 if (!rep_required.IsDouble() || rep_observed.IsDouble()) { |
| 4196 PrintF("#%d %s is used by #%d %s as %s%s\n", |
| 4197 id(), Mnemonic(), use->id(), |
| 4198 use->Mnemonic(), rep_observed.Mnemonic(), |
| 4199 (use->CheckFlag(kTruncatingToInt32) ? "-trunc" : "")); |
| 4200 } else { |
| 4201 PrintF("#%d %s is required by #%d %s as %s%s\n", |
| 4202 id(), Mnemonic(), use->id(), |
| 4203 use->Mnemonic(), rep_required.Mnemonic(), |
| 4204 (use->CheckFlag(kTruncatingToInt32) ? "-trunc" : "")); |
| 4205 } |
| 4206 } |
| 4207 } |
| 4208 return use_double ? Representation::Double() : Representation::Integer32(); |
| 4209 } |
| 4210 |
| 4211 |
4169 HInstruction* HPower::New(Zone* zone, | 4212 HInstruction* HPower::New(Zone* zone, |
4170 HValue* context, | 4213 HValue* context, |
4171 HValue* left, | 4214 HValue* left, |
4172 HValue* right) { | 4215 HValue* right) { |
4173 if (FLAG_fold_constants && left->IsConstant() && right->IsConstant()) { | 4216 if (FLAG_fold_constants && left->IsConstant() && right->IsConstant()) { |
4174 HConstant* c_left = HConstant::cast(left); | 4217 HConstant* c_left = HConstant::cast(left); |
4175 HConstant* c_right = HConstant::cast(right); | 4218 HConstant* c_right = HConstant::cast(right); |
4176 if (c_left->HasNumberValue() && c_right->HasNumberValue()) { | 4219 if (c_left->HasNumberValue() && c_right->HasNumberValue()) { |
4177 double result = power_helper(c_left->DoubleValue(), | 4220 double result = power_helper(c_left->DoubleValue(), |
4178 c_right->DoubleValue()); | 4221 c_right->DoubleValue()); |
(...skipping 542 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4721 break; | 4764 break; |
4722 case kExternalMemory: | 4765 case kExternalMemory: |
4723 stream->Add("[external-memory]"); | 4766 stream->Add("[external-memory]"); |
4724 break; | 4767 break; |
4725 } | 4768 } |
4726 | 4769 |
4727 stream->Add("@%d", offset()); | 4770 stream->Add("@%d", offset()); |
4728 } | 4771 } |
4729 | 4772 |
4730 } } // namespace v8::internal | 4773 } } // namespace v8::internal |
OLD | NEW |