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

Sat, 29 Sep 2012 06:40:00 -0400

author
coleenp
date
Sat, 29 Sep 2012 06:40:00 -0400
changeset 4142
d8ce2825b193
parent 4037
da91efe96a93
child 4318
cd3d6a6b95d9
permissions
-rw-r--r--

8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
Summary: Capitalize these metadata types (and objArrayKlass)
Reviewed-by: stefank, twisti, kvn

     1 /*
     2  * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     8  *
     9  * This code is distributed in the hope that it will be useful, but WITHOUT
    10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    12  * version 2 for more details (a copy is included in the LICENSE file that
    13  * accompanied this code).
    14  *
    15  * You should have received a copy of the GNU General Public License version
    16  * 2 along with this work; if not, write to the Free Software Foundation,
    17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    18  *
    19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    20  * or visit www.oracle.com if you need additional information or have any
    21  * questions.
    22  *
    23  */
    25 #ifndef CPU_X86_VM_FRAME_X86_INLINE_HPP
    26 #define CPU_X86_VM_FRAME_X86_INLINE_HPP
    28 // Inline functions for Intel frames:
    30 // Constructors:
    32 inline frame::frame() {
    33   _pc = NULL;
    34   _sp = NULL;
    35   _unextended_sp = NULL;
    36   _fp = NULL;
    37   _cb = NULL;
    38   _deopt_state = unknown;
    39 }
    41 inline frame::frame(intptr_t* sp, intptr_t* fp, address pc) {
    42   _sp = sp;
    43   _unextended_sp = sp;
    44   _fp = fp;
    45   _pc = pc;
    46   assert(pc != NULL, "no pc?");
    47   _cb = CodeCache::find_blob(pc);
    48   adjust_unextended_sp();
    50   address original_pc = nmethod::get_deopt_original_pc(this);
    51   if (original_pc != NULL) {
    52     _pc = original_pc;
    53     _deopt_state = is_deoptimized;
    54   } else {
    55     _deopt_state = not_deoptimized;
    56   }
    57 }
    59 inline frame::frame(intptr_t* sp, intptr_t* unextended_sp, intptr_t* fp, address pc) {
    60   _sp = sp;
    61   _unextended_sp = unextended_sp;
    62   _fp = fp;
    63   _pc = pc;
    64   assert(pc != NULL, "no pc?");
    65   _cb = CodeCache::find_blob(pc);
    66   adjust_unextended_sp();
    68   address original_pc = nmethod::get_deopt_original_pc(this);
    69   if (original_pc != NULL) {
    70     _pc = original_pc;
    71     assert(((nmethod*)_cb)->insts_contains(_pc), "original PC must be in nmethod");
    72     _deopt_state = is_deoptimized;
    73   } else {
    74     _deopt_state = not_deoptimized;
    75   }
    76 }
    78 inline frame::frame(intptr_t* sp, intptr_t* fp) {
    79   _sp = sp;
    80   _unextended_sp = sp;
    81   _fp = fp;
    82   _pc = (address)(sp[-1]);
    84   // Here's a sticky one. This constructor can be called via AsyncGetCallTrace
    85   // when last_Java_sp is non-null but the pc fetched is junk. If we are truly
    86   // unlucky the junk value could be to a zombied method and we'll die on the
    87   // find_blob call. This is also why we can have no asserts on the validity
    88   // of the pc we find here. AsyncGetCallTrace -> pd_get_top_frame_for_signal_handler
    89   // -> pd_last_frame should use a specialized version of pd_last_frame which could
    90   // call a specilaized frame constructor instead of this one.
    91   // Then we could use the assert below. However this assert is of somewhat dubious
    92   // value.
    93   // assert(_pc != NULL, "no pc?");
    95   _cb = CodeCache::find_blob(_pc);
    96   adjust_unextended_sp();
    98   address original_pc = nmethod::get_deopt_original_pc(this);
    99   if (original_pc != NULL) {
   100     _pc = original_pc;
   101     _deopt_state = is_deoptimized;
   102   } else {
   103     _deopt_state = not_deoptimized;
   104   }
   105 }
   107 // Accessors
   109 inline bool frame::equal(frame other) const {
   110   bool ret =  sp() == other.sp()
   111               && unextended_sp() == other.unextended_sp()
   112               && fp() == other.fp()
   113               && pc() == other.pc();
   114   assert(!ret || ret && cb() == other.cb() && _deopt_state == other._deopt_state, "inconsistent construction");
   115   return ret;
   116 }
   118 // Return unique id for this frame. The id must have a value where we can distinguish
   119 // identity and younger/older relationship. NULL represents an invalid (incomparable)
   120 // frame.
   121 inline intptr_t* frame::id(void) const { return unextended_sp(); }
   123 // Relationals on frames based
   124 // Return true if the frame is younger (more recent activation) than the frame represented by id
   125 inline bool frame::is_younger(intptr_t* id) const { assert(this->id() != NULL && id != NULL, "NULL frame id");
   126                                                     return this->id() < id ; }
   128 // Return true if the frame is older (less recent activation) than the frame represented by id
   129 inline bool frame::is_older(intptr_t* id) const   { assert(this->id() != NULL && id != NULL, "NULL frame id");
   130                                                     return this->id() > id ; }
   134 inline intptr_t* frame::link() const              { return (intptr_t*) *(intptr_t **)addr_at(link_offset); }
   135 inline void      frame::set_link(intptr_t* addr)  { *(intptr_t **)addr_at(link_offset) = addr; }
   138 inline intptr_t* frame::unextended_sp() const     { return _unextended_sp; }
   140 // Return address:
   142 inline address* frame::sender_pc_addr()      const { return (address*) addr_at( return_addr_offset); }
   143 inline address  frame::sender_pc()           const { return *sender_pc_addr(); }
   145 // return address of param, zero origin index.
   146 inline address* frame::native_param_addr(int idx) const { return (address*) addr_at( native_frame_initial_param_offset+idx); }
   148 #ifdef CC_INTERP
   150 inline interpreterState frame::get_interpreterState() const {
   151   return ((interpreterState)addr_at( -((int)sizeof(BytecodeInterpreter))/wordSize ));
   152 }
   154 inline intptr_t*    frame::sender_sp()        const {
   155   // Hmm this seems awfully expensive QQQ, is this really called with interpreted frames?
   156   if (is_interpreted_frame()) {
   157     assert(false, "should never happen");
   158     return get_interpreterState()->sender_sp();
   159   } else {
   160     return            addr_at(sender_sp_offset);
   161   }
   162 }
   164 inline intptr_t** frame::interpreter_frame_locals_addr() const {
   165   assert(is_interpreted_frame(), "must be interpreted");
   166   return &(get_interpreterState()->_locals);
   167 }
   169 inline intptr_t* frame::interpreter_frame_bcx_addr() const {
   170   assert(is_interpreted_frame(), "must be interpreted");
   171   return (intptr_t*) &(get_interpreterState()->_bcp);
   172 }
   175 // Constant pool cache
   177 inline ConstantPoolCache** frame::interpreter_frame_cache_addr() const {
   178   assert(is_interpreted_frame(), "must be interpreted");
   179   return &(get_interpreterState()->_constants);
   180 }
   182 // Method
   184 inline Method** frame::interpreter_frame_method_addr() const {
   185   assert(is_interpreted_frame(), "must be interpreted");
   186   return &(get_interpreterState()->_method);
   187 }
   189 inline intptr_t* frame::interpreter_frame_mdx_addr() const {
   190   assert(is_interpreted_frame(), "must be interpreted");
   191   return (intptr_t*) &(get_interpreterState()->_mdx);
   192 }
   194 // top of expression stack
   195 inline intptr_t* frame::interpreter_frame_tos_address() const {
   196   assert(is_interpreted_frame(), "wrong frame type");
   197   return get_interpreterState()->_stack + 1;
   198 }
   200 #else /* asm interpreter */
   201 inline intptr_t*    frame::sender_sp()        const { return            addr_at(   sender_sp_offset); }
   203 inline intptr_t** frame::interpreter_frame_locals_addr() const {
   204   return (intptr_t**)addr_at(interpreter_frame_locals_offset);
   205 }
   207 inline intptr_t* frame::interpreter_frame_last_sp() const {
   208   return *(intptr_t**)addr_at(interpreter_frame_last_sp_offset);
   209 }
   211 inline intptr_t* frame::interpreter_frame_bcx_addr() const {
   212   return (intptr_t*)addr_at(interpreter_frame_bcx_offset);
   213 }
   216 inline intptr_t* frame::interpreter_frame_mdx_addr() const {
   217   return (intptr_t*)addr_at(interpreter_frame_mdx_offset);
   218 }
   222 // Constant pool cache
   224 inline ConstantPoolCache** frame::interpreter_frame_cache_addr() const {
   225   return (ConstantPoolCache**)addr_at(interpreter_frame_cache_offset);
   226 }
   228 // Method
   230 inline Method** frame::interpreter_frame_method_addr() const {
   231   return (Method**)addr_at(interpreter_frame_method_offset);
   232 }
   234 // top of expression stack
   235 inline intptr_t* frame::interpreter_frame_tos_address() const {
   236   intptr_t* last_sp = interpreter_frame_last_sp();
   237   if (last_sp == NULL) {
   238     return sp();
   239   } else {
   240     // sp() may have been extended or shrunk by an adapter.  At least
   241     // check that we don't fall behind the legal region.
   242     // For top deoptimized frame last_sp == interpreter_frame_monitor_end.
   243     assert(last_sp <= (intptr_t*) interpreter_frame_monitor_end(), "bad tos");
   244     return last_sp;
   245   }
   246 }
   248 #endif /* CC_INTERP */
   250 inline int frame::pd_oop_map_offset_adjustment() const {
   251   return 0;
   252 }
   254 inline int frame::interpreter_frame_monitor_size() {
   255   return BasicObjectLock::size();
   256 }
   259 // expression stack
   260 // (the max_stack arguments are used by the GC; see class FrameClosure)
   262 inline intptr_t* frame::interpreter_frame_expression_stack() const {
   263   intptr_t* monitor_end = (intptr_t*) interpreter_frame_monitor_end();
   264   return monitor_end-1;
   265 }
   268 inline jint frame::interpreter_frame_expression_stack_direction() { return -1; }
   271 // Entry frames
   273 inline JavaCallWrapper* frame::entry_frame_call_wrapper() const {
   274  return (JavaCallWrapper*)at(entry_frame_call_wrapper_offset);
   275 }
   278 // Compiled frames
   280 inline int frame::local_offset_for_compiler(int local_index, int nof_args, int max_nof_locals, int max_nof_monitors) {
   281   return (nof_args - local_index + (local_index < nof_args ? 1: -1));
   282 }
   284 inline int frame::monitor_offset_for_compiler(int local_index, int nof_args, int max_nof_locals, int max_nof_monitors) {
   285   return local_offset_for_compiler(local_index, nof_args, max_nof_locals, max_nof_monitors);
   286 }
   288 inline int frame::min_local_offset_for_compiler(int nof_args, int max_nof_locals, int max_nof_monitors) {
   289   return (nof_args - (max_nof_locals + max_nof_monitors*2) - 1);
   290 }
   292 inline bool frame::volatile_across_calls(Register reg) {
   293   return true;
   294 }
   298 inline oop frame::saved_oop_result(RegisterMap* map) const       {
   299   return *((oop*) map->location(rax->as_VMReg()));
   300 }
   302 inline void frame::set_saved_oop_result(RegisterMap* map, oop obj) {
   303   *((oop*) map->location(rax->as_VMReg())) = obj;
   304 }
   306 #endif // CPU_X86_VM_FRAME_X86_INLINE_HPP

mercurial