| OLD | NEW |
| 1 // Copyright (c) 1994-2006 Sun Microsystems Inc. | 1 // Copyright (c) 1994-2006 Sun Microsystems Inc. |
| 2 // All Rights Reserved. | 2 // All Rights Reserved. |
| 3 // | 3 // |
| 4 // Redistribution and use in source and binary forms, with or without | 4 // Redistribution and use in source and binary forms, with or without |
| 5 // modification, are permitted provided that the following conditions are | 5 // modification, are permitted provided that the following conditions are |
| 6 // met: | 6 // met: |
| 7 // | 7 // |
| 8 // - Redistributions of source code must retain the above copyright notice, | 8 // - Redistributions of source code must retain the above copyright notice, |
| 9 // this list of conditions and the following disclaimer. | 9 // this list of conditions and the following disclaimer. |
| 10 // | 10 // |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 | 71 |
| 72 | 72 |
| 73 // ----------------------------------------------------------------------------- | 73 // ----------------------------------------------------------------------------- |
| 74 // Labels represent pc locations; they are typically jump or call targets. | 74 // Labels represent pc locations; they are typically jump or call targets. |
| 75 // After declaration, a label can be freely used to denote known or (yet) | 75 // After declaration, a label can be freely used to denote known or (yet) |
| 76 // unknown pc location. Assembler::bind() is used to bind a label to the | 76 // unknown pc location. Assembler::bind() is used to bind a label to the |
| 77 // current pc. A label can be bound only once. | 77 // current pc. A label can be bound only once. |
| 78 | 78 |
| 79 class Label BASE_EMBEDDED { | 79 class Label BASE_EMBEDDED { |
| 80 public: | 80 public: |
| 81 INLINE(Label()) { Unuse(); } | 81 enum Distance { |
| 82 kNear, kFar |
| 83 }; |
| 84 |
| 85 INLINE(Label()) { |
| 86 Unuse(); |
| 87 UnuseNear(); |
| 88 } |
| 82 INLINE(~Label()) { ASSERT(!is_linked()); } | 89 INLINE(~Label()) { ASSERT(!is_linked()); } |
| 83 | 90 |
| 84 INLINE(void Unuse()) { pos_ = 0; } | 91 INLINE(void Unuse()) { pos_ = 0; } |
| 92 INLINE(void UnuseNear()) { near_link_pos_ = 0; } |
| 85 | 93 |
| 86 INLINE(bool is_bound() const) { return pos_ < 0; } | 94 INLINE(bool is_bound() const) { return pos_ < 0; } |
| 87 INLINE(bool is_unused() const) { return pos_ == 0; } | 95 INLINE(bool is_unused() const) { return pos_ == 0 && near_link_pos_ == 0; } |
| 88 INLINE(bool is_linked() const) { return pos_ > 0; } | 96 INLINE(bool is_linked() const) { return pos_ > 0; } |
| 97 INLINE(bool is_near_linked() const) { return near_link_pos_ > 0; } |
| 89 | 98 |
| 90 // Returns the position of bound or linked labels. Cannot be used | 99 // Returns the position of bound or linked labels. Cannot be used |
| 91 // for unused labels. | 100 // for unused labels. |
| 92 int pos() const; | 101 int pos() const; |
| 102 int near_link_pos() const { return near_link_pos_ - 1; } |
| 93 | 103 |
| 94 private: | 104 private: |
| 95 // pos_ encodes both the binding state (via its sign) | 105 // pos_ encodes both the binding state (via its sign) |
| 96 // and the binding position (via its value) of a label. | 106 // and the binding position (via its value) of a label. |
| 97 // | 107 // |
| 98 // pos_ < 0 bound label, pos() returns the jump target position | 108 // pos_ < 0 bound label, pos() returns the jump target position |
| 99 // pos_ == 0 unused label | 109 // pos_ == 0 unused label |
| 100 // pos_ > 0 linked label, pos() returns the last reference position | 110 // pos_ > 0 linked label, pos() returns the last reference position |
| 101 int pos_; | 111 int pos_; |
| 102 | 112 |
| 113 // Behaves like |pos_| in the "> 0" case, but for near jumps to this label. |
| 114 int near_link_pos_; |
| 115 |
| 103 void bind_to(int pos) { | 116 void bind_to(int pos) { |
| 104 pos_ = -pos - 1; | 117 pos_ = -pos - 1; |
| 105 ASSERT(is_bound()); | 118 ASSERT(is_bound()); |
| 106 } | 119 } |
| 107 void link_to(int pos) { | 120 void link_to(int pos, Distance distance = kFar) { |
| 108 pos_ = pos + 1; | 121 if (distance == kNear) { |
| 109 ASSERT(is_linked()); | 122 near_link_pos_ = pos + 1; |
| 123 ASSERT(is_near_linked()); |
| 124 } else { |
| 125 pos_ = pos + 1; |
| 126 ASSERT(is_linked()); |
| 127 } |
| 110 } | 128 } |
| 111 | 129 |
| 112 friend class Assembler; | 130 friend class Assembler; |
| 113 friend class RegexpAssembler; | 131 friend class RegexpAssembler; |
| 114 friend class Displacement; | 132 friend class Displacement; |
| 115 friend class RegExpMacroAssemblerIrregexp; | 133 friend class RegExpMacroAssemblerIrregexp; |
| 116 }; | 134 }; |
| 117 | 135 |
| 118 | 136 |
| 119 // ----------------------------------------------------------------------------- | 137 // ----------------------------------------------------------------------------- |
| (...skipping 743 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 863 public: | 881 public: |
| 864 NullCallWrapper() { } | 882 NullCallWrapper() { } |
| 865 virtual ~NullCallWrapper() { } | 883 virtual ~NullCallWrapper() { } |
| 866 virtual void BeforeCall(int call_size) const { } | 884 virtual void BeforeCall(int call_size) const { } |
| 867 virtual void AfterCall() const { } | 885 virtual void AfterCall() const { } |
| 868 }; | 886 }; |
| 869 | 887 |
| 870 } } // namespace v8::internal | 888 } } // namespace v8::internal |
| 871 | 889 |
| 872 #endif // V8_ASSEMBLER_H_ | 890 #endif // V8_ASSEMBLER_H_ |
| OLD | NEW |