src/cpu/x86/vm/frame_x86.inline.hpp

Wed, 05 Dec 2007 09:00:00 -0800

author
dcubed
date
Wed, 05 Dec 2007 09:00:00 -0800
changeset 451
f8236e79048a
parent 435
a61af66fc99e
child 542
93b6525e3b82
permissions
-rw-r--r--

6664627: Merge changes made only in hotspot 11 forward to jdk 7
Reviewed-by: jcoomes

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 Intel 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 _unextended_sp = NULL;
duke@435 33 _fp = NULL;
duke@435 34 _cb = NULL;
duke@435 35 _deopt_state = unknown;
duke@435 36 }
duke@435 37
duke@435 38 inline frame:: frame(intptr_t* sp, intptr_t* fp, address pc) {
duke@435 39 _sp = sp;
duke@435 40 _unextended_sp = sp;
duke@435 41 _fp = fp;
duke@435 42 _pc = pc;
duke@435 43 assert(pc != NULL, "no pc?");
duke@435 44 _cb = CodeCache::find_blob(pc);
duke@435 45 _deopt_state = not_deoptimized;
duke@435 46 if (_cb != NULL && _cb->is_nmethod() && ((nmethod*)_cb)->is_deopt_pc(_pc)) {
duke@435 47 _pc = (((nmethod*)_cb)->get_original_pc(this));
duke@435 48 _deopt_state = is_deoptimized;
duke@435 49 } else {
duke@435 50 _deopt_state = not_deoptimized;
duke@435 51 }
duke@435 52 }
duke@435 53
duke@435 54 inline frame:: frame(intptr_t* sp, intptr_t* unextended_sp, intptr_t* fp, address pc) {
duke@435 55 _sp = sp;
duke@435 56 _unextended_sp = unextended_sp;
duke@435 57 _fp = fp;
duke@435 58 _pc = pc;
duke@435 59 assert(pc != NULL, "no pc?");
duke@435 60 _cb = CodeCache::find_blob(pc);
duke@435 61 _deopt_state = not_deoptimized;
duke@435 62 if (_cb != NULL && _cb->is_nmethod() && ((nmethod*)_cb)->is_deopt_pc(_pc)) {
duke@435 63 _pc = (((nmethod*)_cb)->get_original_pc(this));
duke@435 64 _deopt_state = is_deoptimized;
duke@435 65 } else {
duke@435 66 _deopt_state = not_deoptimized;
duke@435 67 }
duke@435 68 }
duke@435 69
duke@435 70 inline frame::frame(intptr_t* sp, intptr_t* fp) {
duke@435 71 _sp = sp;
duke@435 72 _unextended_sp = sp;
duke@435 73 _fp = fp;
duke@435 74 _pc = (address)(sp[-1]);
duke@435 75 assert(_pc != NULL, "no pc?");
duke@435 76 _cb = CodeCache::find_blob(_pc);
duke@435 77 // In case of native stubs, the pc retreived here might be
duke@435 78 // wrong. (the _last_native_pc will have the right value)
duke@435 79 // So do not put add any asserts on the _pc here.
duke@435 80
duke@435 81 // QQQ The above comment is wrong and has been wrong for years. This constructor
duke@435 82 // should (and MUST) not be called in that situation. In the native situation
duke@435 83 // the pc should be supplied to the constructor.
duke@435 84 _deopt_state = not_deoptimized;
duke@435 85 if (_cb != NULL && _cb->is_nmethod() && ((nmethod*)_cb)->is_deopt_pc(_pc)) {
duke@435 86 _pc = (((nmethod*)_cb)->get_original_pc(this));
duke@435 87 _deopt_state = is_deoptimized;
duke@435 88 } else {
duke@435 89 _deopt_state = not_deoptimized;
duke@435 90 }
duke@435 91 }
duke@435 92
duke@435 93 // Accessors
duke@435 94
duke@435 95 inline bool frame::equal(frame other) const {
duke@435 96 bool ret = sp() == other.sp()
duke@435 97 && unextended_sp() == other.unextended_sp()
duke@435 98 && fp() == other.fp()
duke@435 99 && pc() == other.pc();
duke@435 100 assert(!ret || ret && cb() == other.cb() && _deopt_state == other._deopt_state, "inconsistent construction");
duke@435 101 return ret;
duke@435 102 }
duke@435 103
duke@435 104 // Return unique id for this frame. The id must have a value where we can distinguish
duke@435 105 // identity and younger/older relationship. NULL represents an invalid (incomparable)
duke@435 106 // frame.
duke@435 107 inline intptr_t* frame::id(void) const { return unextended_sp(); }
duke@435 108
duke@435 109 // Relationals on frames based
duke@435 110 // Return true if the frame is younger (more recent activation) than the frame represented by id
duke@435 111 inline bool frame::is_younger(intptr_t* id) const { assert(this->id() != NULL && id != NULL, "NULL frame id");
duke@435 112 return this->id() < id ; }
duke@435 113
duke@435 114 // Return true if the frame is older (less recent activation) than the frame represented by id
duke@435 115 inline bool frame::is_older(intptr_t* id) const { assert(this->id() != NULL && id != NULL, "NULL frame id");
duke@435 116 return this->id() > id ; }
duke@435 117
duke@435 118
duke@435 119
duke@435 120 inline intptr_t* frame::link() const { return (intptr_t*) *(intptr_t **)addr_at(link_offset); }
duke@435 121 inline void frame::set_link(intptr_t* addr) { *(intptr_t **)addr_at(link_offset) = addr; }
duke@435 122
duke@435 123
duke@435 124 inline intptr_t* frame::unextended_sp() const { return _unextended_sp; }
duke@435 125
duke@435 126 // Return address:
duke@435 127
duke@435 128 inline address* frame::sender_pc_addr() const { return (address*) addr_at( return_addr_offset); }
duke@435 129 inline address frame::sender_pc() const { return *sender_pc_addr(); }
duke@435 130
duke@435 131 // return address of param, zero origin index.
duke@435 132 inline address* frame::native_param_addr(int idx) const { return (address*) addr_at( native_frame_initial_param_offset+idx); }
duke@435 133
duke@435 134 #ifdef CC_INTERP
duke@435 135
duke@435 136 inline interpreterState frame::get_interpreterState() const {
duke@435 137 return ((interpreterState)addr_at( -sizeof(BytecodeInterpreter)/wordSize ));
duke@435 138 }
duke@435 139
duke@435 140 inline intptr_t* frame::sender_sp() const {
duke@435 141 // Hmm this seems awfully expensive QQQ, is this really called with interpreted frames?
duke@435 142 if (is_interpreted_frame()) {
duke@435 143 assert(false, "should never happen");
duke@435 144 return get_interpreterState()->sender_sp();
duke@435 145 } else {
duke@435 146 return addr_at(sender_sp_offset);
duke@435 147 }
duke@435 148 }
duke@435 149
duke@435 150 inline intptr_t** frame::interpreter_frame_locals_addr() const {
duke@435 151 assert(is_interpreted_frame(), "must be interpreted");
duke@435 152 return &(get_interpreterState()->_locals);
duke@435 153 }
duke@435 154
duke@435 155 inline intptr_t* frame::interpreter_frame_bcx_addr() const {
duke@435 156 assert(is_interpreted_frame(), "must be interpreted");
duke@435 157 return (jint*) &(get_interpreterState()->_bcp);
duke@435 158 }
duke@435 159
duke@435 160
duke@435 161 // Constant pool cache
duke@435 162
duke@435 163 inline constantPoolCacheOop* frame::interpreter_frame_cache_addr() const {
duke@435 164 assert(is_interpreted_frame(), "must be interpreted");
duke@435 165 return &(get_interpreterState()->_constants);
duke@435 166 }
duke@435 167
duke@435 168 // Method
duke@435 169
duke@435 170 inline methodOop* frame::interpreter_frame_method_addr() const {
duke@435 171 assert(is_interpreted_frame(), "must be interpreted");
duke@435 172 return &(get_interpreterState()->_method);
duke@435 173 }
duke@435 174
duke@435 175 inline intptr_t* frame::interpreter_frame_mdx_addr() const {
duke@435 176 assert(is_interpreted_frame(), "must be interpreted");
duke@435 177 return (jint*) &(get_interpreterState()->_mdx);
duke@435 178 }
duke@435 179
duke@435 180 // top of expression stack
duke@435 181 inline intptr_t* frame::interpreter_frame_tos_address() const {
duke@435 182 assert(is_interpreted_frame(), "wrong frame type");
duke@435 183 return get_interpreterState()->_stack + 1;
duke@435 184 }
duke@435 185
duke@435 186 #else /* asm interpreter */
duke@435 187 inline intptr_t* frame::sender_sp() const { return addr_at( sender_sp_offset); }
duke@435 188
duke@435 189 inline intptr_t** frame::interpreter_frame_locals_addr() const {
duke@435 190 return (intptr_t**)addr_at(interpreter_frame_locals_offset);
duke@435 191 }
duke@435 192
duke@435 193 inline intptr_t* frame::interpreter_frame_last_sp() const {
duke@435 194 return *(intptr_t**)addr_at(interpreter_frame_last_sp_offset);
duke@435 195 }
duke@435 196
duke@435 197 inline intptr_t* frame::interpreter_frame_bcx_addr() const {
duke@435 198 return (intptr_t*)addr_at(interpreter_frame_bcx_offset);
duke@435 199 }
duke@435 200
duke@435 201
duke@435 202 inline intptr_t* frame::interpreter_frame_mdx_addr() const {
duke@435 203 return (intptr_t*)addr_at(interpreter_frame_mdx_offset);
duke@435 204 }
duke@435 205
duke@435 206
duke@435 207
duke@435 208 // Constant pool cache
duke@435 209
duke@435 210 inline constantPoolCacheOop* frame::interpreter_frame_cache_addr() const {
duke@435 211 return (constantPoolCacheOop*)addr_at(interpreter_frame_cache_offset);
duke@435 212 }
duke@435 213
duke@435 214 // Method
duke@435 215
duke@435 216 inline methodOop* frame::interpreter_frame_method_addr() const {
duke@435 217 return (methodOop*)addr_at(interpreter_frame_method_offset);
duke@435 218 }
duke@435 219
duke@435 220 // top of expression stack
duke@435 221 inline intptr_t* frame::interpreter_frame_tos_address() const {
duke@435 222 intptr_t* last_sp = interpreter_frame_last_sp();
duke@435 223 if (last_sp == NULL ) {
duke@435 224 return sp();
duke@435 225 } else {
duke@435 226 // sp() may have been extended by an adapter
duke@435 227 assert(last_sp < fp() && last_sp >= sp(), "bad tos");
duke@435 228 return last_sp;
duke@435 229 }
duke@435 230 }
duke@435 231
duke@435 232 #endif /* CC_INTERP */
duke@435 233
duke@435 234 inline int frame::pd_oop_map_offset_adjustment() const {
duke@435 235 return 0;
duke@435 236 }
duke@435 237
duke@435 238 inline int frame::interpreter_frame_monitor_size() {
duke@435 239 return BasicObjectLock::size();
duke@435 240 }
duke@435 241
duke@435 242
duke@435 243 // expression stack
duke@435 244 // (the max_stack arguments are used by the GC; see class FrameClosure)
duke@435 245
duke@435 246 inline intptr_t* frame::interpreter_frame_expression_stack() const {
duke@435 247 intptr_t* monitor_end = (intptr_t*) interpreter_frame_monitor_end();
duke@435 248 return monitor_end-1;
duke@435 249 }
duke@435 250
duke@435 251
duke@435 252 inline jint frame::interpreter_frame_expression_stack_direction() { return -1; }
duke@435 253
duke@435 254
duke@435 255 // Entry frames
duke@435 256
duke@435 257 inline JavaCallWrapper* frame::entry_frame_call_wrapper() const {
duke@435 258 return (JavaCallWrapper*)at(entry_frame_call_wrapper_offset);
duke@435 259 }
duke@435 260
duke@435 261
duke@435 262 // Compiled frames
duke@435 263
duke@435 264 inline int frame::local_offset_for_compiler(int local_index, int nof_args, int max_nof_locals, int max_nof_monitors) {
duke@435 265 return (nof_args - local_index + (local_index < nof_args ? 1: -1));
duke@435 266 }
duke@435 267
duke@435 268 inline int frame::monitor_offset_for_compiler(int local_index, int nof_args, int max_nof_locals, int max_nof_monitors) {
duke@435 269 return local_offset_for_compiler(local_index, nof_args, max_nof_locals, max_nof_monitors);
duke@435 270 }
duke@435 271
duke@435 272 inline int frame::min_local_offset_for_compiler(int nof_args, int max_nof_locals, int max_nof_monitors) {
duke@435 273 return (nof_args - (max_nof_locals + max_nof_monitors*2) - 1);
duke@435 274 }
duke@435 275
duke@435 276 inline bool frame::volatile_across_calls(Register reg) {
duke@435 277 return true;
duke@435 278 }
duke@435 279
duke@435 280
duke@435 281
duke@435 282 inline oop frame::saved_oop_result(RegisterMap* map) const {
duke@435 283 return *((oop*) map->location(rax->as_VMReg()));
duke@435 284 }
duke@435 285
duke@435 286 inline void frame::set_saved_oop_result(RegisterMap* map, oop obj) {
duke@435 287 *((oop*) map->location(rax->as_VMReg())) = obj;
duke@435 288 }

mercurial