frame.hpp revision 4802:f2110083203d
1126288Smtm/* 298186Sgordon * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. 378344Sobrien * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 498186Sgordon * 578344Sobrien * This code is free software; you can redistribute it and/or modify it 678344Sobrien * under the terms of the GNU General Public License version 2 only, as 778344Sobrien * published by the Free Software Foundation. 878344Sobrien * 978344Sobrien * This code is distributed in the hope that it will be useful, but WITHOUT 1078344Sobrien * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1178344Sobrien * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1278344Sobrien * version 2 for more details (a copy is included in the LICENSE file that 1378344Sobrien * accompanied this code). 1478344Sobrien * 1578344Sobrien * You should have received a copy of the GNU General Public License version 1678344Sobrien * 2 along with this work; if not, write to the Free Software Foundation, 1778344Sobrien * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 1878344Sobrien * 1978344Sobrien * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2078344Sobrien * or visit www.oracle.com if you need additional information or have any 2178344Sobrien * questions. 2278344Sobrien * 2378344Sobrien */ 2478344Sobrien 2578344Sobrien#ifndef SHARE_VM_RUNTIME_FRAME_HPP 2678344Sobrien#define SHARE_VM_RUNTIME_FRAME_HPP 2778344Sobrien 2878344Sobrien#include "oops/method.hpp" 2978344Sobrien#include "runtime/basicLock.hpp" 3078344Sobrien#include "runtime/monitorChunk.hpp" 3178344Sobrien#include "runtime/registerMap.hpp" 3278344Sobrien#include "utilities/top.hpp" 3378344Sobrien#ifdef COMPILER2 3478344Sobrien#ifdef TARGET_ARCH_MODEL_x86_32 3578344Sobrien# include "adfiles/adGlobals_x86_32.hpp" 3678344Sobrien#endif 3778344Sobrien#ifdef TARGET_ARCH_MODEL_x86_64 3878344Sobrien# include "adfiles/adGlobals_x86_64.hpp" 3978344Sobrien#endif 4078344Sobrien#ifdef TARGET_ARCH_MODEL_sparc 4178344Sobrien# include "adfiles/adGlobals_sparc.hpp" 4278344Sobrien#endif 4398186Sgordon#ifdef TARGET_ARCH_MODEL_zero 4498186Sgordon# include "adfiles/adGlobals_zero.hpp" 4598186Sgordon#endif 46131550Scperciva#ifdef TARGET_ARCH_MODEL_arm 47131550Scperciva# include "adfiles/adGlobals_arm.hpp" 48131550Scperciva#endif 49131550Scperciva#ifdef TARGET_ARCH_MODEL_ppc 5098186Sgordon# include "adfiles/adGlobals_ppc.hpp" 5198186Sgordon#endif 5298186Sgordon#endif 53103018Sgordon#ifdef ZERO 54124832Smtm#ifdef TARGET_ARCH_zero 55124832Smtm# include "stack_zero.hpp" 5698186Sgordon#endif 57103018Sgordon#endif 5898186Sgordon 5998186Sgordontypedef class BytecodeInterpreter* interpreterState; 6098186Sgordon 6198186Sgordonclass CodeBlob; 6298186Sgordonclass FrameValues; 6398186Sgordonclass vframeArray; 6498186Sgordon 6598186Sgordon 6698186Sgordon// A frame represents a physical stack frame (an activation). Frames 6778344Sobrien// can be C or Java frames, and the Java frames can be interpreted or 6878344Sobrien// compiled. In contrast, vframes represent source-level activations, 6978344Sobrien// so that one physical frame can correspond to multiple source level 7078344Sobrien// frames because of inlining. 7198186Sgordon 7298186Sgordonclass frame VALUE_OBJ_CLASS_SPEC { 7398186Sgordon private: 7498186Sgordon // Instance variables: 7598186Sgordon intptr_t* _sp; // stack pointer (from Thread::last_Java_sp) 7698186Sgordon address _pc; // program counter (the next instruction after the call) 7798186Sgordon 7898186Sgordon CodeBlob* _cb; // CodeBlob that "owns" pc 7998186Sgordon enum deopt_state { 8098186Sgordon not_deoptimized, 8198186Sgordon is_deoptimized, 8298186Sgordon unknown 8398186Sgordon }; 8498186Sgordon 8598186Sgordon deopt_state _deopt_state; 8698186Sgordon 8798186Sgordon public: 88103018Sgordon // Constructors 8998186Sgordon frame(); 9098186Sgordon 9198186Sgordon // Accessors 9298186Sgordon 9398186Sgordon // pc: Returns the pc at which this frame will continue normally. 9498186Sgordon // It must point at the beginning of the next instruction to execute. 9598186Sgordon address pc() const { return _pc; } 9698186Sgordon 9798186Sgordon // This returns the pc that if you were in the debugger you'd see. Not 9898186Sgordon // the idealized value in the frame object. This undoes the magic conversion 9998186Sgordon // that happens for deoptimized frames. In addition it makes the value the 10098186Sgordon // hardware would want to see in the native frame. The only user (at this point) 10198186Sgordon // is deoptimization. It likely no one else should ever use it. 10298186Sgordon address raw_pc() const; 10398186Sgordon 10498186Sgordon void set_pc( address newpc ); 10598186Sgordon 10698186Sgordon intptr_t* sp() const { return _sp; } 10798186Sgordon void set_sp( intptr_t* newsp ) { _sp = newsp; } 10898186Sgordon 10998186Sgordon 11098186Sgordon CodeBlob* cb() const { return _cb; } 11198186Sgordon 11298186Sgordon // patching operations 113146490Sschweikh void patch_pc(Thread* thread, address pc); 11498186Sgordon 11598186Sgordon // Every frame needs to return a unique id which distinguishes it from all other frames. 11698186Sgordon // For sparc and ia32 use sp. ia64 can have memory frames that are empty so multiple frames 11798186Sgordon // will have identical sp values. For ia64 the bsp (fp) value will serve. No real frame 11898186Sgordon // should have an id() of NULL so it is a distinguishing value for an unmatchable frame. 11998186Sgordon // We also have relationals which allow comparing a frame to anoth frame's id() allow 12098186Sgordon // us to distinguish younger (more recent activation) from older (less recent activations) 12178344Sobrien // A NULL id is only valid when comparing for equality. 12278344Sobrien 12378344Sobrien intptr_t* id(void) const; 12478344Sobrien bool is_younger(intptr_t* id) const; 12578344Sobrien bool is_older(intptr_t* id) const; 12678344Sobrien 12778344Sobrien // testers 12898186Sgordon 12978344Sobrien // Compares for strict equality. Rarely used or needed. 13078344Sobrien // It can return a different result than f1.id() == f2.id() 13178344Sobrien bool equal(frame other) const; 13278344Sobrien 13378344Sobrien // type testers 13478344Sobrien bool is_interpreted_frame() const; 13578344Sobrien bool is_java_frame() const; 13678344Sobrien bool is_entry_frame() const; // Java frame called from C? 13778344Sobrien bool is_stub_frame() const; 13878344Sobrien bool is_ignored_frame() const; 13978344Sobrien bool is_native_frame() const; 14078344Sobrien bool is_runtime_frame() const; 141106643Sgordon bool is_compiled_frame() const; 14278344Sobrien bool is_safepoint_blob_frame() const; 14378344Sobrien bool is_deoptimized_frame() const; 14478344Sobrien 14578344Sobrien // testers 14678344Sobrien bool is_first_frame() const; // oldest frame? (has no sender) 14798186Sgordon bool is_first_java_frame() const; // same for Java frame 14898186Sgordon 14978344Sobrien bool is_interpreted_frame_valid(JavaThread* thread) const; // performs sanity checks on interpreted frames. 15098186Sgordon 15198186Sgordon // tells whether this frame is marked for deoptimization 15298186Sgordon bool should_be_deoptimized() const; 153126286Smtm 15498186Sgordon // tells whether this frame can be deoptimized 15598186Sgordon bool can_be_deoptimized() const; 15698186Sgordon 15798186Sgordon // returns the frame size in stack slots 15898186Sgordon int frame_size(RegisterMap* map) const; 15978344Sobrien 16098186Sgordon // returns the sending frame 16198186Sgordon frame sender(RegisterMap* map) const; 16298186Sgordon 16398186Sgordon // for Profiling - acting on another frame. walks sender frames 16498186Sgordon // if valid. 16578344Sobrien frame profile_find_Java_sender_frame(JavaThread *thread); 16678344Sobrien bool safe_for_sender(JavaThread *thread); 16798186Sgordon 16878344Sobrien // returns the sender, but skips conversion frames 16978344Sobrien frame real_sender(RegisterMap* map) const; 170126285Smtm 17178344Sobrien // returns the the sending Java frame, skipping any intermediate C frames 17278344Sobrien // NB: receiver must not be first frame 173126285Smtm frame java_sender() const; 17478344Sobrien 17578344Sobrien private: 176126285Smtm // Helper methods for better factored code in frame::sender 177126285Smtm frame sender_for_compiled_frame(RegisterMap* map) const; 178126285Smtm frame sender_for_entry_frame(RegisterMap* map) const; 17978344Sobrien frame sender_for_interpreter_frame(RegisterMap* map) const; 18078344Sobrien frame sender_for_native_frame(RegisterMap* map) const; 18198186Sgordon 18278344Sobrien // All frames: 18378344Sobrien 18478344Sobrien // A low-level interface for vframes: 18578344Sobrien 18698186Sgordon public: 18798186Sgordon 18878344Sobrien intptr_t* addr_at(int index) const { return &fp()[index]; } 18998186Sgordon intptr_t at(int index) const { return *addr_at(index); } 19098186Sgordon 19178344Sobrien // accessors for locals 19278344Sobrien oop obj_at(int offset) const { return *obj_at_addr(offset); } 19378344Sobrien void obj_at_put(int offset, oop value) { *obj_at_addr(offset) = value; } 19478344Sobrien 19578344Sobrien jint int_at(int offset) const { return *int_at_addr(offset); } 19698186Sgordon void int_at_put(int offset, jint value) { *int_at_addr(offset) = value; } 19778344Sobrien 19898186Sgordon oop* obj_at_addr(int offset) const { return (oop*) addr_at(offset); } 19978344Sobrien 20078344Sobrien oop* adjusted_obj_at_addr(Method* method, int index) { return obj_at_addr(adjust_offset(method, index)); } 201131061Smtm 20278344Sobrien private: 20378344Sobrien jint* int_at_addr(int offset) const { return (jint*) addr_at(offset); } 20478344Sobrien 20578344Sobrien public: 206139949Skeramida // Link (i.e., the pointer to the previous frame) 20778344Sobrien intptr_t* link() const; 20878344Sobrien void set_link(intptr_t* addr); 20998186Sgordon 21078344Sobrien // Return address 21178344Sobrien address sender_pc() const; 21278344Sobrien 21398186Sgordon // Support for deoptimization 21478344Sobrien void deoptimize(JavaThread* thread); 21598186Sgordon 21698186Sgordon // The frame's original SP, before any extension by an interpreted callee; 21778344Sobrien // used for packing debug info into vframeArray objects and vframeArray lookup. 21878344Sobrien intptr_t* unextended_sp() const; 21978344Sobrien 22078344Sobrien // returns the stack pointer of the calling frame 22198186Sgordon intptr_t* sender_sp() const; 22278344Sobrien 22398186Sgordon // Returns the real 'frame pointer' for the current frame. 22478344Sobrien // This is the value expected by the platform ABI when it defines a 22598186Sgordon // frame pointer register. It may differ from the effective value of 22698186Sgordon // the FP register when that register is used in the JVM for other 22798186Sgordon // purposes (like compiled frames on some platforms). 22898186Sgordon // On other platforms, it is defined so that the stack area used by 22998186Sgordon // this frame goes from real_fp() to sp(). 23098186Sgordon intptr_t* real_fp() const; 23198186Sgordon 23298186Sgordon // Deoptimization info, if needed (platform dependent). 23398186Sgordon // Stored in the initial_info field of the unroll info, to be used by 23498186Sgordon // the platform dependent deoptimization blobs. 23598186Sgordon intptr_t *initial_deoptimization_info(); 23698186Sgordon 23798186Sgordon // Interpreter frames: 23898186Sgordon 23998186Sgordon private: 24098186Sgordon intptr_t** interpreter_frame_locals_addr() const; 24198186Sgordon intptr_t* interpreter_frame_bcx_addr() const; 24298186Sgordon intptr_t* interpreter_frame_mdx_addr() const; 24398186Sgordon 24498186Sgordon public: 24598186Sgordon // Locals 24698186Sgordon 24798186Sgordon // The _at version returns a pointer because the address is used for GC. 24898186Sgordon intptr_t* interpreter_frame_local_at(int index) const; 24998186Sgordon 25098186Sgordon void interpreter_frame_set_locals(intptr_t* locs); 25198186Sgordon 25298186Sgordon // byte code index/pointer (use these functions for unchecked frame access only!) 25398186Sgordon intptr_t interpreter_frame_bcx() const { return *interpreter_frame_bcx_addr(); } 25478344Sobrien void interpreter_frame_set_bcx(intptr_t bcx); 25598186Sgordon 25698186Sgordon // byte code index 25798186Sgordon jint interpreter_frame_bci() const; 25898186Sgordon void interpreter_frame_set_bci(jint bci); 25998186Sgordon 26098186Sgordon // byte code pointer 26178344Sobrien address interpreter_frame_bcp() const; 26298186Sgordon void interpreter_frame_set_bcp(address bcp); 26398186Sgordon 26498186Sgordon // Unchecked access to the method data index/pointer. 26598186Sgordon // Only use this if you know what you are doing. 26698186Sgordon intptr_t interpreter_frame_mdx() const { return *interpreter_frame_mdx_addr(); } 26798186Sgordon void interpreter_frame_set_mdx(intptr_t mdx); 26898186Sgordon 26998186Sgordon // method data pointer 27098186Sgordon address interpreter_frame_mdp() const; 27198186Sgordon void interpreter_frame_set_mdp(address dp); 27298186Sgordon 27398186Sgordon // Find receiver out of caller's (compiled) argument list 274126556Smtm oop retrieve_receiver(RegisterMap *reg_map); 27598186Sgordon 27698186Sgordon // Return the monitor owner and BasicLock for compiled synchronized 277146490Sschweikh // native methods so that biased locking can revoke the receiver's 278146490Sschweikh // bias if necessary. This is also used by JVMTI's GetLocalInstance method 279146490Sschweikh // (via VM_GetReceiver) to retrieve the receiver from a native wrapper frame. 280146490Sschweikh BasicLock* get_native_monitor(); 28198186Sgordon oop get_native_receiver(); 28298186Sgordon 28398186Sgordon // Find receiver for an invoke when arguments are just pushed on stack (i.e., callee stack-frame is 28498186Sgordon // not setup) 28598186Sgordon oop interpreter_callee_receiver(Symbol* signature) { return *interpreter_callee_receiver_addr(signature); } 286114272Smtm 28798186Sgordon 28898186Sgordon oop* interpreter_callee_receiver_addr(Symbol* signature); 28998186Sgordon 29098186Sgordon 29198186Sgordon // expression stack (may go up or down, direction == 1 or -1) 29298186Sgordon public: 29398186Sgordon intptr_t* interpreter_frame_expression_stack() const; 29498186Sgordon static jint interpreter_frame_expression_stack_direction(); 29598186Sgordon 296126286Smtm // The _at version returns a pointer because the address is used for GC. 29798186Sgordon intptr_t* interpreter_frame_expression_stack_at(jint offset) const; 29898186Sgordon 29998186Sgordon // top of expression stack 30098186Sgordon intptr_t* interpreter_frame_tos_at(jint offset) const; 30198186Sgordon intptr_t* interpreter_frame_tos_address() const; 30298186Sgordon 30398186Sgordon 30498186Sgordon jint interpreter_frame_expression_stack_size() const; 30598186Sgordon 30698186Sgordon intptr_t* interpreter_frame_sender_sp() const; 30798186Sgordon 30898186Sgordon#ifndef CC_INTERP 30998186Sgordon // template based interpreter deoptimization support 31078344Sobrien void set_interpreter_frame_sender_sp(intptr_t* sender_sp); 31198186Sgordon void interpreter_frame_set_monitor_end(BasicObjectLock* value); 31298186Sgordon#endif // CC_INTERP 31398186Sgordon 31498186Sgordon // BasicObjectLocks: 31578344Sobrien // 31698186Sgordon // interpreter_frame_monitor_begin is higher in memory than interpreter_frame_monitor_end 31798186Sgordon // Interpreter_frame_monitor_begin points to one element beyond the oldest one, 31898186Sgordon // interpreter_frame_monitor_end points to the youngest one, or if there are none, 31978344Sobrien // it points to one beyond where the first element will be. 32078344Sobrien // interpreter_frame_monitor_size reports the allocation size of a monitor in the interpreter stack. 32178344Sobrien // this value is >= BasicObjectLock::size(), and may be rounded up 32298186Sgordon 32398186Sgordon BasicObjectLock* interpreter_frame_monitor_begin() const; 32498186Sgordon BasicObjectLock* interpreter_frame_monitor_end() const; 32598186Sgordon BasicObjectLock* next_monitor_in_interpreter_frame(BasicObjectLock* current) const; 32698186Sgordon BasicObjectLock* previous_monitor_in_interpreter_frame(BasicObjectLock* current) const; 32778344Sobrien static int interpreter_frame_monitor_size(); 32898186Sgordon 32998186Sgordon void interpreter_frame_verify_monitor(BasicObjectLock* value) const; 33078344Sobrien 33198186Sgordon // Tells whether the current interpreter_frame frame pointer 33298186Sgordon // corresponds to the old compiled/deoptimized fp 333126303Smtm // The receiver used to be a top level frame 33478344Sobrien bool interpreter_frame_equals_unpacked_fp(intptr_t* fp); 33578344Sobrien 33678344Sobrien // Return/result value from this interpreter frame 33798186Sgordon // If the method return type is T_OBJECT or T_ARRAY populates oop_result 33898186Sgordon // For other (non-T_VOID) the appropriate field in the jvalue is populated 33978344Sobrien // with the result value. 34078344Sobrien // Should only be called when at method exit when the method is not 34178344Sobrien // exiting due to an exception. 34298186Sgordon BasicType interpreter_frame_result(oop* oop_result, jvalue* value_result); 34378344Sobrien 34478344Sobrien public: 34578344Sobrien // Method & constant pool cache 34678344Sobrien Method* interpreter_frame_method() const; 34798186Sgordon void interpreter_frame_set_method(Method* method); 34898186Sgordon Method** interpreter_frame_method_addr() const; 34998186Sgordon ConstantPoolCache** interpreter_frame_cache_addr() const; 35078344Sobrien#ifdef PPC 35178344Sobrien oop* interpreter_frame_mirror_addr() const; 35298186Sgordon#endif 35398186Sgordon 35498186Sgordon public: 35578344Sobrien // Entry frames 35698186Sgordon JavaCallWrapper* entry_frame_call_wrapper() const; 35798186Sgordon intptr_t* entry_frame_argument_at(int offset) const; 35878344Sobrien 35978344Sobrien // tells whether there is another chunk of Delta stack above 36078344Sobrien bool entry_frame_is_first() const; 36178344Sobrien 36298186Sgordon // Compiled frames: 36378344Sobrien 36478344Sobrien public: 36578344Sobrien // Given the index of a local, and the number of argument words 36678344Sobrien // in this stack frame, tell which word of the stack frame to find 36778344Sobrien // the local in. Arguments are stored above the ofp/rpc pair, 36878344Sobrien // while other locals are stored below it. 36978344Sobrien // Since monitors (BasicLock blocks) are also assigned indexes, 37078344Sobrien // but may have different storage requirements, their presence 37178344Sobrien // can also affect the calculation of offsets. 37278344Sobrien static int local_offset_for_compiler(int local_index, int nof_args, int max_nof_locals, int max_nof_monitors); 37378344Sobrien 37478344Sobrien // Given the index of a monitor, etc., tell which word of the 37598186Sgordon // stack frame contains the start of the BasicLock block. 37678344Sobrien // Note that the local index by convention is the __higher__ 37778344Sobrien // of the two indexes allocated to the block. 37898186Sgordon static int monitor_offset_for_compiler(int local_index, int nof_args, int max_nof_locals, int max_nof_monitors); 37978344Sobrien 38098186Sgordon // Tell the smallest value that local_offset_for_compiler will attain. 38198186Sgordon // This is used to help determine how much stack frame to allocate. 38298186Sgordon static int min_local_offset_for_compiler(int nof_args, int max_nof_locals, int max_nof_monitors); 38378344Sobrien 38498186Sgordon // Tells if this register must be spilled during a call. 38578344Sobrien // On Intel, all registers are smashed by calls. 38678344Sobrien static bool volatile_across_calls(Register reg); 38798186Sgordon 38898186Sgordon 38998186Sgordon // Safepoints 39098186Sgordon 39178344Sobrien public: 39298186Sgordon oop saved_oop_result(RegisterMap* map) const; 39378344Sobrien void set_saved_oop_result(RegisterMap* map, oop obj); 39498186Sgordon 39598186Sgordon // For debugging 39698186Sgordon private: 39798186Sgordon const char* print_name() const; 39878344Sobrien 39978344Sobrien void describe_pd(FrameValues& values, int frame_no); 40078344Sobrien 40178344Sobrien public: 40278344Sobrien void print_value() const { print_value_on(tty,NULL); } 40378344Sobrien void print_value_on(outputStream* st, JavaThread *thread) const; 40478344Sobrien void print_on(outputStream* st) const; 40578344Sobrien void interpreter_frame_print_on(outputStream* st) const; 40678344Sobrien void print_on_error(outputStream* st, char* buf, int buflen, bool verbose = false) const; 40778344Sobrien 40878344Sobrien // Add annotated descriptions of memory locations belonging to this frame to values 40978344Sobrien void describe(FrameValues& values, int frame_no); 41098186Sgordon 41198186Sgordon // Conversion from an VMReg to physical stack location 41278344Sobrien oop* oopmapreg_to_location(VMReg reg, const RegisterMap* regmap) const; 41398186Sgordon 41498186Sgordon // Oops-do's 41578344Sobrien void oops_compiled_arguments_do(Symbol* signature, bool has_receiver, bool has_appendix, const RegisterMap* reg_map, OopClosure* f); 41678344Sobrien void oops_interpreted_do(OopClosure* f, CLDToOopClosure* cld_f, const RegisterMap* map, bool query_oop_map_cache = true); 41778344Sobrien 41878344Sobrien private: 41998186Sgordon void oops_interpreted_arguments_do(Symbol* signature, bool has_receiver, OopClosure* f); 42078344Sobrien 42198186Sgordon // Iteration of oops 42298186Sgordon void oops_do_internal(OopClosure* f, CLDToOopClosure* cld_f, CodeBlobClosure* cf, RegisterMap* map, bool use_interpreter_oop_map_cache); 42398186Sgordon void oops_entry_do(OopClosure* f, const RegisterMap* map); 42498186Sgordon void oops_code_blob_do(OopClosure* f, CodeBlobClosure* cf, const RegisterMap* map); 42578344Sobrien int adjust_offset(Method* method, int index); // helper for above fn 42698186Sgordon public: 42798186Sgordon // Memory management 42878344Sobrien void oops_do(OopClosure* f, CLDToOopClosure* cld_f, CodeBlobClosure* cf, RegisterMap* map) { oops_do_internal(f, cld_f, cf, map, true); } 42978344Sobrien void nmethods_do(CodeBlobClosure* cf); 43078344Sobrien 43178344Sobrien // RedefineClasses support for finding live interpreted methods on the stack 43298186Sgordon void metadata_do(void f(Metadata*)); 43378344Sobrien 43498186Sgordon void gc_prologue(); 43598186Sgordon void gc_epilogue(); 43698186Sgordon void pd_gc_epilog(); 43798186Sgordon 43898186Sgordon# ifdef ENABLE_ZAP_DEAD_LOCALS 43998186Sgordon private: 44098186Sgordon class CheckValueClosure: public OopClosure { 44198186Sgordon public: 44298186Sgordon void do_oop(oop* p); 443126303Smtm void do_oop(narrowOop* p) { ShouldNotReachHere(); } 44498186Sgordon }; 44598186Sgordon static CheckValueClosure _check_value; 44698186Sgordon 44798186Sgordon class CheckOopClosure: public OopClosure { 44898186Sgordon public: 44998186Sgordon void do_oop(oop* p); 45098186Sgordon void do_oop(narrowOop* p) { ShouldNotReachHere(); } 45198186Sgordon }; 45298186Sgordon static CheckOopClosure _check_oop; 45398186Sgordon 45498186Sgordon static void check_derived_oop(oop* base, oop* derived); 45598186Sgordon 45698186Sgordon class ZapDeadClosure: public OopClosure { 45798186Sgordon public: 45878344Sobrien void do_oop(oop* p); 45978344Sobrien void do_oop(narrowOop* p) { ShouldNotReachHere(); } 460116097Smtm }; 46198186Sgordon static ZapDeadClosure _zap_dead; 46278344Sobrien 46398186Sgordon public: 46478344Sobrien // Zapping 46578344Sobrien void zap_dead_locals (JavaThread* thread, const RegisterMap* map); 466132892Smtm void zap_dead_interpreted_locals(JavaThread* thread, const RegisterMap* map); 467132892Smtm void zap_dead_compiled_locals (JavaThread* thread, const RegisterMap* map); 468132892Smtm void zap_dead_entry_locals (JavaThread* thread, const RegisterMap* map); 469132892Smtm void zap_dead_deoptimized_locals(JavaThread* thread, const RegisterMap* map); 470132892Smtm# endif 471132892Smtm // Verification 472126303Smtm void verify(const RegisterMap* map); 47398186Sgordon static bool verify_return_pc(address x); 47478344Sobrien static bool is_bci(intptr_t bcx); 47598186Sgordon // Usage: 47698186Sgordon // assert(frame::verify_return_pc(return_address), "must be a return pc"); 47778344Sobrien 478126303Smtm int pd_oop_map_offset_adjustment() const; 47998186Sgordon 480126303Smtm#ifdef TARGET_ARCH_x86 481126303Smtm# include "frame_x86.hpp" 48278344Sobrien#endif 48378344Sobrien#ifdef TARGET_ARCH_sparc 48478344Sobrien# include "frame_sparc.hpp" 48578344Sobrien#endif 486126303Smtm#ifdef TARGET_ARCH_zero 487126303Smtm# include "frame_zero.hpp" 488126303Smtm#endif 489126303Smtm#ifdef TARGET_ARCH_arm 490126303Smtm# include "frame_arm.hpp" 491126303Smtm#endif 492126303Smtm#ifdef TARGET_ARCH_ppc 49378344Sobrien# include "frame_ppc.hpp" 49478344Sobrien#endif 49598186Sgordon 49698186Sgordon}; 49798186Sgordon 49898186Sgordon#ifndef PRODUCT 49998186Sgordon// A simple class to describe a location on the stack 50078344Sobrienclass FrameValue VALUE_OBJ_CLASS_SPEC { 50198186Sgordon public: 50278344Sobrien intptr_t* location; 50398186Sgordon char* description; 50498186Sgordon int owner; 505131135Smtm int priority; 506131135Smtm}; 50778344Sobrien 50898186Sgordon 50998186Sgordon// A collection of described stack values that can print a symbolic 51098186Sgordon// description of the stack memory. Interpreter frame values can be 51178344Sobrien// in the caller frames so all the values are collected first and then 51278344Sobrien// sorted before being printed. 51398186Sgordonclass FrameValues { 51478344Sobrien private: 51578344Sobrien GrowableArray<FrameValue> _values; 51678344Sobrien 51798186Sgordon static int compare(FrameValue* a, FrameValue* b) { 51878344Sobrien if (a->location == b->location) { 51978344Sobrien return a->priority - b->priority; 52078344Sobrien } 52178344Sobrien return a->location - b->location; 52298186Sgordon } 52378344Sobrien 52498186Sgordon public: 52578344Sobrien // Used by frame functions to describe locations. 52698186Sgordon void describe(int owner, intptr_t* location, const char* description, int priority = 0); 52798186Sgordon 52898186Sgordon#ifdef ASSERT 52978344Sobrien void validate(); 53098186Sgordon#endif 531124832Smtm void print(JavaThread* thread); 53298186Sgordon}; 53398186Sgordon 53498186Sgordon#endif 53598186Sgordon 53678344Sobrien// 53798186Sgordon// StackFrameStream iterates through the frames of a thread starting from 53878344Sobrien// top most frame. It automatically takes care of updating the location of 53978344Sobrien// all (callee-saved) registers. Notice: If a thread is stopped at 54078344Sobrien// a safepoint, all registers are saved, not only the callee-saved ones. 54198186Sgordon// 54278344Sobrien// Use: 54378344Sobrien// 54478344Sobrien// for(StackFrameStream fst(thread); !fst.is_done(); fst.next()) { 54578344Sobrien// ... 54678344Sobrien// } 54778344Sobrien// 54878344Sobrienclass StackFrameStream : public StackObj { 54978344Sobrien private: 55098186Sgordon frame _fr; 55178344Sobrien RegisterMap _reg_map; 55278344Sobrien bool _is_done; 55378344Sobrien public: 55478344Sobrien StackFrameStream(JavaThread *thread, bool update = true); 55578344Sobrien 55678344Sobrien // Iteration 55798186Sgordon bool is_done() { return (_is_done) ? true : (_is_done = _fr.is_first_frame(), false); } 55898186Sgordon void next() { if (!_is_done) _fr = _fr.sender(&_reg_map); } 55978344Sobrien 56078344Sobrien // Query 56178344Sobrien frame *current() { return &_fr; } 56278344Sobrien RegisterMap* register_map() { return &_reg_map; } 563116097Smtm}; 564116097Smtm 565132892Smtm#endif // SHARE_VM_RUNTIME_FRAME_HPP 566116097Smtm