| 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 1244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1255 } | 1255 } |
| 1256 // Optimize double negation, a common pattern used for ToInt32(x). | 1256 // Optimize double negation, a common pattern used for ToInt32(x). |
| 1257 HValue* arg; | 1257 HValue* arg; |
| 1258 if (MatchDoubleNegation(this, &arg) && !arg->CheckFlag(kUint32)) { | 1258 if (MatchDoubleNegation(this, &arg) && !arg->CheckFlag(kUint32)) { |
| 1259 return arg; | 1259 return arg; |
| 1260 } | 1260 } |
| 1261 return this; | 1261 return this; |
| 1262 } | 1262 } |
| 1263 | 1263 |
| 1264 | 1264 |
| 1265 Representation HAdd::RepresentationFromInputs() { |
| 1266 Representation left_rep = left()->representation(); |
| 1267 if (left_rep.IsExternal()) { |
| 1268 return Representation::External(); |
| 1269 } |
| 1270 return HArithmeticBinaryOperation::RepresentationFromInputs(); |
| 1271 } |
| 1272 |
| 1273 |
| 1274 Representation HAdd::RequiredInputRepresentation(int index) { |
| 1275 if (index == 2) { |
| 1276 Representation left_rep = left()->representation(); |
| 1277 if (left_rep.IsExternal()) { |
| 1278 return Representation::Integer32(); |
| 1279 } |
| 1280 } |
| 1281 return HArithmeticBinaryOperation::RequiredInputRepresentation(index); |
| 1282 } |
| 1283 |
| 1284 |
| 1265 static bool IsIdentityOperation(HValue* arg1, HValue* arg2, int32_t identity) { | 1285 static bool IsIdentityOperation(HValue* arg1, HValue* arg2, int32_t identity) { |
| 1266 return arg1->representation().IsSpecialization() && | 1286 return arg1->representation().IsSpecialization() && |
| 1267 arg2->EqualsInteger32Constant(identity); | 1287 arg2->EqualsInteger32Constant(identity); |
| 1268 } | 1288 } |
| 1269 | 1289 |
| 1270 | 1290 |
| 1271 HValue* HAdd::Canonicalize() { | 1291 HValue* HAdd::Canonicalize() { |
| 1272 // Adding 0 is an identity operation except in case of -0: -0 + 0 = +0 | 1292 // Adding 0 is an identity operation except in case of -0: -0 + 0 = +0 |
| 1273 if (IsIdentityOperation(left(), right(), 0) && | 1293 if (IsIdentityOperation(left(), right(), 0) && |
| 1274 !left()->representation().IsDouble()) { // Left could be -0. | 1294 !left()->representation().IsDouble()) { // Left could be -0. |
| (...skipping 3100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4375 break; | 4395 break; |
| 4376 case kExternalMemory: | 4396 case kExternalMemory: |
| 4377 stream->Add("[external-memory]"); | 4397 stream->Add("[external-memory]"); |
| 4378 break; | 4398 break; |
| 4379 } | 4399 } |
| 4380 | 4400 |
| 4381 stream->Add("@%d", offset()); | 4401 stream->Add("@%d", offset()); |
| 4382 } | 4402 } |
| 4383 | 4403 |
| 4384 } } // namespace v8::internal | 4404 } } // namespace v8::internal |
| OLD | NEW |