annotate src/cpu/x86/vm/frame_x86.inline.hpp @ 0:a61af66fc99e

Initial load
author duke
date Sat, 01 Dec 2007 00:00:00 +0000
parents
children 93b6525e3b82
rev   line source
duke@0 1 /*
duke@0 2 * Copyright 1997-2007 Sun Microsystems, Inc. All Rights Reserved.
duke@0 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@0 4 *
duke@0 5 * This code is free software; you can redistribute it and/or modify it
duke@0 6 * under the terms of the GNU General Public License version 2 only, as
duke@0 7 * published by the Free Software Foundation.
duke@0 8 *
duke@0 9 * This code is distributed in the hope that it will be useful, but WITHOUT
duke@0 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@0 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@0 12 * version 2 for more details (a copy is included in the LICENSE file that
duke@0 13 * accompanied this code).
duke@0 14 *
duke@0 15 * You should have received a copy of the GNU General Public License version
duke@0 16 * 2 along with this work; if not, write to the Free Software Foundation,
duke@0 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@0 18 *
duke@0 19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
duke@0 20 * CA 95054 USA or visit www.sun.com if you need additional information or
duke@0 21 * have any questions.
duke@0 22 *
duke@0 23 */
duke@0 24
duke@0 25 // Inline functions for Intel frames:
duke@0 26
duke@0 27 // Constructors:
duke@0 28
duke@0 29 inline frame::frame() {
duke@0 30 _pc = NULL;
duke@0 31 _sp = NULL;
duke@0 32 _unextended_sp = NULL;
duke@0 33 _fp = NULL;
duke@0 34 _cb = NULL;
duke@0 35 _deopt_state = unknown;
duke@0 36 }
duke@0 37
duke@0 38 inline frame:: frame(intptr_t* sp, intptr_t* fp, address pc) {
duke@0 39 _sp = sp;
duke@0 40 _unextended_sp = sp;
duke@0 41 _fp = fp;
duke@0 42 _pc = pc;
duke@0 43 assert(pc != NULL, "no pc?");
duke@0 44 _cb = CodeCache::find_blob(pc);
duke@0 45 _deopt_state = not_deoptimized;
duke@0 46 if (_cb != NULL && _cb->is_nmethod() && ((nmethod*)_cb)->is_deopt_pc(_pc)) {
duke@0 47 _pc = (((nmethod*)_cb)->get_original_pc(this));
duke@0 48 _deopt_state = is_deoptimized;
duke@0 49 } else {
duke@0 50 _deopt_state = not_deoptimized;
duke@0 51 }
duke@0 52 }
duke@0 53
duke@0 54 inline frame:: frame(intptr_t* sp, intptr_t* unextended_sp, intptr_t* fp, address pc) {
duke@0 55 _sp = sp;
duke@0 56 _unextended_sp = unextended_sp;
duke@0 57 _fp = fp;
duke@0 58 _pc = pc;
duke@0 59 assert(pc != NULL, "no pc?");
duke@0 60 _cb = CodeCache::find_blob(pc);
duke@0 61 _deopt_state = not_deoptimized;
duke@0 62 if (_cb != NULL && _cb->is_nmethod() && ((nmethod*)_cb)->is_deopt_pc(_pc)) {
duke@0 63 _pc = (((nmethod*)_cb)->get_original_pc(this));
duke@0 64 _deopt_state = is_deoptimized;
duke@0 65 } else {
duke@0 66 _deopt_state = not_deoptimized;
duke@0 67 }
duke@0 68 }
duke@0 69
duke@0 70 inline frame::frame(intptr_t* sp, intptr_t* fp) {
duke@0 71 _sp = sp;
duke@0 72 _unextended_sp = sp;
duke@0 73 _fp = fp;
duke@0 74 _pc = (address)(sp[-1]);
duke@0 75 assert(_pc != NULL, "no pc?");
duke@0 76 _cb = CodeCache::find_blob(_pc);
duke@0 77 // In case of native stubs, the pc retreived here might be
duke@0 78 // wrong. (the _last_native_pc will have the right value)
duke@0 79 // So do not put add any asserts on the _pc here.
duke@0 80
duke@0 81 // QQQ The above comment is wrong and has been wrong for years. This constructor
duke@0 82 // should (and MUST) not be called in that situation. In the native situation
duke@0 83 // the pc should be supplied to the constructor.
duke@0 84 _deopt_state = not_deoptimized;
duke@0 85 if (_cb != NULL && _cb->is_nmethod() && ((nmethod*)_cb)->is_deopt_pc(_pc)) {
duke@0 86 _pc = (((nmethod*)_cb)->get_original_pc(this));
duke@0 87 _deopt_state = is_deoptimized;
duke@0 88 } else {
duke@0 89 _deopt_state = not_deoptimized;
duke@0 90 }
duke@0 91 }
duke@0 92
duke@0 93 // Accessors
duke@0 94
duke@0 95 inline bool frame::equal(frame other) const {
duke@0 96 bool ret = sp() == other.sp()
duke@0 97 && unextended_sp() == other.unextended_sp()
duke@0 98 && fp() == other.fp()
duke@0 99 && pc() == other.pc();
duke@0 100 assert(!ret || ret && cb() == other.cb() && _deopt_state == other._deopt_state, "inconsistent construction");
duke@0 101 return ret;
duke@0 102 }
duke@0 103
duke@0 104 // Return unique id for this frame. The id must have a value where we can distinguish
duke@0 105 // identity and younger/older relationship. NULL represents an invalid (incomparable)
duke@0 106 // frame.
duke@0 107 inline intptr_t* frame::id(void) const { return unextended_sp(); }
duke@0 108
duke@0 109 // Relationals on frames based
duke@0 110 // Return true if the frame is younger (more recent activation) than the frame represented by id
duke@0 111 inline bool frame::is_younger(intptr_t* id) const { assert(this->id() != NULL && id != NULL, "NULL frame id");
duke@0 112 return this->id() < id ; }
duke@0 113
duke@0 114 // Return true if the frame is older (less recent activation) than the frame represented by id
duke@0 115 inline bool frame::is_older(intptr_t* id) const { assert(this->id() != NULL && id != NULL, "NULL frame id");
duke@0 116 return this->id() > id ; }
duke@0 117
duke@0 118
duke@0 119
duke@0 120 inline intptr_t* frame::link() const { return (intptr_t*) *(intptr_t **)addr_at(link_offset); }
duke@0 121 inline void frame::set_link(intptr_t* addr) { *(intptr_t **)addr_at(link_offset) = addr; }
duke@0 122
duke@0 123
duke@0 124 inline intptr_t* frame::unextended_sp() const { return _unextended_sp; }
duke@0 125
duke@0 126 // Return address:
duke@0 127
duke@0 128 inline address* frame::sender_pc_addr() const { return (address*) addr_at( return_addr_offset); }
duke@0 129 inline address frame::sender_pc() const { return *sender_pc_addr(); }
duke@0 130
duke@0 131 // return address of param, zero origin index.
duke@0 132 inline address* frame::native_param_addr(int idx) const { return (address*) addr_at( native_frame_initial_param_offset+idx); }
duke@0 133
duke@0 134 #ifdef CC_INTERP
duke@0 135
duke@0 136 inline interpreterState frame::get_interpreterState() const {
duke@0 137 return ((interpreterState)addr_at( -sizeof(BytecodeInterpreter)/wordSize ));
duke@0 138 }
duke@0 139
duke@0 140 inline intptr_t* frame::sender_sp() const {
duke@0 141 // Hmm this seems awfully expensive QQQ, is this really called with interpreted frames?
duke@0 142 if (is_interpreted_frame()) {
duke@0 143 assert(false, "should never happen");
duke@0 144 return get_interpreterState()->sender_sp();
duke@0 145 } else {
duke@0 146 return addr_at(sender_sp_offset);
duke@0 147 }
duke@0 148 }
duke@0 149
duke@0 150 inline intptr_t** frame::interpreter_frame_locals_addr() const {
duke@0 151 assert(is_interpreted_frame(), "must be interpreted");
duke@0 152 return &(get_interpreterState()->_locals);
duke@0 153 }
duke@0 154
duke@0 155 inline intptr_t* frame::interpreter_frame_bcx_addr() const {
duke@0 156 assert(is_interpreted_frame(), "must be interpreted");
duke@0 157 return (jint*) &(get_interpreterState()->_bcp);
duke@0 158 }
duke@0 159
duke@0 160
duke@0 161 // Constant pool cache
duke@0 162
duke@0 163 inline constantPoolCacheOop* frame::interpreter_frame_cache_addr() const {
duke@0 164 assert(is_interpreted_frame(), "must be interpreted");
duke@0 165 return &(get_interpreterState()->_constants);
duke@0 166 }
duke@0 167
duke@0 168 // Method
duke@0 169
duke@0 170 inline methodOop* frame::interpreter_frame_method_addr() const {
duke@0 171 assert(is_interpreted_frame(), "must be interpreted");
duke@0 172 return &(get_interpreterState()->_method);
duke@0 173 }
duke@0 174
duke@0 175 inline intptr_t* frame::interpreter_frame_mdx_addr() const {
duke@0 176 assert(is_interpreted_frame(), "must be interpreted");
duke@0 177 return (jint*) &(get_interpreterState()->_mdx);
duke@0 178 }
duke@0 179
duke@0 180 // top of expression stack
duke@0 181 inline intptr_t* frame::interpreter_frame_tos_address() const {
duke@0 182 assert(is_interpreted_frame(), "wrong frame type");
duke@0 183 return get_interpreterState()->_stack + 1;
duke@0 184 }
duke@0 185
duke@0 186 #else /* asm interpreter */
duke@0 187 inline intptr_t* frame::sender_sp() const { return addr_at( sender_sp_offset); }
duke@0 188
duke@0 189 inline intptr_t** frame::interpreter_frame_locals_addr() const {
duke@0 190 return (intptr_t**)addr_at(interpreter_frame_locals_offset);
duke@0 191 }
duke@0 192
duke@0 193 inline intptr_t* frame::interpreter_frame_last_sp() const {
duke@0 194 return *(intptr_t**)addr_at(interpreter_frame_last_sp_offset);
duke@0 195 }
duke@0 196
duke@0 197 inline intptr_t* frame::interpreter_frame_bcx_addr() const {
duke@0 198 return (intptr_t*)addr_at(interpreter_frame_bcx_offset);
duke@0 199 }
duke@0 200
duke@0 201
duke@0 202 inline intptr_t* frame::interpreter_frame_mdx_addr() const {
duke@0 203 return (intptr_t*)addr_at(interpreter_frame_mdx_offset);
duke@0 204 }
duke@0 205
duke@0 206
duke@0 207
duke@0 208 // Constant pool cache
duke@0 209
duke@0 210 inline constantPoolCacheOop* frame::interpreter_frame_cache_addr() const {
duke@0 211 return (constantPoolCacheOop*)addr_at(interpreter_frame_cache_offset);
duke@0 212 }
duke@0 213
duke@0 214 // Method
duke@0 215
duke@0 216 inline methodOop* frame::interpreter_frame_method_addr() const {
duke@0 217 return (methodOop*)addr_at(interpreter_frame_method_offset);
duke@0 218 }
duke@0 219
duke@0 220 // top of expression stack
duke@0 221 inline intptr_t* frame::interpreter_frame_tos_address() const {
duke@0 222 intptr_t* last_sp = interpreter_frame_last_sp();
duke@0 223 if (last_sp == NULL ) {
duke@0 224 return sp();
duke@0 225 } else {
duke@0 226 // sp() may have been extended by an adapter
duke@0 227 assert(last_sp < fp() && last_sp >= sp(), "bad tos");
duke@0 228 return last_sp;
duke@0 229 }
duke@0 230 }
duke@0 231
duke@0 232 #endif /* CC_INTERP */
duke@0 233
duke@0 234 inline int frame::pd_oop_map_offset_adjustment() const {
duke@0 235 return 0;
duke@0 236 }
duke@0 237
duke@0 238 inline int frame::interpreter_frame_monitor_size() {
duke@0 239 return BasicObjectLock::size();
duke@0 240 }
duke@0 241
duke@0 242
duke@0 243 // expression stack
duke@0 244 // (the max_stack arguments are used by the GC; see class FrameClosure)
duke@0 245
duke@0 246 inline intptr_t* frame::interpreter_frame_expression_stack() const {
duke@0 247 intptr_t* monitor_end = (intptr_t*) interpreter_frame_monitor_end();
duke@0 248 return monitor_end-1;
duke@0 249 }
duke@0 250
duke@0 251
duke@0 252 inline jint frame::interpreter_frame_expression_stack_direction() { return -1; }
duke@0 253
duke@0 254
duke@0 255 // Entry frames
duke@0 256
duke@0 257 inline JavaCallWrapper* frame::entry_frame_call_wrapper() const {
duke@0 258 return (JavaCallWrapper*)at(entry_frame_call_wrapper_offset);
duke@0 259 }
duke@0 260
duke@0 261
duke@0 262 // Compiled frames
duke@0 263
duke@0 264 inline int frame::local_offset_for_compiler(int local_index, int nof_args, int max_nof_locals, int max_nof_monitors) {
duke@0 265 return (nof_args - local_index + (local_index < nof_args ? 1: -1));
duke@0 266 }
duke@0 267
duke@0 268 inline int frame::monitor_offset_for_compiler(int local_index, int nof_args, int max_nof_locals, int max_nof_monitors) {
duke@0 269 return local_offset_for_compiler(local_index, nof_args, max_nof_locals, max_nof_monitors);
duke@0 270 }
duke@0 271
duke@0 272 inline int frame::min_local_offset_for_compiler(int nof_args, int max_nof_locals, int max_nof_monitors) {
duke@0 273 return (nof_args - (max_nof_locals + max_nof_monitors*2) - 1);
duke@0 274 }
duke@0 275
duke@0 276 inline bool frame::volatile_across_calls(Register reg) {
duke@0 277 return true;
duke@0 278 }
duke@0 279
duke@0 280
duke@0 281
duke@0 282 inline oop frame::saved_oop_result(RegisterMap* map) const {
duke@0 283 return *((oop*) map->location(rax->as_VMReg()));
duke@0 284 }
duke@0 285
duke@0 286 inline void frame::set_saved_oop_result(RegisterMap* map, oop obj) {
duke@0 287 *((oop*) map->location(rax->as_VMReg())) = obj;
duke@0 288 }