Fri, 11 Jul 2008 01:14:44 -0700
Merge
duke@435 | 1 | /* |
duke@435 | 2 | * Copyright 1997-2007 Sun Microsystems, Inc. All Rights Reserved. |
duke@435 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
duke@435 | 4 | * |
duke@435 | 5 | * This code is free software; you can redistribute it and/or modify it |
duke@435 | 6 | * under the terms of the GNU General Public License version 2 only, as |
duke@435 | 7 | * published by the Free Software Foundation. |
duke@435 | 8 | * |
duke@435 | 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
duke@435 | 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
duke@435 | 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
duke@435 | 12 | * version 2 for more details (a copy is included in the LICENSE file that |
duke@435 | 13 | * accompanied this code). |
duke@435 | 14 | * |
duke@435 | 15 | * You should have received a copy of the GNU General Public License version |
duke@435 | 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
duke@435 | 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
duke@435 | 18 | * |
duke@435 | 19 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, |
duke@435 | 20 | * CA 95054 USA or visit www.sun.com if you need additional information or |
duke@435 | 21 | * have any questions. |
duke@435 | 22 | * |
duke@435 | 23 | */ |
duke@435 | 24 | |
duke@435 | 25 | // Inline functions for SPARC frames: |
duke@435 | 26 | |
duke@435 | 27 | // Constructors |
duke@435 | 28 | |
duke@435 | 29 | inline frame::frame() { |
duke@435 | 30 | _pc = NULL; |
duke@435 | 31 | _sp = NULL; |
duke@435 | 32 | _younger_sp = NULL; |
duke@435 | 33 | _cb = NULL; |
duke@435 | 34 | _deopt_state = unknown; |
duke@435 | 35 | _sp_adjustment_by_callee = 0; |
duke@435 | 36 | } |
duke@435 | 37 | |
duke@435 | 38 | // Accessors: |
duke@435 | 39 | |
duke@435 | 40 | inline bool frame::equal(frame other) const { |
duke@435 | 41 | bool ret = sp() == other.sp() |
duke@435 | 42 | && fp() == other.fp() |
duke@435 | 43 | && pc() == other.pc(); |
duke@435 | 44 | assert(!ret || ret && cb() == other.cb() && _deopt_state == other._deopt_state, "inconsistent construction"); |
duke@435 | 45 | return ret; |
duke@435 | 46 | } |
duke@435 | 47 | |
duke@435 | 48 | // Return unique id for this frame. The id must have a value where we can distinguish |
duke@435 | 49 | // identity and younger/older relationship. NULL represents an invalid (incomparable) |
duke@435 | 50 | // frame. |
duke@435 | 51 | inline intptr_t* frame::id(void) const { return unextended_sp(); } |
duke@435 | 52 | |
duke@435 | 53 | // Relationals on frames based |
duke@435 | 54 | // Return true if the frame is younger (more recent activation) than the frame represented by id |
duke@435 | 55 | inline bool frame::is_younger(intptr_t* id) const { assert(this->id() != NULL && id != NULL, "NULL frame id"); |
duke@435 | 56 | return this->id() < id ; } |
duke@435 | 57 | |
duke@435 | 58 | // Return true if the frame is older (less recent activation) than the frame represented by id |
duke@435 | 59 | inline bool frame::is_older(intptr_t* id) const { assert(this->id() != NULL && id != NULL, "NULL frame id"); |
duke@435 | 60 | return this->id() > id ; } |
duke@435 | 61 | |
duke@435 | 62 | inline int frame::frame_size() const { return sender_sp() - sp(); } |
duke@435 | 63 | |
duke@435 | 64 | inline intptr_t* frame::link() const { return (intptr_t *)(fp()[FP->sp_offset_in_saved_window()] + STACK_BIAS); } |
duke@435 | 65 | |
duke@435 | 66 | inline void frame::set_link(intptr_t* addr) { assert(link()==addr, "frame nesting is controlled by hardware"); } |
duke@435 | 67 | |
duke@435 | 68 | inline intptr_t* frame::unextended_sp() const { return sp() + _sp_adjustment_by_callee; } |
duke@435 | 69 | |
duke@435 | 70 | // return address: |
duke@435 | 71 | |
duke@435 | 72 | inline address frame::sender_pc() const { return *I7_addr() + pc_return_offset; } |
duke@435 | 73 | |
duke@435 | 74 | inline address* frame::I7_addr() const { return (address*) &sp()[ I7->sp_offset_in_saved_window()]; } |
duke@435 | 75 | inline address* frame::I0_addr() const { return (address*) &sp()[ I0->sp_offset_in_saved_window()]; } |
duke@435 | 76 | |
duke@435 | 77 | inline address* frame::O7_addr() const { return (address*) &younger_sp()[ I7->sp_offset_in_saved_window()]; } |
duke@435 | 78 | inline address* frame::O0_addr() const { return (address*) &younger_sp()[ I0->sp_offset_in_saved_window()]; } |
duke@435 | 79 | |
duke@435 | 80 | inline intptr_t* frame::sender_sp() const { return fp(); } |
duke@435 | 81 | |
duke@435 | 82 | // Used only in frame::oopmapreg_to_location |
duke@435 | 83 | // This return a value in VMRegImpl::slot_size |
duke@435 | 84 | inline int frame::pd_oop_map_offset_adjustment() const { |
duke@435 | 85 | return _sp_adjustment_by_callee * VMRegImpl::slots_per_word; |
duke@435 | 86 | } |
duke@435 | 87 | |
duke@435 | 88 | #ifdef CC_INTERP |
duke@435 | 89 | inline intptr_t** frame::interpreter_frame_locals_addr() const { |
duke@435 | 90 | interpreterState istate = get_interpreterState(); |
duke@435 | 91 | return (intptr_t**) &istate->_locals; |
duke@435 | 92 | } |
duke@435 | 93 | |
duke@435 | 94 | inline intptr_t* frame::interpreter_frame_bcx_addr() const { |
duke@435 | 95 | interpreterState istate = get_interpreterState(); |
duke@435 | 96 | return (intptr_t*) &istate->_bcp; |
duke@435 | 97 | } |
duke@435 | 98 | |
duke@435 | 99 | inline intptr_t* frame::interpreter_frame_mdx_addr() const { |
duke@435 | 100 | interpreterState istate = get_interpreterState(); |
duke@435 | 101 | return (intptr_t*) &istate->_mdx; |
duke@435 | 102 | } |
duke@435 | 103 | |
duke@435 | 104 | inline jint frame::interpreter_frame_expression_stack_direction() { return -1; } |
duke@435 | 105 | |
duke@435 | 106 | // bottom(base) of the expression stack (highest address) |
duke@435 | 107 | inline intptr_t* frame::interpreter_frame_expression_stack() const { |
duke@435 | 108 | return (intptr_t*)interpreter_frame_monitor_end() - 1; |
duke@435 | 109 | } |
duke@435 | 110 | |
duke@435 | 111 | // top of expression stack (lowest address) |
duke@435 | 112 | inline intptr_t* frame::interpreter_frame_tos_address() const { |
duke@435 | 113 | interpreterState istate = get_interpreterState(); |
duke@435 | 114 | return istate->_stack + 1; // Is this off by one? QQQ |
duke@435 | 115 | } |
duke@435 | 116 | |
duke@435 | 117 | // monitor elements |
duke@435 | 118 | |
duke@435 | 119 | // in keeping with Intel side: end is lower in memory than begin; |
duke@435 | 120 | // and beginning element is oldest element |
duke@435 | 121 | // Also begin is one past last monitor. |
duke@435 | 122 | |
duke@435 | 123 | inline BasicObjectLock* frame::interpreter_frame_monitor_begin() const { |
duke@435 | 124 | return get_interpreterState()->monitor_base(); |
duke@435 | 125 | } |
duke@435 | 126 | |
duke@435 | 127 | inline BasicObjectLock* frame::interpreter_frame_monitor_end() const { |
duke@435 | 128 | return (BasicObjectLock*) get_interpreterState()->stack_base(); |
duke@435 | 129 | } |
duke@435 | 130 | |
duke@435 | 131 | |
duke@435 | 132 | inline int frame::interpreter_frame_monitor_size() { |
duke@435 | 133 | return round_to(BasicObjectLock::size(), WordsPerLong); |
duke@435 | 134 | } |
duke@435 | 135 | |
duke@435 | 136 | inline methodOop* frame::interpreter_frame_method_addr() const { |
duke@435 | 137 | interpreterState istate = get_interpreterState(); |
duke@435 | 138 | return &istate->_method; |
duke@435 | 139 | } |
duke@435 | 140 | |
duke@435 | 141 | |
duke@435 | 142 | // Constant pool cache |
duke@435 | 143 | |
duke@435 | 144 | // where LcpoolCache is saved: |
duke@435 | 145 | inline constantPoolCacheOop* frame::interpreter_frame_cpoolcache_addr() const { |
duke@435 | 146 | interpreterState istate = get_interpreterState(); |
duke@435 | 147 | return &istate->_constants; // should really use accessor |
duke@435 | 148 | } |
duke@435 | 149 | |
duke@435 | 150 | inline constantPoolCacheOop* frame::interpreter_frame_cache_addr() const { |
duke@435 | 151 | interpreterState istate = get_interpreterState(); |
duke@435 | 152 | return &istate->_constants; |
duke@435 | 153 | } |
duke@435 | 154 | |
duke@435 | 155 | #else // !CC_INTERP |
duke@435 | 156 | |
duke@435 | 157 | inline intptr_t** frame::interpreter_frame_locals_addr() const { |
duke@435 | 158 | return (intptr_t**) sp_addr_at( Llocals->sp_offset_in_saved_window()); |
duke@435 | 159 | } |
duke@435 | 160 | |
duke@435 | 161 | inline intptr_t* frame::interpreter_frame_bcx_addr() const { |
duke@435 | 162 | // %%%%% reinterpreting Lbcp as a bcx |
duke@435 | 163 | return (intptr_t*) sp_addr_at( Lbcp->sp_offset_in_saved_window()); |
duke@435 | 164 | } |
duke@435 | 165 | |
duke@435 | 166 | inline intptr_t* frame::interpreter_frame_mdx_addr() const { |
duke@435 | 167 | // %%%%% reinterpreting ImethodDataPtr as a mdx |
duke@435 | 168 | return (intptr_t*) sp_addr_at( ImethodDataPtr->sp_offset_in_saved_window()); |
duke@435 | 169 | } |
duke@435 | 170 | |
duke@435 | 171 | inline jint frame::interpreter_frame_expression_stack_direction() { return -1; } |
duke@435 | 172 | |
duke@435 | 173 | // bottom(base) of the expression stack (highest address) |
duke@435 | 174 | inline intptr_t* frame::interpreter_frame_expression_stack() const { |
duke@435 | 175 | return (intptr_t*)interpreter_frame_monitors() - 1; |
duke@435 | 176 | } |
duke@435 | 177 | |
duke@435 | 178 | // top of expression stack (lowest address) |
duke@435 | 179 | inline intptr_t* frame::interpreter_frame_tos_address() const { |
duke@435 | 180 | return *interpreter_frame_esp_addr() + 1; |
duke@435 | 181 | } |
duke@435 | 182 | |
duke@435 | 183 | inline void frame::interpreter_frame_set_tos_address( intptr_t* x ) { |
duke@435 | 184 | *interpreter_frame_esp_addr() = x - 1; |
duke@435 | 185 | } |
duke@435 | 186 | |
duke@435 | 187 | // monitor elements |
duke@435 | 188 | |
duke@435 | 189 | // in keeping with Intel side: end is lower in memory than begin; |
duke@435 | 190 | // and beginning element is oldest element |
duke@435 | 191 | // Also begin is one past last monitor. |
duke@435 | 192 | |
duke@435 | 193 | inline BasicObjectLock* frame::interpreter_frame_monitor_begin() const { |
duke@435 | 194 | int rounded_vm_local_words = round_to(frame::interpreter_frame_vm_local_words, WordsPerLong); |
duke@435 | 195 | return (BasicObjectLock *)fp_addr_at(-rounded_vm_local_words); |
duke@435 | 196 | } |
duke@435 | 197 | |
duke@435 | 198 | inline BasicObjectLock* frame::interpreter_frame_monitor_end() const { |
duke@435 | 199 | return interpreter_frame_monitors(); |
duke@435 | 200 | } |
duke@435 | 201 | |
duke@435 | 202 | |
duke@435 | 203 | inline void frame::interpreter_frame_set_monitor_end(BasicObjectLock* value) { |
duke@435 | 204 | interpreter_frame_set_monitors(value); |
duke@435 | 205 | } |
duke@435 | 206 | |
duke@435 | 207 | inline int frame::interpreter_frame_monitor_size() { |
duke@435 | 208 | return round_to(BasicObjectLock::size(), WordsPerLong); |
duke@435 | 209 | } |
duke@435 | 210 | |
duke@435 | 211 | inline methodOop* frame::interpreter_frame_method_addr() const { |
duke@435 | 212 | return (methodOop*)sp_addr_at( Lmethod->sp_offset_in_saved_window()); |
duke@435 | 213 | } |
duke@435 | 214 | |
duke@435 | 215 | |
duke@435 | 216 | // Constant pool cache |
duke@435 | 217 | |
duke@435 | 218 | // where LcpoolCache is saved: |
duke@435 | 219 | inline constantPoolCacheOop* frame::interpreter_frame_cpoolcache_addr() const { |
duke@435 | 220 | return (constantPoolCacheOop*)sp_addr_at(LcpoolCache->sp_offset_in_saved_window()); |
duke@435 | 221 | } |
duke@435 | 222 | |
duke@435 | 223 | inline constantPoolCacheOop* frame::interpreter_frame_cache_addr() const { |
duke@435 | 224 | return (constantPoolCacheOop*)sp_addr_at( LcpoolCache->sp_offset_in_saved_window()); |
duke@435 | 225 | } |
duke@435 | 226 | #endif // CC_INTERP |
duke@435 | 227 | |
duke@435 | 228 | |
duke@435 | 229 | inline JavaCallWrapper* frame::entry_frame_call_wrapper() const { |
duke@435 | 230 | // note: adjust this code if the link argument in StubGenerator::call_stub() changes! |
duke@435 | 231 | const Argument link = Argument(0, false); |
duke@435 | 232 | return (JavaCallWrapper*)sp()[link.as_in().as_register()->sp_offset_in_saved_window()]; |
duke@435 | 233 | } |
duke@435 | 234 | |
duke@435 | 235 | |
duke@435 | 236 | inline int frame::local_offset_for_compiler(int local_index, int nof_args, int max_nof_locals, int max_nof_monitors) { |
duke@435 | 237 | // always allocate non-argument locals 0..5 as if they were arguments: |
duke@435 | 238 | int allocated_above_frame = nof_args; |
duke@435 | 239 | if (allocated_above_frame < callee_register_argument_save_area_words) |
duke@435 | 240 | allocated_above_frame = callee_register_argument_save_area_words; |
duke@435 | 241 | if (allocated_above_frame > max_nof_locals) |
duke@435 | 242 | allocated_above_frame = max_nof_locals; |
duke@435 | 243 | |
duke@435 | 244 | // Note: monitors (BasicLock blocks) are never allocated in argument slots |
duke@435 | 245 | //assert(local_index >= 0 && local_index < max_nof_locals, "bad local index"); |
duke@435 | 246 | if (local_index < allocated_above_frame) |
duke@435 | 247 | return local_index + callee_register_argument_save_area_sp_offset; |
duke@435 | 248 | else |
duke@435 | 249 | return local_index - (max_nof_locals + max_nof_monitors*2) + compiler_frame_vm_locals_fp_offset; |
duke@435 | 250 | } |
duke@435 | 251 | |
duke@435 | 252 | inline int frame::monitor_offset_for_compiler(int local_index, int nof_args, int max_nof_locals, int max_nof_monitors) { |
duke@435 | 253 | assert(local_index >= max_nof_locals && ((local_index - max_nof_locals) & 1) && (local_index - max_nof_locals) < max_nof_monitors*2, "bad monitor index"); |
duke@435 | 254 | |
duke@435 | 255 | // The compiler uses the __higher__ of two indexes allocated to the monitor. |
duke@435 | 256 | // Increasing local indexes are mapped to increasing memory locations, |
duke@435 | 257 | // so the start of the BasicLock is associated with the __lower__ index. |
duke@435 | 258 | |
duke@435 | 259 | int offset = (local_index-1) - (max_nof_locals + max_nof_monitors*2) + compiler_frame_vm_locals_fp_offset; |
duke@435 | 260 | |
duke@435 | 261 | // We allocate monitors aligned zero mod 8: |
duke@435 | 262 | assert((offset & 1) == 0, "monitor must be an an even address."); |
duke@435 | 263 | // This works because all monitors are allocated after |
duke@435 | 264 | // all locals, and because the highest address corresponding to any |
duke@435 | 265 | // monitor index is always even. |
duke@435 | 266 | assert((compiler_frame_vm_locals_fp_offset & 1) == 0, "end of monitors must be even address"); |
duke@435 | 267 | |
duke@435 | 268 | return offset; |
duke@435 | 269 | } |
duke@435 | 270 | |
duke@435 | 271 | inline int frame::min_local_offset_for_compiler(int nof_args, int max_nof_locals, int max_nof_monitors) { |
duke@435 | 272 | // always allocate non-argument locals 0..5 as if they were arguments: |
duke@435 | 273 | int allocated_above_frame = nof_args; |
duke@435 | 274 | if (allocated_above_frame < callee_register_argument_save_area_words) |
duke@435 | 275 | allocated_above_frame = callee_register_argument_save_area_words; |
duke@435 | 276 | if (allocated_above_frame > max_nof_locals) |
duke@435 | 277 | allocated_above_frame = max_nof_locals; |
duke@435 | 278 | |
duke@435 | 279 | int allocated_in_frame = (max_nof_locals + max_nof_monitors*2) - allocated_above_frame; |
duke@435 | 280 | |
duke@435 | 281 | return compiler_frame_vm_locals_fp_offset - allocated_in_frame; |
duke@435 | 282 | } |
duke@435 | 283 | |
duke@435 | 284 | // On SPARC, the %lN and %iN registers are non-volatile. |
duke@435 | 285 | inline bool frame::volatile_across_calls(Register reg) { |
duke@435 | 286 | // This predicate is (presently) applied only to temporary registers, |
duke@435 | 287 | // and so it need not recognize non-volatile globals. |
duke@435 | 288 | return reg->is_out() || reg->is_global(); |
duke@435 | 289 | } |
duke@435 | 290 | |
duke@435 | 291 | inline oop frame::saved_oop_result(RegisterMap* map) const { |
duke@435 | 292 | return *((oop*) map->location(O0->as_VMReg())); |
duke@435 | 293 | } |
duke@435 | 294 | |
duke@435 | 295 | inline void frame::set_saved_oop_result(RegisterMap* map, oop obj) { |
duke@435 | 296 | *((oop*) map->location(O0->as_VMReg())) = obj; |
duke@435 | 297 | } |