annotate src/share/vm/runtime/frame.hpp @ 2462:3cfb240033d1

7043301: assert(locals < caller->fp() || locals > (caller->fp() + 16)) failed: locals in save area Reviewed-by: kvn
author never
date Mon, 09 May 2011 19:45:52 -0700
parents 167b70ff3abc
children 5432047c7db7
rev   line source
duke@0 1 /*
trims@2273 2 * Copyright (c) 1997, 2011, Oracle and/or its affiliates. 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 *
trims@1472 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
trims@1472 20 * or visit www.oracle.com if you need additional information or have any
trims@1472 21 * questions.
duke@0 22 *
duke@0 23 */
duke@0 24
stefank@1879 25 #ifndef SHARE_VM_RUNTIME_FRAME_HPP
stefank@1879 26 #define SHARE_VM_RUNTIME_FRAME_HPP
stefank@1879 27
stefank@1879 28 #include "asm/assembler.hpp"
stefank@1879 29 #include "oops/methodOop.hpp"
stefank@1879 30 #include "runtime/basicLock.hpp"
stefank@1879 31 #include "runtime/monitorChunk.hpp"
stefank@1879 32 #include "runtime/registerMap.hpp"
stefank@1879 33 #include "utilities/top.hpp"
stefank@1879 34 #ifdef COMPILER2
stefank@1879 35 #ifdef TARGET_ARCH_MODEL_x86_32
stefank@1879 36 # include "adfiles/adGlobals_x86_32.hpp"
stefank@1879 37 #endif
stefank@1879 38 #ifdef TARGET_ARCH_MODEL_x86_64
stefank@1879 39 # include "adfiles/adGlobals_x86_64.hpp"
stefank@1879 40 #endif
stefank@1879 41 #ifdef TARGET_ARCH_MODEL_sparc
stefank@1879 42 # include "adfiles/adGlobals_sparc.hpp"
stefank@1879 43 #endif
stefank@1879 44 #ifdef TARGET_ARCH_MODEL_zero
stefank@1879 45 # include "adfiles/adGlobals_zero.hpp"
stefank@1879 46 #endif
bobv@2073 47 #ifdef TARGET_ARCH_MODEL_arm
bobv@2073 48 # include "adfiles/adGlobals_arm.hpp"
bobv@2073 49 #endif
bobv@2073 50 #ifdef TARGET_ARCH_MODEL_ppc
bobv@2073 51 # include "adfiles/adGlobals_ppc.hpp"
bobv@2073 52 #endif
stefank@1879 53 #endif
stefank@1879 54 #ifdef ZERO
stefank@1879 55 #ifdef TARGET_ARCH_zero
stefank@1879 56 # include "stack_zero.hpp"
stefank@1879 57 #endif
stefank@1879 58 #endif
stefank@1879 59
duke@0 60 typedef class BytecodeInterpreter* interpreterState;
duke@0 61
duke@0 62 class CodeBlob;
never@2433 63 class FrameValues;
bobv@1601 64 class vframeArray;
duke@0 65
duke@0 66
duke@0 67 // A frame represents a physical stack frame (an activation). Frames
duke@0 68 // can be C or Java frames, and the Java frames can be interpreted or
duke@0 69 // compiled. In contrast, vframes represent source-level activations,
duke@0 70 // so that one physical frame can correspond to multiple source level
duke@0 71 // frames because of inlining.
duke@0 72
duke@0 73 class frame VALUE_OBJ_CLASS_SPEC {
duke@0 74 private:
duke@0 75 // Instance variables:
duke@0 76 intptr_t* _sp; // stack pointer (from Thread::last_Java_sp)
duke@0 77 address _pc; // program counter (the next instruction after the call)
duke@0 78
duke@0 79 CodeBlob* _cb; // CodeBlob that "owns" pc
duke@0 80 enum deopt_state {
duke@0 81 not_deoptimized,
duke@0 82 is_deoptimized,
duke@0 83 unknown
duke@0 84 };
duke@0 85
duke@0 86 deopt_state _deopt_state;
duke@0 87
duke@0 88 public:
duke@0 89 // Constructors
duke@0 90 frame();
duke@0 91
duke@0 92 // Accessors
duke@0 93
duke@0 94 // pc: Returns the pc at which this frame will continue normally.
duke@0 95 // It must point at the beginning of the next instruction to execute.
duke@0 96 address pc() const { return _pc; }
duke@0 97
duke@0 98 // This returns the pc that if you were in the debugger you'd see. Not
duke@0 99 // the idealized value in the frame object. This undoes the magic conversion
duke@0 100 // that happens for deoptimized frames. In addition it makes the value the
duke@0 101 // hardware would want to see in the native frame. The only user (at this point)
duke@0 102 // is deoptimization. It likely no one else should ever use it.
duke@0 103 address raw_pc() const;
duke@0 104
duke@0 105 void set_pc( address newpc );
duke@0 106
duke@0 107 intptr_t* sp() const { return _sp; }
duke@0 108 void set_sp( intptr_t* newsp ) { _sp = newsp; }
duke@0 109
duke@0 110
duke@0 111 CodeBlob* cb() const { return _cb; }
duke@0 112
duke@0 113 // patching operations
duke@0 114 void patch_pc(Thread* thread, address pc);
duke@0 115
duke@0 116 // Every frame needs to return a unique id which distinguishes it from all other frames.
duke@0 117 // For sparc and ia32 use sp. ia64 can have memory frames that are empty so multiple frames
duke@0 118 // will have identical sp values. For ia64 the bsp (fp) value will serve. No real frame
duke@0 119 // should have an id() of NULL so it is a distinguishing value for an unmatchable frame.
duke@0 120 // We also have relationals which allow comparing a frame to anoth frame's id() allow
duke@0 121 // us to distinguish younger (more recent activation) from older (less recent activations)
duke@0 122 // A NULL id is only valid when comparing for equality.
duke@0 123
duke@0 124 intptr_t* id(void) const;
duke@0 125 bool is_younger(intptr_t* id) const;
duke@0 126 bool is_older(intptr_t* id) const;
duke@0 127
duke@0 128 // testers
duke@0 129
duke@0 130 // Compares for strict equality. Rarely used or needed.
duke@0 131 // It can return a different result than f1.id() == f2.id()
duke@0 132 bool equal(frame other) const;
duke@0 133
duke@0 134 // type testers
duke@0 135 bool is_interpreted_frame() const;
duke@0 136 bool is_java_frame() const;
duke@0 137 bool is_entry_frame() const; // Java frame called from C?
never@2460 138 bool is_ricochet_frame() const;
duke@0 139 bool is_native_frame() const;
duke@0 140 bool is_runtime_frame() const;
duke@0 141 bool is_compiled_frame() const;
duke@0 142 bool is_safepoint_blob_frame() const;
duke@0 143 bool is_deoptimized_frame() const;
duke@0 144
duke@0 145 // testers
duke@0 146 bool is_first_frame() const; // oldest frame? (has no sender)
duke@0 147 bool is_first_java_frame() const; // same for Java frame
duke@0 148
sgoldman@107 149 bool is_interpreted_frame_valid(JavaThread* thread) const; // performs sanity checks on interpreted frames.
duke@0 150
duke@0 151 // tells whether this frame is marked for deoptimization
duke@0 152 bool should_be_deoptimized() const;
duke@0 153
duke@0 154 // tells whether this frame can be deoptimized
duke@0 155 bool can_be_deoptimized() const;
duke@0 156
duke@0 157 // returns the frame size in stack slots
cfang@793 158 int frame_size(RegisterMap* map) const;
duke@0 159
duke@0 160 // returns the sending frame
duke@0 161 frame sender(RegisterMap* map) const;
duke@0 162
duke@0 163 // for Profiling - acting on another frame. walks sender frames
duke@0 164 // if valid.
duke@0 165 frame profile_find_Java_sender_frame(JavaThread *thread);
duke@0 166 bool safe_for_sender(JavaThread *thread);
duke@0 167
duke@0 168 // returns the sender, but skips conversion frames
duke@0 169 frame real_sender(RegisterMap* map) const;
duke@0 170
duke@0 171 // returns the the sending Java frame, skipping any intermediate C frames
duke@0 172 // NB: receiver must not be first frame
duke@0 173 frame java_sender() const;
duke@0 174
duke@0 175 private:
duke@0 176 // Helper methods for better factored code in frame::sender
duke@0 177 frame sender_for_compiled_frame(RegisterMap* map) const;
duke@0 178 frame sender_for_entry_frame(RegisterMap* map) const;
never@2460 179 frame sender_for_ricochet_frame(RegisterMap* map) const;
duke@0 180 frame sender_for_interpreter_frame(RegisterMap* map) const;
duke@0 181 frame sender_for_native_frame(RegisterMap* map) const;
duke@0 182
duke@0 183 // All frames:
duke@0 184
duke@0 185 // A low-level interface for vframes:
duke@0 186
duke@0 187 public:
duke@0 188
duke@0 189 intptr_t* addr_at(int index) const { return &fp()[index]; }
duke@0 190 intptr_t at(int index) const { return *addr_at(index); }
duke@0 191
duke@0 192 // accessors for locals
duke@0 193 oop obj_at(int offset) const { return *obj_at_addr(offset); }
duke@0 194 void obj_at_put(int offset, oop value) { *obj_at_addr(offset) = value; }
duke@0 195
duke@0 196 jint int_at(int offset) const { return *int_at_addr(offset); }
duke@0 197 void int_at_put(int offset, jint value) { *int_at_addr(offset) = value; }
duke@0 198
duke@0 199 oop* obj_at_addr(int offset) const { return (oop*) addr_at(offset); }
duke@0 200
duke@0 201 oop* adjusted_obj_at_addr(methodOop method, int index) { return obj_at_addr(adjust_offset(method, index)); }
duke@0 202
duke@0 203 private:
duke@0 204 jint* int_at_addr(int offset) const { return (jint*) addr_at(offset); }
duke@0 205
duke@0 206 public:
duke@0 207 // Link (i.e., the pointer to the previous frame)
duke@0 208 intptr_t* link() const;
duke@0 209 void set_link(intptr_t* addr);
duke@0 210
duke@0 211 // Return address
duke@0 212 address sender_pc() const;
duke@0 213
duke@0 214 // Support for deoptimization
never@1647 215 void deoptimize(JavaThread* thread);
duke@0 216
duke@0 217 // The frame's original SP, before any extension by an interpreted callee;
duke@0 218 // used for packing debug info into vframeArray objects and vframeArray lookup.
duke@0 219 intptr_t* unextended_sp() const;
duke@0 220
duke@0 221 // returns the stack pointer of the calling frame
duke@0 222 intptr_t* sender_sp() const;
duke@0 223
duke@0 224
duke@0 225 // Interpreter frames:
duke@0 226
duke@0 227 private:
duke@0 228 intptr_t** interpreter_frame_locals_addr() const;
duke@0 229 intptr_t* interpreter_frame_bcx_addr() const;
duke@0 230 intptr_t* interpreter_frame_mdx_addr() const;
duke@0 231
duke@0 232 public:
duke@0 233 // Locals
duke@0 234
duke@0 235 // The _at version returns a pointer because the address is used for GC.
duke@0 236 intptr_t* interpreter_frame_local_at(int index) const;
duke@0 237
duke@0 238 void interpreter_frame_set_locals(intptr_t* locs);
duke@0 239
duke@0 240 // byte code index/pointer (use these functions for unchecked frame access only!)
duke@0 241 intptr_t interpreter_frame_bcx() const { return *interpreter_frame_bcx_addr(); }
duke@0 242 void interpreter_frame_set_bcx(intptr_t bcx);
duke@0 243
duke@0 244 // byte code index
duke@0 245 jint interpreter_frame_bci() const;
duke@0 246 void interpreter_frame_set_bci(jint bci);
duke@0 247
duke@0 248 // byte code pointer
duke@0 249 address interpreter_frame_bcp() const;
duke@0 250 void interpreter_frame_set_bcp(address bcp);
duke@0 251
duke@0 252 // Unchecked access to the method data index/pointer.
duke@0 253 // Only use this if you know what you are doing.
duke@0 254 intptr_t interpreter_frame_mdx() const { return *interpreter_frame_mdx_addr(); }
duke@0 255 void interpreter_frame_set_mdx(intptr_t mdx);
duke@0 256
duke@0 257 // method data pointer
duke@0 258 address interpreter_frame_mdp() const;
duke@0 259 void interpreter_frame_set_mdp(address dp);
duke@0 260
duke@0 261 // Find receiver out of caller's (compiled) argument list
duke@0 262 oop retrieve_receiver(RegisterMap *reg_map);
duke@0 263
duke@0 264 // Return the monitor owner and BasicLock for compiled synchronized
duke@0 265 // native methods so that biased locking can revoke the receiver's
kamg@1926 266 // bias if necessary. This is also used by JVMTI's GetLocalInstance method
kamg@1926 267 // (via VM_GetReceiver) to retrieve the receiver from a native wrapper frame.
kamg@1926 268 BasicLock* get_native_monitor();
kamg@1926 269 oop get_native_receiver();
duke@0 270
duke@0 271 // Find receiver for an invoke when arguments are just pushed on stack (i.e., callee stack-frame is
duke@0 272 // not setup)
coleenp@2062 273 oop interpreter_callee_receiver(Symbol* signature) { return *interpreter_callee_receiver_addr(signature); }
duke@0 274
duke@0 275
coleenp@2062 276 oop* interpreter_callee_receiver_addr(Symbol* signature);
duke@0 277
duke@0 278
duke@0 279 // expression stack (may go up or down, direction == 1 or -1)
duke@0 280 public:
duke@0 281 intptr_t* interpreter_frame_expression_stack() const;
duke@0 282 static jint interpreter_frame_expression_stack_direction();
duke@0 283
duke@0 284 // The _at version returns a pointer because the address is used for GC.
duke@0 285 intptr_t* interpreter_frame_expression_stack_at(jint offset) const;
duke@0 286
duke@0 287 // top of expression stack
duke@0 288 intptr_t* interpreter_frame_tos_at(jint offset) const;
duke@0 289 intptr_t* interpreter_frame_tos_address() const;
duke@0 290
duke@0 291
duke@0 292 jint interpreter_frame_expression_stack_size() const;
duke@0 293
duke@0 294 intptr_t* interpreter_frame_sender_sp() const;
duke@0 295
duke@0 296 #ifndef CC_INTERP
duke@0 297 // template based interpreter deoptimization support
duke@0 298 void set_interpreter_frame_sender_sp(intptr_t* sender_sp);
duke@0 299 void interpreter_frame_set_monitor_end(BasicObjectLock* value);
duke@0 300 #endif // CC_INTERP
duke@0 301
duke@0 302 // BasicObjectLocks:
duke@0 303 //
duke@0 304 // interpreter_frame_monitor_begin is higher in memory than interpreter_frame_monitor_end
duke@0 305 // Interpreter_frame_monitor_begin points to one element beyond the oldest one,
duke@0 306 // interpreter_frame_monitor_end points to the youngest one, or if there are none,
duke@0 307 // it points to one beyond where the first element will be.
duke@0 308 // interpreter_frame_monitor_size reports the allocation size of a monitor in the interpreter stack.
duke@0 309 // this value is >= BasicObjectLock::size(), and may be rounded up
duke@0 310
duke@0 311 BasicObjectLock* interpreter_frame_monitor_begin() const;
duke@0 312 BasicObjectLock* interpreter_frame_monitor_end() const;
duke@0 313 BasicObjectLock* next_monitor_in_interpreter_frame(BasicObjectLock* current) const;
duke@0 314 BasicObjectLock* previous_monitor_in_interpreter_frame(BasicObjectLock* current) const;
duke@0 315 static int interpreter_frame_monitor_size();
duke@0 316
duke@0 317 void interpreter_frame_verify_monitor(BasicObjectLock* value) const;
duke@0 318
duke@0 319 // Tells whether the current interpreter_frame frame pointer
duke@0 320 // corresponds to the old compiled/deoptimized fp
duke@0 321 // The receiver used to be a top level frame
duke@0 322 bool interpreter_frame_equals_unpacked_fp(intptr_t* fp);
duke@0 323
duke@0 324 // Return/result value from this interpreter frame
duke@0 325 // If the method return type is T_OBJECT or T_ARRAY populates oop_result
duke@0 326 // For other (non-T_VOID) the appropriate field in the jvalue is populated
duke@0 327 // with the result value.
duke@0 328 // Should only be called when at method exit when the method is not
duke@0 329 // exiting due to an exception.
duke@0 330 BasicType interpreter_frame_result(oop* oop_result, jvalue* value_result);
duke@0 331
duke@0 332 public:
duke@0 333 // Method & constant pool cache
duke@0 334 methodOop interpreter_frame_method() const;
duke@0 335 void interpreter_frame_set_method(methodOop method);
duke@0 336 methodOop* interpreter_frame_method_addr() const;
duke@0 337 constantPoolCacheOop* interpreter_frame_cache_addr() const;
bobv@1601 338 #ifdef PPC
bobv@1601 339 oop* interpreter_frame_mirror_addr() const;
bobv@1601 340 #endif
duke@0 341
duke@0 342 public:
duke@0 343 // Entry frames
duke@0 344 JavaCallWrapper* entry_frame_call_wrapper() const;
duke@0 345 intptr_t* entry_frame_argument_at(int offset) const;
duke@0 346
duke@0 347 // tells whether there is another chunk of Delta stack above
duke@0 348 bool entry_frame_is_first() const;
duke@0 349
duke@0 350 // Compiled frames:
duke@0 351
duke@0 352 public:
duke@0 353 // Given the index of a local, and the number of argument words
duke@0 354 // in this stack frame, tell which word of the stack frame to find
duke@0 355 // the local in. Arguments are stored above the ofp/rpc pair,
duke@0 356 // while other locals are stored below it.
duke@0 357 // Since monitors (BasicLock blocks) are also assigned indexes,
duke@0 358 // but may have different storage requirements, their presence
duke@0 359 // can also affect the calculation of offsets.
duke@0 360 static int local_offset_for_compiler(int local_index, int nof_args, int max_nof_locals, int max_nof_monitors);
duke@0 361
duke@0 362 // Given the index of a monitor, etc., tell which word of the
duke@0 363 // stack frame contains the start of the BasicLock block.
duke@0 364 // Note that the local index by convention is the __higher__
duke@0 365 // of the two indexes allocated to the block.
duke@0 366 static int monitor_offset_for_compiler(int local_index, int nof_args, int max_nof_locals, int max_nof_monitors);
duke@0 367
duke@0 368 // Tell the smallest value that local_offset_for_compiler will attain.
duke@0 369 // This is used to help determine how much stack frame to allocate.
duke@0 370 static int min_local_offset_for_compiler(int nof_args, int max_nof_locals, int max_nof_monitors);
duke@0 371
duke@0 372 // Tells if this register must be spilled during a call.
duke@0 373 // On Intel, all registers are smashed by calls.
duke@0 374 static bool volatile_across_calls(Register reg);
duke@0 375
duke@0 376
duke@0 377 // Safepoints
duke@0 378
duke@0 379 public:
duke@0 380 oop saved_oop_result(RegisterMap* map) const;
duke@0 381 void set_saved_oop_result(RegisterMap* map, oop obj);
duke@0 382
duke@0 383 // For debugging
duke@0 384 private:
duke@0 385 const char* print_name() const;
duke@0 386
never@2433 387 void describe_pd(FrameValues& values, int frame_no);
never@2433 388
duke@0 389 public:
duke@0 390 void print_value() const { print_value_on(tty,NULL); }
duke@0 391 void print_value_on(outputStream* st, JavaThread *thread) const;
duke@0 392 void print_on(outputStream* st) const;
duke@0 393 void interpreter_frame_print_on(outputStream* st) const;
duke@0 394 void print_on_error(outputStream* st, char* buf, int buflen, bool verbose = false) const;
duke@0 395
never@2433 396 // Add annotated descriptions of memory locations belonging to this frame to values
never@2433 397 void describe(FrameValues& values, int frame_no);
never@2433 398
duke@0 399 // Conversion from an VMReg to physical stack location
duke@0 400 oop* oopmapreg_to_location(VMReg reg, const RegisterMap* regmap) const;
duke@0 401
duke@0 402 // Oops-do's
coleenp@2062 403 void oops_compiled_arguments_do(Symbol* signature, bool has_receiver, const RegisterMap* reg_map, OopClosure* f);
duke@0 404 void oops_interpreted_do(OopClosure* f, const RegisterMap* map, bool query_oop_map_cache = true);
never@2460 405 void oops_ricochet_do(OopClosure* f, const RegisterMap* map);
duke@0 406
duke@0 407 private:
coleenp@2062 408 void oops_interpreted_arguments_do(Symbol* signature, bool has_receiver, OopClosure* f);
duke@0 409
duke@0 410 // Iteration of oops
jrose@989 411 void oops_do_internal(OopClosure* f, CodeBlobClosure* cf, RegisterMap* map, bool use_interpreter_oop_map_cache);
duke@0 412 void oops_entry_do(OopClosure* f, const RegisterMap* map);
jrose@989 413 void oops_code_blob_do(OopClosure* f, CodeBlobClosure* cf, const RegisterMap* map);
duke@0 414 int adjust_offset(methodOop method, int index); // helper for above fn
duke@0 415 public:
duke@0 416 // Memory management
jrose@989 417 void oops_do(OopClosure* f, CodeBlobClosure* cf, RegisterMap* map) { oops_do_internal(f, cf, map, true); }
jrose@989 418 void nmethods_do(CodeBlobClosure* cf);
duke@0 419
duke@0 420 void gc_prologue();
duke@0 421 void gc_epilogue();
duke@0 422 void pd_gc_epilog();
duke@0 423
duke@0 424 # ifdef ENABLE_ZAP_DEAD_LOCALS
duke@0 425 private:
duke@0 426 class CheckValueClosure: public OopClosure {
coleenp@113 427 public:
coleenp@113 428 void do_oop(oop* p);
coleenp@113 429 void do_oop(narrowOop* p) { ShouldNotReachHere(); }
duke@0 430 };
duke@0 431 static CheckValueClosure _check_value;
duke@0 432
duke@0 433 class CheckOopClosure: public OopClosure {
coleenp@113 434 public:
coleenp@113 435 void do_oop(oop* p);
coleenp@113 436 void do_oop(narrowOop* p) { ShouldNotReachHere(); }
duke@0 437 };
duke@0 438 static CheckOopClosure _check_oop;
duke@0 439
duke@0 440 static void check_derived_oop(oop* base, oop* derived);
duke@0 441
duke@0 442 class ZapDeadClosure: public OopClosure {
coleenp@113 443 public:
coleenp@113 444 void do_oop(oop* p);
coleenp@113 445 void do_oop(narrowOop* p) { ShouldNotReachHere(); }
duke@0 446 };
duke@0 447 static ZapDeadClosure _zap_dead;
duke@0 448
duke@0 449 public:
duke@0 450 // Zapping
duke@0 451 void zap_dead_locals (JavaThread* thread, const RegisterMap* map);
duke@0 452 void zap_dead_interpreted_locals(JavaThread* thread, const RegisterMap* map);
duke@0 453 void zap_dead_compiled_locals (JavaThread* thread, const RegisterMap* map);
duke@0 454 void zap_dead_entry_locals (JavaThread* thread, const RegisterMap* map);
duke@0 455 void zap_dead_deoptimized_locals(JavaThread* thread, const RegisterMap* map);
duke@0 456 # endif
duke@0 457 // Verification
duke@0 458 void verify(const RegisterMap* map);
duke@0 459 static bool verify_return_pc(address x);
duke@0 460 static bool is_bci(intptr_t bcx);
duke@0 461 // Usage:
duke@0 462 // assert(frame::verify_return_pc(return_address), "must be a return pc");
duke@0 463
duke@0 464 int pd_oop_map_offset_adjustment() const;
duke@0 465
stefank@1879 466 #ifdef TARGET_ARCH_x86
stefank@1879 467 # include "frame_x86.hpp"
stefank@1879 468 #endif
stefank@1879 469 #ifdef TARGET_ARCH_sparc
stefank@1879 470 # include "frame_sparc.hpp"
stefank@1879 471 #endif
stefank@1879 472 #ifdef TARGET_ARCH_zero
stefank@1879 473 # include "frame_zero.hpp"
stefank@1879 474 #endif
bobv@2073 475 #ifdef TARGET_ARCH_arm
bobv@2073 476 # include "frame_arm.hpp"
bobv@2073 477 #endif
bobv@2073 478 #ifdef TARGET_ARCH_ppc
bobv@2073 479 # include "frame_ppc.hpp"
bobv@2073 480 #endif
stefank@1879 481
duke@0 482 };
duke@0 483
never@2433 484 #ifdef ASSERT
never@2433 485 // A simple class to describe a location on the stack
never@2433 486 class FrameValue VALUE_OBJ_CLASS_SPEC {
never@2433 487 public:
never@2433 488 intptr_t* location;
never@2433 489 char* description;
never@2433 490 int owner;
never@2433 491 int priority;
never@2433 492 };
never@2433 493
never@2433 494
never@2433 495 // A collection of described stack values that can print a symbolic
never@2433 496 // description of the stack memory. Interpreter frame values can be
never@2433 497 // in the caller frames so all the values are collected first and then
never@2433 498 // sorted before being printed.
never@2433 499 class FrameValues {
never@2433 500 private:
never@2433 501 GrowableArray<FrameValue> _values;
never@2433 502
never@2433 503 static int compare(FrameValue* a, FrameValue* b) {
never@2433 504 if (a->location == b->location) {
never@2433 505 return a->priority - b->priority;
never@2433 506 }
never@2433 507 return a->location - b->location;
never@2433 508 }
never@2433 509
never@2433 510 public:
never@2433 511 // Used by frame functions to describe locations.
never@2433 512 void describe(int owner, intptr_t* location, const char* description, int priority = 0);
never@2433 513
never@2462 514 void validate();
never@2433 515 void print();
never@2433 516 };
never@2433 517
never@2433 518 #endif
duke@0 519
duke@0 520 //
duke@0 521 // StackFrameStream iterates through the frames of a thread starting from
duke@0 522 // top most frame. It automatically takes care of updating the location of
duke@0 523 // all (callee-saved) registers. Notice: If a thread is stopped at
duke@0 524 // a safepoint, all registers are saved, not only the callee-saved ones.
duke@0 525 //
duke@0 526 // Use:
duke@0 527 //
duke@0 528 // for(StackFrameStream fst(thread); !fst.is_done(); fst.next()) {
duke@0 529 // ...
duke@0 530 // }
duke@0 531 //
duke@0 532 class StackFrameStream : public StackObj {
duke@0 533 private:
duke@0 534 frame _fr;
duke@0 535 RegisterMap _reg_map;
duke@0 536 bool _is_done;
duke@0 537 public:
duke@0 538 StackFrameStream(JavaThread *thread, bool update = true);
duke@0 539
duke@0 540 // Iteration
duke@0 541 bool is_done() { return (_is_done) ? true : (_is_done = _fr.is_first_frame(), false); }
duke@0 542 void next() { if (!_is_done) _fr = _fr.sender(&_reg_map); }
duke@0 543
duke@0 544 // Query
duke@0 545 frame *current() { return &_fr; }
duke@0 546 RegisterMap* register_map() { return &_reg_map; }
duke@0 547 };
stefank@1879 548
stefank@1879 549 #endif // SHARE_VM_RUNTIME_FRAME_HPP