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 11 matching lines...) Expand all Loading... |
22 // information we treat constants like normal instructions and insert the | 22 // information we treat constants like normal instructions and insert the |
23 // change instructions for them. | 23 // change instructions for them. |
24 HInstruction* new_value = NULL; | 24 HInstruction* new_value = NULL; |
25 bool is_truncating_to_smi = use_value->CheckFlag(HValue::kTruncatingToSmi); | 25 bool is_truncating_to_smi = use_value->CheckFlag(HValue::kTruncatingToSmi); |
26 bool is_truncating_to_int = use_value->CheckFlag(HValue::kTruncatingToInt32); | 26 bool is_truncating_to_int = use_value->CheckFlag(HValue::kTruncatingToInt32); |
27 if (value->IsConstant()) { | 27 if (value->IsConstant()) { |
28 HConstant* constant = HConstant::cast(value); | 28 HConstant* constant = HConstant::cast(value); |
29 // Try to create a new copy of the constant with the new representation. | 29 // Try to create a new copy of the constant with the new representation. |
30 if (is_truncating_to_int && to.IsInteger32()) { | 30 if (is_truncating_to_int && to.IsInteger32()) { |
31 Maybe<HConstant*> res = constant->CopyToTruncatedInt32(graph()->zone()); | 31 Maybe<HConstant*> res = constant->CopyToTruncatedInt32(graph()->zone()); |
32 if (res.has_value) new_value = res.value; | 32 if (res.IsJust()) new_value = res.FromJust(); |
33 } else { | 33 } else { |
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)); |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 // Process normal instructions. | 204 // Process normal instructions. |
205 for (HInstruction* current = block->first(); current != NULL; ) { | 205 for (HInstruction* current = block->first(); current != NULL; ) { |
206 HInstruction* next = current->next(); | 206 HInstruction* next = current->next(); |
207 InsertRepresentationChangesForValue(current); | 207 InsertRepresentationChangesForValue(current); |
208 current = next; | 208 current = next; |
209 } | 209 } |
210 } | 210 } |
211 } | 211 } |
212 | 212 |
213 } } // namespace v8::internal | 213 } } // namespace v8::internal |
OLD | NEW |