| 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 25 matching lines...) Expand all Loading... |
| 36 #include "small-pointer-list.h" | 36 #include "small-pointer-list.h" |
| 37 #include "string-stream.h" | 37 #include "string-stream.h" |
| 38 #include "v8conversions.h" | 38 #include "v8conversions.h" |
| 39 #include "v8utils.h" | 39 #include "v8utils.h" |
| 40 #include "zone.h" | 40 #include "zone.h" |
| 41 | 41 |
| 42 namespace v8 { | 42 namespace v8 { |
| 43 namespace internal { | 43 namespace internal { |
| 44 | 44 |
| 45 // Forward declarations. | 45 // Forward declarations. |
| 46 class BitRange; |
| 46 class HBasicBlock; | 47 class HBasicBlock; |
| 47 class HEnvironment; | 48 class HEnvironment; |
| 48 class HInferRepresentation; | 49 class HInferRepresentation; |
| 49 class HInstruction; | 50 class HInstruction; |
| 50 class HLoopInformation; | 51 class HLoopInformation; |
| 51 class HValue; | 52 class HValue; |
| 52 class LInstruction; | 53 class LInstruction; |
| 53 class LChunkBuilder; | 54 class LChunkBuilder; |
| 54 | 55 |
| 55 | 56 |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 251 return new(zone) Range(kMinInt, upper_); | 252 return new(zone) Range(kMinInt, upper_); |
| 252 } | 253 } |
| 253 Range* CopyClearUpper(Zone* zone) const { | 254 Range* CopyClearUpper(Zone* zone) const { |
| 254 return new(zone) Range(lower_, kMaxInt); | 255 return new(zone) Range(lower_, kMaxInt); |
| 255 } | 256 } |
| 256 Range* Copy(Zone* zone) const { | 257 Range* Copy(Zone* zone) const { |
| 257 Range* result = new(zone) Range(lower_, upper_); | 258 Range* result = new(zone) Range(lower_, upper_); |
| 258 result->set_can_be_minus_zero(CanBeMinusZero()); | 259 result->set_can_be_minus_zero(CanBeMinusZero()); |
| 259 return result; | 260 return result; |
| 260 } | 261 } |
| 261 int32_t Mask() const; | 262 void ToBitRange(BitRange* bits) const; |
| 262 void set_can_be_minus_zero(bool b) { can_be_minus_zero_ = b; } | 263 void set_can_be_minus_zero(bool b) { can_be_minus_zero_ = b; } |
| 263 bool CanBeMinusZero() const { return CanBeZero() && can_be_minus_zero_; } | 264 bool CanBeMinusZero() const { return CanBeZero() && can_be_minus_zero_; } |
| 264 bool CanBeZero() const { return upper_ >= 0 && lower_ <= 0; } | 265 bool CanBeZero() const { return upper_ >= 0 && lower_ <= 0; } |
| 265 bool CanBeNegative() const { return lower_ < 0; } | 266 bool CanBeNegative() const { return lower_ < 0; } |
| 266 bool CanBePositive() const { return upper_ > 0; } | 267 bool CanBePositive() const { return upper_ > 0; } |
| 267 bool Includes(int value) const { return lower_ <= value && upper_ >= value; } | 268 bool Includes(int value) const { return lower_ <= value && upper_ >= value; } |
| 268 bool IsMostGeneric() const { | 269 bool IsMostGeneric() const { |
| 269 return lower_ == kMinInt && upper_ == kMaxInt && CanBeMinusZero(); | 270 return lower_ == kMinInt && upper_ == kMaxInt && CanBeMinusZero(); |
| 270 } | 271 } |
| 271 bool IsInSmiRange() const { | 272 bool IsInSmiRange() const { |
| (...skipping 26 matching lines...) Expand all Loading... |
| 298 bool MulAndCheckOverflow(Range* other); | 299 bool MulAndCheckOverflow(Range* other); |
| 299 | 300 |
| 300 private: | 301 private: |
| 301 int32_t lower_; | 302 int32_t lower_; |
| 302 int32_t upper_; | 303 int32_t upper_; |
| 303 Range* next_; | 304 Range* next_; |
| 304 bool can_be_minus_zero_; | 305 bool can_be_minus_zero_; |
| 305 }; | 306 }; |
| 306 | 307 |
| 307 | 308 |
| 309 class BitRange { |
| 310 public: |
| 311 BitRange() : known_(0), bits_(0) { } |
| 312 BitRange(int32_t known, int32_t bits) |
| 313 : known_(known), bits_(bits & known) { } |
| 314 |
| 315 static void SetFromRange(BitRange* bits, int32_t lower, int32_t upper) { |
| 316 // Find a mask for the most significant bits that are the same for all |
| 317 // values in the range. |
| 318 int32_t same = ~(lower ^ upper); |
| 319 // Flood zeros to any bits lower than the most significant zero. |
| 320 same &= (same >> 1); |
| 321 same &= (same >> 2); |
| 322 same &= (same >> 4); |
| 323 same &= (same >> 8); |
| 324 same &= (same >> 16); |
| 325 |
| 326 bits->known_ = same; |
| 327 bits->bits_ = lower & same; |
| 328 } |
| 329 |
| 330 void ExtendRange(int32_t* lower, int32_t* upper) const { |
| 331 int32_t limit1 = (~known_ & 0x80000000) | bits_; |
| 332 int32_t limit2 = (~known_ & 0x7fffffff) | bits_; |
| 333 *lower = Min(*lower, Min(limit1, limit2)); |
| 334 *upper = Max(*upper, Max(limit1, limit2)); |
| 335 } |
| 336 |
| 337 static BitRange And(BitRange a, BitRange b) { |
| 338 int32_t known = a.known_ & b.known_; |
| 339 // Zeros in either operand become known. |
| 340 known |= (a.known_ & ~a.bits_); |
| 341 known |= (b.known_ & ~b.bits_); |
| 342 return BitRange(known, a.bits_ & b.bits_); |
| 343 } |
| 344 |
| 345 static BitRange Or(BitRange a, BitRange b) { |
| 346 int32_t known = a.known_ & b.known_; |
| 347 // Ones in either operand become known. |
| 348 known |= (a.known_ & a.bits_); |
| 349 known |= (b.known_ & b.bits_); |
| 350 return BitRange(known, a.bits_ | b.bits_); |
| 351 } |
| 352 |
| 353 static BitRange Xor(BitRange a, BitRange b) { |
| 354 return BitRange(a.known_ & b.known_, a.bits_ ^ b.bits_); |
| 355 } |
| 356 |
| 357 private: |
| 358 int32_t known_; // A mask of known bits. |
| 359 int32_t bits_; // Values of known bits, zero elsewhere. |
| 360 }; |
| 361 |
| 362 |
| 308 class UniqueValueId { | 363 class UniqueValueId { |
| 309 public: | 364 public: |
| 310 UniqueValueId() : raw_address_(NULL) { } | 365 UniqueValueId() : raw_address_(NULL) { } |
| 311 | 366 |
| 312 explicit UniqueValueId(Object* object) { | 367 explicit UniqueValueId(Object* object) { |
| 313 raw_address_ = reinterpret_cast<Address>(object); | 368 raw_address_ = reinterpret_cast<Address>(object); |
| 314 ASSERT(IsInitialized()); | 369 ASSERT(IsInitialized()); |
| 315 } | 370 } |
| 316 | 371 |
| 317 explicit UniqueValueId(Handle<Object> handle) { | 372 explicit UniqueValueId(Handle<Object> handle) { |
| (...skipping 6265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6583 virtual bool IsDeletable() const { return true; } | 6638 virtual bool IsDeletable() const { return true; } |
| 6584 }; | 6639 }; |
| 6585 | 6640 |
| 6586 | 6641 |
| 6587 #undef DECLARE_INSTRUCTION | 6642 #undef DECLARE_INSTRUCTION |
| 6588 #undef DECLARE_CONCRETE_INSTRUCTION | 6643 #undef DECLARE_CONCRETE_INSTRUCTION |
| 6589 | 6644 |
| 6590 } } // namespace v8::internal | 6645 } } // namespace v8::internal |
| 6591 | 6646 |
| 6592 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ | 6647 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ |
| OLD | NEW |