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