| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 1188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1199 } | 1199 } |
| 1200 | 1200 |
| 1201 | 1201 |
| 1202 static bool IsIdentityOperation(HValue* arg1, HValue* arg2, int32_t identity) { | 1202 static bool IsIdentityOperation(HValue* arg1, HValue* arg2, int32_t identity) { |
| 1203 return arg1->representation().IsSpecialization() && | 1203 return arg1->representation().IsSpecialization() && |
| 1204 arg2->EqualsInteger32Constant(identity); | 1204 arg2->EqualsInteger32Constant(identity); |
| 1205 } | 1205 } |
| 1206 | 1206 |
| 1207 | 1207 |
| 1208 HValue* HAdd::Canonicalize() { | 1208 HValue* HAdd::Canonicalize() { |
| 1209 if (IsIdentityOperation(left(), right(), 0)) return left(); | 1209 // Adding 0 is an identity operation except in case of -0: -0 + 0 = +0 |
| 1210 if (IsIdentityOperation(right(), left(), 0)) return right(); | 1210 if (IsIdentityOperation(left(), right(), 0) && |
| 1211 !left()->representation().IsDouble()) { // Left could be -0. |
| 1212 return left(); |
| 1213 } |
| 1214 if (IsIdentityOperation(right(), left(), 0) && |
| 1215 !left()->representation().IsDouble()) { // Right could be -0. |
| 1216 return right(); |
| 1217 } |
| 1211 return this; | 1218 return this; |
| 1212 } | 1219 } |
| 1213 | 1220 |
| 1214 | 1221 |
| 1215 HValue* HSub::Canonicalize() { | 1222 HValue* HSub::Canonicalize() { |
| 1216 if (IsIdentityOperation(left(), right(), 0)) return left(); | 1223 if (IsIdentityOperation(left(), right(), 0)) return left(); |
| 1217 return this; | 1224 return this; |
| 1218 } | 1225 } |
| 1219 | 1226 |
| 1220 | 1227 |
| (...skipping 2952 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4173 break; | 4180 break; |
| 4174 case kExternalMemory: | 4181 case kExternalMemory: |
| 4175 stream->Add("[external-memory]"); | 4182 stream->Add("[external-memory]"); |
| 4176 break; | 4183 break; |
| 4177 } | 4184 } |
| 4178 | 4185 |
| 4179 stream->Add("@%d", offset()); | 4186 stream->Add("@%d", offset()); |
| 4180 } | 4187 } |
| 4181 | 4188 |
| 4182 } } // namespace v8::internal | 4189 } } // namespace v8::internal |
| OLD | NEW |