1 /*
   2  * Copyright (c) 2008, 2016, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "interpreter/interpreter.hpp"
  27 #include "memory/resourceArea.hpp"
  28 #include "oops/markOop.hpp"
  29 #include "oops/method.hpp"
  30 #include "oops/oop.inline.hpp"
  31 #include "runtime/frame.inline.hpp"
  32 #include "runtime/handles.inline.hpp"
  33 #include "runtime/javaCalls.hpp"
  34 #include "runtime/monitorChunk.hpp"
  35 #include "runtime/signature.hpp"
  36 #include "runtime/stubCodeGenerator.hpp"
  37 #include "runtime/stubRoutines.hpp"
  38 #include "vmreg_arm.inline.hpp"
  39 #ifdef COMPILER1
  40 #include "c1/c1_Runtime1.hpp"
  41 #include "runtime/vframeArray.hpp"
  42 #endif
  43 #include "prims/methodHandles.hpp"
  44 
  45 #ifdef ASSERT
  46 void RegisterMap::check_location_valid() {
  47 }
  48 #endif
  49 
  50 
  51 // Profiling/safepoint support
  52 
  53 bool frame::safe_for_sender(JavaThread *thread) {
  54   address   sp = (address)_sp;
  55   address   fp = (address)_fp;
  56   address   unextended_sp = (address)_unextended_sp;
  57 
  58   static size_t stack_guard_size = os::uses_stack_guard_pages() ?
  59     (JavaThread::stack_red_zone_size() + JavaThread::stack_yellow_zone_size()) : 0;
  60   size_t usable_stack_size = thread->stack_size() - stack_guard_size;
  61 
  62   // sp must be within the usable part of the stack (not in guards)
  63   bool sp_safe = (sp != NULL &&
  64                  (sp <= thread->stack_base()) &&
  65                  (sp >= thread->stack_base() - usable_stack_size));
  66 
  67   if (!sp_safe) {
  68     return false;
  69   }
  70 
  71   bool unextended_sp_safe = (unextended_sp != NULL &&
  72                              (unextended_sp <= thread->stack_base()) &&
  73                              (unextended_sp >= sp));
  74   if (!unextended_sp_safe) {
  75     return false;
  76   }
  77 
  78   // We know sp/unextended_sp are safe. Only fp is questionable here.
  79 
  80   bool fp_safe = (fp != NULL &&
  81                   (fp <= thread->stack_base()) &&
  82                   fp >= sp);
  83 
  84   if (_cb != NULL ) {
  85 
  86     // First check if frame is complete and tester is reliable
  87     // Unfortunately we can only check frame complete for runtime stubs and nmethod
  88     // other generic buffer blobs are more problematic so we just assume they are
  89     // ok. adapter blobs never have a frame complete and are never ok.
  90 
  91     if (!_cb->is_frame_complete_at(_pc)) {
  92       if (_cb->is_compiled() || _cb->is_adapter_blob() || _cb->is_runtime_stub()) {
  93         return false;
  94       }
  95     }
  96 
  97     // Could just be some random pointer within the codeBlob
  98     if (!_cb->code_contains(_pc)) {
  99       return false;
 100     }
 101 
 102     // Entry frame checks
 103     if (is_entry_frame()) {
 104       // an entry frame must have a valid fp.
 105       return fp_safe && is_entry_frame_valid(thread);
 106     }
 107 
 108     intptr_t* sender_sp = NULL;
 109     address   sender_pc = NULL;
 110 
 111     if (is_interpreted_frame()) {
 112       // fp must be safe
 113       if (!fp_safe) {
 114         return false;
 115       }
 116 
 117       sender_pc = (address) this->fp()[return_addr_offset];
 118       sender_sp = (intptr_t*) addr_at(sender_sp_offset);
 119 
 120     } else {
 121       // must be some sort of compiled/runtime frame
 122       // fp does not have to be safe (although it could be check for c1?)
 123 
 124       sender_sp = _unextended_sp + _cb->frame_size();
 125       // Is sender_sp safe?
 126       if ((address)sender_sp >= thread->stack_base()) {
 127         return false;
 128       }
 129       // With our calling conventions, the return_address should
 130       // end up being the word on the stack
 131       sender_pc = (address) *(sender_sp - sender_sp_offset + return_addr_offset);
 132     }
 133 
 134     // We must always be able to find a recognizable pc
 135     CodeBlob* sender_blob = CodeCache::find_blob_unsafe(sender_pc);
 136     if (sender_pc == NULL || sender_blob == NULL) {
 137       return false;
 138     }
 139 
 140 
 141     // If the potential sender is the interpreter then we can do some more checking
 142     if (Interpreter::contains(sender_pc)) {
 143 
 144       // FP is always saved in a recognizable place in any code we generate. However
 145       // only if the sender is interpreted/call_stub (c1 too?) are we certain that the saved FP
 146       // is really a frame pointer.
 147 
 148       intptr_t *saved_fp = (intptr_t*)*(sender_sp - frame::sender_sp_offset + link_offset);
 149       bool saved_fp_safe = ((address)saved_fp <= thread->stack_base()) && (saved_fp > sender_sp);
 150 
 151       if (!saved_fp_safe) {
 152         return false;
 153       }
 154 
 155       // construct the potential sender
 156 
 157       frame sender(sender_sp, saved_fp, sender_pc);
 158 
 159       return sender.is_interpreted_frame_valid(thread);
 160     }
 161 
 162     if (sender_blob->is_zombie() || sender_blob->is_unloaded()) {
 163       return false;
 164     }
 165 
 166     // Could just be some random pointer within the codeBlob
 167     if (!sender_blob->code_contains(sender_pc)) {
 168       return false;
 169     }
 170 
 171     // We should never be able to see an adapter if the current frame is something from code cache
 172     if (sender_blob->is_adapter_blob()) {
 173       return false;
 174     }
 175 
 176     // Could be the call_stub
 177     if (StubRoutines::returns_to_call_stub(sender_pc)) {
 178       intptr_t *saved_fp = (intptr_t*)*(sender_sp - frame::sender_sp_offset + link_offset);
 179       bool saved_fp_safe = ((address)saved_fp <= thread->stack_base()) && (saved_fp >= sender_sp);
 180 
 181       if (!saved_fp_safe) {
 182         return false;
 183       }
 184 
 185       // construct the potential sender
 186 
 187       frame sender(sender_sp, saved_fp, sender_pc);
 188 
 189       // Validate the JavaCallWrapper an entry frame must have
 190       address jcw = (address)sender.entry_frame_call_wrapper();
 191 
 192       bool jcw_safe = (jcw <= thread->stack_base()) && (jcw > (address)sender.fp());
 193 
 194       return jcw_safe;
 195     }
 196 
 197     // If the frame size is 0 something (or less) is bad because every nmethod has a non-zero frame size
 198     // because the return address counts against the callee's frame.
 199 
 200     if (sender_blob->frame_size() <= 0) {
 201       assert(!sender_blob->is_compiled(), "should count return address at least");
 202       return false;
 203     }
 204 
 205     // We should never be able to see anything here except an nmethod. If something in the
 206     // code cache (current frame) is called by an entity within the code cache that entity
 207     // should not be anything but the call stub (already covered), the interpreter (already covered)
 208     // or an nmethod.
 209 
 210     if (!sender_blob->is_compiled()) {
 211       return false;
 212     }
 213 
 214     // Could put some more validation for the potential non-interpreted sender
 215     // frame we'd create by calling sender if I could think of any. Wait for next crash in forte...
 216 
 217     // One idea is seeing if the sender_pc we have is one that we'd expect to call to current cb
 218 
 219     // We've validated the potential sender that would be created
 220     return true;
 221   }
 222 
 223   // Must be native-compiled frame. Since sender will try and use fp to find
 224   // linkages it must be safe
 225 
 226   if (!fp_safe) {
 227     return false;
 228   }
 229 
 230   // Will the pc we fetch be non-zero (which we'll find at the oldest frame)
 231 
 232   if ((address) this->fp()[return_addr_offset] == NULL) return false;
 233 
 234 
 235   // could try and do some more potential verification of native frame if we could think of some...
 236 
 237   return true;
 238 }
 239 
 240 
 241 void frame::patch_pc(Thread* thread, address pc) {
 242   address* pc_addr = &((address *)sp())[-sender_sp_offset+return_addr_offset];
 243   if (TracePcPatching) {
 244     tty->print_cr("patch_pc at address" INTPTR_FORMAT " [" INTPTR_FORMAT " -> " INTPTR_FORMAT "] ",
 245                   p2i(pc_addr), p2i(*pc_addr), p2i(pc));
 246   }
 247   *pc_addr = pc;
 248   _cb = CodeCache::find_blob(pc);
 249   address original_pc = CompiledMethod::get_deopt_original_pc(this);
 250   if (original_pc != NULL) {
 251     assert(original_pc == _pc, "expected original PC to be stored before patching");
 252     _deopt_state = is_deoptimized;
 253     // leave _pc as is
 254   } else {
 255     _deopt_state = not_deoptimized;
 256     _pc = pc;
 257   }
 258 }
 259 
 260 bool frame::is_interpreted_frame() const  {
 261   return Interpreter::contains(pc());
 262 }
 263 
 264 int frame::frame_size(RegisterMap* map) const {
 265   frame sender = this->sender(map);
 266   return sender.sp() - sp();
 267 }
 268 
 269 intptr_t* frame::entry_frame_argument_at(int offset) const {
 270   assert(is_entry_frame(), "entry frame expected");
 271   // convert offset to index to deal with tsi
 272   int index = (Interpreter::expr_offset_in_bytes(offset)/wordSize);
 273   // Entry frame's arguments are always in relation to unextended_sp()
 274   return &unextended_sp()[index];
 275 }
 276 
 277 // sender_sp
 278 intptr_t* frame::interpreter_frame_sender_sp() const {
 279   assert(is_interpreted_frame(), "interpreted frame expected");
 280   return (intptr_t*) at(interpreter_frame_sender_sp_offset);
 281 }
 282 
 283 void frame::set_interpreter_frame_sender_sp(intptr_t* sender_sp) {
 284   assert(is_interpreted_frame(), "interpreted frame expected");
 285   ptr_at_put(interpreter_frame_sender_sp_offset, (intptr_t) sender_sp);
 286 }
 287 
 288 
 289 // monitor elements
 290 
 291 BasicObjectLock* frame::interpreter_frame_monitor_begin() const {
 292   return (BasicObjectLock*) addr_at(interpreter_frame_monitor_block_bottom_offset);
 293 }
 294 
 295 BasicObjectLock* frame::interpreter_frame_monitor_end() const {
 296   BasicObjectLock* result = (BasicObjectLock*) *addr_at(interpreter_frame_monitor_block_top_offset);
 297   // make sure the pointer points inside the frame
 298   assert((intptr_t) fp() >  (intptr_t) result, "result must <  than frame pointer");
 299   assert((intptr_t) sp() <= (intptr_t) result, "result must >= than stack pointer");
 300   return result;
 301 }
 302 
 303 void frame::interpreter_frame_set_monitor_end(BasicObjectLock* value) {
 304   *((BasicObjectLock**)addr_at(interpreter_frame_monitor_block_top_offset)) = value;
 305 }
 306 
 307 #ifdef AARCH64
 308 
 309 // Used by template based interpreter deoptimization
 310 void frame::interpreter_frame_set_stack_top(intptr_t* stack_top) {
 311   *((intptr_t**)addr_at(interpreter_frame_stack_top_offset)) = stack_top;
 312 }
 313 
 314 // Used by template based interpreter deoptimization
 315 void frame::interpreter_frame_set_extended_sp(intptr_t* sp) {
 316   *((intptr_t**)addr_at(interpreter_frame_extended_sp_offset)) = sp;
 317 }
 318 
 319 #else
 320 
 321 // Used by template based interpreter deoptimization
 322 void frame::interpreter_frame_set_last_sp(intptr_t* sp) {
 323     *((intptr_t**)addr_at(interpreter_frame_last_sp_offset)) = sp;
 324 }
 325 
 326 #endif // AARCH64
 327 
 328 frame frame::sender_for_entry_frame(RegisterMap* map) const {
 329   assert(map != NULL, "map must be set");
 330   // Java frame called from C; skip all C frames and return top C
 331   // frame of that chunk as the sender
 332   JavaFrameAnchor* jfa = entry_frame_call_wrapper()->anchor();
 333   assert(!entry_frame_is_first(), "next Java fp must be non zero");
 334   assert(jfa->last_Java_sp() > sp(), "must be above this frame on stack");
 335   map->clear();
 336   assert(map->include_argument_oops(), "should be set by clear");
 337 #ifdef AARCH64
 338   assert (jfa->last_Java_pc() != NULL, "pc should be stored");
 339   frame fr(jfa->last_Java_sp(), jfa->last_Java_fp(), jfa->last_Java_pc());
 340   return fr;
 341 #else
 342   if (jfa->last_Java_pc() != NULL) {
 343     frame fr(jfa->last_Java_sp(), jfa->last_Java_fp(), jfa->last_Java_pc());
 344     return fr;
 345   }
 346   frame fr(jfa->last_Java_sp(), jfa->last_Java_fp());
 347   return fr;
 348 #endif // AARCH64
 349 }
 350 
 351 //------------------------------------------------------------------------------
 352 // frame::verify_deopt_original_pc
 353 //
 354 // Verifies the calculated original PC of a deoptimization PC for the
 355 // given unextended SP.  The unextended SP might also be the saved SP
 356 // for MethodHandle call sites.
 357 #ifdef ASSERT
 358 void frame::verify_deopt_original_pc(CompiledMethod* nm, intptr_t* unextended_sp, bool is_method_handle_return) {
 359   frame fr;
 360 
 361   // This is ugly but it's better than to change {get,set}_original_pc
 362   // to take an SP value as argument.  And it's only a debugging
 363   // method anyway.
 364   fr._unextended_sp = unextended_sp;
 365 
 366   address original_pc = nm->get_original_pc(&fr);
 367   assert(nm->insts_contains_inclusive(original_pc),
 368          "original PC must be in the main code section of the the compiled method (or must be immediately following it)");
 369   assert(nm->is_method_handle_return(original_pc) == is_method_handle_return, "must be");
 370 }
 371 #endif
 372 
 373 //------------------------------------------------------------------------------
 374 // frame::adjust_unextended_sp
 375 void frame::adjust_unextended_sp() {
 376   // same as on x86
 377 
 378   // If we are returning to a compiled MethodHandle call site, the
 379   // saved_fp will in fact be a saved value of the unextended SP.  The
 380   // simplest way to tell whether we are returning to such a call site
 381   // is as follows:
 382 
 383   CompiledMethod* sender_cm = (_cb == NULL) ? NULL : _cb->as_compiled_method_or_null();
 384   if (sender_cm != NULL) {
 385     // If the sender PC is a deoptimization point, get the original
 386     // PC.  For MethodHandle call site the unextended_sp is stored in
 387     // saved_fp.
 388     if (sender_cm->is_deopt_mh_entry(_pc)) {
 389       DEBUG_ONLY(verify_deopt_mh_original_pc(sender_cm, _fp));
 390       _unextended_sp = _fp;
 391     }
 392     else if (sender_cm->is_deopt_entry(_pc)) {
 393       DEBUG_ONLY(verify_deopt_original_pc(sender_cm, _unextended_sp));
 394     }
 395     else if (sender_cm->is_method_handle_return(_pc)) {
 396       _unextended_sp = _fp;
 397     }
 398   }
 399 }
 400 
 401 //------------------------------------------------------------------------------
 402 // frame::update_map_with_saved_link
 403 void frame::update_map_with_saved_link(RegisterMap* map, intptr_t** link_addr) {
 404   // see x86 for comments
 405   map->set_location(FP->as_VMReg(), (address) link_addr);
 406 #ifdef AARCH64
 407   // also adjust a high part of register
 408   map->set_location(FP->as_VMReg()->next(), (address) link_addr);
 409 #endif // AARCH64
 410 }
 411 
 412 frame frame::sender_for_interpreter_frame(RegisterMap* map) const {
 413   // SP is the raw SP from the sender after adapter or interpreter
 414   // extension.
 415   intptr_t* sender_sp = this->sender_sp();
 416 
 417   // This is the sp before any possible extension (adapter/locals).
 418   intptr_t* unextended_sp = interpreter_frame_sender_sp();
 419 
 420 #ifdef COMPILER2
 421   if (map->update_map()) {
 422     update_map_with_saved_link(map, (intptr_t**) addr_at(link_offset));
 423   }
 424 #endif // COMPILER2
 425 
 426   return frame(sender_sp, unextended_sp, link(), sender_pc());
 427 }
 428 
 429 frame frame::sender_for_compiled_frame(RegisterMap* map) const {
 430   assert(map != NULL, "map must be set");
 431 
 432   // frame owned by optimizing compiler
 433   assert(_cb->frame_size() >= 0, "must have non-zero frame size");
 434   intptr_t* sender_sp = unextended_sp() + _cb->frame_size();
 435   intptr_t* unextended_sp = sender_sp;
 436 
 437   address sender_pc = (address) *(sender_sp - sender_sp_offset + return_addr_offset);
 438 
 439   // This is the saved value of FP which may or may not really be an FP.
 440   // It is only an FP if the sender is an interpreter frame (or C1?).
 441   intptr_t** saved_fp_addr = (intptr_t**) (sender_sp - sender_sp_offset + link_offset);
 442 
 443   if (map->update_map()) {
 444     // Tell GC to use argument oopmaps for some runtime stubs that need it.
 445     // For C1, the runtime stub might not have oop maps, so set this flag
 446     // outside of update_register_map.
 447     map->set_include_argument_oops(_cb->caller_must_gc_arguments(map->thread()));
 448     if (_cb->oop_maps() != NULL) {
 449       OopMapSet::update_register_map(this, map);
 450     }
 451 
 452     // Since the prolog does the save and restore of FP there is no oopmap
 453     // for it so we must fill in its location as if there was an oopmap entry
 454     // since if our caller was compiled code there could be live jvm state in it.
 455     update_map_with_saved_link(map, saved_fp_addr);
 456   }
 457 
 458   assert(sender_sp != sp(), "must have changed");
 459   return frame(sender_sp, unextended_sp, *saved_fp_addr, sender_pc);
 460 }
 461 
 462 frame frame::sender(RegisterMap* map) const {
 463   // Default is we done have to follow them. The sender_for_xxx will
 464   // update it accordingly
 465   map->set_include_argument_oops(false);
 466 
 467   if (is_entry_frame())       return sender_for_entry_frame(map);
 468   if (is_interpreted_frame()) return sender_for_interpreter_frame(map);
 469   assert(_cb == CodeCache::find_blob(pc()),"Must be the same");
 470 
 471   if (_cb != NULL) {
 472     return sender_for_compiled_frame(map);
 473   }
 474 
 475   assert(false, "should not be called for a C frame");
 476   return frame();
 477 }
 478 
 479 bool frame::is_interpreted_frame_valid(JavaThread* thread) const {
 480   assert(is_interpreted_frame(), "Not an interpreted frame");
 481   // These are reasonable sanity checks
 482   if (fp() == 0 || (intptr_t(fp()) & (wordSize-1)) != 0) {
 483     return false;
 484   }
 485   if (sp() == 0 || (intptr_t(sp()) & (wordSize-1)) != 0) {
 486     return false;
 487   }
 488   if (fp() + interpreter_frame_initial_sp_offset < sp()) {
 489     return false;
 490   }
 491   // These are hacks to keep us out of trouble.
 492   // The problem with these is that they mask other problems
 493   if (fp() <= sp()) {        // this attempts to deal with unsigned comparison above
 494     return false;
 495   }
 496   // do some validation of frame elements
 497 
 498   // first the method
 499 
 500   Method* m = *interpreter_frame_method_addr();
 501 
 502   // validate the method we'd find in this potential sender
 503   if (!m->is_valid_method()) return false;
 504 
 505   // stack frames shouldn't be much larger than max_stack elements
 506 
 507   if (fp() - sp() > 1024 + m->max_stack()*Interpreter::stackElementSize) {
 508     return false;
 509   }
 510 
 511   // validate bci/bcp
 512 
 513   address bcp = interpreter_frame_bcp();
 514   if (m->validate_bci_from_bcp(bcp) < 0) {
 515     return false;
 516   }
 517 
 518   // validate ConstantPoolCache*
 519   ConstantPoolCache* cp = *interpreter_frame_cache_addr();
 520   if (cp == NULL || !cp->is_metaspace_object()) return false;
 521 
 522   // validate locals
 523 
 524   address locals =  (address) *interpreter_frame_locals_addr();
 525 
 526   if (locals > thread->stack_base() || locals < (address) fp()) return false;
 527 
 528   // We'd have to be pretty unlucky to be mislead at this point
 529 
 530   return true;
 531 }
 532 
 533 BasicType frame::interpreter_frame_result(oop* oop_result, jvalue* value_result) {
 534   assert(is_interpreted_frame(), "interpreted frame expected");
 535   Method* method = interpreter_frame_method();
 536   BasicType type = method->result_type();
 537 
 538   intptr_t* res_addr;
 539   if (method->is_native()) {
 540     // Prior to calling into the runtime to report the method_exit both of
 541     // the possible return value registers are saved.
 542 #ifdef AARCH64
 543     // Return value registers are saved into the frame
 544     if (type == T_FLOAT || type == T_DOUBLE) {
 545       res_addr = addr_at(interpreter_frame_fp_saved_result_offset);
 546     } else {
 547       res_addr = addr_at(interpreter_frame_gp_saved_result_offset);
 548     }
 549 #else
 550     // Return value registers are pushed to the native stack
 551     res_addr = (intptr_t*)sp();
 552 #ifdef __ABI_HARD__
 553     // FP result is pushed onto a stack along with integer result registers
 554     if (type == T_FLOAT || type == T_DOUBLE) {
 555       res_addr += 2;
 556     }
 557 #endif // __ABI_HARD__
 558 #endif // AARCH64
 559   } else {
 560     res_addr = (intptr_t*)interpreter_frame_tos_address();
 561   }
 562 
 563   switch (type) {
 564     case T_OBJECT  :
 565     case T_ARRAY   : {
 566       oop obj;
 567       if (method->is_native()) {
 568         obj = cast_to_oop(at(interpreter_frame_oop_temp_offset));
 569       } else {
 570         obj = *(oop*)res_addr;
 571       }
 572       assert(obj == NULL || Universe::heap()->is_in(obj), "sanity check");
 573       *oop_result = obj;
 574       break;
 575     }
 576     case T_BOOLEAN : value_result->z = *(jboolean*)res_addr; break;
 577     case T_BYTE    : value_result->b = *(jbyte*)res_addr; break;
 578     case T_CHAR    : value_result->c = *(jchar*)res_addr; break;
 579     case T_SHORT   : value_result->s = *(jshort*)res_addr; break;
 580     case T_INT     : value_result->i = *(jint*)res_addr; break;
 581     case T_LONG    : value_result->j = *(jlong*)res_addr; break;
 582     case T_FLOAT   : value_result->f = *(jfloat*)res_addr; break;
 583     case T_DOUBLE  : value_result->d = *(jdouble*)res_addr; break;
 584     case T_VOID    : /* Nothing to do */ break;
 585     default        : ShouldNotReachHere();
 586   }
 587 
 588   return type;
 589 }
 590 
 591 
 592 intptr_t* frame::interpreter_frame_tos_at(jint offset) const {
 593   int index = (Interpreter::expr_offset_in_bytes(offset)/wordSize);
 594   return &interpreter_frame_tos_address()[index];
 595 }
 596 
 597 #ifndef PRODUCT
 598 
 599 #define DESCRIBE_FP_OFFSET(name) \
 600   values.describe(frame_no, fp() + frame::name##_offset, #name)
 601 
 602 void frame::describe_pd(FrameValues& values, int frame_no) {
 603   if (is_interpreted_frame()) {
 604     DESCRIBE_FP_OFFSET(interpreter_frame_sender_sp);
 605 #ifdef AARCH64
 606     DESCRIBE_FP_OFFSET(interpreter_frame_stack_top);
 607     DESCRIBE_FP_OFFSET(interpreter_frame_extended_sp);
 608 #else
 609     DESCRIBE_FP_OFFSET(interpreter_frame_last_sp);
 610 #endif // AARCH64
 611     DESCRIBE_FP_OFFSET(interpreter_frame_method);
 612     DESCRIBE_FP_OFFSET(interpreter_frame_mdp);
 613     DESCRIBE_FP_OFFSET(interpreter_frame_cache);
 614     DESCRIBE_FP_OFFSET(interpreter_frame_locals);
 615     DESCRIBE_FP_OFFSET(interpreter_frame_bcp);
 616     DESCRIBE_FP_OFFSET(interpreter_frame_initial_sp);
 617   }
 618 }
 619 
 620 // This is a generic constructor which is only used by pns() in debug.cpp.
 621 frame::frame(void* sp, void* fp, void* pc) {
 622   init((intptr_t*)sp, (intptr_t*)fp, (address)pc);
 623 }
 624 #endif
 625 
 626 intptr_t *frame::initial_deoptimization_info() {
 627   // used to reset the saved FP
 628   return fp();
 629 }
 630 
 631 intptr_t* frame::real_fp() const {
 632 #ifndef AARCH64
 633   if (is_entry_frame()) {
 634     // Work-around: FP (currently) does not conform to the ABI for entry
 635     // frames (see generate_call_stub). Might be worth fixing as another CR.
 636     // Following code assumes (and asserts) this has not yet been fixed.
 637     assert(frame::entry_frame_call_wrapper_offset == 0, "adjust this code");
 638     intptr_t* new_fp = fp();
 639     new_fp += 5; // saved R0,R1,R2,R4,R10
 640 #ifndef __SOFTFP__
 641     new_fp += 8*2; // saved D8..D15
 642 #endif
 643     return new_fp;
 644   }
 645 #endif // !AARCH64
 646   if (_cb != NULL) {
 647     // use the frame size if valid
 648     int size = _cb->frame_size();
 649     if (size > 0) {
 650       return unextended_sp() + size;
 651     }
 652   }
 653   // else rely on fp()
 654   assert(! is_compiled_frame(), "unknown compiled frame size");
 655   return fp();
 656 }