src/cpu/sparc/vm/frame_sparc.inline.hpp

Wed, 24 Apr 2013 20:55:28 -0400

author
dlong
date
Wed, 24 Apr 2013 20:55:28 -0400
changeset 5000
a6e09d6dd8e5
parent 4323
f0c2369fda5a
child 5419
e619a2766bcc
permissions
-rw-r--r--

8003853: specify offset of IC load in java_to_interp stub
Summary: refactored code to allow platform-specific differences
Reviewed-by: dlong, twisti
Contributed-by: Goetz Lindenmaier <goetz.lindenmaier@sap.com>

duke@435 1 /*
bdelsart@3433 2 * Copyright (c) 1997, 2012, Oracle and/or its affiliates. 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 *
trims@1907 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
trims@1907 20 * or visit www.oracle.com if you need additional information or have any
trims@1907 21 * questions.
duke@435 22 *
duke@435 23 */
duke@435 24
stefank@2314 25 #ifndef CPU_SPARC_VM_FRAME_SPARC_INLINE_HPP
stefank@2314 26 #define CPU_SPARC_VM_FRAME_SPARC_INLINE_HPP
stefank@2314 27
twisti@4323 28 #include "asm/macroAssembler.hpp"
twisti@4323 29
duke@435 30 // Inline functions for SPARC frames:
duke@435 31
duke@435 32 // Constructors
duke@435 33
duke@435 34 inline frame::frame() {
duke@435 35 _pc = NULL;
duke@435 36 _sp = NULL;
duke@435 37 _younger_sp = NULL;
duke@435 38 _cb = NULL;
duke@435 39 _deopt_state = unknown;
duke@435 40 _sp_adjustment_by_callee = 0;
duke@435 41 }
duke@435 42
duke@435 43 // Accessors:
duke@435 44
duke@435 45 inline bool frame::equal(frame other) const {
duke@435 46 bool ret = sp() == other.sp()
duke@435 47 && fp() == other.fp()
duke@435 48 && pc() == other.pc();
duke@435 49 assert(!ret || ret && cb() == other.cb() && _deopt_state == other._deopt_state, "inconsistent construction");
duke@435 50 return ret;
duke@435 51 }
duke@435 52
duke@435 53 // Return unique id for this frame. The id must have a value where we can distinguish
duke@435 54 // identity and younger/older relationship. NULL represents an invalid (incomparable)
duke@435 55 // frame.
duke@435 56 inline intptr_t* frame::id(void) const { return unextended_sp(); }
duke@435 57
duke@435 58 // Relationals on frames based
duke@435 59 // Return true if the frame is younger (more recent activation) than the frame represented by id
duke@435 60 inline bool frame::is_younger(intptr_t* id) const { assert(this->id() != NULL && id != NULL, "NULL frame id");
duke@435 61 return this->id() < id ; }
duke@435 62
duke@435 63 // Return true if the frame is older (less recent activation) than the frame represented by id
duke@435 64 inline bool frame::is_older(intptr_t* id) const { assert(this->id() != NULL && id != NULL, "NULL frame id");
duke@435 65 return this->id() > id ; }
duke@435 66
cfang@1228 67 inline int frame::frame_size(RegisterMap* map) const { return sender_sp() - sp(); }
duke@435 68
duke@435 69 inline intptr_t* frame::link() const { return (intptr_t *)(fp()[FP->sp_offset_in_saved_window()] + STACK_BIAS); }
duke@435 70
duke@435 71 inline void frame::set_link(intptr_t* addr) { assert(link()==addr, "frame nesting is controlled by hardware"); }
duke@435 72
duke@435 73 inline intptr_t* frame::unextended_sp() const { return sp() + _sp_adjustment_by_callee; }
duke@435 74
duke@435 75 // return address:
duke@435 76
duke@435 77 inline address frame::sender_pc() const { return *I7_addr() + pc_return_offset; }
duke@435 78
duke@435 79 inline address* frame::I7_addr() const { return (address*) &sp()[ I7->sp_offset_in_saved_window()]; }
duke@435 80 inline address* frame::I0_addr() const { return (address*) &sp()[ I0->sp_offset_in_saved_window()]; }
duke@435 81
duke@435 82 inline address* frame::O7_addr() const { return (address*) &younger_sp()[ I7->sp_offset_in_saved_window()]; }
duke@435 83 inline address* frame::O0_addr() const { return (address*) &younger_sp()[ I0->sp_offset_in_saved_window()]; }
duke@435 84
duke@435 85 inline intptr_t* frame::sender_sp() const { return fp(); }
duke@435 86
bdelsart@3433 87 inline intptr_t* frame::real_fp() const { return fp(); }
bdelsart@3433 88
duke@435 89 // Used only in frame::oopmapreg_to_location
duke@435 90 // This return a value in VMRegImpl::slot_size
duke@435 91 inline int frame::pd_oop_map_offset_adjustment() const {
duke@435 92 return _sp_adjustment_by_callee * VMRegImpl::slots_per_word;
duke@435 93 }
duke@435 94
duke@435 95 #ifdef CC_INTERP
duke@435 96 inline intptr_t** frame::interpreter_frame_locals_addr() const {
duke@435 97 interpreterState istate = get_interpreterState();
duke@435 98 return (intptr_t**) &istate->_locals;
duke@435 99 }
duke@435 100
duke@435 101 inline intptr_t* frame::interpreter_frame_bcx_addr() const {
duke@435 102 interpreterState istate = get_interpreterState();
duke@435 103 return (intptr_t*) &istate->_bcp;
duke@435 104 }
duke@435 105
duke@435 106 inline intptr_t* frame::interpreter_frame_mdx_addr() const {
duke@435 107 interpreterState istate = get_interpreterState();
duke@435 108 return (intptr_t*) &istate->_mdx;
duke@435 109 }
duke@435 110
duke@435 111 inline jint frame::interpreter_frame_expression_stack_direction() { return -1; }
duke@435 112
duke@435 113 // bottom(base) of the expression stack (highest address)
duke@435 114 inline intptr_t* frame::interpreter_frame_expression_stack() const {
duke@435 115 return (intptr_t*)interpreter_frame_monitor_end() - 1;
duke@435 116 }
duke@435 117
duke@435 118 // top of expression stack (lowest address)
duke@435 119 inline intptr_t* frame::interpreter_frame_tos_address() const {
duke@435 120 interpreterState istate = get_interpreterState();
duke@435 121 return istate->_stack + 1; // Is this off by one? QQQ
duke@435 122 }
duke@435 123
duke@435 124 // monitor elements
duke@435 125
duke@435 126 // in keeping with Intel side: end is lower in memory than begin;
duke@435 127 // and beginning element is oldest element
duke@435 128 // Also begin is one past last monitor.
duke@435 129
duke@435 130 inline BasicObjectLock* frame::interpreter_frame_monitor_begin() const {
duke@435 131 return get_interpreterState()->monitor_base();
duke@435 132 }
duke@435 133
duke@435 134 inline BasicObjectLock* frame::interpreter_frame_monitor_end() const {
duke@435 135 return (BasicObjectLock*) get_interpreterState()->stack_base();
duke@435 136 }
duke@435 137
duke@435 138
duke@435 139 inline int frame::interpreter_frame_monitor_size() {
duke@435 140 return round_to(BasicObjectLock::size(), WordsPerLong);
duke@435 141 }
duke@435 142
coleenp@4037 143 inline Method** frame::interpreter_frame_method_addr() const {
duke@435 144 interpreterState istate = get_interpreterState();
duke@435 145 return &istate->_method;
duke@435 146 }
duke@435 147
duke@435 148
duke@435 149 // Constant pool cache
duke@435 150
duke@435 151 // where LcpoolCache is saved:
coleenp@4037 152 inline ConstantPoolCache** frame::interpreter_frame_cpoolcache_addr() const {
duke@435 153 interpreterState istate = get_interpreterState();
duke@435 154 return &istate->_constants; // should really use accessor
duke@435 155 }
duke@435 156
coleenp@4037 157 inline ConstantPoolCache** frame::interpreter_frame_cache_addr() const {
duke@435 158 interpreterState istate = get_interpreterState();
duke@435 159 return &istate->_constants;
duke@435 160 }
duke@435 161
duke@435 162 #else // !CC_INTERP
duke@435 163
duke@435 164 inline intptr_t** frame::interpreter_frame_locals_addr() const {
duke@435 165 return (intptr_t**) sp_addr_at( Llocals->sp_offset_in_saved_window());
duke@435 166 }
duke@435 167
duke@435 168 inline intptr_t* frame::interpreter_frame_bcx_addr() const {
duke@435 169 // %%%%% reinterpreting Lbcp as a bcx
duke@435 170 return (intptr_t*) sp_addr_at( Lbcp->sp_offset_in_saved_window());
duke@435 171 }
duke@435 172
duke@435 173 inline intptr_t* frame::interpreter_frame_mdx_addr() const {
duke@435 174 // %%%%% reinterpreting ImethodDataPtr as a mdx
duke@435 175 return (intptr_t*) sp_addr_at( ImethodDataPtr->sp_offset_in_saved_window());
duke@435 176 }
duke@435 177
duke@435 178 inline jint frame::interpreter_frame_expression_stack_direction() { return -1; }
duke@435 179
duke@435 180 // bottom(base) of the expression stack (highest address)
duke@435 181 inline intptr_t* frame::interpreter_frame_expression_stack() const {
duke@435 182 return (intptr_t*)interpreter_frame_monitors() - 1;
duke@435 183 }
duke@435 184
duke@435 185 // top of expression stack (lowest address)
duke@435 186 inline intptr_t* frame::interpreter_frame_tos_address() const {
duke@435 187 return *interpreter_frame_esp_addr() + 1;
duke@435 188 }
duke@435 189
twisti@4318 190 inline BasicObjectLock** frame::interpreter_frame_monitors_addr() const {
twisti@4318 191 return (BasicObjectLock**) sp_addr_at(Lmonitors->sp_offset_in_saved_window());
twisti@4318 192 }
twisti@4318 193 inline intptr_t** frame::interpreter_frame_esp_addr() const {
twisti@4318 194 return (intptr_t**)sp_addr_at(Lesp->sp_offset_in_saved_window());
twisti@4318 195 }
twisti@4318 196
duke@435 197 inline void frame::interpreter_frame_set_tos_address( intptr_t* x ) {
duke@435 198 *interpreter_frame_esp_addr() = x - 1;
duke@435 199 }
duke@435 200
duke@435 201 // monitor elements
duke@435 202
duke@435 203 // in keeping with Intel side: end is lower in memory than begin;
duke@435 204 // and beginning element is oldest element
duke@435 205 // Also begin is one past last monitor.
duke@435 206
duke@435 207 inline BasicObjectLock* frame::interpreter_frame_monitor_begin() const {
duke@435 208 int rounded_vm_local_words = round_to(frame::interpreter_frame_vm_local_words, WordsPerLong);
duke@435 209 return (BasicObjectLock *)fp_addr_at(-rounded_vm_local_words);
duke@435 210 }
duke@435 211
duke@435 212 inline BasicObjectLock* frame::interpreter_frame_monitor_end() const {
duke@435 213 return interpreter_frame_monitors();
duke@435 214 }
duke@435 215
duke@435 216
duke@435 217 inline void frame::interpreter_frame_set_monitor_end(BasicObjectLock* value) {
duke@435 218 interpreter_frame_set_monitors(value);
duke@435 219 }
duke@435 220
duke@435 221 inline int frame::interpreter_frame_monitor_size() {
duke@435 222 return round_to(BasicObjectLock::size(), WordsPerLong);
duke@435 223 }
duke@435 224
coleenp@4037 225 inline Method** frame::interpreter_frame_method_addr() const {
coleenp@4037 226 return (Method**)sp_addr_at( Lmethod->sp_offset_in_saved_window());
duke@435 227 }
duke@435 228
duke@435 229
duke@435 230 // Constant pool cache
duke@435 231
duke@435 232 // where LcpoolCache is saved:
coleenp@4037 233 inline ConstantPoolCache** frame::interpreter_frame_cpoolcache_addr() const {
coleenp@4037 234 return (ConstantPoolCache**)sp_addr_at(LcpoolCache->sp_offset_in_saved_window());
duke@435 235 }
duke@435 236
coleenp@4037 237 inline ConstantPoolCache** frame::interpreter_frame_cache_addr() const {
coleenp@4037 238 return (ConstantPoolCache**)sp_addr_at( LcpoolCache->sp_offset_in_saved_window());
duke@435 239 }
duke@435 240 #endif // CC_INTERP
duke@435 241
duke@435 242
duke@435 243 inline JavaCallWrapper* frame::entry_frame_call_wrapper() const {
duke@435 244 // note: adjust this code if the link argument in StubGenerator::call_stub() changes!
duke@435 245 const Argument link = Argument(0, false);
duke@435 246 return (JavaCallWrapper*)sp()[link.as_in().as_register()->sp_offset_in_saved_window()];
duke@435 247 }
duke@435 248
duke@435 249
duke@435 250 inline int frame::local_offset_for_compiler(int local_index, int nof_args, int max_nof_locals, int max_nof_monitors) {
duke@435 251 // always allocate non-argument locals 0..5 as if they were arguments:
duke@435 252 int allocated_above_frame = nof_args;
duke@435 253 if (allocated_above_frame < callee_register_argument_save_area_words)
duke@435 254 allocated_above_frame = callee_register_argument_save_area_words;
duke@435 255 if (allocated_above_frame > max_nof_locals)
duke@435 256 allocated_above_frame = max_nof_locals;
duke@435 257
duke@435 258 // Note: monitors (BasicLock blocks) are never allocated in argument slots
duke@435 259 //assert(local_index >= 0 && local_index < max_nof_locals, "bad local index");
duke@435 260 if (local_index < allocated_above_frame)
duke@435 261 return local_index + callee_register_argument_save_area_sp_offset;
duke@435 262 else
duke@435 263 return local_index - (max_nof_locals + max_nof_monitors*2) + compiler_frame_vm_locals_fp_offset;
duke@435 264 }
duke@435 265
duke@435 266 inline int frame::monitor_offset_for_compiler(int local_index, int nof_args, int max_nof_locals, int max_nof_monitors) {
duke@435 267 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 268
duke@435 269 // The compiler uses the __higher__ of two indexes allocated to the monitor.
duke@435 270 // Increasing local indexes are mapped to increasing memory locations,
duke@435 271 // so the start of the BasicLock is associated with the __lower__ index.
duke@435 272
duke@435 273 int offset = (local_index-1) - (max_nof_locals + max_nof_monitors*2) + compiler_frame_vm_locals_fp_offset;
duke@435 274
duke@435 275 // We allocate monitors aligned zero mod 8:
duke@435 276 assert((offset & 1) == 0, "monitor must be an an even address.");
duke@435 277 // This works because all monitors are allocated after
duke@435 278 // all locals, and because the highest address corresponding to any
duke@435 279 // monitor index is always even.
duke@435 280 assert((compiler_frame_vm_locals_fp_offset & 1) == 0, "end of monitors must be even address");
duke@435 281
duke@435 282 return offset;
duke@435 283 }
duke@435 284
duke@435 285 inline int frame::min_local_offset_for_compiler(int nof_args, int max_nof_locals, int max_nof_monitors) {
duke@435 286 // always allocate non-argument locals 0..5 as if they were arguments:
duke@435 287 int allocated_above_frame = nof_args;
duke@435 288 if (allocated_above_frame < callee_register_argument_save_area_words)
duke@435 289 allocated_above_frame = callee_register_argument_save_area_words;
duke@435 290 if (allocated_above_frame > max_nof_locals)
duke@435 291 allocated_above_frame = max_nof_locals;
duke@435 292
duke@435 293 int allocated_in_frame = (max_nof_locals + max_nof_monitors*2) - allocated_above_frame;
duke@435 294
duke@435 295 return compiler_frame_vm_locals_fp_offset - allocated_in_frame;
duke@435 296 }
duke@435 297
duke@435 298 // On SPARC, the %lN and %iN registers are non-volatile.
duke@435 299 inline bool frame::volatile_across_calls(Register reg) {
duke@435 300 // This predicate is (presently) applied only to temporary registers,
duke@435 301 // and so it need not recognize non-volatile globals.
duke@435 302 return reg->is_out() || reg->is_global();
duke@435 303 }
duke@435 304
duke@435 305 inline oop frame::saved_oop_result(RegisterMap* map) const {
duke@435 306 return *((oop*) map->location(O0->as_VMReg()));
duke@435 307 }
duke@435 308
duke@435 309 inline void frame::set_saved_oop_result(RegisterMap* map, oop obj) {
duke@435 310 *((oop*) map->location(O0->as_VMReg())) = obj;
duke@435 311 }
stefank@2314 312
stefank@2314 313 #endif // CPU_SPARC_VM_FRAME_SPARC_INLINE_HPP

mercurial