src/cpu/mips/vm/frame_mips.inline.hpp

Fri, 29 Apr 2016 00:06:10 +0800

author
aoqi
date
Fri, 29 Apr 2016 00:06:10 +0800
changeset 1
2d8a650513c2
child 6880
52ea28d233d2
permissions
-rw-r--r--

Added MIPS 64-bit port.

     1 /*
     2  * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
     3  * Copyright (c) 2015, 2016, Loongson Technology. All rights reserved.
     4  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     5  *
     6  * This code is free software; you can redistribute it and/or modify it
     7  * under the terms of the GNU General Public License version 2 only, as
     8  * published by the Free Software Foundation.
     9  *
    10  * This code is distributed in the hope that it will be useful, but WITHOUT
    11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    12  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    13  * version 2 for more details (a copy is included in the LICENSE file that
    14  * accompanied this code).
    15  *
    16  * You should have received a copy of the GNU General Public License version
    17  * 2 along with this work; if not, write to the Free Software Foundation,
    18  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    19  *
    20  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    21  * or visit www.oracle.com if you need additional information or have any
    22  * questions.
    23  *
    24  */
    26 #ifndef CPU_MIPS_VM_FRAME_MIPS_INLINE_HPP
    27 #define CPU_MIPS_VM_FRAME_MIPS_INLINE_HPP
    29 #include "code/codeCache.hpp"
    31 // Inline functions for Loongson frames:
    33 // Constructors:
    35 inline frame::frame() {
    36   _pc = NULL;
    37   _sp = NULL;
    38   _unextended_sp = NULL;
    39   _fp = NULL;
    40   _cb = NULL;
    41   _deopt_state = unknown;
    42 }
    44 inline frame:: frame(intptr_t* sp, intptr_t* fp, address pc) {
    45   _sp = sp;
    46   _unextended_sp = sp;
    47   _fp = fp;
    48   _pc = pc;
    49   assert(pc != NULL, "no pc?");
    50   _cb = CodeCache::find_blob(pc);
    51   adjust_unextended_sp();
    52   address original_pc = nmethod::get_deopt_original_pc(this);  
    53   if (original_pc != NULL) {
    54     _pc = original_pc;
    55     _deopt_state = is_deoptimized;
    56   } else {
    57     _deopt_state = not_deoptimized;
    58   }
    59 }
    61 inline frame:: frame(intptr_t* sp, intptr_t* unextended_sp, intptr_t* fp, address pc) {
    62   _sp = sp;
    63   _unextended_sp = unextended_sp;
    64   _fp = fp;
    65   _pc = pc;
    66   assert(pc != NULL, "no pc?");
    67   _cb = CodeCache::find_blob(pc);
    68   adjust_unextended_sp();
    69   address original_pc = nmethod::get_deopt_original_pc(this);  
    70   if (original_pc != NULL) {
    71     _pc = original_pc;
    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();
    97   address original_pc = nmethod::get_deopt_original_pc(this);
    98   if (original_pc != NULL) {
    99     _pc = original_pc;
   100     _deopt_state = is_deoptimized;
   101   } else {
   102     _deopt_state = not_deoptimized;
   103   }
   104 }
   106 // Accessors
   108 inline bool frame::equal(frame other) const {
   109   bool ret =  sp() == other.sp()
   110               && unextended_sp() == other.unextended_sp()
   111               && fp() == other.fp()
   112               && pc() == other.pc();
   113   assert(!ret || ret && cb() == other.cb() && _deopt_state == other._deopt_state, "inconsistent construction");
   114   return ret;
   115 }
   117 // Return unique id for this frame. The id must have a value where we can distinguish
   118 // identity and younger/older relationship. NULL represents an invalid (incomparable)
   119 // frame.
   120 inline intptr_t* frame::id(void) const { return unextended_sp(); }
   122 // Relationals on frames based
   123 // Return true if the frame is younger (more recent activation) than the frame represented by id
   124 inline bool frame::is_younger(intptr_t* id) const { assert(this->id() != NULL && id != NULL, "NULL frame id");
   125                                                     return this->id() < id ; }
   127 // Return true if the frame is older (less recent activation) than the frame represented by id
   128 inline bool frame::is_older(intptr_t* id) const   { assert(this->id() != NULL && id != NULL, "NULL frame id");
   129                                                     return this->id() > id ; }
   133 inline intptr_t* frame::link() const              { return (intptr_t*) *(intptr_t **)addr_at(link_offset); }
   134 inline void      frame::set_link(intptr_t* addr)  { *(intptr_t **)addr_at(link_offset) = addr; }
   137 inline intptr_t* frame::unextended_sp() const     { return _unextended_sp; }
   139 // Return address:
   141 inline address* frame::sender_pc_addr()      const { return (address*) addr_at( return_addr_offset); }
   142 inline address  frame::sender_pc()           const { return *sender_pc_addr(); }
   144 // return address of param, zero origin index.
   145 inline address* frame::native_param_addr(int idx) const { return (address*) addr_at( native_frame_initial_param_offset+idx); }
   147 #ifdef CC_INTERP
   149 inline interpreterState frame::get_interpreterState() const {
   150   return ((interpreterState)addr_at( -sizeof(BytecodeInterpreter)/wordSize ));
   151 }
   153 inline intptr_t*    frame::sender_sp()        const {
   154   // Hmm this seems awfully expensive QQQ, is this really called with interpreted frames?
   155   if (is_interpreted_frame()) {
   156     assert(false, "should never happen");
   157     return get_interpreterState()->sender_sp();
   158   } else {
   159     return            addr_at(sender_sp_offset);
   160   }
   161 }
   163 inline intptr_t** frame::interpreter_frame_locals_addr() const {
   164   assert(is_interpreted_frame(), "must be interpreted");
   165   return &(get_interpreterState()->_locals);
   166 }
   168 inline intptr_t* frame::interpreter_frame_bcx_addr() const {
   169   assert(is_interpreted_frame(), "must be interpreted");
   170   return (intptr_t*) &(get_interpreterState()->_bcp);
   171 }
   174 // Constant pool cache
   176 inline ConstantPoolCache** frame::interpreter_frame_cache_addr() const {
   177   assert(is_interpreted_frame(), "must be interpreted");
   178   return &(get_interpreterState()->_constants);
   179 }
   181 // Method
   183 inline Method** frame::interpreter_frame_method_addr() const {
   184   assert(is_interpreted_frame(), "must be interpreted");
   185   return &(get_interpreterState()->_method);
   186 }
   188 inline intptr_t* frame::interpreter_frame_mdx_addr() const {
   189   assert(is_interpreted_frame(), "must be interpreted");
   190   return (intptr_t*) &(get_interpreterState()->_mdx);
   191 }
   193 // top of expression stack
   194 inline intptr_t* frame::interpreter_frame_tos_address() const {
   195   assert(is_interpreted_frame(), "wrong frame type");
   196   return get_interpreterState()->_stack + 1;
   197 }
   199 #else /* asm interpreter */
   200 inline intptr_t*    frame::sender_sp()        const { return            addr_at(   sender_sp_offset); }
   202 inline intptr_t** frame::interpreter_frame_locals_addr() const {
   203   return (intptr_t**)addr_at(interpreter_frame_locals_offset);
   204 }
   206 inline intptr_t* frame::interpreter_frame_last_sp() const {
   207   return *(intptr_t**)addr_at(interpreter_frame_last_sp_offset);
   208 }
   210 inline intptr_t* frame::interpreter_frame_bcx_addr() const {
   211   return (intptr_t*)addr_at(interpreter_frame_bcx_offset);
   212 }
   215 inline intptr_t* frame::interpreter_frame_mdx_addr() const {
   216   return (intptr_t*)addr_at(interpreter_frame_mdx_offset);
   217 }
   221 // Constant pool cache
   223 inline ConstantPoolCache** frame::interpreter_frame_cache_addr() const {
   224   return (ConstantPoolCache**)addr_at(interpreter_frame_cache_offset);
   225 }
   227 // Method
   229 inline Method** frame::interpreter_frame_method_addr() const {
   230   return (Method**)addr_at(interpreter_frame_method_offset);
   231 }
   233 // top of expression stack
   234 inline intptr_t* frame::interpreter_frame_tos_address() const {
   235   intptr_t* last_sp = interpreter_frame_last_sp();
   236   if (last_sp == NULL ) {
   237     return sp();
   238   } else {
   239     // sp() may have been extended by an adapter
   240     assert(last_sp <= (intptr_t*)interpreter_frame_monitor_end(), "bad tos");
   241     return last_sp;
   242   }
   243 }
   245 inline oop* frame::interpreter_frame_temp_oop_addr() const {
   246   return (oop *)(fp() + interpreter_frame_oop_temp_offset);
   247 }
   249 #endif /* CC_INTERP */
   251 inline int frame::pd_oop_map_offset_adjustment() const {
   252   return 0;
   253 }
   255 inline int frame::interpreter_frame_monitor_size() {
   256   return BasicObjectLock::size();
   257 }
   260 // expression stack
   261 // (the max_stack arguments are used by the GC; see class FrameClosure)
   263 inline intptr_t* frame::interpreter_frame_expression_stack() const {
   264   intptr_t* monitor_end = (intptr_t*) interpreter_frame_monitor_end();
   265   return monitor_end-1;
   266 }
   269 inline jint frame::interpreter_frame_expression_stack_direction() { return -1; }
   272 // Entry frames
   273 /* 
   274 inline JavaCallWrapper* frame::entry_frame_call_wrapper() const {
   275  return (JavaCallWrapper*)at(entry_frame_call_wrapper_offset);
   276 }
   277 */
   279 // Entry frames
   281 inline JavaCallWrapper** frame::entry_frame_call_wrapper_addr() const {   // Fu: 20130814
   282   return (JavaCallWrapper**)addr_at(entry_frame_call_wrapper_offset);
   283 }
   285 // Compiled frames
   287 inline int frame::local_offset_for_compiler(int local_index, int nof_args, int max_nof_locals, int max_nof_monitors) {
   288   return (nof_args - local_index + (local_index < nof_args ? 1: -1));
   289 }
   291 inline int frame::monitor_offset_for_compiler(int local_index, int nof_args, int max_nof_locals, int max_nof_monitors) {
   292   return local_offset_for_compiler(local_index, nof_args, max_nof_locals, max_nof_monitors);
   293 }
   295 inline int frame::min_local_offset_for_compiler(int nof_args, int max_nof_locals, int max_nof_monitors) {
   296   return (nof_args - (max_nof_locals + max_nof_monitors*2) - 1);
   297 }
   299 inline bool frame::volatile_across_calls(Register reg) {
   300   return true;
   301 }
   305 inline oop frame::saved_oop_result(RegisterMap* map) const       {
   306   return *((oop*) map->location(V0->as_VMReg()));
   307 }
   309 inline void frame::set_saved_oop_result(RegisterMap* map, oop obj) {
   310   *((oop*) map->location(V0->as_VMReg())) = obj;
   311 }
   313 #endif // CPU_MIPS_VM_FRAME_MIPS_INLINE_HPP

mercurial