 Chromium Code Reviews
 Chromium Code Reviews Issue 7827009:
  Tiny change flags cleanups.  (Closed) 
  Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
    
  
    Issue 7827009:
  Tiny change flags cleanups.  (Closed) 
  Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/| OLD | NEW | 
|---|---|
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 495 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 506 kDeoptimizeOnUndefined, | 506 kDeoptimizeOnUndefined, | 
| 507 kIsArguments, | 507 kIsArguments, | 
| 508 kTruncatingToInt32, | 508 kTruncatingToInt32, | 
| 509 kLastFlag = kTruncatingToInt32 | 509 kLastFlag = kTruncatingToInt32 | 
| 510 }; | 510 }; | 
| 511 | 511 | 
| 512 STATIC_ASSERT(kLastFlag < kBitsPerInt); | 512 STATIC_ASSERT(kLastFlag < kBitsPerInt); | 
| 513 | 513 | 
| 514 static const int kChangesToDependsFlagsLeftShift = 1; | 514 static const int kChangesToDependsFlagsLeftShift = 1; | 
| 515 | 515 | 
| 516 static int ChangesFlagsMask() { | |
| 517 int result = 0; | |
| 518 // Create changes mask. | |
| 519 #define DECLARE_DO(type) result |= (1 << kChanges##type); | |
| 520 GVN_FLAG_LIST(DECLARE_DO) | |
| 521 #undef DECLARE_DO | |
| 522 return result; | |
| 523 } | |
| 524 | |
| 525 static int DependsFlagsMask() { | |
| 526 return ConvertChangesToDependsFlags(ChangesFlagsMask()); | |
| 527 } | |
| 528 | |
| 529 static int ConvertChangesToDependsFlags(int flags) { | 516 static int ConvertChangesToDependsFlags(int flags) { | 
| 530 return flags << kChangesToDependsFlagsLeftShift; | 517 return flags << kChangesToDependsFlagsLeftShift; | 
| 531 } | 518 } | 
| 532 | 519 | 
| 533 static HValue* cast(HValue* value) { return value; } | 520 static HValue* cast(HValue* value) { return value; } | 
| 534 | 521 | 
| 535 enum Opcode { | 522 enum Opcode { | 
| 536 // Declare a unique enum value for each hydrogen instruction. | 523 // Declare a unique enum value for each hydrogen instruction. | 
| 537 #define DECLARE_OPCODE(type) k##type, | 524 #define DECLARE_OPCODE(type) k##type, | 
| 538 HYDROGEN_CONCRETE_INSTRUCTION_LIST(DECLARE_OPCODE) | 525 HYDROGEN_CONCRETE_INSTRUCTION_LIST(DECLARE_OPCODE) | 
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 622 | 609 | 
| 623 int flags() const { return flags_; } | 610 int flags() const { return flags_; } | 
| 624 void SetFlag(Flag f) { flags_ |= (1 << f); } | 611 void SetFlag(Flag f) { flags_ |= (1 << f); } | 
| 625 void ClearFlag(Flag f) { flags_ &= ~(1 << f); } | 612 void ClearFlag(Flag f) { flags_ &= ~(1 << f); } | 
| 626 bool CheckFlag(Flag f) const { return (flags_ & (1 << f)) != 0; } | 613 bool CheckFlag(Flag f) const { return (flags_ & (1 << f)) != 0; } | 
| 627 | 614 | 
| 628 void SetAllSideEffects() { flags_ |= AllSideEffects(); } | 615 void SetAllSideEffects() { flags_ |= AllSideEffects(); } | 
| 629 void ClearAllSideEffects() { flags_ &= ~AllSideEffects(); } | 616 void ClearAllSideEffects() { flags_ &= ~AllSideEffects(); } | 
| 630 bool HasSideEffects() const { return (flags_ & AllSideEffects()) != 0; } | 617 bool HasSideEffects() const { return (flags_ & AllSideEffects()) != 0; } | 
| 631 | 618 | 
| 619 int ChangesFlags() const { return flags_ & ChangesFlagsMask(); } | |
| 620 | |
| 632 Range* range() const { return range_; } | 621 Range* range() const { return range_; } | 
| 633 bool HasRange() const { return range_ != NULL; } | 622 bool HasRange() const { return range_ != NULL; } | 
| 634 void AddNewRange(Range* r); | 623 void AddNewRange(Range* r); | 
| 635 void RemoveLastAddedRange(); | 624 void RemoveLastAddedRange(); | 
| 636 void ComputeInitialRange(); | 625 void ComputeInitialRange(); | 
| 637 | 626 | 
| 638 // Representation helpers. | 627 // Representation helpers. | 
| 639 virtual Representation RequiredInputRepresentation(int index) const = 0; | 628 virtual Representation RequiredInputRepresentation(int index) const = 0; | 
| 640 | 629 | 
| 641 virtual Representation InferredRepresentation() { | 630 virtual Representation InferredRepresentation() { | 
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 686 block_ = NULL; | 675 block_ = NULL; | 
| 687 } | 676 } | 
| 688 | 677 | 
| 689 void set_representation(Representation r) { | 678 void set_representation(Representation r) { | 
| 690 // Representation is set-once. | 679 // Representation is set-once. | 
| 691 ASSERT(representation_.IsNone() && !r.IsNone()); | 680 ASSERT(representation_.IsNone() && !r.IsNone()); | 
| 692 representation_ = r; | 681 representation_ = r; | 
| 693 } | 682 } | 
| 694 | 683 | 
| 695 private: | 684 private: | 
| 685 static int ChangesFlagsMask() { | |
| 686 int result = 0; | |
| 687 // Create changes mask. | |
| 688 #define DECLARE_DO(type) result |= (1 << kChanges##type); | |
| 
Kevin Millikin (Chromium)
2011/09/01 10:03:27
This wasn't introduced in your change, but could y
 
Sven Panne
2011/09/01 11:05:37
Done. Your story explains the strange name, I was
 | |
| 689 GVN_FLAG_LIST(DECLARE_DO) | |
| 690 #undef DECLARE_DO | |
| 691 return result; | |
| 692 } | |
| 693 | |
| 696 // A flag mask to mark an instruction as having arbitrary side effects. | 694 // A flag mask to mark an instruction as having arbitrary side effects. | 
| 697 static int AllSideEffects() { | 695 static int AllSideEffects() { | 
| 698 return ChangesFlagsMask() & ~(1 << kChangesOsrEntries); | 696 return ChangesFlagsMask() & ~(1 << kChangesOsrEntries); | 
| 699 } | 697 } | 
| 700 | 698 | 
| 701 // Remove the matching use from the use list if present. Returns the | 699 // Remove the matching use from the use list if present. Returns the | 
| 702 // removed list node or NULL. | 700 // removed list node or NULL. | 
| 703 HUseListNode* RemoveUse(HValue* value, int index); | 701 HUseListNode* RemoveUse(HValue* value, int index); | 
| 704 | 702 | 
| 705 void RegisterUse(int index, HValue* new_value); | 703 void RegisterUse(int index, HValue* new_value); | 
| (...skipping 3485 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4191 | 4189 | 
| 4192 DECLARE_CONCRETE_INSTRUCTION(In) | 4190 DECLARE_CONCRETE_INSTRUCTION(In) | 
| 4193 }; | 4191 }; | 
| 4194 | 4192 | 
| 4195 #undef DECLARE_INSTRUCTION | 4193 #undef DECLARE_INSTRUCTION | 
| 4196 #undef DECLARE_CONCRETE_INSTRUCTION | 4194 #undef DECLARE_CONCRETE_INSTRUCTION | 
| 4197 | 4195 | 
| 4198 } } // namespace v8::internal | 4196 } } // namespace v8::internal | 
| 4199 | 4197 | 
| 4200 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ | 4198 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ | 
| OLD | NEW |