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 30 matching lines...) Expand all Loading... | |
41 | 41 |
42 namespace v8 { namespace internal { | 42 namespace v8 { namespace internal { |
43 | 43 |
44 | 44 |
45 // ----------------------------------------------------------------------------- | 45 // ----------------------------------------------------------------------------- |
46 // Labels represent pc locations; they are typically jump or call targets. | 46 // Labels represent pc locations; they are typically jump or call targets. |
47 // After declaration, a label can be freely used to denote known or (yet) | 47 // After declaration, a label can be freely used to denote known or (yet) |
48 // unknown pc location. Assembler::bind() is used to bind a label to the | 48 // unknown pc location. Assembler::bind() is used to bind a label to the |
49 // current pc. A label can be bound only once. | 49 // current pc. A label can be bound only once. |
50 | 50 |
51 class Label : public ZoneObject { // ShadowLables are dynamically allocated. | 51 class Label : public ZoneObject { // ShadowedLabels are dynamically allocated. |
iposva
2008/10/22 18:34:33
ShadowedLabels reads like a C++ class to me. You p
| |
52 public: | 52 public: |
53 INLINE(Label()) { Unuse(); } | 53 INLINE(Label()) { Unuse(); } |
54 INLINE(~Label()) { ASSERT(!is_linked()); } | 54 INLINE(~Label()) { ASSERT(!is_linked()); } |
55 | 55 |
56 INLINE(void Unuse()) { pos_ = 0; } | 56 INLINE(void Unuse()) { pos_ = 0; } |
57 | 57 |
58 INLINE(bool is_bound() const) { return pos_ < 0; } | 58 INLINE(bool is_bound() const) { return pos_ < 0; } |
59 INLINE(bool is_unused() const) { return pos_ == 0; } | 59 INLINE(bool is_unused() const) { return pos_ == 0; } |
60 INLINE(bool is_linked() const) { return pos_ > 0; } | 60 INLINE(bool is_linked() const) { return pos_ > 0; } |
61 | 61 |
(...skipping 18 matching lines...) Expand all Loading... | |
80 pos_ = pos + 1; | 80 pos_ = pos + 1; |
81 ASSERT(is_linked()); | 81 ASSERT(is_linked()); |
82 } | 82 } |
83 | 83 |
84 friend class Assembler; | 84 friend class Assembler; |
85 friend class Displacement; | 85 friend class Displacement; |
86 friend class LabelShadow; | 86 friend class LabelShadow; |
87 }; | 87 }; |
88 | 88 |
89 | 89 |
90 // A LabelShadow is a label that temporarily shadows another label. It | 90 // A LabelShadow represents a label that is temporarily shadowed by another |
91 // is used to catch linking and binding of labels in certain scopes, | 91 // label (represented by the original label during shadowing). They are used |
92 // e.g. try blocks. LabelShadows are themselves labels which can be | 92 // to catch jumps to labels in certain contexts, e.g. try blocks. After |
93 // used (only) after they are not shadowing anymore. | 93 // shadowing ends, the formerly shadowed label is again represented by the |
94 // original label and the LabelShadow can be used as a label in its own | |
95 // right, representing the formerly shadowing label. | |
94 class LabelShadow: public Label { | 96 class LabelShadow: public Label { |
95 public: | 97 public: |
96 explicit LabelShadow(Label* shadowed) { | 98 explicit LabelShadow(Label* original) { |
97 ASSERT(shadowed != NULL); | 99 ASSERT(original != NULL); |
98 shadowed_ = shadowed; | 100 original_label_ = original; |
99 shadowed_pos_ = shadowed->pos_; | 101 original_pos_ = original->pos_; |
100 shadowed->Unuse(); | 102 original->Unuse(); |
101 #ifdef DEBUG | 103 #ifdef DEBUG |
102 is_shadowing_ = true; | 104 is_shadowing_ = true; |
103 #endif | 105 #endif |
104 } | 106 } |
105 | 107 |
106 ~LabelShadow() { | 108 ~LabelShadow() { |
107 ASSERT(!is_shadowing_); | 109 ASSERT(!is_shadowing_); |
108 } | 110 } |
109 | 111 |
110 void StopShadowing() { | 112 void StopShadowing() { |
111 ASSERT(is_shadowing_ && is_unused()); | 113 ASSERT(is_shadowing_ && is_unused()); |
112 pos_ = shadowed_->pos_; | 114 pos_ = original_label_->pos_; |
113 shadowed_->pos_ = shadowed_pos_; | 115 original_label_->pos_ = original_pos_; |
114 #ifdef DEBUG | 116 #ifdef DEBUG |
115 is_shadowing_ = false; | 117 is_shadowing_ = false; |
116 #endif | 118 #endif |
117 } | 119 } |
118 | 120 |
119 Label* shadowed() const { return shadowed_; } | 121 Label* original_label() const { return original_label_; } |
120 | 122 |
121 private: | 123 private: |
122 Label* shadowed_; | 124 // During shadowing, the currently shadowing label. After shadowing, the |
123 int shadowed_pos_; | 125 // label that was shadowed. |
126 Label* original_label_; | |
127 | |
128 // During shadowing, the saved state of the original label. | |
129 int original_pos_; | |
130 | |
124 #ifdef DEBUG | 131 #ifdef DEBUG |
125 bool is_shadowing_; | 132 bool is_shadowing_; |
126 #endif | 133 #endif |
127 }; | 134 }; |
128 | 135 |
129 | 136 |
130 // ----------------------------------------------------------------------------- | 137 // ----------------------------------------------------------------------------- |
131 // Relocation information | 138 // Relocation information |
132 | 139 |
133 | 140 |
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
460 static inline bool is_uint4(int x) { return is_uintn(x, 4); } | 467 static inline bool is_uint4(int x) { return is_uintn(x, 4); } |
461 static inline bool is_uint5(int x) { return is_uintn(x, 5); } | 468 static inline bool is_uint5(int x) { return is_uintn(x, 5); } |
462 static inline bool is_uint8(int x) { return is_uintn(x, 8); } | 469 static inline bool is_uint8(int x) { return is_uintn(x, 8); } |
463 static inline bool is_uint12(int x) { return is_uintn(x, 12); } | 470 static inline bool is_uint12(int x) { return is_uintn(x, 12); } |
464 static inline bool is_uint16(int x) { return is_uintn(x, 16); } | 471 static inline bool is_uint16(int x) { return is_uintn(x, 16); } |
465 static inline bool is_uint24(int x) { return is_uintn(x, 24); } | 472 static inline bool is_uint24(int x) { return is_uintn(x, 24); } |
466 | 473 |
467 } } // namespace v8::internal | 474 } } // namespace v8::internal |
468 | 475 |
469 #endif // V8_ASSEMBLER_H_ | 476 #endif // V8_ASSEMBLER_H_ |
OLD | NEW |