1 /*
  2  * Copyright (c) 2016, 2026, Oracle and/or its affiliates. All rights reserved.
  3  * Copyright (c) 2016, 2023 SAP SE. All rights reserved.
  4  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  5  *
  6  * This code is free software; you can redistribute it and/or modify it
  7  * under the terms of the GNU General Public License version 2 only, as
  8  * published by the Free Software Foundation.
  9  *
 10  * This code is distributed in the hope that it will be useful, but WITHOUT
 11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 12  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 13  * version 2 for more details (a copy is included in the LICENSE file that
 14  * accompanied this code).
 15  *
 16  * You should have received a copy of the GNU General Public License version
 17  * 2 along with this work; if not, write to the Free Software Foundation,
 18  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 19  *
 20  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 21  * or visit www.oracle.com if you need additional information or have any
 22  * questions.
 23  *
 24  */
 25 
 26 #include "compiler/oopMap.hpp"
 27 #include "interpreter/interpreter.hpp"
 28 #include "memory/resourceArea.hpp"
 29 #include "memory/universe.hpp"
 30 #include "oops/markWord.hpp"
 31 #include "oops/oop.inline.hpp"
 32 #include "runtime/frame.inline.hpp"
 33 #include "runtime/handles.inline.hpp"
 34 #include "runtime/javaCalls.hpp"
 35 #include "runtime/monitorChunk.hpp"
 36 #include "runtime/os.inline.hpp"
 37 #include "runtime/signature.hpp"
 38 #include "runtime/stubCodeGenerator.hpp"
 39 #include "runtime/stubRoutines.hpp"
 40 #include "vmreg_s390.inline.hpp"
 41 #ifdef COMPILER1
 42 #include "c1/c1_Runtime1.hpp"
 43 #include "runtime/vframeArray.hpp"
 44 #endif
 45 
 46 // Major contributions by Aha, AS.
 47 
 48 #ifdef ASSERT
 49 void RegisterMap::check_location_valid() {
 50 }
 51 #endif // ASSERT
 52 
 53 
 54 // Profiling/safepoint support
 55 
 56 bool frame::safe_for_sender(JavaThread *thread) {
 57   address sp = (address)_sp;
 58   address fp = (address)_fp;
 59   address unextended_sp = (address)_unextended_sp;
 60 
 61   // consider stack guards when trying to determine "safe" stack pointers
 62   // sp must be within the usable part of the stack (not in guards)
 63   if (!thread->is_in_usable_stack(sp)) {
 64     return false;
 65   }
 66 
 67   // Unextended sp must be within the stack
 68   if (!thread->is_in_full_stack_checked(unextended_sp)) {
 69     return false;
 70   }
 71 
 72   // An fp must be within the stack and above (but not equal) sp.
 73   bool fp_safe = thread->is_in_stack_range_excl(fp, sp);
 74   // An interpreter fp must be fp_safe.
 75   // Moreover, it must be at a distance at least the size of the z_ijava_state structure.
 76   bool fp_interp_safe = fp_safe && ((fp - sp) >= z_ijava_state_size);
 77 
 78   // We know sp/unextended_sp are safe, only fp is questionable here
 79 
 80   // If the current frame is known to the code cache then we can attempt to
 81   // construct the sender and do some validation of it. This goes a long way
 82   // toward eliminating issues when we get in frame construction code
 83 
 84   if (_cb != nullptr ) {
 85 
 86     // First check if the frame is complete and the test is reliable.
 87     // Unfortunately we can only check frame completeness for runtime stubs.
 88     // Other generic buffer blobs are more problematic so we just assume they are OK.
 89     // Adapter blobs never have a complete frame and are never OK.
 90     // nmethods should be OK on s390.
 91     if (!_cb->is_frame_complete_at(_pc)) {
 92       if (_cb->is_adapter_blob() || _cb->is_runtime_stub()) {
 93         return false;
 94       }
 95     }
 96 
 97     // Could just be some random pointer within the codeBlob.
 98     if (!_cb->code_contains(_pc)) {
 99       return false;
100     }
101 
102     // Entry frame checks
103     if (is_entry_frame()) {
104       // An entry frame must have a valid fp.
105       return fp_safe && is_entry_frame_valid(thread);
106     }
107 
108     if (is_interpreted_frame() && !fp_interp_safe) {
109       return false;
110     }
111 
112     // At this point, there still is a chance that fp_safe is false.
113     // In particular, fp might be null. So let's check and
114     // bail out before we actually dereference from fp.
115     if (!fp_safe) {
116       return false;
117     }
118 
119     z_common_abi* sender_abi = (z_common_abi*)fp;
120     intptr_t* sender_sp = (intptr_t*) fp;
121     address   sender_pc = (address)   sender_abi->return_pc;
122 
123     // We must always be able to find a recognizable pc.
124     CodeBlob* sender_blob = CodeCache::find_blob(sender_pc);
125     if (sender_blob == nullptr) {
126       return false;
127     }
128 
129     // It should be safe to construct the sender though it might not be valid.
130 
131     frame sender(sender_sp, sender_pc);
132 
133     // Do we have a valid fp?
134     address sender_fp = (address) sender.fp();
135 
136     // sender_fp must be within the stack and above (but not
137     // equal) current frame's fp.
138     if (!thread->is_in_stack_range_excl(sender_fp, fp)) {
139       return false;
140     }
141 
142     // If the potential sender is the interpreter then we can do some more checking.
143     if (Interpreter::contains(sender_pc)) {
144       return sender.is_interpreted_frame_valid(thread);
145     }
146 
147     // Could just be some random pointer within the codeBlob.
148     if (!sender.cb()->code_contains(sender_pc)) {
149       return false;
150     }
151 
152     // We should never be able to see an adapter if the current frame is something from code cache.
153     if (sender_blob->is_adapter_blob()) {
154       return false;
155     }
156 
157     if (sender.is_entry_frame()) {
158       return sender.is_entry_frame_valid(thread);
159     }
160 
161     // Frame size is always greater than zero. If the sender frame size is zero or less,
162     // something is really weird and we better give up.
163     if (sender_blob->frame_size() <= 0) {
164       return false;
165     }
166 
167     return true;
168   }
169 
170   // Must be native-compiled frame. Since sender will try and use fp to find
171   // linkages it must be safe
172 
173   if (!fp_safe) {
174     return false;
175   }
176 
177   return true;
178 }
179 
180 bool frame::is_interpreted_frame() const {
181   return Interpreter::contains(pc());
182 }
183 
184 // locals
185 
186 void frame::interpreter_frame_set_locals(intptr_t* locs)  {
187   assert(is_interpreted_frame(), "interpreted frame expected");
188   // set relativized locals
189   *addr_at(_z_ijava_idx(locals)) = (intptr_t) (locs - fp());
190 }
191 
192 // sender_sp
193 
194 intptr_t* frame::interpreter_frame_sender_sp() const {
195   return sender_sp();
196 }
197 
198 frame frame::sender_for_entry_frame(RegisterMap *map) const {
199   assert(map != nullptr, "map must be set");
200   // Java frame called from C. Skip all C frames and return top C
201   // frame of that chunk as the sender.
202   JavaFrameAnchor* jfa = entry_frame_call_wrapper()->anchor();
203 
204   assert(!entry_frame_is_first(), "next Java sp must be non zero");
205   assert(jfa->last_Java_sp() > _sp, "must be above this frame on stack");
206 
207   map->clear();
208 
209   assert(map->include_argument_oops(), "should be set by clear");
210 
211   if (jfa->last_Java_pc() != nullptr) {
212     frame fr(jfa->last_Java_sp(), jfa->last_Java_pc());
213     return fr;
214   }
215   // Last_java_pc is not set if we come here from compiled code.
216   frame fr(jfa->last_Java_sp());
217   return fr;
218 }
219 
220 UpcallStub::FrameData* UpcallStub::frame_data_for_frame(const frame& frame) const {
221   assert(frame.is_upcall_stub_frame(), "wrong frame");
222   // need unextended_sp here, since normal sp is wrong for interpreter callees
223   return reinterpret_cast<UpcallStub::FrameData*>(
224     reinterpret_cast<address>(frame.unextended_sp()) + in_bytes(_frame_data_offset));
225 }
226 
227 bool frame::upcall_stub_frame_is_first() const {
228   assert(is_upcall_stub_frame(), "must be optimized entry frame");
229   UpcallStub* blob = _cb->as_upcall_stub();
230   JavaFrameAnchor* jfa = blob->jfa_for_frame(*this);
231   return jfa->last_Java_sp() == nullptr;
232 }
233 
234 frame frame::sender_for_upcall_stub_frame(RegisterMap* map) const {
235   assert(map != nullptr, "map must be set");
236   UpcallStub* blob = _cb->as_upcall_stub();
237   // Java frame called from C; skip all C frames and return top C
238   // frame of that chunk as the sender
239   JavaFrameAnchor* jfa = blob->jfa_for_frame(*this);
240   assert(!upcall_stub_frame_is_first(), "must have a frame anchor to go back to");
241   assert(jfa->last_Java_sp() > sp(), "must be above this frame on stack");
242   map->clear();
243   assert(map->include_argument_oops(), "should be set by clear");
244   frame fr(jfa->last_Java_sp(), jfa->last_Java_pc());
245 
246   return fr;
247 }
248 
249 JavaThread** frame::saved_thread_address(const frame& f) {
250   Unimplemented();
251   return nullptr;
252 }
253 
254 frame frame::sender_for_interpreter_frame(RegisterMap *map) const {
255   // Pass callers sender_sp as unextended_sp.
256   return frame(sender_sp(), sender_pc(), (intptr_t*)(ijava_state()->sender_sp));
257 }
258 
259 void frame::patch_pc(Thread* thread, address pc) {
260   assert(_cb == CodeCache::find_blob(pc), "unexpected pc");
261   address* pc_addr = (address*)&(own_abi()->return_pc);
262 
263   if (TracePcPatching) {
264     tty->print_cr("patch_pc at address  " PTR_FORMAT " [" PTR_FORMAT " -> " PTR_FORMAT "] ",
265                   p2i(&((address*) _sp)[-1]), p2i(((address*) _sp)[-1]), p2i(pc));
266   }
267   assert(!Continuation::is_return_barrier_entry(*pc_addr), "return barrier");
268   assert(_pc == *pc_addr || pc == *pc_addr || nullptr == *pc_addr,
269          "must be (pc: " INTPTR_FORMAT " _pc: " INTPTR_FORMAT " pc_addr: " INTPTR_FORMAT
270          " *pc_addr: " INTPTR_FORMAT  " sp: " INTPTR_FORMAT ")",
271          p2i(pc), p2i(_pc), p2i(pc_addr), p2i(*pc_addr), p2i(sp()));
272   DEBUG_ONLY(address old_pc = _pc;)
273   own_abi()->return_pc = (uint64_t)pc;
274   _pc = pc; // must be set before call to get_deopt_original_pc
275   address original_pc = get_deopt_original_pc();
276   if (original_pc != nullptr) {
277     // assert(original_pc == _pc, "expected original to be stored before patching");
278     _deopt_state = is_deoptimized;
279     _pc = original_pc;
280   } else {
281     _deopt_state = not_deoptimized;
282   }
283   assert(!is_compiled_frame() || !_cb->as_nmethod()->is_deopt_entry(_pc), "must be");
284 
285   #ifdef ASSERT
286   {
287     frame f(this->sp(), pc, this->unextended_sp());
288     assert(f.is_deoptimized_frame() == this->is_deoptimized_frame() && f.pc() == this->pc() && f.raw_pc() == this->raw_pc(),
289            "must be (f.is_deoptimized_frame(): %d this->is_deoptimized_frame(): %d "
290            "f.pc(): " INTPTR_FORMAT " this->pc(): " INTPTR_FORMAT " f.raw_pc(): " INTPTR_FORMAT " this->raw_pc(): " INTPTR_FORMAT ")",
291            f.is_deoptimized_frame(), this->is_deoptimized_frame(), p2i(f.pc()), p2i(this->pc()), p2i(f.raw_pc()), p2i(this->raw_pc()));
292   }
293   #endif
294 }
295 
296 bool frame::is_interpreted_frame_valid(JavaThread* thread) const {
297   assert(is_interpreted_frame(), "Not an interpreted frame");
298   // These are reasonable sanity checks
299   if (fp() == nullptr || (intptr_t(fp()) & (wordSize-1)) != 0) {
300     return false;
301   }
302   if (sp() == nullptr || (intptr_t(sp()) & (wordSize-1)) != 0) {
303     return false;
304   }
305   int min_frame_slots = (z_common_abi_size + z_ijava_state_size) / sizeof(intptr_t);
306   if (fp() - min_frame_slots < sp()) {
307     return false;
308   }
309   // These are hacks to keep us out of trouble.
310   // The problem with these is that they mask other problems
311   if (fp() <= sp()) {        // this attempts to deal with unsigned comparison above
312     return false;
313   }
314 
315   // do some validation of frame elements
316 
317   // first the method
318   // Need to use "unchecked" versions to avoid "z_istate_magic_number" assertion.
319   Method* m = (Method*)(ijava_state_unchecked()->method);
320 
321   // validate the method we'd find in this potential sender
322   if (!Method::is_valid_method(m)) return false;
323 
324   // stack frames shouldn't be much larger than max_stack elements
325   // this test requires the use of unextended_sp which is the sp as seen by
326   // the current frame, and not sp which is the "raw" pc which could point
327   // further because of local variables of the callee method inserted after
328   // method arguments
329   if (fp() - unextended_sp() > 1024 + m->max_stack()*Interpreter::stackElementSize) {
330     return false;
331   }
332 
333   // validate bci/bcx
334   address bcp = (address)(ijava_state_unchecked()->bcp);
335   if (m->validate_bci_from_bcp(bcp) < 0) {
336     return false;
337   }
338 
339   // validate constantPoolCache*
340   ConstantPoolCache* cp = (ConstantPoolCache*)(ijava_state_unchecked()->cpoolCache);
341   if (MetaspaceObj::is_valid(cp) == false) return false;
342 
343   // validate locals
344   address locals = (address)interpreter_frame_locals();
345   return thread->is_in_stack_range_incl(locals, (address)fp());
346 }
347 
348 BasicType frame::interpreter_frame_result(oop* oop_result, jvalue* value_result) {
349   assert(is_interpreted_frame(), "interpreted frame expected");
350   Method* method = interpreter_frame_method();
351   BasicType type = method->result_type();
352 
353   if (method->is_native()) {
354     address lresult = (address)&(ijava_state()->lresult);
355     address fresult = (address)&(ijava_state()->fresult);
356 
357     switch (type) {
358       case T_OBJECT:
359       case T_ARRAY: {
360         *oop_result = cast_to_oop((void*) ijava_state()->oop_tmp);
361         break;
362       }
363       // We use std/stfd to store the values.
364       case T_BOOLEAN : value_result->z = (jboolean) *(unsigned long*)lresult; break;
365       case T_INT     : value_result->i = (jint)     *(long*)lresult;          break;
366       case T_CHAR    : value_result->c = (jchar)    *(unsigned long*)lresult; break;
367       case T_SHORT   : value_result->s = (jshort)   *(long*)lresult;          break;
368       case T_BYTE    : value_result->z = (jbyte)    *(long*)lresult;          break;
369       case T_LONG    : value_result->j = (jlong)    *(long*)lresult;          break;
370       case T_FLOAT   : value_result->f = (jfloat)   *(float*)fresult;        break;
371       case T_DOUBLE  : value_result->d = (jdouble)  *(double*)fresult;        break;
372       case T_VOID    : break; // Nothing to do.
373       default        : ShouldNotReachHere();
374     }
375   } else {
376     intptr_t* tos_addr = interpreter_frame_tos_address();
377     switch (type) {
378       case T_OBJECT:
379       case T_ARRAY: {
380        oop obj = *(oop*)tos_addr;
381        assert(Universe::is_in_heap_or_null(obj), "sanity check");
382        *oop_result = obj;
383        break;
384       }
385       case T_BOOLEAN : value_result->z = (jboolean) *(jint*)tos_addr; break;
386       case T_BYTE    : value_result->b = (jbyte) *(jint*)tos_addr; break;
387       case T_CHAR    : value_result->c = (jchar) *(jint*)tos_addr; break;
388       case T_SHORT   : value_result->s = (jshort) *(jint*)tos_addr; break;
389       case T_INT     : value_result->i = *(jint*)tos_addr; break;
390       case T_LONG    : value_result->j = *(jlong*)tos_addr; break;
391       case T_FLOAT   : value_result->f = *(jfloat*)tos_addr; break;
392       case T_DOUBLE  : value_result->d = *(jdouble*)tos_addr; break;
393       case T_VOID    : break; // Nothing to do.
394       default        : ShouldNotReachHere();
395     }
396   }
397 
398   return type;
399 }
400 
401 
402 // Dump all frames starting a given C stack-pointer.
403 // Use max_frames to limit the number of traced frames.
404 void frame::back_trace(outputStream* st, intptr_t* start_sp, intptr_t* top_pc, unsigned long flags, int max_frames) {
405 
406   static char buf[ 150 ];
407 
408   bool print_outgoing_arguments = flags & 0x1;
409   bool print_istate_pointers    = flags & 0x2;
410   int num = 0;
411 
412   intptr_t* current_sp = (intptr_t*) start_sp;
413   int last_num_jargs = 0;
414   int frame_type = 0;
415   int last_frame_type = 0;
416 
417   while (current_sp) {
418     intptr_t* current_fp = (intptr_t*) *current_sp;
419     address   current_pc = (num == 0)
420                            ? (address) top_pc
421                            : (address) *((intptr_t*)(((address) current_sp) + _z_abi(return_pc)));
422 
423     if ((intptr_t*) current_fp != nullptr && (intptr_t*) current_fp <= current_sp) {
424       st->print_cr("ERROR: corrupt stack");
425       return;
426     }
427 
428     st->print("#%-3d ", num);
429     const char* type_name = "    ";
430     const char* function_name = nullptr;
431 
432     // Detect current frame's frame_type, default to 'C frame'.
433     frame_type = 0;
434 
435     CodeBlob* blob = nullptr;
436 
437     if (Interpreter::contains(current_pc)) {
438       frame_type = 1;
439     } else if (StubRoutines::contains(current_pc)) {
440       if (StubRoutines::returns_to_call_stub(current_pc)) {
441         frame_type = 2;
442       } else {
443         frame_type = 4;
444         type_name = "stu";
445         StubCodeDesc* desc = StubCodeDesc::desc_for (current_pc);
446         if (desc) {
447           function_name = desc->name();
448         } else {
449           function_name = "unknown stub";
450         }
451       }
452     } else if (CodeCache::contains(current_pc)) {
453       blob = CodeCache::find_blob(current_pc);
454       if (blob) {
455         if (blob->is_nmethod()) {
456           frame_type = 3;
457         } else if (blob->is_deoptimization_stub()) {
458           frame_type = 4;
459           type_name = "deo";
460           function_name = "deoptimization blob";
461         } else if (blob->is_uncommon_trap_stub()) {
462           frame_type = 4;
463           type_name = "uct";
464           function_name = "uncommon trap blob";
465         } else if (blob->is_exception_stub()) {
466           frame_type = 4;
467           type_name = "exc";
468           function_name = "exception blob";
469         } else if (blob->is_safepoint_stub()) {
470           frame_type = 4;
471           type_name = "saf";
472           function_name = "safepoint blob";
473         } else if (blob->is_runtime_stub()) {
474           frame_type = 4;
475           type_name = "run";
476           function_name = ((RuntimeStub *)blob)->name();
477         } else if (blob->is_method_handles_adapter_blob()) {
478           frame_type = 4;
479           type_name = "mha";
480           function_name = "method handles adapter blob";
481         } else {
482           frame_type = 4;
483           type_name = "blo";
484           function_name = "unknown code blob";
485         }
486       } else {
487         frame_type = 4;
488         type_name = "blo";
489         function_name = "unknown code blob";
490       }
491     }
492 
493     st->print("sp=" PTR_FORMAT " ", p2i(current_sp));
494 
495     if (frame_type == 0) {
496       current_pc = (address) *((intptr_t*)(((address) current_sp) + _z_abi(gpr14)));
497     }
498 
499     st->print("pc=" PTR_FORMAT " ", p2i(current_pc));
500     st->print(" ");
501 
502     switch (frame_type) {
503       case 0: // C frame:
504         {
505           st->print("    ");
506           if (current_pc == nullptr) {
507             st->print("? ");
508           } else {
509              // name
510             int func_offset;
511             char demangled_name[256];
512             int demangled_name_len = 256;
513             if (os::dll_address_to_function_name(current_pc, demangled_name, demangled_name_len, &func_offset)) {
514               demangled_name[demangled_name_len-1] = '\0';
515               st->print(func_offset == -1 ? "%s " : "%s+0x%x", demangled_name, func_offset);
516             } else {
517               st->print("? ");
518             }
519           }
520         }
521         break;
522 
523       case 1: // interpreter frame:
524         {
525           st->print(" i  ");
526 
527           if (last_frame_type != 1) last_num_jargs = 8;
528 
529           // name
530           Method* method = *(Method**)((address)current_fp + _z_ijava_state_neg(method));
531           if (method) {
532             ResourceMark rm;
533             if (method->is_synchronized()) st->print("synchronized ");
534             if (method->is_static()) st->print("static ");
535             if (method->is_native()) st->print("native ");
536             method->name_and_sig_as_C_string(buf, sizeof(buf));
537             st->print("%s ", buf);
538           }
539           else
540             st->print("? ");
541 
542           intptr_t* tos = (intptr_t*) *(intptr_t*)((address)current_fp + _z_ijava_state_neg(esp));
543           if (print_istate_pointers) {
544             st->cr();
545             st->print("     ");
546             st->print("ts=" PTR_FORMAT " ", p2i(tos));
547           }
548 
549           // Dump some Java stack slots.
550           if (print_outgoing_arguments) {
551             if (method->is_native()) {
552 #ifdef ASSERT
553               intptr_t* cargs = (intptr_t*) (((address)current_sp) + _z_abi(carg_1));
554               for (int i = 0; i < last_num_jargs; i++) {
555                 // Cargs is not prepushed.
556                 st->cr();
557                 st->print("        ");
558                 st->print(PTR_FORMAT, *(cargs));
559                 cargs++;
560               }
561 #endif /* ASSERT */
562             }
563             else {
564               if (tos) {
565                 for (int i = 0; i < last_num_jargs; i++) {
566                   // tos+0 is prepushed, ignore.
567                   tos++;
568                   if (tos >= (intptr_t *)((address)current_fp + _z_ijava_state_neg(monitors)))
569                     break;
570                   st->cr();
571                   st->print("        ");
572                   st->print(PTR_FORMAT " %+.3e %+.3le", *(tos), *(float*)(tos), *(double*)(tos));
573                 }
574               }
575             }
576             last_num_jargs = method->size_of_parameters();
577           }
578         }
579         break;
580 
581       case 2: // entry frame:
582         {
583           st->print("v2i ");
584 
585           // name
586           st->print("call stub");
587         }
588         break;
589 
590       case 3: // compiled frame:
591         {
592           st->print(" c  ");
593 
594           // name
595           Method* method = ((nmethod *)blob)->method();
596           if (method) {
597             ResourceMark rm;
598             method->name_and_sig_as_C_string(buf, sizeof(buf));
599             st->print("%s ", buf);
600           }
601           else
602             st->print("? ");
603         }
604         break;
605 
606       case 4: // named frames
607         {
608           st->print("%s ", type_name);
609 
610           // name
611           if (function_name)
612             st->print("%s", function_name);
613         }
614         break;
615 
616       default:
617         break;
618     }
619 
620     st->cr();
621     st->flush();
622 
623     current_sp = current_fp;
624     last_frame_type = frame_type;
625     num++;
626     // Check for maximum # of frames, and stop when reached.
627     if (max_frames > 0 && --max_frames == 0)
628       break;
629   }
630 
631 }
632 
633 // Convenience function for calls from the debugger.
634 
635 extern "C" void bt(intptr_t* start_sp,intptr_t* top_pc) {
636   frame::back_trace(tty,start_sp, top_pc, 0);
637 }
638 
639 extern "C" void bt_full(intptr_t* start_sp,intptr_t* top_pc) {
640   frame::back_trace(tty,start_sp, top_pc, (unsigned long)(long)-1);
641 }
642 
643 
644 // Function for tracing a limited number of frames.
645 // Use this one if you only need to see the "top of stack" frames.
646 extern "C" void bt_max(intptr_t *start_sp, intptr_t *top_pc, int max_frames) {
647   frame::back_trace(tty, start_sp, top_pc, 0, max_frames);
648 }
649 
650 #if !defined(PRODUCT)
651 
652 #define DESCRIBE_ADDRESS(name) \
653   values.describe(frame_no, (intptr_t*)&ijava_state()->name, #name);
654 
655 void frame::describe_pd(FrameValues& values, int frame_no) {
656   if (is_interpreted_frame()) {
657     // Describe z_ijava_state elements.
658     DESCRIBE_ADDRESS(method);
659     DESCRIBE_ADDRESS(locals);
660     DESCRIBE_ADDRESS(monitors);
661     DESCRIBE_ADDRESS(cpoolCache);
662     DESCRIBE_ADDRESS(bcp);
663     DESCRIBE_ADDRESS(mdx);
664     DESCRIBE_ADDRESS(esp);
665     DESCRIBE_ADDRESS(sender_sp);
666     DESCRIBE_ADDRESS(top_frame_sp);
667     DESCRIBE_ADDRESS(oop_tmp);
668     DESCRIBE_ADDRESS(lresult);
669     DESCRIBE_ADDRESS(fresult);
670   }
671 }
672 
673 #endif // !PRODUCT
674 
675 intptr_t *frame::initial_deoptimization_info() {
676   // Used to reset the saved FP.
677   return fp();
678 }
679 
680 BasicObjectLock* frame::interpreter_frame_monitor_end() const {
681   return interpreter_frame_monitors();
682 }
683 
684 intptr_t* frame::interpreter_frame_tos_at(jint offset) const {
685   return &interpreter_frame_tos_address()[offset];
686 }
687 
688 intptr_t* frame::repair_sender_sp(intptr_t* sender_sp, intptr_t** saved_fp_addr) const {
689   Unimplemented();
690   return nullptr;
691 }
692 
693 intptr_t* frame::repair_sender_sp(nmethod* nm, intptr_t* sp, intptr_t** saved_fp_addr) {
694   Unimplemented();
695   return nullptr;
696 }
697 
698 bool frame::was_augmented_on_entry(int& real_size) const {
699   Unimplemented();
700   return false;
701 }