1 /* 2 * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved. 3 * Copyright (c) 2014, Red Hat Inc. All rights reserved. 4 * Copyright (c) 2015, Linaro Ltd. All rights reserved. 5 * Copyright (c) 2015-2018, Azul Systems, Inc. All rights reserved. 6 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 7 * 8 * This code is free software; you can redistribute it and/or modify it 9 * under the terms of the GNU General Public License version 2 only, as 10 * published by the Free Software Foundation. 11 * 12 * This code is distributed in the hope that it will be useful, but WITHOUT 13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 15 * version 2 for more details (a copy is included in the LICENSE file that 16 * accompanied this code). 17 * 18 * You should have received a copy of the GNU General Public License version 19 * 2 along with this work; if not, write to the Free Software Foundation, 20 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 21 * 22 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 23 * or visit www.oracle.com if you need additional information or have any 24 * questions. 25 * 26 */ 27 28 #ifndef CPU_AARCH32_VM_FRAME_AARCH32_INLINE_HPP 29 #define CPU_AARCH32_VM_FRAME_AARCH32_INLINE_HPP 30 31 #include "code/codeCache.hpp" 32 #include "code/vmreg.inline.hpp" 33 34 // Inline functions for AArch64 frames: 35 36 // Constructors: 37 38 inline frame::frame() { 39 _pc = NULL; 40 _sp = NULL; 41 _unextended_sp = NULL; 42 _fp = NULL; 43 _cb = NULL; 44 _deopt_state = unknown; 45 } 46 47 static int spin; 48 49 inline void frame::init(intptr_t* sp, intptr_t* fp, address pc) { 50 intptr_t a = intptr_t(sp); 51 intptr_t b = intptr_t(fp); 52 _sp = sp; 53 _unextended_sp = sp; 54 _fp = fp; 55 _pc = pc; 56 assert(pc != NULL, "no pc?"); 57 _cb = CodeCache::find_blob(pc); 58 adjust_unextended_sp(); 59 60 address original_pc = CompiledMethod::get_deopt_original_pc(this); 61 if (original_pc != NULL) { 62 _pc = original_pc; 63 _deopt_state = is_deoptimized; 64 } else { 65 _deopt_state = not_deoptimized; 66 } 67 } 68 69 inline frame::frame(intptr_t* sp, intptr_t* fp, address pc) { 70 init(sp, fp, pc); 71 } 72 73 inline frame::frame(intptr_t* sp, intptr_t* unextended_sp, intptr_t* fp, address pc) { 74 intptr_t a = intptr_t(sp); 75 intptr_t b = intptr_t(fp); 76 _sp = sp; 77 _unextended_sp = unextended_sp; 78 _fp = fp; 79 _pc = pc; 80 assert(pc != NULL, "no pc?"); 81 _cb = CodeCache::find_blob(pc); 82 adjust_unextended_sp(); 83 84 address original_pc = CompiledMethod::get_deopt_original_pc(this); 85 if (original_pc != NULL) { 86 _pc = original_pc; 87 assert(_cb->as_compiled_method()->insts_contains_inclusive(_pc), 88 "original PC must be in the main code section of the the compiled method (or must be immediately following it)"); 89 _deopt_state = is_deoptimized; 90 } else { 91 _deopt_state = not_deoptimized; 92 } 93 } 94 95 inline frame::frame(intptr_t* sp, intptr_t* fp) { 96 _sp = sp; 97 _unextended_sp = sp; 98 _fp = fp; 99 assert(sp != NULL, "null SP ?"); 100 // C2 generated code does not use or set fp 101 _pc = (address)(/*fp != NULL ? fp[0] : */sp[-1]); 102 103 // Here's a sticky one. This constructor can be called via AsyncGetCallTrace 104 // when last_Java_sp is non-null but the pc fetched is junk. If we are truly 105 // unlucky the junk value could be to a zombied method and we'll die on the 106 // find_blob call. This is also why we can have no asserts on the validity 107 // of the pc we find here. AsyncGetCallTrace -> pd_get_top_frame_for_signal_handler 108 // -> pd_last_frame should use a specialized version of pd_last_frame which could 109 // call a specilaized frame constructor instead of this one. 110 // Then we could use the assert below. However this assert is of somewhat dubious 111 // value. 112 // assert(_pc != NULL, "no pc?"); 113 114 _cb = CodeCache::find_blob(_pc); 115 adjust_unextended_sp(); 116 117 address original_pc = CompiledMethod::get_deopt_original_pc(this); 118 if (original_pc != NULL) { 119 _pc = original_pc; 120 _deopt_state = is_deoptimized; 121 } else { 122 _deopt_state = not_deoptimized; 123 } 124 } 125 126 // Accessors 127 128 inline bool frame::equal(frame other) const { 129 bool ret = sp() == other.sp() 130 && unextended_sp() == other.unextended_sp() 131 && fp() == other.fp() 132 && pc() == other.pc(); 133 assert(!ret || ret && cb() == other.cb() && _deopt_state == other._deopt_state, "inconsistent construction"); 134 return ret; 135 } 136 137 // Return unique id for this frame. The id must have a value where we can distinguish 138 // identity and younger/older relationship. NULL represents an invalid (incomparable) 139 // frame. 140 inline intptr_t* frame::id(void) const { return unextended_sp(); } 141 142 // Relationals on frames based 143 // Return true if the frame is younger (more recent activation) than the frame represented by id 144 inline bool frame::is_younger(intptr_t* id) const { assert(this->id() != NULL && id != NULL, "NULL frame id"); 145 return this->id() < id ; } 146 147 // Return true if the frame is older (less recent activation) than the frame represented by id 148 inline bool frame::is_older(intptr_t* id) const { assert(this->id() != NULL && id != NULL, "NULL frame id"); 149 return this->id() > id ; } 150 151 inline intptr_t* frame::link() const { return *(intptr_t **)addr_at(get_link_offset(VMFrameAPCS)); } 152 153 inline intptr_t* frame::unextended_sp() const { return _unextended_sp; } 154 155 inline address frame::sender_pc() const { return *(address*) addr_at(get_return_addr_offset(VMFrameAPCS)); } 156 157 inline intptr_t* frame::sender_sp() const { return addr_at(sender_sp_offset); } 158 159 inline intptr_t** frame::interpreter_frame_locals_addr() const { 160 return (intptr_t**)addr_at(get_interpreter_frame_locals_offset()); 161 } 162 163 inline intptr_t* frame::interpreter_frame_last_sp() const { 164 return *(intptr_t**)addr_at(get_interpreter_frame_last_sp_offset()); 165 } 166 167 inline intptr_t* frame::interpreter_frame_bcp_addr() const { 168 return (intptr_t*) addr_at(get_interpreter_frame_bcp_offset()); 169 } 170 171 inline intptr_t* frame::interpreter_frame_mdp_addr() const { 172 return (intptr_t*) addr_at(get_interpreter_frame_mdp_offset()); 173 } 174 175 176 // Constant pool cache 177 178 inline ConstantPoolCache** frame::interpreter_frame_cache_addr() const { 179 return (ConstantPoolCache**)addr_at(get_interpreter_frame_cache_offset()); 180 } 181 182 // Method 183 184 inline Method** frame::interpreter_frame_method_addr() const { 185 return (Method**)addr_at(get_interpreter_frame_method_offset()); 186 } 187 188 // Mirror 189 190 inline oop* frame::interpreter_frame_mirror_addr() const { 191 return (oop*)addr_at(get_interpreter_frame_mirror_offset()); 192 } 193 194 // top of expression stack 195 inline intptr_t* frame::interpreter_frame_tos_address() const { 196 intptr_t* last_sp = interpreter_frame_last_sp(); 197 if (last_sp == NULL) { 198 return sp(); 199 } else { 200 // sp() may have been extended or shrunk by an adapter. At least 201 // check that we don't fall behind the legal region. 202 // For top deoptimized frame last_sp == interpreter_frame_monitor_end. 203 assert(last_sp <= (intptr_t*) interpreter_frame_monitor_end(), "bad tos"); 204 return last_sp; 205 } 206 } 207 208 inline oop* frame::interpreter_frame_temp_oop_addr() const { 209 return (oop *)(fp() + interpreter_frame_oop_temp_offset); 210 } 211 212 inline int frame::interpreter_frame_monitor_size() { 213 return BasicObjectLock::size(); 214 } 215 216 217 // expression stack 218 // (the max_stack arguments are used by the GC; see class FrameClosure) 219 220 inline intptr_t* frame::interpreter_frame_expression_stack() const { 221 intptr_t* monitor_end = (intptr_t*) interpreter_frame_monitor_end(); 222 return monitor_end-1; 223 } 224 225 226 // Entry frames 227 228 inline JavaCallWrapper** frame::entry_frame_call_wrapper_addr() const { 229 return (JavaCallWrapper**)addr_at(get_entry_frame_call_wrapper_offset()); 230 } 231 232 233 // Compiled frames 234 235 inline oop frame::saved_oop_result(RegisterMap* map) const { 236 oop* result_adr = (oop *)map->location(r0->as_VMReg()); 237 guarantee(result_adr != NULL, "bad register save location"); 238 239 return (*result_adr); 240 } 241 242 inline void frame::set_saved_oop_result(RegisterMap* map, oop obj) { 243 oop* result_adr = (oop *)map->location(r0->as_VMReg()); 244 guarantee(result_adr != NULL, "bad register save location"); 245 246 *result_adr = obj; 247 } 248 249 #endif // CPU_AARCH32_VM_FRAME_AARCH32_INLINE_HPP