| 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 1200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1211 } | 1211 } |
| 1212 | 1212 |
| 1213 | 1213 |
| 1214 static bool IsIdentityOperation(HValue* arg1, HValue* arg2, int32_t identity) { | 1214 static bool IsIdentityOperation(HValue* arg1, HValue* arg2, int32_t identity) { |
| 1215 return arg1->representation().IsSpecialization() && | 1215 return arg1->representation().IsSpecialization() && |
| 1216 arg2->EqualsInteger32Constant(identity); | 1216 arg2->EqualsInteger32Constant(identity); |
| 1217 } | 1217 } |
| 1218 | 1218 |
| 1219 | 1219 |
| 1220 HValue* HAdd::Canonicalize() { | 1220 HValue* HAdd::Canonicalize() { |
| 1221 if (IsIdentityOperation(left(), right(), 0)) return left(); | 1221 // Adding 0 is an identity operation except in case of -0: -0 + 0 = +0 |
| 1222 if (IsIdentityOperation(right(), left(), 0)) return right(); | 1222 if (IsIdentityOperation(left(), right(), 0) && |
| 1223 !left()->representation().IsDouble()) { // Left could be -0. |
| 1224 return left(); |
| 1225 } |
| 1226 if (IsIdentityOperation(right(), left(), 0) && |
| 1227 !left()->representation().IsDouble()) { // Right could be -0. |
| 1228 return right(); |
| 1229 } |
| 1223 return this; | 1230 return this; |
| 1224 } | 1231 } |
| 1225 | 1232 |
| 1226 | 1233 |
| 1227 HValue* HSub::Canonicalize() { | 1234 HValue* HSub::Canonicalize() { |
| 1228 if (IsIdentityOperation(left(), right(), 0)) return left(); | 1235 if (IsIdentityOperation(left(), right(), 0)) return left(); |
| 1229 return this; | 1236 return this; |
| 1230 } | 1237 } |
| 1231 | 1238 |
| 1232 | 1239 |
| (...skipping 3005 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4238 break; | 4245 break; |
| 4239 case kExternalMemory: | 4246 case kExternalMemory: |
| 4240 stream->Add("[external-memory]"); | 4247 stream->Add("[external-memory]"); |
| 4241 break; | 4248 break; |
| 4242 } | 4249 } |
| 4243 | 4250 |
| 4244 stream->Add("@%d", offset()); | 4251 stream->Add("@%d", offset()); |
| 4245 } | 4252 } |
| 4246 | 4253 |
| 4247 } } // namespace v8::internal | 4254 } } // namespace v8::internal |
| OLD | NEW |