| 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-representation-changes.h" | 5 #include "src/hydrogen-representation-changes.h" |
| 6 | 6 |
| 7 namespace v8 { | 7 namespace v8 { |
| 8 namespace internal { | 8 namespace internal { |
| 9 | 9 |
| 10 void HRepresentationChangesPhase::InsertRepresentationChangeForUse( | 10 void HRepresentationChangesPhase::InsertRepresentationChangeForUse( |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 new_value = constant->CopyToRepresentation(to, graph()->zone()); | 34 new_value = constant->CopyToRepresentation(to, graph()->zone()); |
| 35 } | 35 } |
| 36 } | 36 } |
| 37 | 37 |
| 38 if (new_value == NULL) { | 38 if (new_value == NULL) { |
| 39 new_value = new(graph()->zone()) HChange( | 39 new_value = new(graph()->zone()) HChange( |
| 40 value, to, is_truncating_to_smi, is_truncating_to_int); | 40 value, to, is_truncating_to_smi, is_truncating_to_int); |
| 41 if (!use_value->operand_position(use_index).IsUnknown()) { | 41 if (!use_value->operand_position(use_index).IsUnknown()) { |
| 42 new_value->set_position(use_value->operand_position(use_index)); | 42 new_value->set_position(use_value->operand_position(use_index)); |
| 43 } else { | 43 } else { |
| 44 ASSERT(!FLAG_hydrogen_track_positions || | 44 DCHECK(!FLAG_hydrogen_track_positions || |
| 45 !graph()->info()->IsOptimizing()); | 45 !graph()->info()->IsOptimizing()); |
| 46 } | 46 } |
| 47 } | 47 } |
| 48 | 48 |
| 49 new_value->InsertBefore(next); | 49 new_value->InsertBefore(next); |
| 50 use_value->SetOperandAt(use_index, new_value); | 50 use_value->SetOperandAt(use_index, new_value); |
| 51 } | 51 } |
| 52 | 52 |
| 53 | 53 |
| 54 static bool IsNonDeoptingIntToSmiChange(HChange* change) { | 54 static bool IsNonDeoptingIntToSmiChange(HChange* change) { |
| 55 Representation from_rep = change->from(); | 55 Representation from_rep = change->from(); |
| 56 Representation to_rep = change->to(); | 56 Representation to_rep = change->to(); |
| 57 // Flags indicating Uint32 operations are set in a later Hydrogen phase. | 57 // Flags indicating Uint32 operations are set in a later Hydrogen phase. |
| 58 ASSERT(!change->CheckFlag(HValue::kUint32)); | 58 DCHECK(!change->CheckFlag(HValue::kUint32)); |
| 59 return from_rep.IsInteger32() && to_rep.IsSmi() && SmiValuesAre32Bits(); | 59 return from_rep.IsInteger32() && to_rep.IsSmi() && SmiValuesAre32Bits(); |
| 60 } | 60 } |
| 61 | 61 |
| 62 | 62 |
| 63 void HRepresentationChangesPhase::InsertRepresentationChangesForValue( | 63 void HRepresentationChangesPhase::InsertRepresentationChangesForValue( |
| 64 HValue* value) { | 64 HValue* value) { |
| 65 Representation r = value->representation(); | 65 Representation r = value->representation(); |
| 66 if (r.IsNone()) return; | 66 if (r.IsNone()) return; |
| 67 if (value->HasNoUses()) { | 67 if (value->HasNoUses()) { |
| 68 if (value->IsForceRepresentation()) value->DeleteAndReplaceWith(NULL); | 68 if (value->IsForceRepresentation()) value->DeleteAndReplaceWith(NULL); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 86 HChange* change = HChange::cast(input); | 86 HChange* change = HChange::cast(input); |
| 87 if (change->from().Equals(req) && IsNonDeoptingIntToSmiChange(change)) { | 87 if (change->from().Equals(req) && IsNonDeoptingIntToSmiChange(change)) { |
| 88 use_value->SetOperandAt(use_index, change->value()); | 88 use_value->SetOperandAt(use_index, change->value()); |
| 89 continue; | 89 continue; |
| 90 } | 90 } |
| 91 } | 91 } |
| 92 } | 92 } |
| 93 InsertRepresentationChangeForUse(value, use_value, use_index, req); | 93 InsertRepresentationChangeForUse(value, use_value, use_index, req); |
| 94 } | 94 } |
| 95 if (value->HasNoUses()) { | 95 if (value->HasNoUses()) { |
| 96 ASSERT(value->IsConstant() || value->IsForceRepresentation()); | 96 DCHECK(value->IsConstant() || value->IsForceRepresentation()); |
| 97 value->DeleteAndReplaceWith(NULL); | 97 value->DeleteAndReplaceWith(NULL); |
| 98 } else { | 98 } else { |
| 99 // The only purpose of a HForceRepresentation is to represent the value | 99 // The only purpose of a HForceRepresentation is to represent the value |
| 100 // after the (possible) HChange instruction. We make it disappear. | 100 // after the (possible) HChange instruction. We make it disappear. |
| 101 if (value->IsForceRepresentation()) { | 101 if (value->IsForceRepresentation()) { |
| 102 value->DeleteAndReplaceWith(HForceRepresentation::cast(value)->value()); | 102 value->DeleteAndReplaceWith(HForceRepresentation::cast(value)->value()); |
| 103 } | 103 } |
| 104 } | 104 } |
| 105 } | 105 } |
| 106 | 106 |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 // Process normal instructions. | 194 // Process normal instructions. |
| 195 for (HInstruction* current = block->first(); current != NULL; ) { | 195 for (HInstruction* current = block->first(); current != NULL; ) { |
| 196 HInstruction* next = current->next(); | 196 HInstruction* next = current->next(); |
| 197 InsertRepresentationChangesForValue(current); | 197 InsertRepresentationChangesForValue(current); |
| 198 current = next; | 198 current = next; |
| 199 } | 199 } |
| 200 } | 200 } |
| 201 } | 201 } |
| 202 | 202 |
| 203 } } // namespace v8::internal | 203 } } // namespace v8::internal |
| OLD | NEW |