src/hotspot/cpu/aarch64/frame_aarch64.inline.hpp
changeset 47216 71c04702a3d5
parent 43474 8fbf946045f6
child 49397 d3a8aa01f26f
equal deleted inserted replaced
47215:4ebc2e2fb97c 47216:71c04702a3d5
       
     1 /*
       
     2  * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
       
     3  * Copyright (c) 2014, Red Hat Inc. 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  */
       
    25 
       
    26 #ifndef CPU_AARCH64_VM_FRAME_AARCH64_INLINE_HPP
       
    27 #define CPU_AARCH64_VM_FRAME_AARCH64_INLINE_HPP
       
    28 
       
    29 #include "code/codeCache.hpp"
       
    30 #include "code/vmreg.inline.hpp"
       
    31 
       
    32 // Inline functions for AArch64 frames:
       
    33 
       
    34 // Constructors:
       
    35 
       
    36 inline frame::frame() {
       
    37   _pc = NULL;
       
    38   _sp = NULL;
       
    39   _unextended_sp = NULL;
       
    40   _fp = NULL;
       
    41   _cb = NULL;
       
    42   _deopt_state = unknown;
       
    43 }
       
    44 
       
    45 static int spin;
       
    46 
       
    47 inline void frame::init(intptr_t* sp, intptr_t* fp, address pc) {
       
    48   intptr_t a = intptr_t(sp);
       
    49   intptr_t b = intptr_t(fp);
       
    50   _sp = sp;
       
    51   _unextended_sp = sp;
       
    52   _fp = fp;
       
    53   _pc = pc;
       
    54   assert(pc != NULL, "no pc?");
       
    55   _cb = CodeCache::find_blob(pc);
       
    56   adjust_unextended_sp();
       
    57 
       
    58   address original_pc = CompiledMethod::get_deopt_original_pc(this);
       
    59   if (original_pc != NULL) {
       
    60     _pc = original_pc;
       
    61     _deopt_state = is_deoptimized;
       
    62   } else {
       
    63     _deopt_state = not_deoptimized;
       
    64   }
       
    65 }
       
    66 
       
    67 inline frame::frame(intptr_t* sp, intptr_t* fp, address pc) {
       
    68   init(sp, fp, pc);
       
    69 }
       
    70 
       
    71 inline frame::frame(intptr_t* sp, intptr_t* unextended_sp, intptr_t* fp, address pc) {
       
    72   intptr_t a = intptr_t(sp);
       
    73   intptr_t b = intptr_t(fp);
       
    74   _sp = sp;
       
    75   _unextended_sp = unextended_sp;
       
    76   _fp = fp;
       
    77   _pc = pc;
       
    78   assert(pc != NULL, "no pc?");
       
    79   _cb = CodeCache::find_blob(pc);
       
    80   adjust_unextended_sp();
       
    81 
       
    82   address original_pc = CompiledMethod::get_deopt_original_pc(this);
       
    83   if (original_pc != NULL) {
       
    84     _pc = original_pc;
       
    85     assert(_cb->as_compiled_method()->insts_contains_inclusive(_pc),
       
    86            "original PC must be in the main code section of the the compiled method (or must be immediately following it)");
       
    87     _deopt_state = is_deoptimized;
       
    88   } else {
       
    89     _deopt_state = not_deoptimized;
       
    90   }
       
    91 }
       
    92 
       
    93 inline frame::frame(intptr_t* sp, intptr_t* fp) {
       
    94   intptr_t a = intptr_t(sp);
       
    95   intptr_t b = intptr_t(fp);
       
    96   _sp = sp;
       
    97   _unextended_sp = sp;
       
    98   _fp = fp;
       
    99   _pc = (address)(sp[-1]);
       
   100 
       
   101   // Here's a sticky one. This constructor can be called via AsyncGetCallTrace
       
   102   // when last_Java_sp is non-null but the pc fetched is junk. If we are truly
       
   103   // unlucky the junk value could be to a zombied method and we'll die on the
       
   104   // find_blob call. This is also why we can have no asserts on the validity
       
   105   // of the pc we find here. AsyncGetCallTrace -> pd_get_top_frame_for_signal_handler
       
   106   // -> pd_last_frame should use a specialized version of pd_last_frame which could
       
   107   // call a specilaized frame constructor instead of this one.
       
   108   // Then we could use the assert below. However this assert is of somewhat dubious
       
   109   // value.
       
   110   // assert(_pc != NULL, "no pc?");
       
   111 
       
   112   _cb = CodeCache::find_blob(_pc);
       
   113   adjust_unextended_sp();
       
   114 
       
   115   address original_pc = CompiledMethod::get_deopt_original_pc(this);
       
   116   if (original_pc != NULL) {
       
   117     _pc = original_pc;
       
   118     _deopt_state = is_deoptimized;
       
   119   } else {
       
   120     _deopt_state = not_deoptimized;
       
   121   }
       
   122 }
       
   123 
       
   124 // Accessors
       
   125 
       
   126 inline bool frame::equal(frame other) const {
       
   127   bool ret =  sp() == other.sp()
       
   128               && unextended_sp() == other.unextended_sp()
       
   129               && fp() == other.fp()
       
   130               && pc() == other.pc();
       
   131   assert(!ret || ret && cb() == other.cb() && _deopt_state == other._deopt_state, "inconsistent construction");
       
   132   return ret;
       
   133 }
       
   134 
       
   135 // Return unique id for this frame. The id must have a value where we can distinguish
       
   136 // identity and younger/older relationship. NULL represents an invalid (incomparable)
       
   137 // frame.
       
   138 inline intptr_t* frame::id(void) const { return unextended_sp(); }
       
   139 
       
   140 // Relationals on frames based
       
   141 // Return true if the frame is younger (more recent activation) than the frame represented by id
       
   142 inline bool frame::is_younger(intptr_t* id) const { assert(this->id() != NULL && id != NULL, "NULL frame id");
       
   143                                                     return this->id() < id ; }
       
   144 
       
   145 // Return true if the frame is older (less recent activation) than the frame represented by id
       
   146 inline bool frame::is_older(intptr_t* id) const   { assert(this->id() != NULL && id != NULL, "NULL frame id");
       
   147                                                     return this->id() > id ; }
       
   148 
       
   149 
       
   150 
       
   151 inline intptr_t* frame::link() const              { return (intptr_t*) *(intptr_t **)addr_at(link_offset); }
       
   152 
       
   153 
       
   154 inline intptr_t* frame::unextended_sp() const     { return _unextended_sp; }
       
   155 
       
   156 // Return address:
       
   157 
       
   158 inline address* frame::sender_pc_addr()      const { return (address*) addr_at( return_addr_offset); }
       
   159 inline address  frame::sender_pc()           const { return *sender_pc_addr(); }
       
   160 
       
   161 inline intptr_t*    frame::sender_sp()        const { return            addr_at(   sender_sp_offset); }
       
   162 
       
   163 inline intptr_t** frame::interpreter_frame_locals_addr() const {
       
   164   return (intptr_t**)addr_at(interpreter_frame_locals_offset);
       
   165 }
       
   166 
       
   167 inline intptr_t* frame::interpreter_frame_last_sp() const {
       
   168   return *(intptr_t**)addr_at(interpreter_frame_last_sp_offset);
       
   169 }
       
   170 
       
   171 inline intptr_t* frame::interpreter_frame_bcp_addr() const {
       
   172   return (intptr_t*)addr_at(interpreter_frame_bcp_offset);
       
   173 }
       
   174 
       
   175 inline intptr_t* frame::interpreter_frame_mdp_addr() const {
       
   176   return (intptr_t*)addr_at(interpreter_frame_mdp_offset);
       
   177 }
       
   178 
       
   179 
       
   180 // Constant pool cache
       
   181 
       
   182 inline ConstantPoolCache** frame::interpreter_frame_cache_addr() const {
       
   183   return (ConstantPoolCache**)addr_at(interpreter_frame_cache_offset);
       
   184 }
       
   185 
       
   186 // Method
       
   187 
       
   188 inline Method** frame::interpreter_frame_method_addr() const {
       
   189   return (Method**)addr_at(interpreter_frame_method_offset);
       
   190 }
       
   191 
       
   192 // Mirror
       
   193 
       
   194 inline oop* frame::interpreter_frame_mirror_addr() const {
       
   195   return (oop*)addr_at(interpreter_frame_mirror_offset);
       
   196 }
       
   197 
       
   198 // top of expression stack
       
   199 inline intptr_t* frame::interpreter_frame_tos_address() const {
       
   200   intptr_t* last_sp = interpreter_frame_last_sp();
       
   201   if (last_sp == NULL) {
       
   202     return sp();
       
   203   } else {
       
   204     // sp() may have been extended or shrunk by an adapter.  At least
       
   205     // check that we don't fall behind the legal region.
       
   206     // For top deoptimized frame last_sp == interpreter_frame_monitor_end.
       
   207     assert(last_sp <= (intptr_t*) interpreter_frame_monitor_end(), "bad tos");
       
   208     return last_sp;
       
   209   }
       
   210 }
       
   211 
       
   212 inline oop* frame::interpreter_frame_temp_oop_addr() const {
       
   213   return (oop *)(fp() + interpreter_frame_oop_temp_offset);
       
   214 }
       
   215 
       
   216 inline int frame::pd_oop_map_offset_adjustment() const {
       
   217   return 0;
       
   218 }
       
   219 
       
   220 inline int frame::interpreter_frame_monitor_size() {
       
   221   return BasicObjectLock::size();
       
   222 }
       
   223 
       
   224 
       
   225 // expression stack
       
   226 // (the max_stack arguments are used by the GC; see class FrameClosure)
       
   227 
       
   228 inline intptr_t* frame::interpreter_frame_expression_stack() const {
       
   229   intptr_t* monitor_end = (intptr_t*) interpreter_frame_monitor_end();
       
   230   return monitor_end-1;
       
   231 }
       
   232 
       
   233 
       
   234 inline jint frame::interpreter_frame_expression_stack_direction() { return -1; }
       
   235 
       
   236 
       
   237 // Entry frames
       
   238 
       
   239 inline JavaCallWrapper** frame::entry_frame_call_wrapper_addr() const {
       
   240  return (JavaCallWrapper**)addr_at(entry_frame_call_wrapper_offset);
       
   241 }
       
   242 
       
   243 
       
   244 // Compiled frames
       
   245 
       
   246 inline int frame::local_offset_for_compiler(int local_index, int nof_args, int max_nof_locals, int max_nof_monitors) {
       
   247   return (nof_args - local_index + (local_index < nof_args ? 1: -1));
       
   248 }
       
   249 
       
   250 inline int frame::monitor_offset_for_compiler(int local_index, int nof_args, int max_nof_locals, int max_nof_monitors) {
       
   251   return local_offset_for_compiler(local_index, nof_args, max_nof_locals, max_nof_monitors);
       
   252 }
       
   253 
       
   254 inline int frame::min_local_offset_for_compiler(int nof_args, int max_nof_locals, int max_nof_monitors) {
       
   255   return (nof_args - (max_nof_locals + max_nof_monitors*2) - 1);
       
   256 }
       
   257 
       
   258 inline bool frame::volatile_across_calls(Register reg) {
       
   259   return true;
       
   260 }
       
   261 
       
   262 
       
   263 
       
   264 inline oop frame::saved_oop_result(RegisterMap* map) const {
       
   265   oop* result_adr = (oop *)map->location(r0->as_VMReg());
       
   266   guarantee(result_adr != NULL, "bad register save location");
       
   267 
       
   268   return (*result_adr);
       
   269 }
       
   270 
       
   271 inline void frame::set_saved_oop_result(RegisterMap* map, oop obj) {
       
   272   oop* result_adr = (oop *)map->location(r0->as_VMReg());
       
   273   guarantee(result_adr != NULL, "bad register save location");
       
   274 
       
   275   *result_adr = obj;
       
   276 }
       
   277 
       
   278 #endif // CPU_AARCH64_VM_FRAME_AARCH64_INLINE_HPP