vframe.cpp revision 11079:69d081845165
1/*
2 * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25#include "precompiled.hpp"
26#include "classfile/javaClasses.hpp"
27#include "classfile/systemDictionary.hpp"
28#include "classfile/vmSymbols.hpp"
29#include "code/codeCache.hpp"
30#include "code/debugInfoRec.hpp"
31#include "code/nmethod.hpp"
32#include "code/pcDesc.hpp"
33#include "code/scopeDesc.hpp"
34#include "interpreter/interpreter.hpp"
35#include "interpreter/oopMapCache.hpp"
36#include "memory/resourceArea.hpp"
37#include "oops/instanceKlass.hpp"
38#include "oops/oop.inline.hpp"
39#include "runtime/handles.inline.hpp"
40#include "runtime/objectMonitor.hpp"
41#include "runtime/objectMonitor.inline.hpp"
42#include "runtime/signature.hpp"
43#include "runtime/stubRoutines.hpp"
44#include "runtime/synchronizer.hpp"
45#include "runtime/vframe.hpp"
46#include "runtime/vframeArray.hpp"
47#include "runtime/vframe_hp.hpp"
48
49vframe::vframe(const frame* fr, const RegisterMap* reg_map, JavaThread* thread)
50: _reg_map(reg_map), _thread(thread) {
51  assert(fr != NULL, "must have frame");
52  _fr = *fr;
53}
54
55vframe::vframe(const frame* fr, JavaThread* thread)
56: _reg_map(thread), _thread(thread) {
57  assert(fr != NULL, "must have frame");
58  _fr = *fr;
59}
60
61vframe* vframe::new_vframe(const frame* f, const RegisterMap* reg_map, JavaThread* thread) {
62  // Interpreter frame
63  if (f->is_interpreted_frame()) {
64    return new interpretedVFrame(f, reg_map, thread);
65  }
66
67  // Compiled frame
68  CodeBlob* cb = f->cb();
69  if (cb != NULL) {
70    if (cb->is_compiled()) {
71      CompiledMethod* nm = (CompiledMethod*)cb;
72      return new compiledVFrame(f, reg_map, thread, nm);
73    }
74
75    if (f->is_runtime_frame()) {
76      // Skip this frame and try again.
77      RegisterMap temp_map = *reg_map;
78      frame s = f->sender(&temp_map);
79      return new_vframe(&s, &temp_map, thread);
80    }
81  }
82
83  // External frame
84  return new externalVFrame(f, reg_map, thread);
85}
86
87vframe* vframe::sender() const {
88  RegisterMap temp_map = *register_map();
89  assert(is_top(), "just checking");
90  if (_fr.is_entry_frame() && _fr.is_first_frame()) return NULL;
91  frame s = _fr.real_sender(&temp_map);
92  if (s.is_first_frame()) return NULL;
93  return vframe::new_vframe(&s, &temp_map, thread());
94}
95
96vframe* vframe::top() const {
97  vframe* vf = (vframe*) this;
98  while (!vf->is_top()) vf = vf->sender();
99  return vf;
100}
101
102
103javaVFrame* vframe::java_sender() const {
104  vframe* f = sender();
105  while (f != NULL) {
106    if (f->is_java_frame()) return javaVFrame::cast(f);
107    f = f->sender();
108  }
109  return NULL;
110}
111
112// ------------- javaVFrame --------------
113
114GrowableArray<MonitorInfo*>* javaVFrame::locked_monitors() {
115  assert(SafepointSynchronize::is_at_safepoint() || JavaThread::current() == thread(),
116         "must be at safepoint or it's a java frame of the current thread");
117
118  GrowableArray<MonitorInfo*>* mons = monitors();
119  GrowableArray<MonitorInfo*>* result = new GrowableArray<MonitorInfo*>(mons->length());
120  if (mons->is_empty()) return result;
121
122  bool found_first_monitor = false;
123  ObjectMonitor *pending_monitor = thread()->current_pending_monitor();
124  ObjectMonitor *waiting_monitor = thread()->current_waiting_monitor();
125  oop pending_obj = (pending_monitor != NULL ? (oop) pending_monitor->object() : (oop) NULL);
126  oop waiting_obj = (waiting_monitor != NULL ? (oop) waiting_monitor->object() : (oop) NULL);
127
128  for (int index = (mons->length()-1); index >= 0; index--) {
129    MonitorInfo* monitor = mons->at(index);
130    if (monitor->eliminated() && is_compiled_frame()) continue; // skip eliminated monitor
131    oop obj = monitor->owner();
132    if (obj == NULL) continue; // skip unowned monitor
133    //
134    // Skip the monitor that the thread is blocked to enter or waiting on
135    //
136    if (!found_first_monitor && (obj == pending_obj || obj == waiting_obj)) {
137      continue;
138    }
139    found_first_monitor = true;
140    result->append(monitor);
141  }
142  return result;
143}
144
145void javaVFrame::print_locked_object_class_name(outputStream* st, Handle obj, const char* lock_state) {
146  if (obj.not_null()) {
147    st->print("\t- %s <" INTPTR_FORMAT "> ", lock_state, p2i(obj()));
148    if (obj->klass() == SystemDictionary::Class_klass()) {
149      st->print_cr("(a java.lang.Class for %s)", java_lang_Class::as_external_name(obj()));
150    } else {
151      Klass* k = obj->klass();
152      st->print_cr("(a %s)", k->external_name());
153    }
154  }
155}
156
157void javaVFrame::print_lock_info_on(outputStream* st, int frame_count) {
158  ResourceMark rm;
159
160  // If this is the first frame and it is java.lang.Object.wait(...)
161  // then print out the receiver. Locals are not always available,
162  // e.g., compiled native frames have no scope so there are no locals.
163  if (frame_count == 0) {
164    if (method()->name() == vmSymbols::wait_name() &&
165        method()->method_holder()->name() == vmSymbols::java_lang_Object()) {
166      const char *wait_state = "waiting on"; // assume we are waiting
167      // If earlier in the output we reported java.lang.Thread.State ==
168      // "WAITING (on object monitor)" and now we report "waiting on", then
169      // we are still waiting for notification or timeout. Otherwise if
170      // we earlier reported java.lang.Thread.State == "BLOCKED (on object
171      // monitor)", then we are actually waiting to re-lock the monitor.
172      // At this level we can't distinguish the two cases to report
173      // "waited on" rather than "waiting on" for the second case.
174      StackValueCollection* locs = locals();
175      if (!locs->is_empty()) {
176        StackValue* sv = locs->at(0);
177        if (sv->type() == T_OBJECT) {
178          Handle o = locs->at(0)->get_obj();
179          print_locked_object_class_name(st, o, wait_state);
180        }
181      } else {
182        st->print_cr("\t- %s <no object reference available>", wait_state);
183      }
184    } else if (thread()->current_park_blocker() != NULL) {
185      oop obj = thread()->current_park_blocker();
186      Klass* k = obj->klass();
187      st->print_cr("\t- %s <" INTPTR_FORMAT "> (a %s)", "parking to wait for ", p2i(obj), k->external_name());
188    }
189  }
190
191  // Print out all monitors that we have locked, or are trying to lock,
192  // including re-locking after being notified or timing out in a wait().
193  GrowableArray<MonitorInfo*>* mons = monitors();
194  if (!mons->is_empty()) {
195    bool found_first_monitor = false;
196    for (int index = (mons->length()-1); index >= 0; index--) {
197      MonitorInfo* monitor = mons->at(index);
198      if (monitor->eliminated() && is_compiled_frame()) { // Eliminated in compiled code
199        if (monitor->owner_is_scalar_replaced()) {
200          Klass* k = java_lang_Class::as_Klass(monitor->owner_klass());
201          // format below for lockbits matches this one.
202          st->print("\t- eliminated <owner is scalar replaced> (a %s)", k->external_name());
203        } else {
204          oop obj = monitor->owner();
205          if (obj != NULL) {
206            print_locked_object_class_name(st, obj, "eliminated");
207          }
208        }
209        continue;
210      }
211      if (monitor->owner() != NULL) {
212        // the monitor is associated with an object, i.e., it is locked
213
214        markOop mark = NULL;
215        const char *lock_state = "locked"; // assume we have the monitor locked
216        if (!found_first_monitor && frame_count == 0) {
217          // If this is the first frame and we haven't found an owned
218          // monitor before, then we need to see if we have completed
219          // the lock or if we are blocked trying to acquire it. Only
220          // an inflated monitor that is first on the monitor list in
221          // the first frame can block us on a monitor enter.
222          mark = monitor->owner()->mark();
223          if (mark->has_monitor() &&
224              ( // we have marked ourself as pending on this monitor
225                mark->monitor() == thread()->current_pending_monitor() ||
226                // we are not the owner of this monitor
227                !mark->monitor()->is_entered(thread())
228              )) {
229            lock_state = "waiting to lock";
230          } else {
231            // We own the monitor which is not as interesting so
232            // disable the extra printing below.
233            mark = NULL;
234          }
235        } else if (frame_count != 0) {
236          // This is not the first frame so we either own this monitor
237          // or we owned the monitor before and called wait(). Because
238          // wait() could have been called on any monitor in a lower
239          // numbered frame on the stack, we have to check all the
240          // monitors on the list for this frame.
241          mark = monitor->owner()->mark();
242          if (mark->has_monitor() &&
243              ( // we have marked ourself as pending on this monitor
244                mark->monitor() == thread()->current_pending_monitor() ||
245                // we are not the owner of this monitor
246                !mark->monitor()->is_entered(thread())
247              )) {
248            lock_state = "waiting to re-lock in wait()";
249          } else {
250            // We own the monitor which is not as interesting so
251            // disable the extra printing below.
252            mark = NULL;
253          }
254        }
255        print_locked_object_class_name(st, monitor->owner(), lock_state);
256        if (ObjectMonitor::Knob_Verbose && mark != NULL) {
257          st->print("\t- lockbits=");
258          mark->print_on(st);
259          st->cr();
260        }
261
262        found_first_monitor = true;
263      }
264    }
265  }
266}
267
268// ------------- interpretedVFrame --------------
269
270u_char* interpretedVFrame::bcp() const {
271  return fr().interpreter_frame_bcp();
272}
273
274void interpretedVFrame::set_bcp(u_char* bcp) {
275  fr().interpreter_frame_set_bcp(bcp);
276}
277
278intptr_t* interpretedVFrame::locals_addr_at(int offset) const {
279  assert(fr().is_interpreted_frame(), "frame should be an interpreted frame");
280  return fr().interpreter_frame_local_at(offset);
281}
282
283
284GrowableArray<MonitorInfo*>* interpretedVFrame::monitors() const {
285  GrowableArray<MonitorInfo*>* result = new GrowableArray<MonitorInfo*>(5);
286  for (BasicObjectLock* current = (fr().previous_monitor_in_interpreter_frame(fr().interpreter_frame_monitor_begin()));
287       current >= fr().interpreter_frame_monitor_end();
288       current = fr().previous_monitor_in_interpreter_frame(current)) {
289    result->push(new MonitorInfo(current->obj(), current->lock(), false, false));
290  }
291  return result;
292}
293
294int interpretedVFrame::bci() const {
295  return method()->bci_from(bcp());
296}
297
298Method* interpretedVFrame::method() const {
299  return fr().interpreter_frame_method();
300}
301
302static StackValue* create_stack_value_from_oop_map(const InterpreterOopMap& oop_mask,
303                                                   int index,
304                                                   const intptr_t* const addr) {
305
306  assert(index >= 0 &&
307         index < oop_mask.number_of_entries(), "invariant");
308
309  // categorize using oop_mask
310  if (oop_mask.is_oop(index)) {
311    // reference (oop) "r"
312    Handle h(addr != NULL ? (*(oop*)addr) : (oop)NULL);
313    return new StackValue(h);
314  }
315  // value (integer) "v"
316  return new StackValue(addr != NULL ? *addr : 0);
317}
318
319static bool is_in_expression_stack(const frame& fr, const intptr_t* const addr) {
320  assert(addr != NULL, "invariant");
321
322  // Ensure to be 'inside' the expresion stack (i.e., addr >= sp for Intel).
323  // In case of exceptions, the expression stack is invalid and the sp
324  // will be reset to express this condition.
325  if (frame::interpreter_frame_expression_stack_direction() > 0) {
326    return addr <= fr.interpreter_frame_tos_address();
327  }
328
329  return addr >= fr.interpreter_frame_tos_address();
330}
331
332static void stack_locals(StackValueCollection* result,
333                         int length,
334                         const InterpreterOopMap& oop_mask,
335                         const frame& fr) {
336
337  assert(result != NULL, "invariant");
338
339  for (int i = 0; i < length; ++i) {
340    const intptr_t* const addr = fr.interpreter_frame_local_at(i);
341    assert(addr != NULL, "invariant");
342    assert(addr >= fr.sp(), "must be inside the frame");
343
344    StackValue* const sv = create_stack_value_from_oop_map(oop_mask, i, addr);
345    assert(sv != NULL, "sanity check");
346
347    result->add(sv);
348  }
349}
350
351static void stack_expressions(StackValueCollection* result,
352                              int length,
353                              int max_locals,
354                              const InterpreterOopMap& oop_mask,
355                              const frame& fr) {
356
357  assert(result != NULL, "invariant");
358
359  for (int i = 0; i < length; ++i) {
360    const intptr_t* addr = fr.interpreter_frame_expression_stack_at(i);
361    assert(addr != NULL, "invariant");
362    if (!is_in_expression_stack(fr, addr)) {
363      // Need to ensure no bogus escapes.
364      addr = NULL;
365    }
366
367    StackValue* const sv = create_stack_value_from_oop_map(oop_mask,
368                                                           i + max_locals,
369                                                           addr);
370    assert(sv != NULL, "sanity check");
371
372    result->add(sv);
373  }
374}
375
376StackValueCollection* interpretedVFrame::locals() const {
377  return stack_data(false);
378}
379
380StackValueCollection* interpretedVFrame::expressions() const {
381  return stack_data(true);
382}
383
384/*
385 * Worker routine for fetching references and/or values
386 * for a particular bci in the interpretedVFrame.
387 *
388 * Returns data for either "locals" or "expressions",
389 * using bci relative oop_map (oop_mask) information.
390 *
391 * @param expressions  bool switch controlling what data to return
392                       (false == locals / true == expression)
393 *
394 */
395StackValueCollection* interpretedVFrame::stack_data(bool expressions) const {
396
397  InterpreterOopMap oop_mask;
398  // oopmap for current bci
399  if ((TraceDeoptimization && Verbose) JVMCI_ONLY( || PrintDeoptimizationDetails)) {
400    methodHandle m_h(Thread::current(), method());
401    OopMapCache::compute_one_oop_map(m_h, bci(), &oop_mask);
402  } else {
403    method()->mask_for(bci(), &oop_mask);
404  }
405
406  const int mask_len = oop_mask.number_of_entries();
407
408  // If the method is native, method()->max_locals() is not telling the truth.
409  // For our purposes, max locals instead equals the size of parameters.
410  const int max_locals = method()->is_native() ?
411    method()->size_of_parameters() : method()->max_locals();
412
413  assert(mask_len >= max_locals, "invariant");
414
415  const int length = expressions ? mask_len - max_locals : max_locals;
416  assert(length >= 0, "invariant");
417
418  StackValueCollection* const result = new StackValueCollection(length);
419
420  if (0 == length) {
421    return result;
422  }
423
424  if (expressions) {
425    stack_expressions(result, length, max_locals, oop_mask, fr());
426  } else {
427    stack_locals(result, length, oop_mask, fr());
428  }
429
430  assert(length == result->size(), "invariant");
431
432  return result;
433}
434
435void interpretedVFrame::set_locals(StackValueCollection* values) const {
436  if (values == NULL || values->size() == 0) return;
437
438  // If the method is native, max_locals is not telling the truth.
439  // maxlocals then equals the size of parameters
440  const int max_locals = method()->is_native() ?
441    method()->size_of_parameters() : method()->max_locals();
442
443  assert(max_locals == values->size(), "Mismatch between actual stack format and supplied data");
444
445  // handle locals
446  for (int i = 0; i < max_locals; i++) {
447    // Find stack location
448    intptr_t *addr = locals_addr_at(i);
449
450    // Depending on oop/int put it in the right package
451    const StackValue* const sv = values->at(i);
452    assert(sv != NULL, "sanity check");
453    if (sv->type() == T_OBJECT) {
454      *(oop *) addr = (sv->get_obj())();
455    } else {                   // integer
456      *addr = sv->get_int();
457    }
458  }
459}
460
461// ------------- cChunk --------------
462
463entryVFrame::entryVFrame(const frame* fr, const RegisterMap* reg_map, JavaThread* thread)
464: externalVFrame(fr, reg_map, thread) {}
465
466
467void vframeStreamCommon::found_bad_method_frame() {
468  // 6379830 Cut point for an assertion that occasionally fires when
469  // we are using the performance analyzer.
470  // Disable this assert when testing the analyzer with fastdebug.
471  // -XX:SuppressErrorAt=vframe.cpp:XXX (XXX=following line number)
472  assert(false, "invalid bci or invalid scope desc");
473}
474
475// top-frame will be skipped
476vframeStream::vframeStream(JavaThread* thread, frame top_frame,
477  bool stop_at_java_call_stub) : vframeStreamCommon(thread) {
478  _stop_at_java_call_stub = stop_at_java_call_stub;
479
480  // skip top frame, as it may not be at safepoint
481  _frame  = top_frame.sender(&_reg_map);
482  while (!fill_from_frame()) {
483    _frame = _frame.sender(&_reg_map);
484  }
485}
486
487
488// Step back n frames, skip any pseudo frames in between.
489// This function is used in Class.forName, Class.newInstance, Method.Invoke,
490// AccessController.doPrivileged.
491void vframeStreamCommon::security_get_caller_frame(int depth) {
492  assert(depth >= 0, "invalid depth: %d", depth);
493  for (int n = 0; !at_end(); security_next()) {
494    if (!method()->is_ignored_by_security_stack_walk()) {
495      if (n == depth) {
496        // We have reached the desired depth; return.
497        return;
498      }
499      n++;  // this is a non-skipped frame; count it against the depth
500    }
501  }
502  // NOTE: At this point there were not enough frames on the stack
503  // to walk to depth.  Callers of this method have to check for at_end.
504}
505
506
507void vframeStreamCommon::security_next() {
508  if (method()->is_prefixed_native()) {
509    skip_prefixed_method_and_wrappers();  // calls next()
510  } else {
511    next();
512  }
513}
514
515
516void vframeStreamCommon::skip_prefixed_method_and_wrappers() {
517  ResourceMark rm;
518  HandleMark hm;
519
520  int    method_prefix_count = 0;
521  char** method_prefixes = JvmtiExport::get_all_native_method_prefixes(&method_prefix_count);
522  KlassHandle prefixed_klass(method()->method_holder());
523  const char* prefixed_name = method()->name()->as_C_string();
524  size_t prefixed_name_len = strlen(prefixed_name);
525  int prefix_index = method_prefix_count-1;
526
527  while (!at_end()) {
528    next();
529    if (method()->method_holder() != prefixed_klass()) {
530      break; // classes don't match, can't be a wrapper
531    }
532    const char* name = method()->name()->as_C_string();
533    size_t name_len = strlen(name);
534    size_t prefix_len = prefixed_name_len - name_len;
535    if (prefix_len <= 0 || strcmp(name, prefixed_name + prefix_len) != 0) {
536      break; // prefixed name isn't prefixed version of method name, can't be a wrapper
537    }
538    for (; prefix_index >= 0; --prefix_index) {
539      const char* possible_prefix = method_prefixes[prefix_index];
540      size_t possible_prefix_len = strlen(possible_prefix);
541      if (possible_prefix_len == prefix_len &&
542          strncmp(possible_prefix, prefixed_name, prefix_len) == 0) {
543        break; // matching prefix found
544      }
545    }
546    if (prefix_index < 0) {
547      break; // didn't find the prefix, can't be a wrapper
548    }
549    prefixed_name = name;
550    prefixed_name_len = name_len;
551  }
552}
553
554
555void vframeStreamCommon::skip_reflection_related_frames() {
556  while (!at_end() &&
557          (method()->method_holder()->is_subclass_of(SystemDictionary::reflect_MethodAccessorImpl_klass()) ||
558           method()->method_holder()->is_subclass_of(SystemDictionary::reflect_ConstructorAccessorImpl_klass()))) {
559    next();
560  }
561}
562
563
564#ifndef PRODUCT
565void vframe::print() {
566  if (WizardMode) _fr.print_value_on(tty,NULL);
567}
568
569
570void vframe::print_value() const {
571  ((vframe*)this)->print();
572}
573
574
575void entryVFrame::print_value() const {
576  ((entryVFrame*)this)->print();
577}
578
579void entryVFrame::print() {
580  vframe::print();
581  tty->print_cr("C Chunk inbetween Java");
582  tty->print_cr("C     link " INTPTR_FORMAT, p2i(_fr.link()));
583}
584
585
586// ------------- javaVFrame --------------
587
588static void print_stack_values(const char* title, StackValueCollection* values) {
589  if (values->is_empty()) return;
590  tty->print_cr("\t%s:", title);
591  values->print();
592}
593
594
595void javaVFrame::print() {
596  ResourceMark rm;
597  vframe::print();
598  tty->print("\t");
599  method()->print_value();
600  tty->cr();
601  tty->print_cr("\tbci:    %d", bci());
602
603  print_stack_values("locals",      locals());
604  print_stack_values("expressions", expressions());
605
606  GrowableArray<MonitorInfo*>* list = monitors();
607  if (list->is_empty()) return;
608  tty->print_cr("\tmonitor list:");
609  for (int index = (list->length()-1); index >= 0; index--) {
610    MonitorInfo* monitor = list->at(index);
611    tty->print("\t  obj\t");
612    if (monitor->owner_is_scalar_replaced()) {
613      Klass* k = java_lang_Class::as_Klass(monitor->owner_klass());
614      tty->print("( is scalar replaced %s)", k->external_name());
615    } else if (monitor->owner() == NULL) {
616      tty->print("( null )");
617    } else {
618      monitor->owner()->print_value();
619      tty->print("(owner=" INTPTR_FORMAT ")", p2i(monitor->owner()));
620    }
621    if (monitor->eliminated()) {
622      if(is_compiled_frame()) {
623        tty->print(" ( lock is eliminated in compiled frame )");
624      } else {
625        tty->print(" ( lock is eliminated, frame not compiled )");
626      }
627    }
628    tty->cr();
629    tty->print("\t  ");
630    monitor->lock()->print_on(tty);
631    tty->cr();
632  }
633}
634
635
636void javaVFrame::print_value() const {
637  Method*    m = method();
638  InstanceKlass*     k = m->method_holder();
639  tty->print_cr("frame( sp=" INTPTR_FORMAT ", unextended_sp=" INTPTR_FORMAT ", fp=" INTPTR_FORMAT ", pc=" INTPTR_FORMAT ")",
640                p2i(_fr.sp()),  p2i(_fr.unextended_sp()), p2i(_fr.fp()), p2i(_fr.pc()));
641  tty->print("%s.%s", k->internal_name(), m->name()->as_C_string());
642
643  if (!m->is_native()) {
644    Symbol*  source_name = k->source_file_name();
645    int        line_number = m->line_number_from_bci(bci());
646    if (source_name != NULL && (line_number != -1)) {
647      tty->print("(%s:%d)", source_name->as_C_string(), line_number);
648    }
649  } else {
650    tty->print("(Native Method)");
651  }
652  // Check frame size and print warning if it looks suspiciously large
653  if (fr().sp() != NULL) {
654    RegisterMap map = *register_map();
655    uint size = fr().frame_size(&map);
656#ifdef _LP64
657    if (size > 8*K) warning("SUSPICIOUSLY LARGE FRAME (%d)", size);
658#else
659    if (size > 4*K) warning("SUSPICIOUSLY LARGE FRAME (%d)", size);
660#endif
661  }
662}
663
664
665bool javaVFrame::structural_compare(javaVFrame* other) {
666  // Check static part
667  if (method() != other->method()) return false;
668  if (bci()    != other->bci())    return false;
669
670  // Check locals
671  StackValueCollection *locs = locals();
672  StackValueCollection *other_locs = other->locals();
673  assert(locs->size() == other_locs->size(), "sanity check");
674  int i;
675  for(i = 0; i < locs->size(); i++) {
676    // it might happen the compiler reports a conflict and
677    // the interpreter reports a bogus int.
678    if (       is_compiled_frame() &&       locs->at(i)->type() == T_CONFLICT) continue;
679    if (other->is_compiled_frame() && other_locs->at(i)->type() == T_CONFLICT) continue;
680
681    if (!locs->at(i)->equal(other_locs->at(i)))
682      return false;
683  }
684
685  // Check expressions
686  StackValueCollection* exprs = expressions();
687  StackValueCollection* other_exprs = other->expressions();
688  assert(exprs->size() == other_exprs->size(), "sanity check");
689  for(i = 0; i < exprs->size(); i++) {
690    if (!exprs->at(i)->equal(other_exprs->at(i)))
691      return false;
692  }
693
694  return true;
695}
696
697
698void javaVFrame::print_activation(int index) const {
699  // frame number and method
700  tty->print("%2d - ", index);
701  ((vframe*)this)->print_value();
702  tty->cr();
703
704  if (WizardMode) {
705    ((vframe*)this)->print();
706    tty->cr();
707  }
708}
709
710
711void javaVFrame::verify() const {
712}
713
714
715void interpretedVFrame::verify() const {
716}
717
718
719// ------------- externalVFrame --------------
720
721void externalVFrame::print() {
722  _fr.print_value_on(tty,NULL);
723}
724
725
726void externalVFrame::print_value() const {
727  ((vframe*)this)->print();
728}
729#endif // PRODUCT
730