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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 // time. When a representation change is not possible without loss of | 44 // time. When a representation change is not possible without loss of |
45 // information we treat constants like normal instructions and insert the | 45 // information we treat constants like normal instructions and insert the |
46 // change instructions for them. | 46 // change instructions for them. |
47 HInstruction* new_value = NULL; | 47 HInstruction* new_value = NULL; |
48 bool is_truncating = use_value->CheckFlag(HValue::kTruncatingToInt32); | 48 bool is_truncating = use_value->CheckFlag(HValue::kTruncatingToInt32); |
49 bool allow_undefined_as_nan = | 49 bool allow_undefined_as_nan = |
50 use_value->CheckFlag(HValue::kAllowUndefinedAsNaN); | 50 use_value->CheckFlag(HValue::kAllowUndefinedAsNaN); |
51 if (value->IsConstant()) { | 51 if (value->IsConstant()) { |
52 HConstant* constant = HConstant::cast(value); | 52 HConstant* constant = HConstant::cast(value); |
53 // Try to create a new copy of the constant with the new representation. | 53 // Try to create a new copy of the constant with the new representation. |
54 new_value = (is_truncating && to.IsInteger32()) | 54 if (is_truncating && to.IsInteger32()) { |
55 ? constant->CopyToTruncatedInt32(graph()->zone()) | 55 Maybe<HConstant*> res = constant->CopyToTruncatedInt32(graph()->zone()); |
56 : constant->CopyToRepresentation(to, graph()->zone()); | 56 if (res.has_value) new_value = res.value; |
| 57 } else { |
| 58 new_value = constant->CopyToRepresentation(to, graph()->zone()); |
| 59 } |
57 } | 60 } |
58 | 61 |
59 if (new_value == NULL) { | 62 if (new_value == NULL) { |
60 new_value = new(graph()->zone()) HChange(value, to, | 63 new_value = new(graph()->zone()) HChange(value, to, |
61 is_truncating, | 64 is_truncating, |
62 allow_undefined_as_nan); | 65 allow_undefined_as_nan); |
63 } | 66 } |
64 | 67 |
65 new_value->InsertBefore(next); | 68 new_value->InsertBefore(next); |
66 use_value->SetOperandAt(use_index, new_value); | 69 use_value->SetOperandAt(use_index, new_value); |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 // Process normal instructions. | 161 // Process normal instructions. |
159 for (HInstruction* current = block->first(); current != NULL; ) { | 162 for (HInstruction* current = block->first(); current != NULL; ) { |
160 HInstruction* next = current->next(); | 163 HInstruction* next = current->next(); |
161 InsertRepresentationChangesForValue(current); | 164 InsertRepresentationChangesForValue(current); |
162 current = next; | 165 current = next; |
163 } | 166 } |
164 } | 167 } |
165 } | 168 } |
166 | 169 |
167 } } // namespace v8::internal | 170 } } // namespace v8::internal |
OLD | NEW |