| 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 931 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 942 length_rep = Representation::Smi(); | 942 length_rep = Representation::Smi(); |
| 943 } | 943 } |
| 944 Representation r = index_rep.generalize(length_rep); | 944 Representation r = index_rep.generalize(length_rep); |
| 945 if (r.is_more_general_than(Representation::Integer32())) { | 945 if (r.is_more_general_than(Representation::Integer32())) { |
| 946 r = Representation::Integer32(); | 946 r = Representation::Integer32(); |
| 947 } | 947 } |
| 948 UpdateRepresentation(r, h_infer, "boundscheck"); | 948 UpdateRepresentation(r, h_infer, "boundscheck"); |
| 949 } | 949 } |
| 950 | 950 |
| 951 | 951 |
| 952 Range* HBoundsCheck::InferRange(Zone* zone) { |
| 953 Representation r = representation(); |
| 954 if (r.IsSmiOrInteger32() && length()->HasRange()) { |
| 955 int upper = length()->range()->upper() - (allow_equality() ? 0 : 1); |
| 956 int lower = 0; |
| 957 |
| 958 Range* result = new(zone) Range(lower, upper); |
| 959 if (index()->HasRange()) { |
| 960 result->Intersect(index()->range()); |
| 961 } |
| 962 |
| 963 // In case of Smi representation, clamp result to Smi::kMaxValue. |
| 964 if (r.IsSmi()) result->ClampToSmi(); |
| 965 return result; |
| 966 } |
| 967 return HValue::InferRange(zone); |
| 968 } |
| 969 |
| 970 |
| 952 void HBoundsCheckBaseIndexInformation::PrintDataTo(StringStream* stream) { | 971 void HBoundsCheckBaseIndexInformation::PrintDataTo(StringStream* stream) { |
| 953 stream->Add("base: "); | 972 stream->Add("base: "); |
| 954 base_index()->PrintNameTo(stream); | 973 base_index()->PrintNameTo(stream); |
| 955 stream->Add(", check: "); | 974 stream->Add(", check: "); |
| 956 base_index()->PrintNameTo(stream); | 975 base_index()->PrintNameTo(stream); |
| 957 } | 976 } |
| 958 | 977 |
| 959 | 978 |
| 960 void HCallConstantFunction::PrintDataTo(StringStream* stream) { | 979 void HCallConstantFunction::PrintDataTo(StringStream* stream) { |
| 961 if (IsApplyFunction()) { | 980 if (IsApplyFunction()) { |
| (...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1257 } | 1276 } |
| 1258 // Optimize double negation, a common pattern used for ToInt32(x). | 1277 // Optimize double negation, a common pattern used for ToInt32(x). |
| 1259 HValue* arg; | 1278 HValue* arg; |
| 1260 if (MatchDoubleNegation(this, &arg) && !arg->CheckFlag(kUint32)) { | 1279 if (MatchDoubleNegation(this, &arg) && !arg->CheckFlag(kUint32)) { |
| 1261 return arg; | 1280 return arg; |
| 1262 } | 1281 } |
| 1263 return this; | 1282 return this; |
| 1264 } | 1283 } |
| 1265 | 1284 |
| 1266 | 1285 |
| 1286 Representation HAdd::RepresentationFromInputs() { |
| 1287 Representation left_rep = left()->representation(); |
| 1288 if (left_rep.IsExternal()) { |
| 1289 return Representation::External(); |
| 1290 } |
| 1291 return HArithmeticBinaryOperation::RepresentationFromInputs(); |
| 1292 } |
| 1293 |
| 1294 |
| 1295 Representation HAdd::RequiredInputRepresentation(int index) { |
| 1296 if (index == 2) { |
| 1297 Representation left_rep = left()->representation(); |
| 1298 if (left_rep.IsExternal()) { |
| 1299 return Representation::Integer32(); |
| 1300 } |
| 1301 } |
| 1302 return HArithmeticBinaryOperation::RequiredInputRepresentation(index); |
| 1303 } |
| 1304 |
| 1305 |
| 1267 static bool IsIdentityOperation(HValue* arg1, HValue* arg2, int32_t identity) { | 1306 static bool IsIdentityOperation(HValue* arg1, HValue* arg2, int32_t identity) { |
| 1268 return arg1->representation().IsSpecialization() && | 1307 return arg1->representation().IsSpecialization() && |
| 1269 arg2->EqualsInteger32Constant(identity); | 1308 arg2->EqualsInteger32Constant(identity); |
| 1270 } | 1309 } |
| 1271 | 1310 |
| 1272 | 1311 |
| 1273 HValue* HAdd::Canonicalize() { | 1312 HValue* HAdd::Canonicalize() { |
| 1274 // Adding 0 is an identity operation except in case of -0: -0 + 0 = +0 | 1313 // Adding 0 is an identity operation except in case of -0: -0 + 0 = +0 |
| 1275 if (IsIdentityOperation(left(), right(), 0) && | 1314 if (IsIdentityOperation(left(), right(), 0) && |
| 1276 !left()->representation().IsDouble()) { // Left could be -0. | 1315 !left()->representation().IsDouble()) { // Left could be -0. |
| (...skipping 3099 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4376 break; | 4415 break; |
| 4377 case kExternalMemory: | 4416 case kExternalMemory: |
| 4378 stream->Add("[external-memory]"); | 4417 stream->Add("[external-memory]"); |
| 4379 break; | 4418 break; |
| 4380 } | 4419 } |
| 4381 | 4420 |
| 4382 stream->Add("@%d", offset()); | 4421 stream->Add("@%d", offset()); |
| 4383 } | 4422 } |
| 4384 | 4423 |
| 4385 } } // namespace v8::internal | 4424 } } // namespace v8::internal |
| OLD | NEW |