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 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.
| |
82 | |
83 INLINE(Label()) { | |
84 Unuse(); | |
85 UnuseNear(); | |
86 } | |
82 INLINE(~Label()) { ASSERT(!is_linked()); } | 87 INLINE(~Label()) { ASSERT(!is_linked()); } |
83 | 88 |
84 INLINE(void Unuse()) { pos_ = 0; } | 89 INLINE(void Unuse()) { pos_ = 0; } |
90 INLINE(void UnuseNear()) { near_link_pos_ = 0; } | |
85 | 91 |
86 INLINE(bool is_bound() const) { return pos_ < 0; } | 92 INLINE(bool is_bound() const) { return pos_ < 0; } |
87 INLINE(bool is_unused() const) { return pos_ == 0; } | 93 INLINE(bool is_unused() const) { return pos_ == 0 && near_link_pos_ == 0; } |
88 INLINE(bool is_linked() const) { return pos_ > 0; } | 94 INLINE(bool is_linked() const) { return pos_ > 0; } |
95 INLINE(bool is_near_linked() const) { return near_link_pos_ > 0; } | |
89 | 96 |
90 // Returns the position of bound or linked labels. Cannot be used | 97 // Returns the position of bound or linked labels. Cannot be used |
91 // for unused labels. | 98 // for unused labels. |
92 int pos() const; | 99 int pos() const; |
100 int near_link_pos() const { return near_link_pos_ - 1; } | |
93 | 101 |
94 private: | 102 private: |
95 // pos_ encodes both the binding state (via its sign) | 103 // pos_ encodes both the binding state (via its sign) |
96 // and the binding position (via its value) of a label. | 104 // and the binding position (via its value) of a label. |
97 // | 105 // |
98 // pos_ < 0 bound label, pos() returns the jump target position | 106 // pos_ < 0 bound label, pos() returns the jump target position |
99 // pos_ == 0 unused label | 107 // pos_ == 0 unused label |
100 // pos_ > 0 linked label, pos() returns the last reference position | 108 // pos_ > 0 linked label, pos() returns the last reference position |
101 int pos_; | 109 int pos_; |
102 | 110 |
111 // Behaves like |pos_| in the "> 0" case, but for near jumps to this label. | |
112 int near_link_pos_; | |
113 | |
103 void bind_to(int pos) { | 114 void bind_to(int pos) { |
104 pos_ = -pos - 1; | 115 pos_ = -pos - 1; |
105 ASSERT(is_bound()); | 116 ASSERT(is_bound()); |
106 } | 117 } |
107 void link_to(int pos) { | 118 void link_to(int pos, bool near = kFar) { |
108 pos_ = pos + 1; | 119 if (near == kNear) { |
109 ASSERT(is_linked()); | 120 near_link_pos_ = pos + 1; |
121 ASSERT(is_near_linked()); | |
122 } else { | |
123 pos_ = pos + 1; | |
124 ASSERT(is_linked()); | |
125 } | |
110 } | 126 } |
111 | 127 |
112 friend class Assembler; | 128 friend class Assembler; |
113 friend class RegexpAssembler; | 129 friend class RegexpAssembler; |
114 friend class Displacement; | 130 friend class Displacement; |
115 friend class RegExpMacroAssemblerIrregexp; | 131 friend class RegExpMacroAssemblerIrregexp; |
116 }; | 132 }; |
117 | 133 |
118 | 134 |
119 // ----------------------------------------------------------------------------- | 135 // ----------------------------------------------------------------------------- |
(...skipping 743 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
863 public: | 879 public: |
864 NullCallWrapper() { } | 880 NullCallWrapper() { } |
865 virtual ~NullCallWrapper() { } | 881 virtual ~NullCallWrapper() { } |
866 virtual void BeforeCall(int call_size) const { } | 882 virtual void BeforeCall(int call_size) const { } |
867 virtual void AfterCall() const { } | 883 virtual void AfterCall() const { } |
868 }; | 884 }; |
869 | 885 |
870 } } // namespace v8::internal | 886 } } // namespace v8::internal |
871 | 887 |
872 #endif // V8_ASSEMBLER_H_ | 888 #endif // V8_ASSEMBLER_H_ |
OLD | NEW |