src/cpu/ppc/vm/frame_ppc.inline.hpp

Wed, 15 Apr 2020 11:49:55 +0800

author
aoqi
date
Wed, 15 Apr 2020 11:49:55 +0800
changeset 9852
70aa912cebe5
parent 6876
710a3c8b516e
permissions
-rw-r--r--

Merge

     1 /*
     2  * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
     3  * Copyright 2012, 2014 SAP AG. 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_PPC_VM_FRAME_PPC_INLINE_HPP
    27 #define CPU_PPC_VM_FRAME_PPC_INLINE_HPP
    29 #include "code/codeCache.hpp"
    31 // Inline functions for ppc64 frames:
    33 // Find codeblob and set deopt_state.
    34 inline void frame::find_codeblob_and_set_pc_and_deopt_state(address pc) {
    35   assert(pc != NULL, "precondition: must have PC");
    37   _cb = CodeCache::find_blob(pc);
    38   _pc = pc;   // Must be set for get_deopt_original_pc()
    40   _fp = (intptr_t*)own_abi()->callers_sp;
    41   // Use _fp - frame_size, needs to be done between _cb and _pc initialization
    42   // and get_deopt_original_pc.
    43   adjust_unextended_sp();
    45   address original_pc = nmethod::get_deopt_original_pc(this);
    46   if (original_pc != NULL) {
    47     _pc = original_pc;
    48     _deopt_state = is_deoptimized;
    49   } else {
    50     _deopt_state = not_deoptimized;
    51   }
    53   assert(((uint64_t)_sp & 0xf) == 0, "SP must be 16-byte aligned");
    54 }
    56 // Constructors
    58 // Initialize all fields, _unextended_sp will be adjusted in find_codeblob_and_set_pc_and_deopt_state.
    59 inline frame::frame() : _sp(NULL), _unextended_sp(NULL), _fp(NULL), _cb(NULL), _pc(NULL), _deopt_state(unknown) {}
    61 inline frame::frame(intptr_t* sp) : _sp(sp), _unextended_sp(sp) {
    62   find_codeblob_and_set_pc_and_deopt_state((address)own_abi()->lr); // also sets _fp and adjusts _unextended_sp
    63 }
    65 inline frame::frame(intptr_t* sp, address pc) : _sp(sp), _unextended_sp(sp) {
    66   find_codeblob_and_set_pc_and_deopt_state(pc); // also sets _fp and adjusts _unextended_sp
    67 }
    69 inline frame::frame(intptr_t* sp, address pc, intptr_t* unextended_sp) : _sp(sp), _unextended_sp(unextended_sp) {
    70   find_codeblob_and_set_pc_and_deopt_state(pc); // also sets _fp and adjusts _unextended_sp
    71 }
    73 // Accessors
    75 // Return unique id for this frame. The id must have a value where we
    76 // can distinguish identity and younger/older relationship. NULL
    77 // represents an invalid (incomparable) frame.
    78 inline intptr_t* frame::id(void) const {
    79   // Use _fp. _sp or _unextended_sp wouldn't be correct due to resizing.
    80   return _fp;
    81 }
    83 // Return true if this frame is older (less recent activation) than
    84 // the frame represented by id.
    85 inline bool frame::is_older(intptr_t* id) const {
    86    assert(this->id() != NULL && id != NULL, "NULL frame id");
    87    // Stack grows towards smaller addresses on ppc64.
    88    return this->id() > id;
    89 }
    91 inline int frame::frame_size(RegisterMap* map) const {
    92   // Stack grows towards smaller addresses on PPC64: sender is at a higher address.
    93   return sender_sp() - sp();
    94 }
    96 // Return the frame's stack pointer before it has been extended by a
    97 // c2i adapter. This is needed by deoptimization for ignoring c2i adapter
    98 // frames.
    99 inline intptr_t* frame::unextended_sp() const {
   100   return _unextended_sp;
   101 }
   103 // All frames have this field.
   104 inline address frame::sender_pc() const {
   105   return (address)callers_abi()->lr;
   106 }
   107 inline address* frame::sender_pc_addr() const {
   108   return (address*)&(callers_abi()->lr);
   109 }
   111 // All frames have this field.
   112 inline intptr_t* frame::sender_sp() const {
   113   return (intptr_t*)callers_abi();
   114 }
   116 // All frames have this field.
   117 inline intptr_t* frame::link() const {
   118   return (intptr_t*)callers_abi()->callers_sp;
   119 }
   121 inline intptr_t* frame::real_fp() const {
   122   return fp();
   123 }
   125 #ifdef CC_INTERP
   127 inline interpreterState frame::get_interpreterState() const {
   128   return (interpreterState)(((address)callers_abi())
   129                             - frame::interpreter_frame_cinterpreterstate_size_in_bytes());
   130 }
   132 inline intptr_t** frame::interpreter_frame_locals_addr() const {
   133   interpreterState istate = get_interpreterState();
   134   return (intptr_t**)&istate->_locals;
   135 }
   137 inline intptr_t* frame::interpreter_frame_bcx_addr() const {
   138   interpreterState istate = get_interpreterState();
   139   return (intptr_t*)&istate->_bcp;
   140 }
   142 inline intptr_t* frame::interpreter_frame_mdx_addr() const {
   143   interpreterState istate = get_interpreterState();
   144   return (intptr_t*)&istate->_mdx;
   145 }
   147 inline intptr_t* frame::interpreter_frame_expression_stack() const {
   148   return (intptr_t*)interpreter_frame_monitor_end() - 1;
   149 }
   151 inline jint frame::interpreter_frame_expression_stack_direction() {
   152   return -1;
   153 }
   155 // top of expression stack
   156 inline intptr_t* frame::interpreter_frame_tos_address() const {
   157   interpreterState istate = get_interpreterState();
   158   return istate->_stack + 1;
   159 }
   161 inline intptr_t* frame::interpreter_frame_tos_at(jint offset) const {
   162   return &interpreter_frame_tos_address()[offset];
   163 }
   165 // monitor elements
   167 // in keeping with Intel side: end is lower in memory than begin;
   168 // and beginning element is oldest element
   169 // Also begin is one past last monitor.
   171 inline BasicObjectLock* frame::interpreter_frame_monitor_begin() const {
   172   return get_interpreterState()->monitor_base();
   173 }
   175 inline BasicObjectLock* frame::interpreter_frame_monitor_end() const {
   176   return (BasicObjectLock*)get_interpreterState()->stack_base();
   177 }
   179 inline int frame::interpreter_frame_cinterpreterstate_size_in_bytes() {
   180   // Size of an interpreter object. Not aligned with frame size.
   181   return round_to(sizeof(BytecodeInterpreter), 8);
   182 }
   184 inline Method** frame::interpreter_frame_method_addr() const {
   185   interpreterState istate = get_interpreterState();
   186   return &istate->_method;
   187 }
   189 // Constant pool cache
   191 inline ConstantPoolCache** frame::interpreter_frame_cpoolcache_addr() const {
   192   interpreterState istate = get_interpreterState();
   193   return &istate->_constants; // should really use accessor
   194 }
   196 inline ConstantPoolCache** frame::interpreter_frame_cache_addr() const {
   197   interpreterState istate = get_interpreterState();
   198   return &istate->_constants;
   199 }
   201 #else // !CC_INTERP
   203 // Template Interpreter frame value accessors.
   205 inline frame::ijava_state* frame::get_ijava_state() const {
   206   return (ijava_state*) ((uintptr_t)fp() - ijava_state_size);
   207 }
   209 inline intptr_t** frame::interpreter_frame_locals_addr() const {
   210   return (intptr_t**) &(get_ijava_state()->locals);
   211 }
   212 inline intptr_t* frame::interpreter_frame_bcx_addr() const {
   213   return (intptr_t*) &(get_ijava_state()->bcp);
   214 }
   215 inline intptr_t* frame::interpreter_frame_mdx_addr() const {
   216   return (intptr_t*) &(get_ijava_state()->mdx);
   217 }
   218 // Pointer beyond the "oldest/deepest" BasicObjectLock on stack.
   219 inline BasicObjectLock* frame::interpreter_frame_monitor_end() const {
   220   return (BasicObjectLock *) get_ijava_state()->monitors;
   221 }
   223 inline BasicObjectLock* frame::interpreter_frame_monitor_begin() const {
   224   return (BasicObjectLock *) get_ijava_state();
   225 }
   227 // SAPJVM ASc 2012-11-21. Return register stack slot addr at which currently interpreted method is found
   228 inline Method** frame::interpreter_frame_method_addr() const {
   229   return (Method**) &(get_ijava_state()->method);
   230 }
   231 inline ConstantPoolCache** frame::interpreter_frame_cpoolcache_addr() const {
   232   return (ConstantPoolCache**) &(get_ijava_state()->cpoolCache);
   233 }
   234 inline ConstantPoolCache** frame::interpreter_frame_cache_addr() const {
   235   return (ConstantPoolCache**) &(get_ijava_state()->cpoolCache);
   236 }
   238 inline oop* frame::interpreter_frame_temp_oop_addr() const {
   239   return (oop *) &(get_ijava_state()->oop_tmp);
   240 }
   241 inline intptr_t* frame::interpreter_frame_esp() const {
   242   return (intptr_t*) get_ijava_state()->esp;
   243 }
   245 // Convenient setters
   246 inline void frame::interpreter_frame_set_monitor_end(BasicObjectLock* end)    { get_ijava_state()->monitors = (intptr_t) end;}
   247 inline void frame::interpreter_frame_set_cpcache(ConstantPoolCache* cp)       { *frame::interpreter_frame_cpoolcache_addr() = cp; }
   248 inline void frame::interpreter_frame_set_esp(intptr_t* esp)                   { get_ijava_state()->esp = (intptr_t) esp; }
   249 inline void frame::interpreter_frame_set_top_frame_sp(intptr_t* top_frame_sp) { get_ijava_state()->top_frame_sp = (intptr_t) top_frame_sp; }
   250 inline void frame::interpreter_frame_set_sender_sp(intptr_t* sender_sp)       { get_ijava_state()->sender_sp = (intptr_t) sender_sp; }
   252 inline intptr_t* frame::interpreter_frame_expression_stack() const {
   253   return (intptr_t*)interpreter_frame_monitor_end() - 1;
   254 }
   256 inline jint frame::interpreter_frame_expression_stack_direction() {
   257   return -1;
   258 }
   260 // top of expression stack
   261 inline intptr_t* frame::interpreter_frame_tos_address() const {
   262   return ((intptr_t*) get_ijava_state()->esp) + Interpreter::stackElementWords;
   263 }
   265 inline intptr_t* frame::interpreter_frame_tos_at(jint offset) const {
   266   return &interpreter_frame_tos_address()[offset];
   267 }
   269 #endif // CC_INTERP
   271 inline int frame::interpreter_frame_monitor_size() {
   272   // Number of stack slots for a monitor.
   273   return round_to(BasicObjectLock::size(),  // number of stack slots
   274                   WordsPerLong);            // number of stack slots for a Java long
   275 }
   277 inline int frame::interpreter_frame_monitor_size_in_bytes() {
   278   return frame::interpreter_frame_monitor_size() * wordSize;
   279 }
   281 // entry frames
   283 inline intptr_t* frame::entry_frame_argument_at(int offset) const {
   284   // Since an entry frame always calls the interpreter first, the
   285   // parameters are on the stack and relative to known register in the
   286   // entry frame.
   287   intptr_t* tos = (intptr_t*)get_entry_frame_locals()->arguments_tos_address;
   288   return &tos[offset + 1]; // prepushed tos
   289 }
   291 inline JavaCallWrapper** frame::entry_frame_call_wrapper_addr() const {
   292   return (JavaCallWrapper**)&get_entry_frame_locals()->call_wrapper_address;
   293 }
   295 inline oop frame::saved_oop_result(RegisterMap* map) const {
   296   return *((oop*)map->location(R3->as_VMReg()));
   297 }
   299 inline void frame::set_saved_oop_result(RegisterMap* map, oop obj) {
   300   *((oop*)map->location(R3->as_VMReg())) = obj;
   301 }
   303 #endif // CPU_PPC_VM_FRAME_PPC_INLINE_HPP

mercurial