annotate hotspot/src/cpu/aarch64/vm/frame_aarch64.inline.hpp @ 30552:ff209a4a81b5

8079564: Use FP register as proper frame pointer in JIT compiled code on aarch64 Summary: Add support for PreserveFramePointer for debug/profile Reviewed-by: kvn
author enevill
date Fri, 15 May 2015 09:21:48 +0000
parents d148e1b2fac2
children d86005e0b4c2
rev   line source
aph@29183 1 /*
mikael@29571 2 * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
aph@29183 3 * Copyright (c) 2014, Red Hat Inc. All rights reserved.
aph@29183 4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
aph@29183 5 *
aph@29183 6 * This code is free software; you can redistribute it and/or modify it
aph@29183 7 * under the terms of the GNU General Public License version 2 only, as
aph@29183 8 * published by the Free Software Foundation.
aph@29183 9 *
aph@29183 10 * This code is distributed in the hope that it will be useful, but WITHOUT
aph@29183 11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
aph@29183 12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
aph@29183 13 * version 2 for more details (a copy is included in the LICENSE file that
aph@29183 14 * accompanied this code).
aph@29183 15 *
aph@29183 16 * You should have received a copy of the GNU General Public License version
aph@29183 17 * 2 along with this work; if not, write to the Free Software Foundation,
aph@29183 18 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
aph@29183 19 *
aph@29183 20 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
aph@29183 21 * or visit www.oracle.com if you need additional information or have any
aph@29183 22 * questions.
aph@29183 23 *
aph@29183 24 */
aph@29183 25
aph@29183 26 #ifndef CPU_AARCH64_VM_FRAME_AARCH64_INLINE_HPP
aph@29183 27 #define CPU_AARCH64_VM_FRAME_AARCH64_INLINE_HPP
aph@29183 28
aph@29183 29 #include "code/codeCache.hpp"
aph@29183 30 #include "code/vmreg.inline.hpp"
aph@29183 31
aph@29183 32 // Inline functions for AArch64 frames:
aph@29183 33
aph@29183 34 // Constructors:
aph@29183 35
aph@29183 36 inline frame::frame() {
aph@29183 37 _pc = NULL;
aph@29183 38 _sp = NULL;
aph@29183 39 _unextended_sp = NULL;
aph@29183 40 _fp = NULL;
aph@29183 41 _cb = NULL;
aph@29183 42 _deopt_state = unknown;
aph@29183 43 }
aph@29183 44
aph@29183 45 static int spin;
aph@29183 46
aph@29183 47 inline void frame::init(intptr_t* sp, intptr_t* fp, address pc) {
aph@29183 48 intptr_t a = intptr_t(sp);
aph@29183 49 intptr_t b = intptr_t(fp);
aph@29183 50 _sp = sp;
aph@29183 51 _unextended_sp = sp;
aph@29183 52 _fp = fp;
aph@29183 53 _pc = pc;
aph@29183 54 assert(pc != NULL, "no pc?");
aph@29183 55 _cb = CodeCache::find_blob(pc);
aph@29183 56 adjust_unextended_sp();
aph@29183 57
aph@29183 58 address original_pc = nmethod::get_deopt_original_pc(this);
aph@29183 59 if (original_pc != NULL) {
aph@29183 60 _pc = original_pc;
aph@29183 61 _deopt_state = is_deoptimized;
aph@29183 62 } else {
aph@29183 63 _deopt_state = not_deoptimized;
aph@29183 64 }
aph@29183 65 }
aph@29183 66
aph@29183 67 inline frame::frame(intptr_t* sp, intptr_t* fp, address pc) {
aph@29183 68 init(sp, fp, pc);
aph@29183 69 }
aph@29183 70
aph@29183 71 inline frame::frame(intptr_t* sp, intptr_t* unextended_sp, intptr_t* fp, address pc) {
aph@29183 72 intptr_t a = intptr_t(sp);
aph@29183 73 intptr_t b = intptr_t(fp);
aph@29183 74 _sp = sp;
aph@29183 75 _unextended_sp = unextended_sp;
aph@29183 76 _fp = fp;
aph@29183 77 _pc = pc;
aph@29183 78 assert(pc != NULL, "no pc?");
aph@29183 79 _cb = CodeCache::find_blob(pc);
aph@29183 80 adjust_unextended_sp();
aph@29183 81
aph@29183 82 address original_pc = nmethod::get_deopt_original_pc(this);
aph@29183 83 if (original_pc != NULL) {
aph@29183 84 _pc = original_pc;
aph@29183 85 assert(((nmethod*)_cb)->insts_contains(_pc), "original PC must be in nmethod");
aph@29183 86 _deopt_state = is_deoptimized;
aph@29183 87 } else {
aph@29183 88 _deopt_state = not_deoptimized;
aph@29183 89 }
aph@29183 90 }
aph@29183 91
aph@29183 92 inline frame::frame(intptr_t* sp, intptr_t* fp) {
aph@29183 93 intptr_t a = intptr_t(sp);
aph@29183 94 intptr_t b = intptr_t(fp);
aph@29183 95 _sp = sp;
aph@29183 96 _unextended_sp = sp;
aph@29183 97 _fp = fp;
aph@29183 98 _pc = (address)(sp[-1]);
aph@29183 99
aph@29183 100 // Here's a sticky one. This constructor can be called via AsyncGetCallTrace
aph@29183 101 // when last_Java_sp is non-null but the pc fetched is junk. If we are truly
aph@29183 102 // unlucky the junk value could be to a zombied method and we'll die on the
aph@29183 103 // find_blob call. This is also why we can have no asserts on the validity
aph@29183 104 // of the pc we find here. AsyncGetCallTrace -> pd_get_top_frame_for_signal_handler
aph@29183 105 // -> pd_last_frame should use a specialized version of pd_last_frame which could
aph@29183 106 // call a specilaized frame constructor instead of this one.
aph@29183 107 // Then we could use the assert below. However this assert is of somewhat dubious
aph@29183 108 // value.
aph@29183 109 // assert(_pc != NULL, "no pc?");
aph@29183 110
aph@29183 111 _cb = CodeCache::find_blob(_pc);
aph@29183 112 adjust_unextended_sp();
aph@29183 113
aph@29183 114 address original_pc = nmethod::get_deopt_original_pc(this);
aph@29183 115 if (original_pc != NULL) {
aph@29183 116 _pc = original_pc;
aph@29183 117 _deopt_state = is_deoptimized;
aph@29183 118 } else {
aph@29183 119 _deopt_state = not_deoptimized;
aph@29183 120 }
aph@29183 121 }
aph@29183 122
aph@29183 123 // Accessors
aph@29183 124
aph@29183 125 inline bool frame::equal(frame other) const {
aph@29183 126 bool ret = sp() == other.sp()
aph@29183 127 && unextended_sp() == other.unextended_sp()
aph@29183 128 && fp() == other.fp()
aph@29183 129 && pc() == other.pc();
aph@29183 130 assert(!ret || ret && cb() == other.cb() && _deopt_state == other._deopt_state, "inconsistent construction");
aph@29183 131 return ret;
aph@29183 132 }
aph@29183 133
aph@29183 134 // Return unique id for this frame. The id must have a value where we can distinguish
aph@29183 135 // identity and younger/older relationship. NULL represents an invalid (incomparable)
aph@29183 136 // frame.
aph@29183 137 inline intptr_t* frame::id(void) const { return unextended_sp(); }
aph@29183 138
aph@29183 139 // Relationals on frames based
aph@29183 140 // Return true if the frame is younger (more recent activation) than the frame represented by id
aph@29183 141 inline bool frame::is_younger(intptr_t* id) const { assert(this->id() != NULL && id != NULL, "NULL frame id");
aph@29183 142 return this->id() < id ; }
aph@29183 143
aph@29183 144 // Return true if the frame is older (less recent activation) than the frame represented by id
aph@29183 145 inline bool frame::is_older(intptr_t* id) const { assert(this->id() != NULL && id != NULL, "NULL frame id");
aph@29183 146 return this->id() > id ; }
aph@29183 147
aph@29183 148
aph@29183 149
aph@29183 150 inline intptr_t* frame::link() const { return (intptr_t*) *(intptr_t **)addr_at(link_offset); }
aph@29183 151
aph@29183 152
aph@29183 153 inline intptr_t* frame::unextended_sp() const { return _unextended_sp; }
aph@29183 154
aph@29183 155 // Return address:
aph@29183 156
aph@29183 157 inline address* frame::sender_pc_addr() const { return (address*) addr_at( return_addr_offset); }
aph@29183 158 inline address frame::sender_pc() const { return *sender_pc_addr(); }
aph@29183 159
aph@29183 160 #ifdef CC_INTERP
aph@29183 161
aph@29183 162 inline interpreterState frame::get_interpreterState() const {
aph@29183 163 return ((interpreterState)addr_at( -((int)sizeof(BytecodeInterpreter))/wordSize ));
aph@29183 164 }
aph@29183 165
aph@29183 166 inline intptr_t* frame::sender_sp() const {
aph@29183 167 // Hmm this seems awfully expensive QQQ, is this really called with interpreted frames?
aph@29183 168 if (is_interpreted_frame()) {
aph@29183 169 assert(false, "should never happen");
aph@29183 170 return get_interpreterState()->sender_sp();
aph@29183 171 } else {
aph@29183 172 return addr_at(sender_sp_offset);
aph@29183 173 }
aph@29183 174 }
aph@29183 175
aph@29183 176 inline intptr_t** frame::interpreter_frame_locals_addr() const {
aph@29183 177 assert(is_interpreted_frame(), "must be interpreted");
aph@29183 178 return &(get_interpreterState()->_locals);
aph@29183 179 }
aph@29183 180
aph@29183 181 inline intptr_t* frame::interpreter_frame_bcx_addr() const {
aph@29183 182 assert(is_interpreted_frame(), "must be interpreted");
aph@29183 183 return (intptr_t*) &(get_interpreterState()->_bcp);
aph@29183 184 }
aph@29183 185
aph@29183 186
aph@29183 187 // Constant pool cache
aph@29183 188
aph@29183 189 inline constantPoolCacheOop* frame::interpreter_frame_cache_addr() const {
aph@29183 190 assert(is_interpreted_frame(), "must be interpreted");
aph@29183 191 return &(get_interpreterState()->_constants);
aph@29183 192 }
aph@29183 193
aph@29183 194 // Method
aph@29183 195
aph@29183 196 inline methodOop* frame::interpreter_frame_method_addr() const {
aph@29183 197 assert(is_interpreted_frame(), "must be interpreted");
aph@29183 198 return &(get_interpreterState()->_method);
aph@29183 199 }
aph@29183 200
aph@29183 201 inline intptr_t* frame::interpreter_frame_mdx_addr() const {
aph@29183 202 assert(is_interpreted_frame(), "must be interpreted");
aph@29183 203 return (intptr_t*) &(get_interpreterState()->_mdx);
aph@29183 204 }
aph@29183 205
aph@29183 206 // top of expression stack
aph@29183 207 inline intptr_t* frame::interpreter_frame_tos_address() const {
aph@29183 208 assert(is_interpreted_frame(), "wrong frame type");
aph@29183 209 return get_interpreterState()->_stack + 1;
aph@29183 210 }
aph@29183 211
aph@29183 212 #else /* asm interpreter */
aph@29183 213 inline intptr_t* frame::sender_sp() const { return addr_at( sender_sp_offset); }
aph@29183 214
aph@29183 215 inline intptr_t** frame::interpreter_frame_locals_addr() const {
aph@29183 216 return (intptr_t**)addr_at(interpreter_frame_locals_offset);
aph@29183 217 }
aph@29183 218
aph@29183 219 inline intptr_t* frame::interpreter_frame_last_sp() const {
aph@29183 220 return *(intptr_t**)addr_at(interpreter_frame_last_sp_offset);
aph@29183 221 }
aph@29183 222
aph@29183 223 inline intptr_t* frame::interpreter_frame_bcp_addr() const {
aph@29183 224 return (intptr_t*)addr_at(interpreter_frame_bcp_offset);
aph@29183 225 }
aph@29183 226
aph@29183 227 inline intptr_t* frame::interpreter_frame_mdp_addr() const {
aph@29183 228 return (intptr_t*)addr_at(interpreter_frame_mdp_offset);
aph@29183 229 }
aph@29183 230
aph@29183 231
aph@29183 232 // Constant pool cache
aph@29183 233
aph@29183 234 inline ConstantPoolCache** frame::interpreter_frame_cache_addr() const {
aph@29183 235 return (ConstantPoolCache**)addr_at(interpreter_frame_cache_offset);
aph@29183 236 }
aph@29183 237
aph@29183 238 // Method
aph@29183 239
aph@29183 240 inline Method** frame::interpreter_frame_method_addr() const {
aph@29183 241 return (Method**)addr_at(interpreter_frame_method_offset);
aph@29183 242 }
aph@29183 243
aph@29183 244 // top of expression stack
aph@29183 245 inline intptr_t* frame::interpreter_frame_tos_address() const {
aph@29183 246 intptr_t* last_sp = interpreter_frame_last_sp();
aph@29183 247 if (last_sp == NULL) {
aph@29183 248 return sp();
aph@29183 249 } else {
aph@29183 250 // sp() may have been extended or shrunk by an adapter. At least
aph@29183 251 // check that we don't fall behind the legal region.
aph@29183 252 // For top deoptimized frame last_sp == interpreter_frame_monitor_end.
aph@29183 253 assert(last_sp <= (intptr_t*) interpreter_frame_monitor_end(), "bad tos");
aph@29183 254 return last_sp;
aph@29183 255 }
aph@29183 256 }
aph@29183 257
aph@29183 258 inline oop* frame::interpreter_frame_temp_oop_addr() const {
aph@29183 259 return (oop *)(fp() + interpreter_frame_oop_temp_offset);
aph@29183 260 }
aph@29183 261
aph@29183 262 #endif /* CC_INTERP */
aph@29183 263
aph@29183 264 inline int frame::pd_oop_map_offset_adjustment() const {
aph@29183 265 return 0;
aph@29183 266 }
aph@29183 267
aph@29183 268 inline int frame::interpreter_frame_monitor_size() {
aph@29183 269 return BasicObjectLock::size();
aph@29183 270 }
aph@29183 271
aph@29183 272
aph@29183 273 // expression stack
aph@29183 274 // (the max_stack arguments are used by the GC; see class FrameClosure)
aph@29183 275
aph@29183 276 inline intptr_t* frame::interpreter_frame_expression_stack() const {
aph@29183 277 intptr_t* monitor_end = (intptr_t*) interpreter_frame_monitor_end();
aph@29183 278 return monitor_end-1;
aph@29183 279 }
aph@29183 280
aph@29183 281
aph@29183 282 inline jint frame::interpreter_frame_expression_stack_direction() { return -1; }
aph@29183 283
aph@29183 284
aph@29183 285 // Entry frames
aph@29183 286
aph@29183 287 inline JavaCallWrapper** frame::entry_frame_call_wrapper_addr() const {
aph@29183 288 return (JavaCallWrapper**)addr_at(entry_frame_call_wrapper_offset);
aph@29183 289 }
aph@29183 290
aph@29183 291
aph@29183 292 // Compiled frames
aph@29183 293
aph@29183 294 inline int frame::local_offset_for_compiler(int local_index, int nof_args, int max_nof_locals, int max_nof_monitors) {
aph@29183 295 return (nof_args - local_index + (local_index < nof_args ? 1: -1));
aph@29183 296 }
aph@29183 297
aph@29183 298 inline int frame::monitor_offset_for_compiler(int local_index, int nof_args, int max_nof_locals, int max_nof_monitors) {
aph@29183 299 return local_offset_for_compiler(local_index, nof_args, max_nof_locals, max_nof_monitors);
aph@29183 300 }
aph@29183 301
aph@29183 302 inline int frame::min_local_offset_for_compiler(int nof_args, int max_nof_locals, int max_nof_monitors) {
aph@29183 303 return (nof_args - (max_nof_locals + max_nof_monitors*2) - 1);
aph@29183 304 }
aph@29183 305
aph@29183 306 inline bool frame::volatile_across_calls(Register reg) {
aph@29183 307 return true;
aph@29183 308 }
aph@29183 309
aph@29183 310
aph@29183 311
aph@29183 312 inline oop frame::saved_oop_result(RegisterMap* map) const {
aph@29183 313 oop* result_adr = (oop *)map->location(r0->as_VMReg());
aph@29183 314 guarantee(result_adr != NULL, "bad register save location");
aph@29183 315
aph@29183 316 return (*result_adr);
aph@29183 317 }
aph@29183 318
aph@29183 319 inline void frame::set_saved_oop_result(RegisterMap* map, oop obj) {
aph@29183 320 oop* result_adr = (oop *)map->location(r0->as_VMReg());
aph@29183 321 guarantee(result_adr != NULL, "bad register save location");
aph@29183 322
aph@29183 323 *result_adr = obj;
aph@29183 324 }
aph@29183 325
aph@29183 326 #endif // CPU_AARCH64_VM_FRAME_AARCH64_INLINE_HPP