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 2292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2303 | 2303 |
2304 void HMathMinMax::InferRepresentation(HInferRepresentation* h_infer) { | 2304 void HMathMinMax::InferRepresentation(HInferRepresentation* h_infer) { |
2305 ASSERT(CheckFlag(kFlexibleRepresentation)); | 2305 ASSERT(CheckFlag(kFlexibleRepresentation)); |
2306 Representation new_rep = RepresentationFromInputs(); | 2306 Representation new_rep = RepresentationFromInputs(); |
2307 UpdateRepresentation(new_rep, h_infer, "inputs"); | 2307 UpdateRepresentation(new_rep, h_infer, "inputs"); |
2308 // Do not care about uses. | 2308 // Do not care about uses. |
2309 } | 2309 } |
2310 | 2310 |
2311 | 2311 |
2312 Range* HBitwise::InferRange(Zone* zone) { | 2312 Range* HBitwise::InferRange(Zone* zone) { |
2313 if (op() == Token::BIT_XOR) return HValue::InferRange(zone); | 2313 if (op() == Token::BIT_XOR) { |
2314 if (left()->range() != NULL && right()->range() != NULL) { | |
Sven Panne
2013/06/04 12:15:27
We traditionally use HasRange() for stuff like thi
| |
2315 // The maximum value has the high bit, and all bits below, set: | |
2316 // (1 << high) - 1. | |
2317 // If the range can be negative, the minimum int is a negative number with | |
2318 // the high bit, and all bits below, unset: | |
2319 // -(1 << high). | |
2320 // If it cannot be negative, conservatively choose 0 as minimum int. | |
2321 int64_t left_upper = left()->range()->upper(); | |
2322 int64_t left_lower = left()->range()->lower(); | |
2323 int64_t right_upper = right()->range()->upper(); | |
2324 int64_t right_lower = right()->range()->lower(); | |
2325 | |
2326 // With the same number of bits, 1 lower value can be represented on the | |
2327 // negative side. Lower the number of required negative bits of log2 | |
2328 // values by removing this value. | |
2329 if (left_upper < 0) left_upper = llabs(left_upper + 1); | |
2330 if (left_lower < 0) left_lower = llabs(left_lower + 1); | |
2331 if (right_upper < 0) right_upper = llabs(right_upper + 1); | |
2332 if (right_lower < 0) right_lower = llabs(right_lower + 1); | |
2333 | |
2334 // Find the highest used bit. | |
2335 int high = static_cast<int>(log2(left_upper)); | |
2336 high = Max(high, static_cast<int>(log2(left_lower))); | |
2337 high = Max(high, static_cast<int>(log2(right_upper))); | |
2338 high = Max(high, static_cast<int>(log2(right_lower))); | |
2339 | |
2340 int64_t limit = 1; | |
2341 limit <<= high + 1; | |
2342 int32_t min = (left()->range()->CanBeNegative() || | |
2343 right()->range()->CanBeNegative()) | |
2344 ? static_cast<int32_t>(-limit) : 0; | |
2345 return new(zone) Range(min, static_cast<int32_t>(limit - 1)); | |
2346 } | |
2347 return HValue::InferRange(zone); | |
2348 } | |
2314 const int32_t kDefaultMask = static_cast<int32_t>(0xffffffff); | 2349 const int32_t kDefaultMask = static_cast<int32_t>(0xffffffff); |
2315 int32_t left_mask = (left()->range() != NULL) | 2350 int32_t left_mask = (left()->range() != NULL) |
2316 ? left()->range()->Mask() | 2351 ? left()->range()->Mask() |
2317 : kDefaultMask; | 2352 : kDefaultMask; |
2318 int32_t right_mask = (right()->range() != NULL) | 2353 int32_t right_mask = (right()->range() != NULL) |
2319 ? right()->range()->Mask() | 2354 ? right()->range()->Mask() |
2320 : kDefaultMask; | 2355 : kDefaultMask; |
2321 int32_t result_mask = (op() == Token::BIT_AND) | 2356 int32_t result_mask = (op() == Token::BIT_AND) |
2322 ? left_mask & right_mask | 2357 ? left_mask & right_mask |
2323 : left_mask | right_mask; | 2358 : left_mask | right_mask; |
(...skipping 1436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3760 case kBackingStore: | 3795 case kBackingStore: |
3761 if (!name_.is_null()) stream->Add(*String::cast(*name_)->ToCString()); | 3796 if (!name_.is_null()) stream->Add(*String::cast(*name_)->ToCString()); |
3762 stream->Add("[backing-store]"); | 3797 stream->Add("[backing-store]"); |
3763 break; | 3798 break; |
3764 } | 3799 } |
3765 | 3800 |
3766 stream->Add("@%d", offset()); | 3801 stream->Add("@%d", offset()); |
3767 } | 3802 } |
3768 | 3803 |
3769 } } // namespace v8::internal | 3804 } } // namespace v8::internal |
OLD | NEW |