duke@435: /* coleenp@4037: * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. duke@435: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. duke@435: * duke@435: * This code is free software; you can redistribute it and/or modify it duke@435: * under the terms of the GNU General Public License version 2 only, as duke@435: * published by the Free Software Foundation. duke@435: * duke@435: * This code is distributed in the hope that it will be useful, but WITHOUT duke@435: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or duke@435: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License duke@435: * version 2 for more details (a copy is included in the LICENSE file that duke@435: * accompanied this code). duke@435: * duke@435: * You should have received a copy of the GNU General Public License version duke@435: * 2 along with this work; if not, write to the Free Software Foundation, duke@435: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. duke@435: * trims@1907: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA trims@1907: * or visit www.oracle.com if you need additional information or have any trims@1907: * questions. duke@435: * duke@435: */ duke@435: stefank@2314: #ifndef CPU_X86_VM_FRAME_X86_INLINE_HPP stefank@2314: #define CPU_X86_VM_FRAME_X86_INLINE_HPP stefank@2314: twisti@4318: #include "code/codeCache.hpp" twisti@4318: duke@435: // Inline functions for Intel frames: duke@435: duke@435: // Constructors: duke@435: duke@435: inline frame::frame() { duke@435: _pc = NULL; duke@435: _sp = NULL; duke@435: _unextended_sp = NULL; duke@435: _fp = NULL; duke@435: _cb = NULL; duke@435: _deopt_state = unknown; duke@435: } duke@435: twisti@1639: inline frame::frame(intptr_t* sp, intptr_t* fp, address pc) { duke@435: _sp = sp; duke@435: _unextended_sp = sp; duke@435: _fp = fp; duke@435: _pc = pc; duke@435: assert(pc != NULL, "no pc?"); duke@435: _cb = CodeCache::find_blob(pc); jrose@2952: adjust_unextended_sp(); twisti@1639: twisti@1639: address original_pc = nmethod::get_deopt_original_pc(this); twisti@1639: if (original_pc != NULL) { twisti@1639: _pc = original_pc; duke@435: _deopt_state = is_deoptimized; duke@435: } else { duke@435: _deopt_state = not_deoptimized; duke@435: } duke@435: } duke@435: twisti@1639: inline frame::frame(intptr_t* sp, intptr_t* unextended_sp, intptr_t* fp, address pc) { duke@435: _sp = sp; duke@435: _unextended_sp = unextended_sp; duke@435: _fp = fp; duke@435: _pc = pc; duke@435: assert(pc != NULL, "no pc?"); duke@435: _cb = CodeCache::find_blob(pc); never@2895: adjust_unextended_sp(); twisti@1639: twisti@1639: address original_pc = nmethod::get_deopt_original_pc(this); twisti@1639: if (original_pc != NULL) { twisti@1639: _pc = original_pc; twisti@2103: assert(((nmethod*)_cb)->insts_contains(_pc), "original PC must be in nmethod"); duke@435: _deopt_state = is_deoptimized; duke@435: } else { duke@435: _deopt_state = not_deoptimized; duke@435: } duke@435: } duke@435: duke@435: inline frame::frame(intptr_t* sp, intptr_t* fp) { duke@435: _sp = sp; duke@435: _unextended_sp = sp; duke@435: _fp = fp; duke@435: _pc = (address)(sp[-1]); sgoldman@542: sgoldman@542: // Here's a sticky one. This constructor can be called via AsyncGetCallTrace sgoldman@542: // when last_Java_sp is non-null but the pc fetched is junk. If we are truly sgoldman@542: // unlucky the junk value could be to a zombied method and we'll die on the sgoldman@542: // find_blob call. This is also why we can have no asserts on the validity sgoldman@542: // of the pc we find here. AsyncGetCallTrace -> pd_get_top_frame_for_signal_handler sgoldman@542: // -> pd_last_frame should use a specialized version of pd_last_frame which could sgoldman@542: // call a specilaized frame constructor instead of this one. sgoldman@542: // Then we could use the assert below. However this assert is of somewhat dubious sgoldman@542: // value. sgoldman@542: // assert(_pc != NULL, "no pc?"); sgoldman@542: duke@435: _cb = CodeCache::find_blob(_pc); jrose@2952: adjust_unextended_sp(); duke@435: twisti@1639: address original_pc = nmethod::get_deopt_original_pc(this); twisti@1639: if (original_pc != NULL) { twisti@1639: _pc = original_pc; duke@435: _deopt_state = is_deoptimized; duke@435: } else { duke@435: _deopt_state = not_deoptimized; duke@435: } duke@435: } duke@435: duke@435: // Accessors duke@435: duke@435: inline bool frame::equal(frame other) const { duke@435: bool ret = sp() == other.sp() duke@435: && unextended_sp() == other.unextended_sp() duke@435: && fp() == other.fp() duke@435: && pc() == other.pc(); duke@435: assert(!ret || ret && cb() == other.cb() && _deopt_state == other._deopt_state, "inconsistent construction"); duke@435: return ret; duke@435: } duke@435: duke@435: // Return unique id for this frame. The id must have a value where we can distinguish duke@435: // identity and younger/older relationship. NULL represents an invalid (incomparable) duke@435: // frame. duke@435: inline intptr_t* frame::id(void) const { return unextended_sp(); } duke@435: duke@435: // Relationals on frames based duke@435: // Return true if the frame is younger (more recent activation) than the frame represented by id duke@435: inline bool frame::is_younger(intptr_t* id) const { assert(this->id() != NULL && id != NULL, "NULL frame id"); duke@435: return this->id() < id ; } duke@435: duke@435: // Return true if the frame is older (less recent activation) than the frame represented by id duke@435: inline bool frame::is_older(intptr_t* id) const { assert(this->id() != NULL && id != NULL, "NULL frame id"); duke@435: return this->id() > id ; } duke@435: duke@435: duke@435: duke@435: inline intptr_t* frame::link() const { return (intptr_t*) *(intptr_t **)addr_at(link_offset); } duke@435: inline void frame::set_link(intptr_t* addr) { *(intptr_t **)addr_at(link_offset) = addr; } duke@435: duke@435: duke@435: inline intptr_t* frame::unextended_sp() const { return _unextended_sp; } duke@435: duke@435: // Return address: duke@435: duke@435: inline address* frame::sender_pc_addr() const { return (address*) addr_at( return_addr_offset); } duke@435: inline address frame::sender_pc() const { return *sender_pc_addr(); } duke@435: duke@435: // return address of param, zero origin index. duke@435: inline address* frame::native_param_addr(int idx) const { return (address*) addr_at( native_frame_initial_param_offset+idx); } duke@435: duke@435: #ifdef CC_INTERP duke@435: duke@435: inline interpreterState frame::get_interpreterState() const { coleenp@955: return ((interpreterState)addr_at( -((int)sizeof(BytecodeInterpreter))/wordSize )); duke@435: } duke@435: duke@435: inline intptr_t* frame::sender_sp() const { duke@435: // Hmm this seems awfully expensive QQQ, is this really called with interpreted frames? duke@435: if (is_interpreted_frame()) { duke@435: assert(false, "should never happen"); duke@435: return get_interpreterState()->sender_sp(); duke@435: } else { duke@435: return addr_at(sender_sp_offset); duke@435: } duke@435: } duke@435: duke@435: inline intptr_t** frame::interpreter_frame_locals_addr() const { duke@435: assert(is_interpreted_frame(), "must be interpreted"); duke@435: return &(get_interpreterState()->_locals); duke@435: } duke@435: duke@435: inline intptr_t* frame::interpreter_frame_bcx_addr() const { duke@435: assert(is_interpreted_frame(), "must be interpreted"); never@739: return (intptr_t*) &(get_interpreterState()->_bcp); duke@435: } duke@435: duke@435: duke@435: // Constant pool cache duke@435: coleenp@4037: inline ConstantPoolCache** frame::interpreter_frame_cache_addr() const { duke@435: assert(is_interpreted_frame(), "must be interpreted"); duke@435: return &(get_interpreterState()->_constants); duke@435: } duke@435: duke@435: // Method duke@435: coleenp@4037: inline Method** frame::interpreter_frame_method_addr() const { duke@435: assert(is_interpreted_frame(), "must be interpreted"); duke@435: return &(get_interpreterState()->_method); duke@435: } duke@435: duke@435: inline intptr_t* frame::interpreter_frame_mdx_addr() const { duke@435: assert(is_interpreted_frame(), "must be interpreted"); never@739: return (intptr_t*) &(get_interpreterState()->_mdx); duke@435: } duke@435: duke@435: // top of expression stack duke@435: inline intptr_t* frame::interpreter_frame_tos_address() const { duke@435: assert(is_interpreted_frame(), "wrong frame type"); duke@435: return get_interpreterState()->_stack + 1; duke@435: } duke@435: duke@435: #else /* asm interpreter */ duke@435: inline intptr_t* frame::sender_sp() const { return addr_at( sender_sp_offset); } duke@435: duke@435: inline intptr_t** frame::interpreter_frame_locals_addr() const { duke@435: return (intptr_t**)addr_at(interpreter_frame_locals_offset); duke@435: } duke@435: duke@435: inline intptr_t* frame::interpreter_frame_last_sp() const { duke@435: return *(intptr_t**)addr_at(interpreter_frame_last_sp_offset); duke@435: } duke@435: duke@435: inline intptr_t* frame::interpreter_frame_bcx_addr() const { duke@435: return (intptr_t*)addr_at(interpreter_frame_bcx_offset); duke@435: } duke@435: duke@435: duke@435: inline intptr_t* frame::interpreter_frame_mdx_addr() const { duke@435: return (intptr_t*)addr_at(interpreter_frame_mdx_offset); duke@435: } duke@435: duke@435: duke@435: duke@435: // Constant pool cache duke@435: coleenp@4037: inline ConstantPoolCache** frame::interpreter_frame_cache_addr() const { coleenp@4037: return (ConstantPoolCache**)addr_at(interpreter_frame_cache_offset); duke@435: } duke@435: duke@435: // Method duke@435: coleenp@4037: inline Method** frame::interpreter_frame_method_addr() const { coleenp@4037: return (Method**)addr_at(interpreter_frame_method_offset); duke@435: } duke@435: duke@435: // top of expression stack duke@435: inline intptr_t* frame::interpreter_frame_tos_address() const { duke@435: intptr_t* last_sp = interpreter_frame_last_sp(); twisti@1572: if (last_sp == NULL) { duke@435: return sp(); duke@435: } else { twisti@1572: // sp() may have been extended or shrunk by an adapter. At least twisti@1572: // check that we don't fall behind the legal region. kvn@1690: // For top deoptimized frame last_sp == interpreter_frame_monitor_end. kvn@1690: assert(last_sp <= (intptr_t*) interpreter_frame_monitor_end(), "bad tos"); duke@435: return last_sp; duke@435: } duke@435: } duke@435: duke@435: #endif /* CC_INTERP */ duke@435: duke@435: inline int frame::pd_oop_map_offset_adjustment() const { duke@435: return 0; duke@435: } duke@435: duke@435: inline int frame::interpreter_frame_monitor_size() { duke@435: return BasicObjectLock::size(); duke@435: } duke@435: duke@435: duke@435: // expression stack duke@435: // (the max_stack arguments are used by the GC; see class FrameClosure) duke@435: duke@435: inline intptr_t* frame::interpreter_frame_expression_stack() const { duke@435: intptr_t* monitor_end = (intptr_t*) interpreter_frame_monitor_end(); duke@435: return monitor_end-1; duke@435: } duke@435: duke@435: duke@435: inline jint frame::interpreter_frame_expression_stack_direction() { return -1; } duke@435: duke@435: duke@435: // Entry frames duke@435: duke@435: inline JavaCallWrapper* frame::entry_frame_call_wrapper() const { duke@435: return (JavaCallWrapper*)at(entry_frame_call_wrapper_offset); duke@435: } duke@435: duke@435: duke@435: // Compiled frames duke@435: duke@435: inline int frame::local_offset_for_compiler(int local_index, int nof_args, int max_nof_locals, int max_nof_monitors) { duke@435: return (nof_args - local_index + (local_index < nof_args ? 1: -1)); duke@435: } duke@435: duke@435: inline int frame::monitor_offset_for_compiler(int local_index, int nof_args, int max_nof_locals, int max_nof_monitors) { duke@435: return local_offset_for_compiler(local_index, nof_args, max_nof_locals, max_nof_monitors); duke@435: } duke@435: duke@435: inline int frame::min_local_offset_for_compiler(int nof_args, int max_nof_locals, int max_nof_monitors) { duke@435: return (nof_args - (max_nof_locals + max_nof_monitors*2) - 1); duke@435: } duke@435: duke@435: inline bool frame::volatile_across_calls(Register reg) { duke@435: return true; duke@435: } duke@435: duke@435: duke@435: duke@435: inline oop frame::saved_oop_result(RegisterMap* map) const { duke@435: return *((oop*) map->location(rax->as_VMReg())); duke@435: } duke@435: duke@435: inline void frame::set_saved_oop_result(RegisterMap* map, oop obj) { duke@435: *((oop*) map->location(rax->as_VMReg())) = obj; duke@435: } stefank@2314: stefank@2314: #endif // CPU_X86_VM_FRAME_X86_INLINE_HPP