1 /* |
1 /* |
2 * Copyright 1997-2006 Sun Microsystems, Inc. All Rights Reserved. |
2 * Copyright 1997-2009 Sun Microsystems, Inc. All Rights Reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. |
7 * published by the Free Software Foundation. |
141 }; |
141 }; |
142 |
142 |
143 // A union type for code which has to assemble both constant and |
143 // A union type for code which has to assemble both constant and |
144 // non-constant operands, when the distinction cannot be made |
144 // non-constant operands, when the distinction cannot be made |
145 // statically. |
145 // statically. |
146 class RegisterConstant VALUE_OBJ_CLASS_SPEC { |
146 class RegisterOrConstant VALUE_OBJ_CLASS_SPEC { |
147 private: |
147 private: |
148 Register _r; |
148 Register _r; |
149 intptr_t _c; |
149 intptr_t _c; |
150 |
150 |
151 public: |
151 public: |
152 RegisterConstant(): _r(noreg), _c(0) {} |
152 RegisterOrConstant(): _r(noreg), _c(0) {} |
153 RegisterConstant(Register r): _r(r), _c(0) {} |
153 RegisterOrConstant(Register r): _r(r), _c(0) {} |
154 RegisterConstant(intptr_t c): _r(noreg), _c(c) {} |
154 RegisterOrConstant(intptr_t c): _r(noreg), _c(c) {} |
155 |
155 |
156 Register as_register() const { assert(is_register(),""); return _r; } |
156 Register as_register() const { assert(is_register(),""); return _r; } |
157 intptr_t as_constant() const { assert(is_constant(),""); return _c; } |
157 intptr_t as_constant() const { assert(is_constant(),""); return _c; } |
158 |
158 |
159 Register register_or_noreg() const { return _r; } |
159 Register register_or_noreg() const { return _r; } |
308 // Thus, the eventual value of the constant must not be zero. |
308 // Thus, the eventual value of the constant must not be zero. |
309 // This is fine, since this is designed for embedding object field |
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. |
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) |
311 // Field offsets are never zero, since an object's header (mark word) |
312 // is located at offset zero. |
312 // is located at offset zero. |
313 RegisterConstant delayed_value(int(*value_fn)(), Register tmp, int offset = 0) { |
313 RegisterOrConstant delayed_value(int(*value_fn)(), Register tmp, int offset = 0) { |
314 return delayed_value(delayed_value_addr(value_fn), tmp, offset); |
314 return delayed_value_impl(delayed_value_addr(value_fn), tmp, offset); |
315 } |
315 } |
316 RegisterConstant delayed_value(address(*value_fn)(), Register tmp, int offset = 0) { |
316 RegisterOrConstant delayed_value(address(*value_fn)(), Register tmp, int offset = 0) { |
317 return delayed_value(delayed_value_addr(value_fn), tmp, offset); |
317 return delayed_value_impl(delayed_value_addr(value_fn), tmp, offset); |
318 } |
318 } |
319 virtual RegisterConstant delayed_value(intptr_t* delayed_value_addr, Register tmp, int offset) = 0; |
319 virtual RegisterOrConstant delayed_value_impl(intptr_t* delayed_value_addr, Register tmp, int offset) = 0; |
320 // Last overloading is platform-dependent; look in assembler_<arch>.cpp. |
320 // Last overloading is platform-dependent; look in assembler_<arch>.cpp. |
321 static intptr_t* delayed_value_addr(int(*constant_fn)()); |
321 static intptr_t* delayed_value_addr(int(*constant_fn)()); |
322 static intptr_t* delayed_value_addr(address(*constant_fn)()); |
322 static intptr_t* delayed_value_addr(address(*constant_fn)()); |
323 static void update_delayed_values(); |
323 static void update_delayed_values(); |
324 |
324 |