1 /*
   2  * Copyright (c) 1997, 2024, 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 "classfile/moduleEntry.hpp"
  27 #include "code/codeCache.hpp"
  28 #include "code/scopeDesc.hpp"
  29 #include "code/vmreg.inline.hpp"
  30 #include "compiler/abstractCompiler.hpp"
  31 #include "compiler/disassembler.hpp"
  32 #include "compiler/oopMap.hpp"
  33 #include "gc/shared/collectedHeap.inline.hpp"
  34 #include "interpreter/interpreter.hpp"
  35 #include "interpreter/oopMapCache.hpp"
  36 #include "logging/log.hpp"
  37 #include "memory/resourceArea.hpp"
  38 #include "memory/universe.hpp"
  39 #include "oops/markWord.hpp"
  40 #include "oops/method.inline.hpp"
  41 #include "oops/methodData.hpp"
  42 #include "oops/oop.inline.hpp"
  43 #include "oops/stackChunkOop.inline.hpp"
  44 #include "oops/verifyOopClosure.hpp"
  45 #include "prims/methodHandles.hpp"
  46 #include "runtime/continuation.hpp"
  47 #include "runtime/continuationEntry.inline.hpp"
  48 #include "runtime/frame.inline.hpp"
  49 #include "runtime/handles.inline.hpp"
  50 #include "runtime/javaCalls.hpp"
  51 #include "runtime/javaThread.hpp"
  52 #include "runtime/monitorChunk.hpp"
  53 #include "runtime/os.hpp"
  54 #include "runtime/sharedRuntime.hpp"
  55 #include "runtime/safefetch.hpp"
  56 #include "runtime/signature.hpp"
  57 #include "runtime/stackValue.hpp"
  58 #include "runtime/stubCodeGenerator.hpp"
  59 #include "runtime/stubRoutines.hpp"
  60 #include "utilities/debug.hpp"
  61 #include "utilities/decoder.hpp"
  62 #include "utilities/formatBuffer.hpp"
  63 
  64 RegisterMap::RegisterMap(JavaThread *thread, UpdateMap update_map, ProcessFrames process_frames, WalkContinuation walk_cont) {
  65   _thread         = thread;
  66   _update_map     = update_map == UpdateMap::include;
  67   _process_frames = process_frames == ProcessFrames::include;
  68   _walk_cont      = walk_cont == WalkContinuation::include;
  69   clear();
  70   DEBUG_ONLY (_update_for_id = nullptr;)
  71   NOT_PRODUCT(_skip_missing = false;)
  72   NOT_PRODUCT(_async = false;)
  73 
  74   if (walk_cont == WalkContinuation::include && thread != nullptr && thread->last_continuation() != nullptr) {
  75     _chunk = stackChunkHandle(Thread::current()->handle_area()->allocate_null_handle(), true /* dummy */);
  76   }
  77   _chunk_index = -1;
  78 
  79 #ifndef PRODUCT
  80   for (int i = 0; i < reg_count ; i++ ) _location[i] = nullptr;
  81 #endif /* PRODUCT */
  82 }
  83 
  84 RegisterMap::RegisterMap(oop continuation, UpdateMap update_map) {
  85   _thread         = nullptr;
  86   _update_map     = update_map == UpdateMap::include;
  87   _process_frames = false;
  88   _walk_cont      = true;
  89   clear();
  90   DEBUG_ONLY (_update_for_id = nullptr;)
  91   NOT_PRODUCT(_skip_missing = false;)
  92   NOT_PRODUCT(_async = false;)
  93 
  94   _chunk = stackChunkHandle(Thread::current()->handle_area()->allocate_null_handle(), true /* dummy */);
  95   _chunk_index = -1;
  96 
  97 #ifndef PRODUCT
  98   for (int i = 0; i < reg_count ; i++ ) _location[i] = nullptr;
  99 #endif /* PRODUCT */
 100 }
 101 
 102 RegisterMap::RegisterMap(const RegisterMap* map) {
 103   assert(map != this, "bad initialization parameter");
 104   assert(map != nullptr, "RegisterMap must be present");
 105   _thread                = map->thread();
 106   _update_map            = map->update_map();
 107   _process_frames        = map->process_frames();
 108   _walk_cont             = map->_walk_cont;
 109   _include_argument_oops = map->include_argument_oops();
 110   DEBUG_ONLY (_update_for_id = map->_update_for_id;)
 111   NOT_PRODUCT(_skip_missing = map->_skip_missing;)
 112   NOT_PRODUCT(_async = map->_async;)
 113 
 114   // only the original RegisterMap's handle lives long enough for StackWalker; this is bound to cause trouble with nested continuations.
 115   _chunk = map->_chunk;
 116   _chunk_index = map->_chunk_index;
 117 
 118   pd_initialize_from(map);
 119   if (update_map()) {
 120     for(int i = 0; i < location_valid_size; i++) {
 121       LocationValidType bits = map->_location_valid[i];
 122       _location_valid[i] = bits;
 123       // for whichever bits are set, pull in the corresponding map->_location
 124       int j = i*location_valid_type_size;
 125       while (bits != 0) {
 126         if ((bits & 1) != 0) {
 127           assert(0 <= j && j < reg_count, "range check");
 128           _location[j] = map->_location[j];
 129         }
 130         bits >>= 1;
 131         j += 1;
 132       }
 133     }
 134   }
 135 }
 136 
 137 oop RegisterMap::cont() const {
 138   return _chunk() != nullptr ? _chunk()->cont() : (oop)nullptr;
 139 }
 140 
 141 void RegisterMap::set_stack_chunk(stackChunkOop chunk) {
 142   assert(chunk == nullptr || _walk_cont, "");
 143   assert(chunk == nullptr || _chunk.not_null(), "");
 144   if (_chunk.is_null()) return;
 145   log_trace(continuations)("set_stack_chunk: " INTPTR_FORMAT " this: " INTPTR_FORMAT, p2i((oopDesc*)chunk), p2i(this));
 146   _chunk.replace(chunk); // reuse handle. see comment above in the constructor
 147   if (chunk == nullptr) {
 148     _chunk_index = -1;
 149   } else {
 150     _chunk_index++;
 151   }
 152 }
 153 
 154 void RegisterMap::clear() {
 155   set_include_argument_oops(true);
 156   if (update_map()) {
 157     for(int i = 0; i < location_valid_size; i++) {
 158       _location_valid[i] = 0;
 159     }
 160     pd_clear();
 161   } else {
 162     pd_initialize();
 163   }
 164 }
 165 
 166 #ifndef PRODUCT
 167 
 168 VMReg RegisterMap::find_register_spilled_here(void* p, intptr_t* sp) {
 169   for(int i = 0; i < RegisterMap::reg_count; i++) {
 170     VMReg r = VMRegImpl::as_VMReg(i);
 171     if (p == location(r, sp)) return r;
 172   }
 173   return nullptr;
 174 }
 175 
 176 void RegisterMap::print_on(outputStream* st) const {
 177   st->print_cr("Register map");
 178   for(int i = 0; i < reg_count; i++) {
 179 
 180     VMReg r = VMRegImpl::as_VMReg(i);
 181     intptr_t* src = (intptr_t*) location(r, nullptr);
 182     if (src != nullptr) {
 183 
 184       r->print_on(st);
 185       st->print(" [" INTPTR_FORMAT "] = ", p2i(src));
 186       if (((uintptr_t)src & (sizeof(*src)-1)) != 0) {
 187         st->print_cr("<misaligned>");
 188       } else {
 189         st->print_cr(INTPTR_FORMAT, *src);
 190       }
 191     }
 192   }
 193 }
 194 
 195 void RegisterMap::print() const {
 196   print_on(tty);
 197 }
 198 
 199 #endif
 200 // This returns the pc that if you were in the debugger you'd see. Not
 201 // the idealized value in the frame object. This undoes the magic conversion
 202 // that happens for deoptimized frames. In addition it makes the value the
 203 // hardware would want to see in the native frame. The only user (at this point)
 204 // is deoptimization. It likely no one else should ever use it.
 205 
 206 address frame::raw_pc() const {
 207   if (is_deoptimized_frame()) {
 208     nmethod* nm = cb()->as_nmethod_or_null();
 209     assert(nm != nullptr, "only nmethod is expected here");
 210     if (nm->is_method_handle_return(pc()))
 211       return nm->deopt_mh_handler_begin() - pc_return_offset;
 212     else
 213       return nm->deopt_handler_begin() - pc_return_offset;
 214   } else {
 215     return (pc() - pc_return_offset);
 216   }
 217 }
 218 
 219 // Change the pc in a frame object. This does not change the actual pc in
 220 // actual frame. To do that use patch_pc.
 221 //
 222 void frame::set_pc(address newpc) {
 223 #ifdef ASSERT
 224   if (_cb != nullptr && _cb->is_nmethod()) {
 225     assert(!((nmethod*)_cb)->is_deopt_pc(_pc), "invariant violation");
 226   }
 227 #endif // ASSERT
 228 
 229   // Unsafe to use the is_deoptimized tester after changing pc
 230   _deopt_state = unknown;
 231   _pc = newpc;
 232   _cb = CodeCache::find_blob(_pc);
 233 
 234 }
 235 
 236 // type testers
 237 bool frame::is_ignored_frame() const {
 238   return false;  // FIXME: some LambdaForm frames should be ignored
 239 }
 240 
 241 bool frame::is_native_frame() const {
 242   return (_cb != nullptr &&
 243           _cb->is_nmethod() &&
 244           ((nmethod*)_cb)->is_native_method());
 245 }
 246 
 247 bool frame::is_java_frame() const {
 248   if (is_interpreted_frame()) return true;
 249   if (is_compiled_frame())    return true;
 250   return false;
 251 }
 252 
 253 bool frame::is_runtime_frame() const {
 254   return (_cb != nullptr && _cb->is_runtime_stub());
 255 }
 256 
 257 bool frame::is_safepoint_blob_frame() const {
 258   return (_cb != nullptr && _cb->is_safepoint_stub());
 259 }
 260 
 261 // testers
 262 
 263 bool frame::is_first_java_frame() const {
 264   RegisterMap map(JavaThread::current(),
 265                   RegisterMap::UpdateMap::skip,
 266                   RegisterMap::ProcessFrames::include,
 267                   RegisterMap::WalkContinuation::skip); // No update
 268   frame s;
 269   for (s = sender(&map); !(s.is_java_frame() || s.is_first_frame()); s = s.sender(&map));
 270   return s.is_first_frame();
 271 }
 272 
 273 bool frame::is_first_vthread_frame(JavaThread* thread) const {
 274   return Continuation::is_continuation_enterSpecial(*this)
 275     && Continuation::get_continuation_entry_for_entry_frame(thread, *this)->is_virtual_thread();
 276 }
 277 
 278 bool frame::entry_frame_is_first() const {
 279   return entry_frame_call_wrapper()->is_first_frame();
 280 }
 281 
 282 JavaCallWrapper* frame::entry_frame_call_wrapper_if_safe(JavaThread* thread) const {
 283   JavaCallWrapper** jcw = entry_frame_call_wrapper_addr();
 284   address addr = (address) jcw;
 285 
 286   // addr must be within the usable part of the stack
 287   if (thread->is_in_usable_stack(addr)) {
 288     return *jcw;
 289   }
 290 
 291   return nullptr;
 292 }
 293 
 294 bool frame::is_entry_frame_valid(JavaThread* thread) const {
 295   // Validate the JavaCallWrapper an entry frame must have
 296   address jcw = (address)entry_frame_call_wrapper();
 297   if (!thread->is_in_stack_range_excl(jcw, (address)fp())) {
 298     return false;
 299   }
 300 
 301   // Validate sp saved in the java frame anchor
 302   JavaFrameAnchor* jfa = entry_frame_call_wrapper()->anchor();
 303   return (jfa->last_Java_sp() > sp());
 304 }
 305 
 306 Method* frame::safe_interpreter_frame_method() const {
 307   Method** m_addr = interpreter_frame_method_addr();
 308   if (m_addr == nullptr) {
 309     return nullptr;
 310   }
 311   return (Method*) SafeFetchN((intptr_t*) m_addr, 0);
 312 }
 313 
 314 bool frame::should_be_deoptimized() const {
 315   if (_deopt_state == is_deoptimized ||
 316       !is_compiled_frame() ) return false;
 317   assert(_cb != nullptr && _cb->is_nmethod(), "must be an nmethod");
 318   nmethod* nm = _cb->as_nmethod();
 319   LogTarget(Debug, dependencies) lt;
 320   if (lt.is_enabled()) {
 321     LogStream ls(&lt);
 322     ls.print("checking (%s) ", nm->is_marked_for_deoptimization() ? "true" : "false");
 323     nm->print_value_on(&ls);
 324     ls.cr();
 325   }
 326 
 327   if( !nm->is_marked_for_deoptimization() )
 328     return false;
 329 
 330   // If at the return point, then the frame has already been popped, and
 331   // only the return needs to be executed. Don't deoptimize here.
 332   return !nm->is_at_poll_return(pc());
 333 }
 334 
 335 bool frame::can_be_deoptimized() const {
 336   if (!is_compiled_frame()) return false;
 337   nmethod* nm = _cb->as_nmethod();
 338 
 339   if(!nm->can_be_deoptimized())
 340     return false;
 341 
 342   return !nm->is_at_poll_return(pc());
 343 }
 344 
 345 void frame::deoptimize(JavaThread* thread) {
 346   assert(thread == nullptr
 347          || (thread->frame_anchor()->has_last_Java_frame() &&
 348              thread->frame_anchor()->walkable()), "must be");
 349   // Schedule deoptimization of an nmethod activation with this frame.
 350   assert(_cb != nullptr && _cb->is_nmethod(), "must be");
 351 
 352   // If the call site is a MethodHandle call site use the MH deopt handler.
 353   nmethod* nm = _cb->as_nmethod();
 354   address deopt = nm->is_method_handle_return(pc()) ?
 355                         nm->deopt_mh_handler_begin() :
 356                         nm->deopt_handler_begin();
 357 
 358   NativePostCallNop* inst = nativePostCallNop_at(pc());
 359 
 360   // Save the original pc before we patch in the new one
 361   nm->set_original_pc(this, pc());
 362   patch_pc(thread, deopt);
 363   assert(is_deoptimized_frame(), "must be");
 364 
 365 #ifdef ASSERT
 366   if (thread != nullptr) {
 367     frame check = thread->last_frame();
 368     if (is_older(check.id())) {
 369       RegisterMap map(thread,
 370                       RegisterMap::UpdateMap::skip,
 371                       RegisterMap::ProcessFrames::include,
 372                       RegisterMap::WalkContinuation::skip);
 373       while (id() != check.id()) {
 374         check = check.sender(&map);
 375       }
 376       assert(check.is_deoptimized_frame(), "missed deopt");
 377     }
 378   }
 379 #endif // ASSERT
 380 }
 381 
 382 frame frame::java_sender() const {
 383   RegisterMap map(JavaThread::current(),
 384                   RegisterMap::UpdateMap::skip,
 385                   RegisterMap::ProcessFrames::include,
 386                   RegisterMap::WalkContinuation::skip);
 387   frame s;
 388   for (s = sender(&map); !(s.is_java_frame() || s.is_first_frame()); s = s.sender(&map)) ;
 389   guarantee(s.is_java_frame(), "tried to get caller of first java frame");
 390   return s;
 391 }
 392 
 393 frame frame::real_sender(RegisterMap* map) const {
 394   frame result = sender(map);
 395   while (result.is_runtime_frame() ||
 396          result.is_ignored_frame()) {
 397     result = result.sender(map);
 398   }
 399   return result;
 400 }
 401 
 402 // Interpreter frames
 403 
 404 
 405 Method* frame::interpreter_frame_method() const {
 406   assert(is_interpreted_frame(), "interpreted frame expected");
 407   Method* m = *interpreter_frame_method_addr();
 408   assert(m->is_method(), "not a Method*");
 409   return m;
 410 }
 411 
 412 void frame::interpreter_frame_set_method(Method* method) {
 413   assert(is_interpreted_frame(), "interpreted frame expected");
 414   *interpreter_frame_method_addr() = method;
 415 }
 416 
 417 void frame::interpreter_frame_set_mirror(oop mirror) {
 418   assert(is_interpreted_frame(), "interpreted frame expected");
 419   *interpreter_frame_mirror_addr() = mirror;
 420 }
 421 
 422 jint frame::interpreter_frame_bci() const {
 423   assert(is_interpreted_frame(), "interpreted frame expected");
 424   address bcp = interpreter_frame_bcp();
 425   return interpreter_frame_method()->bci_from(bcp);
 426 }
 427 
 428 address frame::interpreter_frame_bcp() const {
 429   assert(is_interpreted_frame(), "interpreted frame expected");
 430   address bcp = (address)*interpreter_frame_bcp_addr();
 431   return interpreter_frame_method()->bcp_from(bcp);
 432 }
 433 
 434 void frame::interpreter_frame_set_bcp(address bcp) {
 435   assert(is_interpreted_frame(), "interpreted frame expected");
 436   *interpreter_frame_bcp_addr() = (intptr_t)bcp;
 437 }
 438 
 439 address frame::interpreter_frame_mdp() const {
 440   assert(ProfileInterpreter, "must be profiling interpreter");
 441   assert(is_interpreted_frame(), "interpreted frame expected");
 442   return (address)*interpreter_frame_mdp_addr();
 443 }
 444 
 445 void frame::interpreter_frame_set_mdp(address mdp) {
 446   assert(is_interpreted_frame(), "interpreted frame expected");
 447   assert(ProfileInterpreter, "must be profiling interpreter");
 448   *interpreter_frame_mdp_addr() = (intptr_t)mdp;
 449 }
 450 
 451 BasicObjectLock* frame::next_monitor_in_interpreter_frame(BasicObjectLock* current) const {
 452   assert(is_interpreted_frame(), "Not an interpreted frame");
 453 #ifdef ASSERT
 454   interpreter_frame_verify_monitor(current);
 455 #endif
 456   BasicObjectLock* next = (BasicObjectLock*) (((intptr_t*) current) + interpreter_frame_monitor_size());
 457   return next;
 458 }
 459 
 460 BasicObjectLock* frame::previous_monitor_in_interpreter_frame(BasicObjectLock* current) const {
 461   assert(is_interpreted_frame(), "Not an interpreted frame");
 462 #ifdef ASSERT
 463 //   // This verification needs to be checked before being enabled
 464 //   interpreter_frame_verify_monitor(current);
 465 #endif
 466   BasicObjectLock* previous = (BasicObjectLock*) (((intptr_t*) current) - interpreter_frame_monitor_size());
 467   return previous;
 468 }
 469 
 470 // Interpreter locals and expression stack locations.
 471 
 472 intptr_t* frame::interpreter_frame_local_at(int index) const {
 473   const int n = Interpreter::local_offset_in_bytes(index)/wordSize;
 474   intptr_t* first = interpreter_frame_locals();
 475   return &(first[n]);
 476 }
 477 
 478 intptr_t* frame::interpreter_frame_expression_stack_at(jint offset) const {
 479   const int i = offset * interpreter_frame_expression_stack_direction();
 480   const int n = i * Interpreter::stackElementWords;
 481   return &(interpreter_frame_expression_stack()[n]);
 482 }
 483 
 484 jint frame::interpreter_frame_expression_stack_size() const {
 485   // Number of elements on the interpreter expression stack
 486   // Callers should span by stackElementWords
 487   int element_size = Interpreter::stackElementWords;
 488   size_t stack_size = 0;
 489   if (frame::interpreter_frame_expression_stack_direction() < 0) {
 490     stack_size = (interpreter_frame_expression_stack() -
 491                   interpreter_frame_tos_address() + 1)/element_size;
 492   } else {
 493     stack_size = (interpreter_frame_tos_address() -
 494                   interpreter_frame_expression_stack() + 1)/element_size;
 495   }
 496   assert(stack_size <= (size_t)max_jint, "stack size too big");
 497   return (jint)stack_size;
 498 }
 499 
 500 
 501 // (frame::interpreter_frame_sender_sp accessor is in frame_<arch>.cpp)
 502 
 503 const char* frame::print_name() const {
 504   if (is_native_frame())      return "Native";
 505   if (is_interpreted_frame()) return "Interpreted";
 506   if (is_compiled_frame()) {
 507     if (is_deoptimized_frame()) return "Deoptimized";
 508     return "Compiled";
 509   }
 510   if (sp() == nullptr)            return "Empty";
 511   return "C";
 512 }
 513 
 514 void frame::print_value_on(outputStream* st) const {
 515   NOT_PRODUCT(address begin = pc()-40;)
 516   NOT_PRODUCT(address end   = nullptr;)
 517 
 518   st->print("%s frame (sp=" INTPTR_FORMAT " unextended sp=" INTPTR_FORMAT, print_name(), p2i(sp()), p2i(unextended_sp()));
 519   if (sp() != nullptr)
 520     st->print(", fp=" INTPTR_FORMAT ", real_fp=" INTPTR_FORMAT ", pc=" INTPTR_FORMAT,
 521               p2i(fp()), p2i(real_fp()), p2i(pc()));
 522   st->print_cr(")");
 523 
 524   if (StubRoutines::contains(pc())) {
 525     StubCodeDesc* desc = StubCodeDesc::desc_for(pc());
 526     st->print("~Stub::%s", desc->name());
 527     NOT_PRODUCT(begin = desc->begin(); end = desc->end();)
 528   } else if (Interpreter::contains(pc())) {
 529     InterpreterCodelet* desc = Interpreter::codelet_containing(pc());
 530     if (desc != nullptr) {
 531       st->print("~");
 532       desc->print_on(st);
 533       NOT_PRODUCT(begin = desc->code_begin(); end = desc->code_end();)
 534     } else {
 535       st->print("~interpreter");
 536     }
 537   }
 538 
 539 #ifndef PRODUCT
 540   if (_cb != nullptr) {
 541     st->print("     ");
 542     _cb->print_value_on(st);
 543     if (end == nullptr) {
 544       begin = _cb->code_begin();
 545       end   = _cb->code_end();
 546     }
 547   }
 548   if (WizardMode && Verbose) Disassembler::decode(begin, end);
 549 #endif
 550 }
 551 
 552 void frame::print_on(outputStream* st) const {
 553   print_value_on(st);
 554   if (is_interpreted_frame()) {
 555     interpreter_frame_print_on(st);
 556   }
 557 }
 558 
 559 void frame::interpreter_frame_print_on(outputStream* st) const {
 560 #ifndef PRODUCT
 561   assert(is_interpreted_frame(), "Not an interpreted frame");
 562   jint i;
 563   for (i = 0; i < interpreter_frame_method()->max_locals(); i++ ) {
 564     intptr_t x = *interpreter_frame_local_at(i);
 565     st->print(" - local  [" INTPTR_FORMAT "]", x);
 566     st->fill_to(23);
 567     st->print_cr("; #%d", i);
 568   }
 569   for (i = interpreter_frame_expression_stack_size() - 1; i >= 0; --i ) {
 570     intptr_t x = *interpreter_frame_expression_stack_at(i);
 571     st->print(" - stack  [" INTPTR_FORMAT "]", x);
 572     st->fill_to(23);
 573     st->print_cr("; #%d", i);
 574   }
 575   // locks for synchronization
 576   for (BasicObjectLock* current = interpreter_frame_monitor_end();
 577        current < interpreter_frame_monitor_begin();
 578        current = next_monitor_in_interpreter_frame(current)) {
 579     st->print(" - obj    [%s", current->obj() == nullptr ? "null" : "");
 580     if (current->obj() != nullptr) current->obj()->print_value_on(st);
 581     st->print_cr("]");
 582     st->print(" - lock   [");
 583     current->lock()->print_on(st, current->obj());
 584     st->print_cr("]");
 585   }
 586   // monitor
 587   st->print_cr(" - monitor[" INTPTR_FORMAT "]", p2i(interpreter_frame_monitor_begin()));
 588   // bcp
 589   st->print(" - bcp    [" INTPTR_FORMAT "]", p2i(interpreter_frame_bcp()));
 590   st->fill_to(23);
 591   st->print_cr("; @%d", interpreter_frame_bci());
 592   // locals
 593   st->print_cr(" - locals [" INTPTR_FORMAT "]", p2i(interpreter_frame_local_at(0)));
 594   // method
 595   st->print(" - method [" INTPTR_FORMAT "]", p2i(interpreter_frame_method()));
 596   st->fill_to(23);
 597   st->print("; ");
 598   interpreter_frame_method()->print_name(st);
 599   st->cr();
 600 #endif
 601 }
 602 
 603 // Print whether the frame is in the VM or OS indicating a HotSpot problem.
 604 // Otherwise, it's likely a bug in the native library that the Java code calls,
 605 // hopefully indicating where to submit bugs.
 606 void frame::print_C_frame(outputStream* st, char* buf, int buflen, address pc) {
 607   // C/C++ frame
 608   bool in_vm = os::address_is_in_vm(pc);
 609   st->print(in_vm ? "V" : "C");
 610 
 611   int offset;
 612   bool found;
 613 
 614   if (buf == nullptr || buflen < 1) return;
 615   // libname
 616   buf[0] = '\0';
 617   found = os::dll_address_to_library_name(pc, buf, buflen, &offset);
 618   if (found && buf[0] != '\0') {
 619     // skip directory names
 620     const char *p1, *p2;
 621     p1 = buf;
 622     int len = (int)strlen(os::file_separator());
 623     while ((p2 = strstr(p1, os::file_separator())) != nullptr) p1 = p2 + len;
 624     st->print("  [%s+0x%x]", p1, offset);
 625   } else {
 626     st->print("  " PTR_FORMAT, p2i(pc));
 627   }
 628 
 629   found = os::dll_address_to_function_name(pc, buf, buflen, &offset);
 630   if (found) {
 631     st->print("  %s+0x%x", buf, offset);
 632   }
 633 }
 634 
 635 // frame::print_on_error() is called by fatal error handler. Notice that we may
 636 // crash inside this function if stack frame is corrupted. The fatal error
 637 // handler can catch and handle the crash. Here we assume the frame is valid.
 638 //
 639 // First letter indicates type of the frame:
 640 //    J: Java frame (compiled)
 641 //    j: Java frame (interpreted)
 642 //    V: VM frame (C/C++)
 643 //    v: Other frames running VM generated code (e.g. stubs, adapters, etc.)
 644 //    C: C/C++ frame
 645 //
 646 // We don't need detailed frame type as that in frame::print_name(). "C"
 647 // suggests the problem is in user lib; everything else is likely a VM bug.
 648 
 649 void frame::print_on_error(outputStream* st, char* buf, int buflen, bool verbose) const {
 650   if (_cb != nullptr) {
 651     if (Interpreter::contains(pc())) {
 652       Method* m = this->interpreter_frame_method();
 653       if (m != nullptr) {
 654         m->name_and_sig_as_C_string(buf, buflen);
 655         st->print("j  %s", buf);
 656         st->print("+%d", this->interpreter_frame_bci());
 657         ModuleEntry* module = m->method_holder()->module();
 658         if (module->is_named()) {
 659           module->name()->as_C_string(buf, buflen);
 660           st->print(" %s", buf);
 661           if (module->version() != nullptr) {
 662             module->version()->as_C_string(buf, buflen);
 663             st->print("@%s", buf);
 664           }
 665         }
 666       } else {
 667         st->print("j  " PTR_FORMAT, p2i(pc()));
 668       }
 669     } else if (StubRoutines::contains(pc())) {
 670       StubCodeDesc* desc = StubCodeDesc::desc_for(pc());
 671       if (desc != nullptr) {
 672         st->print("v  ~StubRoutines::%s " PTR_FORMAT, desc->name(), p2i(pc()));
 673       } else {
 674         st->print("v  ~StubRoutines::" PTR_FORMAT, p2i(pc()));
 675       }
 676     } else if (_cb->is_buffer_blob()) {
 677       st->print("v  ~BufferBlob::%s " PTR_FORMAT, ((BufferBlob *)_cb)->name(), p2i(pc()));
 678     } else if (_cb->is_nmethod()) {
 679       nmethod* nm = _cb->as_nmethod();
 680       Method* m = nm->method();
 681       if (m != nullptr) {
 682         st->print("J %d%s", nm->compile_id(), (nm->is_osr_method() ? "%" : ""));
 683         st->print(" %s", nm->compiler_name());
 684         m->name_and_sig_as_C_string(buf, buflen);
 685         st->print(" %s", buf);
 686         ModuleEntry* module = m->method_holder()->module();
 687         if (module->is_named()) {
 688           module->name()->as_C_string(buf, buflen);
 689           st->print(" %s", buf);
 690           if (module->version() != nullptr) {
 691             module->version()->as_C_string(buf, buflen);
 692             st->print("@%s", buf);
 693           }
 694         }
 695         st->print(" (%d bytes) @ " PTR_FORMAT " [" PTR_FORMAT "+" INTPTR_FORMAT "]",
 696                   m->code_size(), p2i(_pc), p2i(_cb->code_begin()), _pc - _cb->code_begin());
 697 #if INCLUDE_JVMCI
 698         const char* jvmciName = nm->jvmci_name();
 699         if (jvmciName != nullptr) {
 700           st->print(" (%s)", jvmciName);
 701         }
 702 #endif
 703       } else {
 704         st->print("J  " PTR_FORMAT, p2i(pc()));
 705       }
 706     } else if (_cb->is_runtime_stub()) {
 707       st->print("v  ~RuntimeStub::%s " PTR_FORMAT, ((RuntimeStub *)_cb)->name(), p2i(pc()));
 708     } else if (_cb->is_deoptimization_stub()) {
 709       st->print("v  ~DeoptimizationBlob " PTR_FORMAT, p2i(pc()));
 710     } else if (_cb->is_exception_stub()) {
 711       st->print("v  ~ExceptionBlob " PTR_FORMAT, p2i(pc()));
 712     } else if (_cb->is_safepoint_stub()) {
 713       st->print("v  ~SafepointBlob " PTR_FORMAT, p2i(pc()));
 714     } else if (_cb->is_adapter_blob()) {
 715       st->print("v  ~AdapterBlob " PTR_FORMAT, p2i(pc()));
 716     } else if (_cb->is_vtable_blob()) {
 717       st->print("v  ~VtableBlob " PTR_FORMAT, p2i(pc()));
 718     } else if (_cb->is_method_handles_adapter_blob()) {
 719       st->print("v  ~MethodHandlesAdapterBlob " PTR_FORMAT, p2i(pc()));
 720     } else if (_cb->is_uncommon_trap_stub()) {
 721       st->print("v  ~UncommonTrapBlob " PTR_FORMAT, p2i(pc()));
 722     } else if (_cb->is_upcall_stub()) {
 723       st->print("v  ~UpcallStub::%s " PTR_FORMAT, _cb->name(), p2i(pc()));
 724     } else {
 725       st->print("v  blob " PTR_FORMAT, p2i(pc()));
 726     }
 727   } else {
 728     print_C_frame(st, buf, buflen, pc());
 729   }
 730 }
 731 
 732 
 733 /*
 734   The interpreter_frame_expression_stack_at method in the case of SPARC needs the
 735   max_stack value of the method in order to compute the expression stack address.
 736   It uses the Method* in order to get the max_stack value but during GC this
 737   Method* value saved on the frame is changed by reverse_and_push and hence cannot
 738   be used. So we save the max_stack value in the FrameClosure object and pass it
 739   down to the interpreter_frame_expression_stack_at method
 740 */
 741 class InterpreterFrameClosure : public OffsetClosure {
 742  private:
 743   const frame* _fr;
 744   OopClosure*  _f;
 745   int          _max_locals;
 746   int          _max_stack;
 747 
 748  public:
 749   InterpreterFrameClosure(const frame* fr, int max_locals, int max_stack,
 750                           OopClosure* f) {
 751     _fr         = fr;
 752     _max_locals = max_locals;
 753     _max_stack  = max_stack;
 754     _f          = f;
 755   }
 756 
 757   void offset_do(int offset) {
 758     oop* addr;
 759     if (offset < _max_locals) {
 760       addr = (oop*) _fr->interpreter_frame_local_at(offset);
 761       assert((intptr_t*)addr >= _fr->sp(), "must be inside the frame");
 762       _f->do_oop(addr);
 763     } else {
 764       addr = (oop*) _fr->interpreter_frame_expression_stack_at((offset - _max_locals));
 765       // In case of exceptions, the expression stack is invalid and the esp will be reset to express
 766       // this condition. Therefore, we call f only if addr is 'inside' the stack (i.e., addr >= esp for Intel).
 767       bool in_stack;
 768       if (frame::interpreter_frame_expression_stack_direction() > 0) {
 769         in_stack = (intptr_t*)addr <= _fr->interpreter_frame_tos_address();
 770       } else {
 771         in_stack = (intptr_t*)addr >= _fr->interpreter_frame_tos_address();
 772       }
 773       if (in_stack) {
 774         _f->do_oop(addr);
 775       }
 776     }
 777   }
 778 };
 779 
 780 
 781 class InterpretedArgumentOopFinder: public SignatureIterator {
 782  private:
 783   OopClosure*  _f;             // Closure to invoke
 784   int          _offset;        // TOS-relative offset, decremented with each argument
 785   bool         _has_receiver;  // true if the callee has a receiver
 786   const frame* _fr;
 787 
 788   friend class SignatureIterator;  // so do_parameters_on can call do_type
 789   void do_type(BasicType type) {
 790     _offset -= parameter_type_word_count(type);
 791     if (is_reference_type(type)) oop_offset_do();
 792    }
 793 
 794   void oop_offset_do() {
 795     oop* addr;
 796     addr = (oop*)_fr->interpreter_frame_tos_at(_offset);
 797     _f->do_oop(addr);
 798   }
 799 
 800  public:
 801   InterpretedArgumentOopFinder(Symbol* signature, bool has_receiver, const frame* fr, OopClosure* f) : SignatureIterator(signature), _has_receiver(has_receiver) {
 802     // compute size of arguments
 803     int args_size = ArgumentSizeComputer(signature).size() + (has_receiver ? 1 : 0);
 804     assert(!fr->is_interpreted_frame() ||
 805            args_size <= fr->interpreter_frame_expression_stack_size(),
 806             "args cannot be on stack anymore");
 807     // initialize InterpretedArgumentOopFinder
 808     _f         = f;
 809     _fr        = fr;
 810     _offset    = args_size;
 811   }
 812 
 813   void oops_do() {
 814     if (_has_receiver) {
 815       --_offset;
 816       oop_offset_do();
 817     }
 818     do_parameters_on(this);
 819   }
 820 };
 821 
 822 
 823 // Entry frame has following form (n arguments)
 824 //         +-----------+
 825 //   sp -> |  last arg |
 826 //         +-----------+
 827 //         :    :::    :
 828 //         +-----------+
 829 // (sp+n)->|  first arg|
 830 //         +-----------+
 831 
 832 
 833 
 834 // visits and GC's all the arguments in entry frame
 835 class EntryFrameOopFinder: public SignatureIterator {
 836  private:
 837   bool         _is_static;
 838   int          _offset;
 839   const frame* _fr;
 840   OopClosure*  _f;
 841 
 842   friend class SignatureIterator;  // so do_parameters_on can call do_type
 843   void do_type(BasicType type) {
 844     // decrement offset before processing the type
 845     _offset -= parameter_type_word_count(type);
 846     assert (_offset >= 0, "illegal offset");
 847     if (is_reference_type(type))  oop_at_offset_do(_offset);
 848  }
 849 
 850   void oop_at_offset_do(int offset) {
 851     assert (offset >= 0, "illegal offset");
 852     oop* addr = (oop*) _fr->entry_frame_argument_at(offset);
 853     _f->do_oop(addr);
 854   }
 855 
 856  public:
 857   EntryFrameOopFinder(const frame* frame, Symbol* signature, bool is_static) : SignatureIterator(signature) {
 858     _f = nullptr; // will be set later
 859     _fr = frame;
 860     _is_static = is_static;
 861     _offset = ArgumentSizeComputer(signature).size();  // pre-decremented down to zero
 862   }
 863 
 864   void arguments_do(OopClosure* f) {
 865     _f = f;
 866     if (!_is_static)  oop_at_offset_do(_offset); // do the receiver
 867     do_parameters_on(this);
 868   }
 869 
 870 };
 871 
 872 oop* frame::interpreter_callee_receiver_addr(Symbol* signature) {
 873   ArgumentSizeComputer asc(signature);
 874   int size = asc.size();
 875   return (oop *)interpreter_frame_tos_at(size);
 876 }
 877 
 878 oop frame::interpreter_callee_receiver(Symbol* signature) {
 879   return *interpreter_callee_receiver_addr(signature);
 880 }
 881 
 882 void frame::oops_interpreted_do(OopClosure* f, const RegisterMap* map, bool query_oop_map_cache) const {
 883   assert(is_interpreted_frame(), "Not an interpreted frame");
 884   Thread *thread = Thread::current();
 885   methodHandle m (thread, interpreter_frame_method());
 886   jint      bci = interpreter_frame_bci();
 887 
 888   assert(!Universe::heap()->is_in(m()),
 889           "must be valid oop");
 890   assert(m->is_method(), "checking frame value");
 891   assert((m->is_native() && bci == 0)  ||
 892          (!m->is_native() && bci >= 0 && bci < m->code_size()),
 893          "invalid bci value");
 894 
 895   // Handle the monitor elements in the activation
 896   for (
 897     BasicObjectLock* current = interpreter_frame_monitor_end();
 898     current < interpreter_frame_monitor_begin();
 899     current = next_monitor_in_interpreter_frame(current)
 900   ) {
 901 #ifdef ASSERT
 902     interpreter_frame_verify_monitor(current);
 903 #endif
 904     current->oops_do(f);
 905   }
 906 
 907   if (m->is_native()) {
 908     f->do_oop(interpreter_frame_temp_oop_addr());
 909   }
 910 
 911   // The method pointer in the frame might be the only path to the method's
 912   // klass, and the klass needs to be kept alive while executing. The GCs
 913   // don't trace through method pointers, so the mirror of the method's klass
 914   // is installed as a GC root.
 915   f->do_oop(interpreter_frame_mirror_addr());
 916 
 917   int max_locals = m->is_native() ? m->size_of_parameters() : m->max_locals();
 918 
 919   Symbol* signature = nullptr;
 920   bool has_receiver = false;
 921 
 922   // Process a callee's arguments if we are at a call site
 923   // (i.e., if we are at an invoke bytecode)
 924   // This is used sometimes for calling into the VM, not for another
 925   // interpreted or compiled frame.
 926   if (!m->is_native()) {
 927     Bytecode_invoke call = Bytecode_invoke_check(m, bci);
 928     if (map != nullptr && call.is_valid()) {
 929       signature = call.signature();
 930       has_receiver = call.has_receiver();
 931       if (map->include_argument_oops() &&
 932           interpreter_frame_expression_stack_size() > 0) {
 933         ResourceMark rm(thread);  // is this right ???
 934         // we are at a call site & the expression stack is not empty
 935         // => process callee's arguments
 936         //
 937         // Note: The expression stack can be empty if an exception
 938         //       occurred during method resolution/execution. In all
 939         //       cases we empty the expression stack completely be-
 940         //       fore handling the exception (the exception handling
 941         //       code in the interpreter calls a blocking runtime
 942         //       routine which can cause this code to be executed).
 943         //       (was bug gri 7/27/98)
 944         oops_interpreted_arguments_do(signature, has_receiver, f);
 945       }
 946     }
 947   }
 948 
 949   InterpreterFrameClosure blk(this, max_locals, m->max_stack(), f);
 950 
 951   // process locals & expression stack
 952   InterpreterOopMap mask;
 953   if (query_oop_map_cache) {
 954     m->mask_for(m, bci, &mask);
 955   } else {
 956     OopMapCache::compute_one_oop_map(m, bci, &mask);
 957   }
 958   mask.iterate_oop(&blk);
 959 }
 960 
 961 
 962 void frame::oops_interpreted_arguments_do(Symbol* signature, bool has_receiver, OopClosure* f) const {
 963   InterpretedArgumentOopFinder finder(signature, has_receiver, this, f);
 964   finder.oops_do();
 965 }
 966 
 967 void frame::oops_nmethod_do(OopClosure* f, NMethodClosure* cf, DerivedOopClosure* df, DerivedPointerIterationMode derived_mode, const RegisterMap* reg_map) const {
 968   assert(_cb != nullptr, "sanity check");
 969   assert((oop_map() == nullptr) == (_cb->oop_maps() == nullptr), "frame and _cb must agree that oopmap is set or not");
 970   if (oop_map() != nullptr) {
 971     if (df != nullptr) {
 972       _oop_map->oops_do(this, reg_map, f, df);
 973     } else {
 974       _oop_map->oops_do(this, reg_map, f, derived_mode);
 975     }
 976 
 977     // Preserve potential arguments for a callee. We handle this by dispatching
 978     // on the codeblob. For c2i, we do
 979     if (reg_map->include_argument_oops() && _cb->is_nmethod()) {
 980       // Only nmethod preserves outgoing arguments at call.
 981       _cb->as_nmethod()->preserve_callee_argument_oops(*this, reg_map, f);
 982     }
 983   }
 984   // In cases where perm gen is collected, GC will want to mark
 985   // oops referenced from nmethods active on thread stacks so as to
 986   // prevent them from being collected. However, this visit should be
 987   // restricted to certain phases of the collection only. The
 988   // closure decides how it wants nmethods to be traced.
 989   if (cf != nullptr && _cb->is_nmethod())
 990     cf->do_nmethod(_cb->as_nmethod());
 991 }
 992 
 993 class CompiledArgumentOopFinder: public SignatureIterator {
 994  protected:
 995   OopClosure*     _f;
 996   int             _offset;        // the current offset, incremented with each argument
 997   bool            _has_receiver;  // true if the callee has a receiver
 998   bool            _has_appendix;  // true if the call has an appendix
 999   frame           _fr;
1000   RegisterMap*    _reg_map;
1001   int             _arg_size;
1002   VMRegPair*      _regs;        // VMReg list of arguments
1003 
1004   friend class SignatureIterator;  // so do_parameters_on can call do_type
1005   void do_type(BasicType type) {
1006     if (is_reference_type(type))  handle_oop_offset();
1007     _offset += parameter_type_word_count(type);
1008   }
1009 
1010   virtual void handle_oop_offset() {
1011     // Extract low order register number from register array.
1012     // In LP64-land, the high-order bits are valid but unhelpful.
1013     VMReg reg = _regs[_offset].first();
1014     oop *loc = _fr.oopmapreg_to_oop_location(reg, _reg_map);
1015   #ifdef ASSERT
1016     if (loc == nullptr) {
1017       if (_reg_map->should_skip_missing()) {
1018         return;
1019       }
1020       tty->print_cr("Error walking frame oops:");
1021       _fr.print_on(tty);
1022       assert(loc != nullptr, "missing register map entry reg: %d %s loc: " INTPTR_FORMAT, reg->value(), reg->name(), p2i(loc));
1023     }
1024   #endif
1025     _f->do_oop(loc);
1026   }
1027 
1028  public:
1029   CompiledArgumentOopFinder(Symbol* signature, bool has_receiver, bool has_appendix, OopClosure* f, frame fr, const RegisterMap* reg_map)
1030     : SignatureIterator(signature) {
1031 
1032     // initialize CompiledArgumentOopFinder
1033     _f         = f;
1034     _offset    = 0;
1035     _has_receiver = has_receiver;
1036     _has_appendix = has_appendix;
1037     _fr        = fr;
1038     _reg_map   = (RegisterMap*)reg_map;
1039     _arg_size  = ArgumentSizeComputer(signature).size() + (has_receiver ? 1 : 0) + (has_appendix ? 1 : 0);
1040 
1041     int arg_size;
1042     _regs = SharedRuntime::find_callee_arguments(signature, has_receiver, has_appendix, &arg_size);
1043     assert(arg_size == _arg_size, "wrong arg size");
1044   }
1045 
1046   void oops_do() {
1047     if (_has_receiver) {
1048       handle_oop_offset();
1049       _offset++;
1050     }
1051     do_parameters_on(this);
1052     if (_has_appendix) {
1053       handle_oop_offset();
1054       _offset++;
1055     }
1056   }
1057 };
1058 
1059 void frame::oops_compiled_arguments_do(Symbol* signature, bool has_receiver, bool has_appendix,
1060                                        const RegisterMap* reg_map, OopClosure* f) const {
1061   // ResourceMark rm;
1062   CompiledArgumentOopFinder finder(signature, has_receiver, has_appendix, f, *this, reg_map);
1063   finder.oops_do();
1064 }
1065 
1066 // Get receiver out of callers frame, i.e. find parameter 0 in callers
1067 // frame.  Consult ADLC for where parameter 0 is to be found.  Then
1068 // check local reg_map for it being a callee-save register or argument
1069 // register, both of which are saved in the local frame.  If not found
1070 // there, it must be an in-stack argument of the caller.
1071 // Note: caller.sp() points to callee-arguments
1072 oop frame::retrieve_receiver(RegisterMap* reg_map) {
1073   frame caller = *this;
1074 
1075   // First consult the ADLC on where it puts parameter 0 for this signature.
1076   VMReg reg = SharedRuntime::name_for_receiver();
1077   oop* oop_adr = caller.oopmapreg_to_oop_location(reg, reg_map);
1078   if (oop_adr == nullptr) {
1079     guarantee(oop_adr != nullptr, "bad register save location");
1080     return nullptr;
1081   }
1082   oop r = *oop_adr;
1083   assert(Universe::heap()->is_in_or_null(r), "bad receiver: " INTPTR_FORMAT " (" INTX_FORMAT ")", p2i(r), p2i(r));
1084   return r;
1085 }
1086 
1087 
1088 BasicLock* frame::get_native_monitor() {
1089   nmethod* nm = (nmethod*)_cb;
1090   assert(_cb != nullptr && _cb->is_nmethod() && nm->method()->is_native(),
1091          "Should not call this unless it's a native nmethod");
1092   int byte_offset = in_bytes(nm->native_basic_lock_sp_offset());
1093   assert(byte_offset >= 0, "should not see invalid offset");
1094   return (BasicLock*) &sp()[byte_offset / wordSize];
1095 }
1096 
1097 oop frame::get_native_receiver() {
1098   nmethod* nm = (nmethod*)_cb;
1099   assert(_cb != nullptr && _cb->is_nmethod() && nm->method()->is_native(),
1100          "Should not call this unless it's a native nmethod");
1101   int byte_offset = in_bytes(nm->native_receiver_sp_offset());
1102   assert(byte_offset >= 0, "should not see invalid offset");
1103   oop owner = ((oop*) sp())[byte_offset / wordSize];
1104   assert( Universe::heap()->is_in(owner), "bad receiver" );
1105   return owner;
1106 }
1107 
1108 void frame::oops_entry_do(OopClosure* f, const RegisterMap* map) const {
1109   assert(map != nullptr, "map must be set");
1110   if (map->include_argument_oops()) {
1111     // must collect argument oops, as nobody else is doing it
1112     Thread *thread = Thread::current();
1113     methodHandle m (thread, entry_frame_call_wrapper()->callee_method());
1114     EntryFrameOopFinder finder(this, m->signature(), m->is_static());
1115     finder.arguments_do(f);
1116   }
1117   // Traverse the Handle Block saved in the entry frame
1118   entry_frame_call_wrapper()->oops_do(f);
1119 }
1120 
1121 void frame::oops_upcall_do(OopClosure* f, const RegisterMap* map) const {
1122   assert(map != nullptr, "map must be set");
1123   if (map->include_argument_oops()) {
1124     // Upcall stubs call a MethodHandle impl method of which only the receiver
1125     // is ever an oop.
1126     // Currently we should not be able to get here, since there are no
1127     // safepoints in the one resolve stub we can get into (handle_wrong_method)
1128     // Leave this here as a trap in case we ever do:
1129     ShouldNotReachHere(); // not implemented
1130   }
1131   _cb->as_upcall_stub()->oops_do(f, *this);
1132 }
1133 
1134 bool frame::is_deoptimized_frame() const {
1135   assert(_deopt_state != unknown, "not answerable");
1136   if (_deopt_state == is_deoptimized) {
1137     return true;
1138   }
1139 
1140   /* This method only checks if the frame is deoptimized
1141    * as in return address being patched.
1142    * It doesn't care if the OP that we return to is a
1143    * deopt instruction */
1144   /*if (_cb != nullptr && _cb->is_nmethod()) {
1145     return NativeDeoptInstruction::is_deopt_at(_pc);
1146   }*/
1147   return false;
1148 }
1149 
1150 void frame::oops_do_internal(OopClosure* f, NMethodClosure* cf,
1151                              DerivedOopClosure* df, DerivedPointerIterationMode derived_mode,
1152                              const RegisterMap* map, bool use_interpreter_oop_map_cache) const {
1153 #ifndef PRODUCT
1154   // simulate GC crash here to dump java thread in error report
1155   if (CrashGCForDumpingJavaThread) {
1156     char *t = nullptr;
1157     *t = 'c';
1158   }
1159 #endif
1160   if (is_interpreted_frame()) {
1161     oops_interpreted_do(f, map, use_interpreter_oop_map_cache);
1162   } else if (is_entry_frame()) {
1163     oops_entry_do(f, map);
1164   } else if (is_upcall_stub_frame()) {
1165     oops_upcall_do(f, map);
1166   } else if (CodeCache::contains(pc())) {
1167     oops_nmethod_do(f, cf, df, derived_mode, map);
1168   } else {
1169     ShouldNotReachHere();
1170   }
1171 }
1172 
1173 void frame::nmethod_do(NMethodClosure* cf) const {
1174   if (_cb != nullptr && _cb->is_nmethod()) {
1175     cf->do_nmethod(_cb->as_nmethod());
1176   }
1177 }
1178 
1179 
1180 // Call f closure on the interpreted Method*s in the stack.
1181 void frame::metadata_do(MetadataClosure* f) const {
1182   ResourceMark rm;
1183   if (is_interpreted_frame()) {
1184     Method* m = this->interpreter_frame_method();
1185     assert(m != nullptr, "expecting a method in this frame");
1186     f->do_metadata(m);
1187   }
1188 }
1189 
1190 void frame::verify(const RegisterMap* map) const {
1191 #ifndef PRODUCT
1192   if (TraceCodeBlobStacks) {
1193     tty->print_cr("*** verify");
1194     print_on(tty);
1195   }
1196 #endif
1197 
1198   // for now make sure receiver type is correct
1199   if (is_interpreted_frame()) {
1200     Method* method = interpreter_frame_method();
1201     guarantee(method->is_method(), "method is wrong in frame::verify");
1202     if (!method->is_static()) {
1203       // fetch the receiver
1204       oop* p = (oop*) interpreter_frame_local_at(0);
1205       // make sure we have the right receiver type
1206     }
1207   }
1208 #if COMPILER2_OR_JVMCI
1209   assert(DerivedPointerTable::is_empty(), "must be empty before verify");
1210 #endif
1211 
1212   if (map->update_map()) { // The map has to be up-to-date for the current frame
1213     oops_do_internal(&VerifyOopClosure::verify_oop, nullptr, nullptr, DerivedPointerIterationMode::_ignore, map, false);
1214   }
1215 }
1216 
1217 
1218 #ifdef ASSERT
1219 bool frame::verify_return_pc(address x) {
1220 #ifdef TARGET_ARCH_aarch64
1221   if (!pauth_ptr_is_raw(x)) {
1222     return false;
1223   }
1224 #endif
1225   if (StubRoutines::returns_to_call_stub(x)) {
1226     return true;
1227   }
1228   if (CodeCache::contains(x)) {
1229     return true;
1230   }
1231   if (Interpreter::contains(x)) {
1232     return true;
1233   }
1234   return false;
1235 }
1236 #endif
1237 
1238 #ifdef ASSERT
1239 void frame::interpreter_frame_verify_monitor(BasicObjectLock* value) const {
1240   assert(is_interpreted_frame(), "Not an interpreted frame");
1241   // verify that the value is in the right part of the frame
1242   address low_mark  = (address) interpreter_frame_monitor_end();
1243   address high_mark = (address) interpreter_frame_monitor_begin();
1244   address current   = (address) value;
1245 
1246   const int monitor_size = frame::interpreter_frame_monitor_size();
1247   guarantee((high_mark - current) % monitor_size  ==  0         , "Misaligned top of BasicObjectLock*");
1248   guarantee( high_mark > current                                , "Current BasicObjectLock* higher than high_mark");
1249 
1250   guarantee((current - low_mark) % monitor_size  ==  0         , "Misaligned bottom of BasicObjectLock*");
1251   guarantee( current >= low_mark                               , "Current BasicObjectLock* below than low_mark");
1252 }
1253 #endif
1254 
1255 #ifndef PRODUCT
1256 
1257 // Returns true iff the address p is readable and *(intptr_t*)p != errvalue
1258 extern "C" bool dbg_is_safe(const void* p, intptr_t errvalue);
1259 
1260 class FrameValuesOopClosure: public OopClosure, public DerivedOopClosure {
1261 private:
1262   GrowableArray<oop*>* _oops;
1263   GrowableArray<narrowOop*>* _narrow_oops;
1264   GrowableArray<derived_base*>* _base;
1265   GrowableArray<derived_pointer*>* _derived;
1266   NoSafepointVerifier nsv;
1267 
1268 public:
1269   FrameValuesOopClosure() {
1270     _oops = new (mtThread) GrowableArray<oop*>(100, mtThread);
1271     _narrow_oops = new (mtThread) GrowableArray<narrowOop*>(100, mtThread);
1272     _base = new (mtThread) GrowableArray<derived_base*>(100, mtThread);
1273     _derived = new (mtThread) GrowableArray<derived_pointer*>(100, mtThread);
1274   }
1275   ~FrameValuesOopClosure() {
1276     delete _oops;
1277     delete _narrow_oops;
1278     delete _base;
1279     delete _derived;
1280   }
1281 
1282   virtual void do_oop(oop* p) override { _oops->push(p); }
1283   virtual void do_oop(narrowOop* p) override { _narrow_oops->push(p); }
1284   virtual void do_derived_oop(derived_base* base_loc, derived_pointer* derived_loc) override {
1285     _base->push(base_loc);
1286     _derived->push(derived_loc);
1287   }
1288 
1289   bool is_good(oop* p) {
1290     return *p == nullptr || (dbg_is_safe(*p, -1) && dbg_is_safe((*p)->klass(), -1) && oopDesc::is_oop_or_null(*p));
1291   }
1292   void describe(FrameValues& values, int frame_no) {
1293     for (int i = 0; i < _oops->length(); i++) {
1294       oop* p = _oops->at(i);
1295       values.describe(frame_no, (intptr_t*)p, err_msg("oop%s for #%d", is_good(p) ? "" : " (BAD)", frame_no));
1296     }
1297     for (int i = 0; i < _narrow_oops->length(); i++) {
1298       narrowOop* p = _narrow_oops->at(i);
1299       // we can't check for bad compressed oops, as decoding them might crash
1300       values.describe(frame_no, (intptr_t*)p, err_msg("narrow oop for #%d", frame_no));
1301     }
1302     assert(_base->length() == _derived->length(), "should be the same");
1303     for (int i = 0; i < _base->length(); i++) {
1304       derived_base* base = _base->at(i);
1305       derived_pointer* derived = _derived->at(i);
1306       values.describe(frame_no, (intptr_t*)derived, err_msg("derived pointer (base: " INTPTR_FORMAT ") for #%d", p2i(base), frame_no));
1307     }
1308   }
1309 };
1310 
1311 class FrameValuesOopMapClosure: public OopMapClosure {
1312 private:
1313   const frame* _fr;
1314   const RegisterMap* _reg_map;
1315   FrameValues& _values;
1316   int _frame_no;
1317 
1318 public:
1319   FrameValuesOopMapClosure(const frame* fr, const RegisterMap* reg_map, FrameValues& values, int frame_no)
1320    : _fr(fr), _reg_map(reg_map), _values(values), _frame_no(frame_no) {}
1321 
1322   virtual void do_value(VMReg reg, OopMapValue::oop_types type) override {
1323     intptr_t* p = (intptr_t*)_fr->oopmapreg_to_location(reg, _reg_map);
1324     if (p != nullptr && (((intptr_t)p & WordAlignmentMask) == 0)) {
1325       const char* type_name = nullptr;
1326       switch(type) {
1327         case OopMapValue::oop_value:          type_name = "oop";          break;
1328         case OopMapValue::narrowoop_value:    type_name = "narrow oop";   break;
1329         case OopMapValue::callee_saved_value: type_name = "callee-saved"; break;
1330         case OopMapValue::derived_oop_value:  type_name = "derived";      break;
1331         // case OopMapValue::live_value:         type_name = "live";         break;
1332         default: break;
1333       }
1334       if (type_name != nullptr) {
1335         _values.describe(_frame_no, p, err_msg("%s for #%d", type_name, _frame_no));
1336       }
1337     }
1338   }
1339 };
1340 
1341 // callers need a ResourceMark because of name_and_sig_as_C_string() usage,
1342 // RA allocated string is returned to the caller
1343 void frame::describe(FrameValues& values, int frame_no, const RegisterMap* reg_map) {
1344   // boundaries: sp and the 'real' frame pointer
1345   values.describe(-1, sp(), err_msg("sp for #%d", frame_no), 0);
1346   intptr_t* frame_pointer = real_fp(); // Note: may differ from fp()
1347 
1348   // print frame info at the highest boundary
1349   intptr_t* info_address = MAX2(sp(), frame_pointer);
1350 
1351   if (info_address != frame_pointer) {
1352     // print frame_pointer explicitly if not marked by the frame info
1353     values.describe(-1, frame_pointer, err_msg("frame pointer for #%d", frame_no), 1);
1354   }
1355 
1356   if (is_entry_frame() || is_compiled_frame() || is_interpreted_frame() || is_native_frame()) {
1357     // Label values common to most frames
1358     values.describe(-1, unextended_sp(), err_msg("unextended_sp for #%d", frame_no), 0);
1359   }
1360 
1361   if (is_interpreted_frame()) {
1362     Method* m = interpreter_frame_method();
1363     int bci = interpreter_frame_bci();
1364     InterpreterCodelet* desc = Interpreter::codelet_containing(pc());
1365 
1366     // Label the method and current bci
1367     values.describe(-1, info_address,
1368                     FormatBuffer<1024>("#%d method %s @ %d", frame_no, m->name_and_sig_as_C_string(), bci), 3);
1369     if (desc != nullptr) {
1370       values.describe(-1, info_address, err_msg("- %s codelet: %s",
1371         desc->bytecode()    >= 0    ? Bytecodes::name(desc->bytecode()) : "",
1372         desc->description() != nullptr ? desc->description()               : "?"), 2);
1373     }
1374     values.describe(-1, info_address,
1375                     err_msg("- %d locals %d max stack", m->max_locals(), m->max_stack()), 2);
1376     // return address will be emitted by caller in describe_pd
1377     // values.describe(frame_no, (intptr_t*)sender_pc_addr(), Continuation::is_return_barrier_entry(*sender_pc_addr()) ? "return address (return barrier)" : "return address");
1378 
1379     if (m->max_locals() > 0) {
1380       intptr_t* l0 = interpreter_frame_local_at(0);
1381       intptr_t* ln = interpreter_frame_local_at(m->max_locals() - 1);
1382       values.describe(-1, MAX2(l0, ln), err_msg("locals for #%d", frame_no), 2);
1383       // Report each local and mark as owned by this frame
1384       for (int l = 0; l < m->max_locals(); l++) {
1385         intptr_t* l0 = interpreter_frame_local_at(l);
1386         values.describe(frame_no, l0, err_msg("local %d", l), 1);
1387       }
1388     }
1389 
1390     if (interpreter_frame_monitor_begin() != interpreter_frame_monitor_end()) {
1391       values.describe(frame_no, (intptr_t*)interpreter_frame_monitor_begin(), "monitors begin");
1392       values.describe(frame_no, (intptr_t*)interpreter_frame_monitor_end(), "monitors end");
1393     }
1394 
1395     // Compute the actual expression stack size
1396     InterpreterOopMap mask;
1397     OopMapCache::compute_one_oop_map(methodHandle(Thread::current(), m), bci, &mask);
1398     intptr_t* tos = nullptr;
1399     // Report each stack element and mark as owned by this frame
1400     for (int e = 0; e < mask.expression_stack_size(); e++) {
1401       tos = MAX2(tos, interpreter_frame_expression_stack_at(e));
1402       values.describe(frame_no, interpreter_frame_expression_stack_at(e),
1403                       err_msg("stack %d", e), 1);
1404     }
1405     if (tos != nullptr) {
1406       values.describe(-1, tos, err_msg("expression stack for #%d", frame_no), 2);
1407     }
1408 
1409     if (reg_map != nullptr) {
1410       FrameValuesOopClosure oopsFn;
1411       oops_do(&oopsFn, nullptr, &oopsFn, reg_map);
1412       oopsFn.describe(values, frame_no);
1413     }
1414   } else if (is_entry_frame()) {
1415     // For now just label the frame
1416     values.describe(-1, info_address, err_msg("#%d entry frame", frame_no), 2);
1417   } else if (cb()->is_nmethod()) {
1418     // For now just label the frame
1419     nmethod* nm = cb()->as_nmethod();
1420     values.describe(-1, info_address,
1421                     FormatBuffer<1024>("#%d nmethod " INTPTR_FORMAT " for method J %s%s", frame_no,
1422                                        p2i(nm),
1423                                        nm->method()->name_and_sig_as_C_string(),
1424                                        (_deopt_state == is_deoptimized) ?
1425                                        " (deoptimized)" :
1426                                        ((_deopt_state == unknown) ? " (state unknown)" : "")),
1427                     3);
1428 
1429     { // mark arguments (see nmethod::print_nmethod_labels)
1430       Method* m = nm->method();
1431 
1432       int stack_slot_offset = nm->frame_size() * wordSize; // offset, in bytes, to caller sp
1433       int sizeargs = m->size_of_parameters();
1434 
1435       BasicType* sig_bt = NEW_RESOURCE_ARRAY(BasicType, sizeargs);
1436       VMRegPair* regs   = NEW_RESOURCE_ARRAY(VMRegPair, sizeargs);
1437       {
1438         int sig_index = 0;
1439         if (!m->is_static()) {
1440           sig_bt[sig_index++] = T_OBJECT; // 'this'
1441         }
1442         for (SignatureStream ss(m->signature()); !ss.at_return_type(); ss.next()) {
1443           BasicType t = ss.type();
1444           assert(type2size[t] == 1 || type2size[t] == 2, "size is 1 or 2");
1445           sig_bt[sig_index++] = t;
1446           if (type2size[t] == 2) {
1447             sig_bt[sig_index++] = T_VOID;
1448           }
1449         }
1450         assert(sig_index == sizeargs, "");
1451       }
1452       int stack_arg_slots = SharedRuntime::java_calling_convention(sig_bt, regs, sizeargs);
1453       assert(stack_arg_slots ==  nm->as_nmethod()->num_stack_arg_slots(false /* rounded */) || nm->is_osr_method(), "");
1454       int out_preserve = SharedRuntime::out_preserve_stack_slots();
1455       int sig_index = 0;
1456       int arg_index = (m->is_static() ? 0 : -1);
1457       for (SignatureStream ss(m->signature()); !ss.at_return_type(); ) {
1458         bool at_this = (arg_index == -1);
1459         bool at_old_sp = false;
1460         BasicType t = (at_this ? T_OBJECT : ss.type());
1461         assert(t == sig_bt[sig_index], "sigs in sync");
1462         VMReg fst = regs[sig_index].first();
1463         if (fst->is_stack()) {
1464           assert(((int)fst->reg2stack()) >= 0, "reg2stack: %d", fst->reg2stack());
1465           int offset = (fst->reg2stack() + out_preserve) * VMRegImpl::stack_slot_size + stack_slot_offset;
1466           intptr_t* stack_address = (intptr_t*)((address)unextended_sp() + offset);
1467           if (at_this) {
1468             values.describe(frame_no, stack_address, err_msg("this for #%d", frame_no), 1);
1469           } else {
1470             values.describe(frame_no, stack_address, err_msg("param %d %s for #%d", arg_index, type2name(t), frame_no), 1);
1471           }
1472         }
1473         sig_index += type2size[t];
1474         arg_index += 1;
1475         if (!at_this) {
1476           ss.next();
1477         }
1478       }
1479     }
1480 
1481     if (reg_map != nullptr && is_java_frame()) {
1482       int scope_no = 0;
1483       for (ScopeDesc* scope = nm->scope_desc_at(pc()); scope != nullptr; scope = scope->sender(), scope_no++) {
1484         Method* m = scope->method();
1485         int  bci = scope->bci();
1486         values.describe(-1, info_address, err_msg("- #%d scope %s @ %d", scope_no, m->name_and_sig_as_C_string(), bci), 2);
1487 
1488         { // mark locals
1489           GrowableArray<ScopeValue*>* scvs = scope->locals();
1490           int scvs_length = scvs != nullptr ? scvs->length() : 0;
1491           for (int i = 0; i < scvs_length; i++) {
1492             intptr_t* stack_address = (intptr_t*)StackValue::stack_value_address(this, reg_map, scvs->at(i));
1493             if (stack_address != nullptr) {
1494               values.describe(frame_no, stack_address, err_msg("local %d for #%d (scope %d)", i, frame_no, scope_no), 1);
1495             }
1496           }
1497         }
1498         { // mark expression stack
1499           GrowableArray<ScopeValue*>* scvs = scope->expressions();
1500           int scvs_length = scvs != nullptr ? scvs->length() : 0;
1501           for (int i = 0; i < scvs_length; i++) {
1502             intptr_t* stack_address = (intptr_t*)StackValue::stack_value_address(this, reg_map, scvs->at(i));
1503             if (stack_address != nullptr) {
1504               values.describe(frame_no, stack_address, err_msg("stack %d for #%d (scope %d)", i, frame_no, scope_no), 1);
1505             }
1506           }
1507         }
1508       }
1509 
1510       FrameValuesOopClosure oopsFn;
1511       oops_do(&oopsFn, nullptr, &oopsFn, reg_map);
1512       oopsFn.describe(values, frame_no);
1513 
1514       if (oop_map() != nullptr) {
1515         FrameValuesOopMapClosure valuesFn(this, reg_map, values, frame_no);
1516         // also OopMapValue::live_value ??
1517         oop_map()->all_type_do(this, OopMapValue::callee_saved_value, &valuesFn);
1518       }
1519     }
1520 
1521     if (nm->method()->is_continuation_enter_intrinsic()) {
1522       ContinuationEntry* ce = Continuation::get_continuation_entry_for_entry_frame(reg_map->thread(), *this); // (ContinuationEntry*)unextended_sp();
1523       ce->describe(values, frame_no);
1524     }
1525   } else if (is_native_frame()) {
1526     // For now just label the frame
1527     nmethod* nm = cb()->as_nmethod_or_null();
1528     values.describe(-1, info_address,
1529                     FormatBuffer<1024>("#%d nmethod " INTPTR_FORMAT " for native method %s", frame_no,
1530                                        p2i(nm), nm->method()->name_and_sig_as_C_string()), 2);
1531   } else {
1532     // provide default info if not handled before
1533     char *info = (char *) "special frame";
1534     if ((_cb != nullptr) &&
1535         (_cb->name() != nullptr)) {
1536       info = (char *)_cb->name();
1537     }
1538     values.describe(-1, info_address, err_msg("#%d <%s>", frame_no, info), 2);
1539   }
1540 
1541   // platform dependent additional data
1542   describe_pd(values, frame_no);
1543 }
1544 
1545 #endif
1546 
1547 #ifndef PRODUCT
1548 
1549 void FrameValues::describe(int owner, intptr_t* location, const char* description, int priority) {
1550   FrameValue fv;
1551   fv.location = location;
1552   fv.owner = owner;
1553   fv.priority = priority;
1554   fv.description = NEW_RESOURCE_ARRAY(char, strlen(description) + 1);
1555   strcpy(fv.description, description);
1556   _values.append(fv);
1557 }
1558 
1559 
1560 #ifdef ASSERT
1561 void FrameValues::validate() {
1562   _values.sort(compare);
1563   bool error = false;
1564   FrameValue prev;
1565   prev.owner = -1;
1566   for (int i = _values.length() - 1; i >= 0; i--) {
1567     FrameValue fv = _values.at(i);
1568     if (fv.owner == -1) continue;
1569     if (prev.owner == -1) {
1570       prev = fv;
1571       continue;
1572     }
1573     if (prev.location == fv.location) {
1574       if (fv.owner != prev.owner) {
1575         tty->print_cr("overlapping storage");
1576         tty->print_cr(" " INTPTR_FORMAT ": " INTPTR_FORMAT " %s", p2i(prev.location), *prev.location, prev.description);
1577         tty->print_cr(" " INTPTR_FORMAT ": " INTPTR_FORMAT " %s", p2i(fv.location), *fv.location, fv.description);
1578         error = true;
1579       }
1580     } else {
1581       prev = fv;
1582     }
1583   }
1584   // if (error) { tty->cr(); print_on(static_cast<JavaThread*>(nullptr), tty); }
1585   assert(!error, "invalid layout");
1586 }
1587 #endif // ASSERT
1588 
1589 void FrameValues::print_on(JavaThread* thread, outputStream* st) {
1590   _values.sort(compare);
1591 
1592   // Sometimes values like the fp can be invalid values if the
1593   // register map wasn't updated during the walk.  Trim out values
1594   // that aren't actually in the stack of the thread.
1595   int min_index = 0;
1596   int max_index = _values.length() - 1;
1597   intptr_t* v0 = _values.at(min_index).location;
1598   intptr_t* v1 = _values.at(max_index).location;
1599 
1600   if (thread != nullptr) {
1601     if (thread == Thread::current()) {
1602       while (!thread->is_in_live_stack((address)v0)) v0 = _values.at(++min_index).location;
1603       while (!thread->is_in_live_stack((address)v1)) v1 = _values.at(--max_index).location;
1604     } else {
1605       while (!thread->is_in_full_stack((address)v0)) v0 = _values.at(++min_index).location;
1606       while (!thread->is_in_full_stack((address)v1)) v1 = _values.at(--max_index).location;
1607     }
1608   }
1609 
1610   print_on(st, min_index, max_index, v0, v1);
1611 }
1612 
1613 void FrameValues::print_on(stackChunkOop chunk, outputStream* st) {
1614   _values.sort(compare);
1615 
1616   intptr_t* start = chunk->start_address();
1617   intptr_t* end = chunk->end_address() + 1;
1618 
1619   int min_index = 0;
1620   int max_index = _values.length() - 1;
1621   intptr_t* v0 = _values.at(min_index).location;
1622   intptr_t* v1 = _values.at(max_index).location;
1623   while (!(start <= v0 && v0 <= end)) v0 = _values.at(++min_index).location;
1624   while (!(start <= v1 && v1 <= end)) v1 = _values.at(--max_index).location;
1625 
1626   print_on(st, min_index, max_index, v0, v1);
1627 }
1628 
1629 void FrameValues::print_on(outputStream* st, int min_index, int max_index, intptr_t* v0, intptr_t* v1) {
1630   intptr_t* min = MIN2(v0, v1);
1631   intptr_t* max = MAX2(v0, v1);
1632   intptr_t* cur = max;
1633   intptr_t* last = nullptr;
1634   intptr_t* fp = nullptr;
1635   for (int i = max_index; i >= min_index; i--) {
1636     FrameValue fv = _values.at(i);
1637     while (cur > fv.location) {
1638       st->print_cr(" " INTPTR_FORMAT ": " INTPTR_FORMAT, p2i(cur), *cur);
1639       cur--;
1640     }
1641     if (last == fv.location) {
1642       const char* spacer = "          " LP64_ONLY("        ");
1643       st->print_cr(" %s  %s %s", spacer, spacer, fv.description);
1644     } else {
1645       if (*fv.description == '#' && isdigit(fv.description[1])) {
1646         // The fv.description string starting with a '#' is the line for the
1647         // saved frame pointer eg. "#10 method java.lang.invoke.LambdaForm..."
1648         // basicaly means frame 10.
1649         fp = fv.location;
1650       }
1651       // To print a fp-relative value:
1652       //   1. The content of *fv.location must be such that we think it's a
1653       //      fp-relative number, i.e [-100..100].
1654       //   2. We must have found the frame pointer.
1655       //   3. The line can not be the line for the saved frame pointer.
1656       //   4. Recognize it as being part of the "fixed frame".
1657       if (*fv.location != 0 && *fv.location > -100 && *fv.location < 100
1658           && fp != nullptr && *fv.description != '#'
1659 #if !defined(PPC64)
1660           && (strncmp(fv.description, "interpreter_frame_", 18) == 0 || strstr(fv.description, " method "))
1661 #else  // !defined(PPC64)
1662           && (strcmp(fv.description, "sender_sp") == 0 || strcmp(fv.description, "top_frame_sp") == 0 ||
1663               strcmp(fv.description, "esp") == 0 || strcmp(fv.description, "monitors") == 0 ||
1664               strcmp(fv.description, "locals") == 0 || strstr(fv.description, " method "))
1665 #endif //!defined(PPC64)
1666           ) {
1667         st->print_cr(" " INTPTR_FORMAT ": " INTPTR_FORMAT " %-32s (relativized: fp%+d)",
1668                      p2i(fv.location), p2i(&fp[*fv.location]), fv.description, (int)*fv.location);
1669       } else {
1670         st->print_cr(" " INTPTR_FORMAT ": " INTPTR_FORMAT " %s", p2i(fv.location), *fv.location, fv.description);
1671       }
1672       last = fv.location;
1673       cur--;
1674     }
1675   }
1676 }
1677 
1678 #endif // ndef PRODUCT