Chromium Code Reviews| Index: src/assembler.h |
| diff --git a/src/assembler.h b/src/assembler.h |
| index 10d90a922b19a94a22682bdbb4c919677513a7bf..d7743cb9b912a38d3b4e5f31544a37e6f66014ae 100644 |
| --- a/src/assembler.h |
| +++ b/src/assembler.h |
| @@ -78,18 +78,26 @@ class DoubleConstant: public AllStatic { |
| class Label BASE_EMBEDDED { |
| public: |
| - INLINE(Label()) { Unuse(); } |
| + static const bool kNear = true, kFar = false; |
|
Mads Ager (chromium)
2011/05/09 11:21:55
Make this an enum instead.
Jakob Kummerow
2011/05/09 16:25:24
Done.
|
| + |
| + INLINE(Label()) { |
| + Unuse(); |
| + UnuseNear(); |
| + } |
| INLINE(~Label()) { ASSERT(!is_linked()); } |
| INLINE(void Unuse()) { pos_ = 0; } |
| + INLINE(void UnuseNear()) { near_link_pos_ = 0; } |
| INLINE(bool is_bound() const) { return pos_ < 0; } |
| - INLINE(bool is_unused() const) { return pos_ == 0; } |
| + INLINE(bool is_unused() const) { return pos_ == 0 && near_link_pos_ == 0; } |
| INLINE(bool is_linked() const) { return pos_ > 0; } |
| + INLINE(bool is_near_linked() const) { return near_link_pos_ > 0; } |
| // Returns the position of bound or linked labels. Cannot be used |
| // for unused labels. |
| int pos() const; |
| + int near_link_pos() const { return near_link_pos_ - 1; } |
| private: |
| // pos_ encodes both the binding state (via its sign) |
| @@ -100,13 +108,21 @@ class Label BASE_EMBEDDED { |
| // pos_ > 0 linked label, pos() returns the last reference position |
| int pos_; |
| + // Behaves like |pos_| in the "> 0" case, but for near jumps to this label. |
| + int near_link_pos_; |
| + |
| void bind_to(int pos) { |
| pos_ = -pos - 1; |
| ASSERT(is_bound()); |
| } |
| - void link_to(int pos) { |
| - pos_ = pos + 1; |
| - ASSERT(is_linked()); |
| + void link_to(int pos, bool near = kFar) { |
| + if (near == kNear) { |
| + near_link_pos_ = pos + 1; |
| + ASSERT(is_near_linked()); |
| + } else { |
| + pos_ = pos + 1; |
| + ASSERT(is_linked()); |
| + } |
| } |
| friend class Assembler; |