138 Label() { |
138 Label() { |
139 init(); |
139 init(); |
140 } |
140 } |
141 }; |
141 }; |
142 |
142 |
|
143 // A union type for code which has to assemble both constant and |
|
144 // non-constant operands, when the distinction cannot be made |
|
145 // statically. |
|
146 class RegisterConstant VALUE_OBJ_CLASS_SPEC { |
|
147 private: |
|
148 Register _r; |
|
149 intptr_t _c; |
|
150 |
|
151 public: |
|
152 RegisterConstant(): _r(noreg), _c(0) {} |
|
153 RegisterConstant(Register r): _r(r), _c(0) {} |
|
154 RegisterConstant(intptr_t c): _r(noreg), _c(c) {} |
|
155 |
|
156 Register as_register() const { assert(is_register(),""); return _r; } |
|
157 intptr_t as_constant() const { assert(is_constant(),""); return _c; } |
|
158 |
|
159 Register register_or_noreg() const { return _r; } |
|
160 intptr_t constant_or_zero() const { return _c; } |
|
161 |
|
162 bool is_register() const { return _r != noreg; } |
|
163 bool is_constant() const { return _r == noreg; } |
|
164 }; |
143 |
165 |
144 // The Abstract Assembler: Pure assembler doing NO optimizations on the |
166 // The Abstract Assembler: Pure assembler doing NO optimizations on the |
145 // instruction level; i.e., what you write is what you get. |
167 // instruction level; i.e., what you write is what you get. |
146 // The Assembler is generating code into a CodeBuffer. |
168 // The Assembler is generating code into a CodeBuffer. |
147 class AbstractAssembler : public ResourceObj { |
169 class AbstractAssembler : public ResourceObj { |
278 return ptr; |
300 return ptr; |
279 } |
301 } |
280 inline address address_constant(Label& L); |
302 inline address address_constant(Label& L); |
281 inline address address_table_constant(GrowableArray<Label*> label); |
303 inline address address_table_constant(GrowableArray<Label*> label); |
282 |
304 |
|
305 // Bootstrapping aid to cope with delayed determination of constants. |
|
306 // Returns a static address which will eventually contain the constant. |
|
307 // The value zero (NULL) stands instead of a constant which is still uncomputed. |
|
308 // Thus, the eventual value of the constant must not be zero. |
|
309 // This is fine, since this is designed for embedding object field |
|
310 // offsets in code which must be generated before the object class is loaded. |
|
311 // Field offsets are never zero, since an object's header (mark word) |
|
312 // is located at offset zero. |
|
313 RegisterConstant delayed_value(int(*value_fn)(), Register tmp, int offset = 0) { |
|
314 return delayed_value(delayed_value_addr(value_fn), tmp, offset); |
|
315 } |
|
316 RegisterConstant delayed_value(address(*value_fn)(), Register tmp, int offset = 0) { |
|
317 return delayed_value(delayed_value_addr(value_fn), tmp, offset); |
|
318 } |
|
319 virtual RegisterConstant delayed_value(intptr_t* delayed_value_addr, Register tmp, int offset) = 0; |
|
320 // Last overloading is platform-dependent; look in assembler_<arch>.cpp. |
|
321 static intptr_t* delayed_value_addr(int(*constant_fn)()); |
|
322 static intptr_t* delayed_value_addr(address(*constant_fn)()); |
|
323 static void update_delayed_values(); |
|
324 |
283 // Bang stack to trigger StackOverflowError at a safe location |
325 // Bang stack to trigger StackOverflowError at a safe location |
284 // implementation delegates to machine-specific bang_stack_with_offset |
326 // implementation delegates to machine-specific bang_stack_with_offset |
285 void generate_stack_overflow_check( int frame_size_in_bytes ); |
327 void generate_stack_overflow_check( int frame_size_in_bytes ); |
286 virtual void bang_stack_with_offset(int offset) = 0; |
328 virtual void bang_stack_with_offset(int offset) = 0; |
287 |
329 |