Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(233)

Side by Side Diff: src/hydrogen-instructions.h

Issue 17093005: Revert "Improved range analysis for bitwise operations." (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | src/hydrogen-instructions.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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;
47 class HBasicBlock; 46 class HBasicBlock;
48 class HEnvironment; 47 class HEnvironment;
49 class HInferRepresentation; 48 class HInferRepresentation;
50 class HInstruction; 49 class HInstruction;
51 class HLoopInformation; 50 class HLoopInformation;
52 class HValue; 51 class HValue;
53 class LInstruction; 52 class LInstruction;
54 class LChunkBuilder; 53 class LChunkBuilder;
55 54
56 55
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 return new(zone) Range(kMinInt, upper_); 252 return new(zone) Range(kMinInt, upper_);
254 } 253 }
255 Range* CopyClearUpper(Zone* zone) const { 254 Range* CopyClearUpper(Zone* zone) const {
256 return new(zone) Range(lower_, kMaxInt); 255 return new(zone) Range(lower_, kMaxInt);
257 } 256 }
258 Range* Copy(Zone* zone) const { 257 Range* Copy(Zone* zone) const {
259 Range* result = new(zone) Range(lower_, upper_); 258 Range* result = new(zone) Range(lower_, upper_);
260 result->set_can_be_minus_zero(CanBeMinusZero()); 259 result->set_can_be_minus_zero(CanBeMinusZero());
261 return result; 260 return result;
262 } 261 }
263 void ToBitRange(BitRange* bits) const; 262 int32_t Mask() const;
264 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; }
265 bool CanBeMinusZero() const { return CanBeZero() && can_be_minus_zero_; } 264 bool CanBeMinusZero() const { return CanBeZero() && can_be_minus_zero_; }
266 bool CanBeZero() const { return upper_ >= 0 && lower_ <= 0; } 265 bool CanBeZero() const { return upper_ >= 0 && lower_ <= 0; }
267 bool CanBeNegative() const { return lower_ < 0; } 266 bool CanBeNegative() const { return lower_ < 0; }
268 bool CanBePositive() const { return upper_ > 0; } 267 bool CanBePositive() const { return upper_ > 0; }
269 bool Includes(int value) const { return lower_ <= value && upper_ >= value; } 268 bool Includes(int value) const { return lower_ <= value && upper_ >= value; }
270 bool IsMostGeneric() const { 269 bool IsMostGeneric() const {
271 return lower_ == kMinInt && upper_ == kMaxInt && CanBeMinusZero(); 270 return lower_ == kMinInt && upper_ == kMaxInt && CanBeMinusZero();
272 } 271 }
273 bool IsInSmiRange() const { 272 bool IsInSmiRange() const {
(...skipping 26 matching lines...) Expand all
300 bool MulAndCheckOverflow(Range* other); 299 bool MulAndCheckOverflow(Range* other);
301 300
302 private: 301 private:
303 int32_t lower_; 302 int32_t lower_;
304 int32_t upper_; 303 int32_t upper_;
305 Range* next_; 304 Range* next_;
306 bool can_be_minus_zero_; 305 bool can_be_minus_zero_;
307 }; 306 };
308 307
309 308
310 class BitRange {
311 public:
312 BitRange() : known_(0), bits_(0) { }
313 BitRange(int32_t known, int32_t bits)
314 : known_(known), bits_(bits & known) { }
315
316 static void SetFromRange(BitRange* bits, int32_t lower, int32_t upper) {
317 // Find a mask for the most significant bits that are the same for all
318 // values in the range.
319 int32_t same = ~(lower ^ upper);
320 // Flood zeros to any bits lower than the most significant zero.
321 same &= (same >> 1);
322 same &= (same >> 2);
323 same &= (same >> 4);
324 same &= (same >> 8);
325 same &= (same >> 16);
326
327 bits->known_ = same;
328 bits->bits_ = lower & same;
329 }
330
331 void ExtendRange(int32_t* lower, int32_t* upper) const {
332 int32_t limit1 = (~known_ & 0x80000000) | bits_;
333 int32_t limit2 = (~known_ & 0x7fffffff) | bits_;
334 *lower = Min(*lower, Min(limit1, limit2));
335 *upper = Max(*upper, Max(limit1, limit2));
336 }
337
338 static BitRange And(BitRange a, BitRange b) {
339 int32_t known = a.known_ & b.known_;
340 // Zeros in either operand become known.
341 known |= (a.known_ & ~a.bits_);
342 known |= (b.known_ & ~b.bits_);
343 return BitRange(known, a.bits_ & b.bits_);
344 }
345
346 static BitRange Or(BitRange a, BitRange b) {
347 int32_t known = a.known_ & b.known_;
348 // Ones in either operand become known.
349 known |= (a.known_ & a.bits_);
350 known |= (b.known_ & b.bits_);
351 return BitRange(known, a.bits_ | b.bits_);
352 }
353
354 static BitRange Xor(BitRange a, BitRange b) {
355 return BitRange(a.known_ & b.known_, a.bits_ ^ b.bits_);
356 }
357
358 private:
359 int32_t known_; // A mask of known bits.
360 int32_t bits_; // Values of known bits, zero elsewhere.
361 };
362
363
364 class UniqueValueId { 309 class UniqueValueId {
365 public: 310 public:
366 UniqueValueId() : raw_address_(NULL) { } 311 UniqueValueId() : raw_address_(NULL) { }
367 312
368 explicit UniqueValueId(Object* object) { 313 explicit UniqueValueId(Object* object) {
369 raw_address_ = reinterpret_cast<Address>(object); 314 raw_address_ = reinterpret_cast<Address>(object);
370 ASSERT(IsInitialized()); 315 ASSERT(IsInitialized());
371 } 316 }
372 317
373 explicit UniqueValueId(Handle<Object> handle) { 318 explicit UniqueValueId(Handle<Object> handle) {
(...skipping 6289 matching lines...) Expand 10 before | Expand all | Expand 10 after
6663 virtual bool IsDeletable() const { return true; } 6608 virtual bool IsDeletable() const { return true; }
6664 }; 6609 };
6665 6610
6666 6611
6667 #undef DECLARE_INSTRUCTION 6612 #undef DECLARE_INSTRUCTION
6668 #undef DECLARE_CONCRETE_INSTRUCTION 6613 #undef DECLARE_CONCRETE_INSTRUCTION
6669 6614
6670 } } // namespace v8::internal 6615 } } // namespace v8::internal
6671 6616
6672 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ 6617 #endif // V8_HYDROGEN_INSTRUCTIONS_H_
OLDNEW
« no previous file with comments | « no previous file | src/hydrogen-instructions.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698