aoqi@0: /* drchase@7605: * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. aoqi@0: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. aoqi@0: * aoqi@0: * This code is free software; you can redistribute it and/or modify it aoqi@0: * under the terms of the GNU General Public License version 2 only, as aoqi@0: * published by the Free Software Foundation. aoqi@0: * aoqi@0: * This code is distributed in the hope that it will be useful, but WITHOUT aoqi@0: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or aoqi@0: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License aoqi@0: * version 2 for more details (a copy is included in the LICENSE file that aoqi@0: * accompanied this code). aoqi@0: * aoqi@0: * You should have received a copy of the GNU General Public License version aoqi@0: * 2 along with this work; if not, write to the Free Software Foundation, aoqi@0: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. aoqi@0: * aoqi@0: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA aoqi@0: * or visit www.oracle.com if you need additional information or have any aoqi@0: * questions. aoqi@0: * aoqi@0: */ aoqi@0: aoqi@0: #include "precompiled.hpp" aoqi@0: #include "classfile/javaClasses.hpp" aoqi@0: #include "classfile/systemDictionary.hpp" aoqi@0: #include "classfile/vmSymbols.hpp" aoqi@0: #include "code/codeCache.hpp" aoqi@0: #include "code/debugInfoRec.hpp" aoqi@0: #include "code/nmethod.hpp" aoqi@0: #include "code/pcDesc.hpp" aoqi@0: #include "code/scopeDesc.hpp" aoqi@0: #include "interpreter/interpreter.hpp" aoqi@0: #include "interpreter/oopMapCache.hpp" aoqi@0: #include "memory/resourceArea.hpp" aoqi@0: #include "oops/instanceKlass.hpp" aoqi@0: #include "oops/oop.inline.hpp" aoqi@0: #include "runtime/handles.inline.hpp" aoqi@0: #include "runtime/objectMonitor.hpp" aoqi@0: #include "runtime/objectMonitor.inline.hpp" aoqi@0: #include "runtime/signature.hpp" aoqi@0: #include "runtime/stubRoutines.hpp" aoqi@0: #include "runtime/synchronizer.hpp" aoqi@0: #include "runtime/vframe.hpp" aoqi@0: #include "runtime/vframeArray.hpp" aoqi@0: #include "runtime/vframe_hp.hpp" aoqi@0: aoqi@0: PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC aoqi@0: aoqi@0: vframe::vframe(const frame* fr, const RegisterMap* reg_map, JavaThread* thread) aoqi@0: : _reg_map(reg_map), _thread(thread) { aoqi@0: assert(fr != NULL, "must have frame"); aoqi@0: _fr = *fr; aoqi@0: } aoqi@0: aoqi@0: vframe::vframe(const frame* fr, JavaThread* thread) aoqi@0: : _reg_map(thread), _thread(thread) { aoqi@0: assert(fr != NULL, "must have frame"); aoqi@0: _fr = *fr; aoqi@0: } aoqi@0: aoqi@0: vframe* vframe::new_vframe(const frame* f, const RegisterMap* reg_map, JavaThread* thread) { aoqi@0: // Interpreter frame aoqi@0: if (f->is_interpreted_frame()) { aoqi@0: return new interpretedVFrame(f, reg_map, thread); aoqi@0: } aoqi@0: aoqi@0: // Compiled frame aoqi@0: CodeBlob* cb = f->cb(); aoqi@0: if (cb != NULL) { aoqi@0: if (cb->is_nmethod()) { aoqi@0: nmethod* nm = (nmethod*)cb; aoqi@0: return new compiledVFrame(f, reg_map, thread, nm); aoqi@0: } aoqi@0: aoqi@0: if (f->is_runtime_frame()) { aoqi@0: // Skip this frame and try again. aoqi@0: RegisterMap temp_map = *reg_map; aoqi@0: frame s = f->sender(&temp_map); aoqi@0: return new_vframe(&s, &temp_map, thread); aoqi@0: } aoqi@0: } aoqi@0: aoqi@0: // External frame aoqi@0: return new externalVFrame(f, reg_map, thread); aoqi@0: } aoqi@0: aoqi@0: vframe* vframe::sender() const { aoqi@0: RegisterMap temp_map = *register_map(); aoqi@0: assert(is_top(), "just checking"); aoqi@0: if (_fr.is_entry_frame() && _fr.is_first_frame()) return NULL; aoqi@0: frame s = _fr.real_sender(&temp_map); aoqi@0: if (s.is_first_frame()) return NULL; aoqi@0: return vframe::new_vframe(&s, &temp_map, thread()); aoqi@0: } aoqi@0: aoqi@0: vframe* vframe::top() const { aoqi@0: vframe* vf = (vframe*) this; aoqi@0: while (!vf->is_top()) vf = vf->sender(); aoqi@0: return vf; aoqi@0: } aoqi@0: aoqi@0: aoqi@0: javaVFrame* vframe::java_sender() const { aoqi@0: vframe* f = sender(); aoqi@0: while (f != NULL) { aoqi@0: if (f->is_java_frame()) return javaVFrame::cast(f); aoqi@0: f = f->sender(); aoqi@0: } aoqi@0: return NULL; aoqi@0: } aoqi@0: aoqi@0: // ------------- javaVFrame -------------- aoqi@0: aoqi@0: GrowableArray* javaVFrame::locked_monitors() { aoqi@0: assert(SafepointSynchronize::is_at_safepoint() || JavaThread::current() == thread(), aoqi@0: "must be at safepoint or it's a java frame of the current thread"); aoqi@0: aoqi@0: GrowableArray* mons = monitors(); aoqi@0: GrowableArray* result = new GrowableArray(mons->length()); aoqi@0: if (mons->is_empty()) return result; aoqi@0: aoqi@0: bool found_first_monitor = false; aoqi@0: ObjectMonitor *pending_monitor = thread()->current_pending_monitor(); aoqi@0: ObjectMonitor *waiting_monitor = thread()->current_waiting_monitor(); aoqi@0: oop pending_obj = (pending_monitor != NULL ? (oop) pending_monitor->object() : (oop) NULL); aoqi@0: oop waiting_obj = (waiting_monitor != NULL ? (oop) waiting_monitor->object() : (oop) NULL); aoqi@0: aoqi@0: for (int index = (mons->length()-1); index >= 0; index--) { aoqi@0: MonitorInfo* monitor = mons->at(index); aoqi@0: if (monitor->eliminated() && is_compiled_frame()) continue; // skip eliminated monitor aoqi@0: oop obj = monitor->owner(); aoqi@0: if (obj == NULL) continue; // skip unowned monitor aoqi@0: // aoqi@0: // Skip the monitor that the thread is blocked to enter or waiting on aoqi@0: // aoqi@0: if (!found_first_monitor && (obj == pending_obj || obj == waiting_obj)) { aoqi@0: continue; aoqi@0: } aoqi@0: found_first_monitor = true; aoqi@0: result->append(monitor); aoqi@0: } aoqi@0: return result; aoqi@0: } aoqi@0: aoqi@0: static void print_locked_object_class_name(outputStream* st, Handle obj, const char* lock_state) { aoqi@0: if (obj.not_null()) { aoqi@0: st->print("\t- %s <" INTPTR_FORMAT "> ", lock_state, (address)obj()); aoqi@0: if (obj->klass() == SystemDictionary::Class_klass()) { vkempik@8060: st->print_cr("(a java.lang.Class for %s)", java_lang_Class::as_external_name(obj())); aoqi@0: } else { aoqi@0: Klass* k = obj->klass(); aoqi@0: st->print_cr("(a %s)", k->external_name()); aoqi@0: } aoqi@0: } aoqi@0: } aoqi@0: aoqi@0: void javaVFrame::print_lock_info_on(outputStream* st, int frame_count) { aoqi@0: ResourceMark rm; aoqi@0: aoqi@0: // If this is the first frame, and java.lang.Object.wait(...) then print out the receiver. aoqi@0: if (frame_count == 0) { aoqi@0: if (method()->name() == vmSymbols::wait_name() && aoqi@0: method()->method_holder()->name() == vmSymbols::java_lang_Object()) { aoqi@0: StackValueCollection* locs = locals(); aoqi@0: if (!locs->is_empty()) { aoqi@0: StackValue* sv = locs->at(0); aoqi@0: if (sv->type() == T_OBJECT) { aoqi@0: Handle o = locs->at(0)->get_obj(); aoqi@0: print_locked_object_class_name(st, o, "waiting on"); aoqi@0: } aoqi@0: } aoqi@0: } else if (thread()->current_park_blocker() != NULL) { aoqi@0: oop obj = thread()->current_park_blocker(); aoqi@0: Klass* k = obj->klass(); aoqi@0: st->print_cr("\t- %s <" INTPTR_FORMAT "> (a %s)", "parking to wait for ", (address)obj, k->external_name()); aoqi@0: } aoqi@0: } aoqi@0: aoqi@0: aoqi@0: // Print out all monitors that we have locked or are trying to lock aoqi@0: GrowableArray* mons = monitors(); aoqi@0: if (!mons->is_empty()) { aoqi@0: bool found_first_monitor = false; aoqi@0: for (int index = (mons->length()-1); index >= 0; index--) { aoqi@0: MonitorInfo* monitor = mons->at(index); aoqi@0: if (monitor->eliminated() && is_compiled_frame()) { // Eliminated in compiled code aoqi@0: if (monitor->owner_is_scalar_replaced()) { aoqi@0: Klass* k = java_lang_Class::as_Klass(monitor->owner_klass()); drchase@7605: // format below for lockbits matches this one. aoqi@0: st->print("\t- eliminated (a %s)", k->external_name()); aoqi@0: } else { aoqi@0: oop obj = monitor->owner(); aoqi@0: if (obj != NULL) { aoqi@0: print_locked_object_class_name(st, obj, "eliminated"); aoqi@0: } aoqi@0: } aoqi@0: continue; aoqi@0: } aoqi@0: if (monitor->owner() != NULL) { aoqi@0: // the monitor is associated with an object, i.e., it is locked aoqi@0: aoqi@0: // First, assume we have the monitor locked. If we haven't found an aoqi@0: // owned monitor before and this is the first frame, then we need to aoqi@0: // see if we have completed the lock or we are blocked trying to aoqi@0: // acquire it - we can only be blocked if the monitor is inflated aoqi@0: drchase@7605: markOop mark = NULL; aoqi@0: const char *lock_state = "locked"; // assume we have the monitor locked aoqi@0: if (!found_first_monitor && frame_count == 0) { drchase@7605: mark = monitor->owner()->mark(); aoqi@0: if (mark->has_monitor() && aoqi@0: ( // we have marked ourself as pending on this monitor aoqi@0: mark->monitor() == thread()->current_pending_monitor() || aoqi@0: // we are not the owner of this monitor aoqi@0: !mark->monitor()->is_entered(thread()) aoqi@0: )) { aoqi@0: lock_state = "waiting to lock"; drchase@7605: } else { drchase@7605: mark = NULL; // Disable printing below aoqi@0: } aoqi@0: } drchase@7605: print_locked_object_class_name(st, monitor->owner(), lock_state); drchase@7605: if (Verbose && mark != NULL) { drchase@7605: // match with format above, replacing "-" with " ". drchase@7605: st->print("\t lockbits="); drchase@7605: mark->print_on(st); drchase@7605: st->cr(); drchase@7605: } aoqi@0: aoqi@0: found_first_monitor = true; aoqi@0: } aoqi@0: } aoqi@0: } aoqi@0: } aoqi@0: aoqi@0: // ------------- interpretedVFrame -------------- aoqi@0: aoqi@0: u_char* interpretedVFrame::bcp() const { aoqi@0: return fr().interpreter_frame_bcp(); aoqi@0: } aoqi@0: aoqi@0: void interpretedVFrame::set_bcp(u_char* bcp) { aoqi@0: fr().interpreter_frame_set_bcp(bcp); aoqi@0: } aoqi@0: aoqi@0: intptr_t* interpretedVFrame::locals_addr_at(int offset) const { aoqi@0: assert(fr().is_interpreted_frame(), "frame should be an interpreted frame"); aoqi@0: return fr().interpreter_frame_local_at(offset); aoqi@0: } aoqi@0: aoqi@0: aoqi@0: GrowableArray* interpretedVFrame::monitors() const { aoqi@0: GrowableArray* result = new GrowableArray(5); aoqi@0: for (BasicObjectLock* current = (fr().previous_monitor_in_interpreter_frame(fr().interpreter_frame_monitor_begin())); aoqi@0: current >= fr().interpreter_frame_monitor_end(); aoqi@0: current = fr().previous_monitor_in_interpreter_frame(current)) { aoqi@0: result->push(new MonitorInfo(current->obj(), current->lock(), false, false)); aoqi@0: } aoqi@0: return result; aoqi@0: } aoqi@0: aoqi@0: int interpretedVFrame::bci() const { aoqi@0: return method()->bci_from(bcp()); aoqi@0: } aoqi@0: aoqi@0: Method* interpretedVFrame::method() const { aoqi@0: return fr().interpreter_frame_method(); aoqi@0: } aoqi@0: mgronlun@7215: static StackValue* create_stack_value_from_oop_map(const InterpreterOopMap& oop_mask, mgronlun@7215: int index, mgronlun@7215: const intptr_t* const addr) { aoqi@0: mgronlun@7215: assert(index >= 0 && mgronlun@7215: index < oop_mask.number_of_entries(), "invariant"); mgronlun@7215: mgronlun@7215: // categorize using oop_mask mgronlun@7215: if (oop_mask.is_oop(index)) { mgronlun@7215: // reference (oop) "r" mgronlun@7215: Handle h(addr != NULL ? (*(oop*)addr) : (oop)NULL); mgronlun@7215: return new StackValue(h); mgronlun@7215: } mgronlun@7215: // value (integer) "v" mgronlun@7215: return new StackValue(addr != NULL ? *addr : 0); mgronlun@7215: } mgronlun@7215: mgronlun@7215: static bool is_in_expression_stack(const frame& fr, const intptr_t* const addr) { mgronlun@7215: assert(addr != NULL, "invariant"); mgronlun@7215: mgronlun@7215: // Ensure to be 'inside' the expresion stack (i.e., addr >= sp for Intel). mgronlun@7215: // In case of exceptions, the expression stack is invalid and the sp mgronlun@7215: // will be reset to express this condition. mgronlun@7215: if (frame::interpreter_frame_expression_stack_direction() > 0) { mgronlun@7215: return addr <= fr.interpreter_frame_tos_address(); aoqi@0: } aoqi@0: mgronlun@7215: return addr >= fr.interpreter_frame_tos_address(); mgronlun@7215: } aoqi@0: mgronlun@7215: static void stack_locals(StackValueCollection* result, mgronlun@7215: int length, mgronlun@7215: const InterpreterOopMap& oop_mask, mgronlun@7215: const frame& fr) { mgronlun@7215: mgronlun@7215: assert(result != NULL, "invariant"); mgronlun@7215: mgronlun@7215: for (int i = 0; i < length; ++i) { mgronlun@7215: const intptr_t* const addr = fr.interpreter_frame_local_at(i); mgronlun@7215: assert(addr != NULL, "invariant"); mgronlun@7215: assert(addr >= fr.sp(), "must be inside the frame"); mgronlun@7215: mgronlun@7215: StackValue* const sv = create_stack_value_from_oop_map(oop_mask, i, addr); mgronlun@7215: assert(sv != NULL, "sanity check"); mgronlun@7215: mgronlun@7215: result->add(sv); mgronlun@7215: } mgronlun@7215: } mgronlun@7215: mgronlun@7215: static void stack_expressions(StackValueCollection* result, mgronlun@7215: int length, mgronlun@7215: int max_locals, mgronlun@7215: const InterpreterOopMap& oop_mask, mgronlun@7215: const frame& fr) { mgronlun@7215: mgronlun@7215: assert(result != NULL, "invariant"); mgronlun@7215: mgronlun@7215: for (int i = 0; i < length; ++i) { mgronlun@7215: const intptr_t* addr = fr.interpreter_frame_expression_stack_at(i); mgronlun@7215: assert(addr != NULL, "invariant"); mgronlun@7215: if (!is_in_expression_stack(fr, addr)) { mgronlun@7215: // Need to ensure no bogus escapes. mgronlun@7215: addr = NULL; mgronlun@7215: } mgronlun@7215: mgronlun@7215: StackValue* const sv = create_stack_value_from_oop_map(oop_mask, mgronlun@7215: i + max_locals, mgronlun@7215: addr); mgronlun@7215: assert(sv != NULL, "sanity check"); mgronlun@7215: mgronlun@7215: result->add(sv); mgronlun@7215: } mgronlun@7215: } mgronlun@7215: mgronlun@7215: StackValueCollection* interpretedVFrame::locals() const { mgronlun@7215: return stack_data(false); mgronlun@7215: } mgronlun@7215: mgronlun@7215: StackValueCollection* interpretedVFrame::expressions() const { mgronlun@7215: return stack_data(true); mgronlun@7215: } mgronlun@7215: mgronlun@7215: /* mgronlun@7215: * Worker routine for fetching references and/or values mgronlun@7215: * for a particular bci in the interpretedVFrame. mgronlun@7215: * mgronlun@7215: * Returns data for either "locals" or "expressions", mgronlun@7215: * using bci relative oop_map (oop_mask) information. mgronlun@7215: * mgronlun@7215: * @param expressions bool switch controlling what data to return mgronlun@7215: (false == locals / true == expressions) mgronlun@7215: * mgronlun@7215: */ mgronlun@7215: StackValueCollection* interpretedVFrame::stack_data(bool expressions) const { mgronlun@7215: aoqi@0: InterpreterOopMap oop_mask; mgronlun@7215: // oopmap for current bci aoqi@0: if (TraceDeoptimization && Verbose) { mgronlun@7215: methodHandle m_h(Thread::current(), method()); aoqi@0: OopMapCache::compute_one_oop_map(m_h, bci(), &oop_mask); aoqi@0: } else { aoqi@0: method()->mask_for(bci(), &oop_mask); aoqi@0: } aoqi@0: mgronlun@7215: const int mask_len = oop_mask.number_of_entries(); mgronlun@7215: mgronlun@7215: // If the method is native, method()->max_locals() is not telling the truth. mgronlun@7215: // For our purposes, max locals instead equals the size of parameters. mgronlun@7215: const int max_locals = method()->is_native() ? mgronlun@7215: method()->size_of_parameters() : method()->max_locals(); mgronlun@7215: mgronlun@7215: assert(mask_len >= max_locals, "invariant"); mgronlun@7215: mgronlun@7215: const int length = expressions ? mask_len - max_locals : max_locals; mgronlun@7215: assert(length >= 0, "invariant"); mgronlun@7215: mgronlun@7215: StackValueCollection* const result = new StackValueCollection(length); mgronlun@7215: mgronlun@7215: if (0 == length) { mgronlun@7215: return result; aoqi@0: } mgronlun@7215: mgronlun@7215: if (expressions) { mgronlun@7215: stack_expressions(result, length, max_locals, oop_mask, fr()); mgronlun@7215: } else { mgronlun@7215: stack_locals(result, length, oop_mask, fr()); mgronlun@7215: } mgronlun@7215: mgronlun@7215: assert(length == result->size(), "invariant"); mgronlun@7215: aoqi@0: return result; aoqi@0: } aoqi@0: aoqi@0: void interpretedVFrame::set_locals(StackValueCollection* values) const { aoqi@0: if (values == NULL || values->size() == 0) return; aoqi@0: mgronlun@7215: // If the method is native, max_locals is not telling the truth. mgronlun@7215: // maxlocals then equals the size of parameters mgronlun@7215: const int max_locals = method()->is_native() ? mgronlun@7215: method()->size_of_parameters() : method()->max_locals(); aoqi@0: mgronlun@7215: assert(max_locals == values->size(), "Mismatch between actual stack format and supplied data"); aoqi@0: aoqi@0: // handle locals mgronlun@7215: for (int i = 0; i < max_locals; i++) { aoqi@0: // Find stack location aoqi@0: intptr_t *addr = locals_addr_at(i); aoqi@0: aoqi@0: // Depending on oop/int put it in the right package mgronlun@7215: const StackValue* const sv = values->at(i); aoqi@0: assert(sv != NULL, "sanity check"); aoqi@0: if (sv->type() == T_OBJECT) { aoqi@0: *(oop *) addr = (sv->get_obj())(); aoqi@0: } else { // integer aoqi@0: *addr = sv->get_int(); aoqi@0: } aoqi@0: } aoqi@0: } aoqi@0: aoqi@0: // ------------- cChunk -------------- aoqi@0: aoqi@0: entryVFrame::entryVFrame(const frame* fr, const RegisterMap* reg_map, JavaThread* thread) aoqi@0: : externalVFrame(fr, reg_map, thread) {} aoqi@0: aoqi@0: aoqi@0: void vframeStreamCommon::found_bad_method_frame() { aoqi@0: // 6379830 Cut point for an assertion that occasionally fires when aoqi@0: // we are using the performance analyzer. aoqi@0: // Disable this assert when testing the analyzer with fastdebug. aoqi@0: // -XX:SuppressErrorAt=vframe.cpp:XXX (XXX=following line number) aoqi@0: assert(false, "invalid bci or invalid scope desc"); aoqi@0: } aoqi@0: aoqi@0: // top-frame will be skipped aoqi@0: vframeStream::vframeStream(JavaThread* thread, frame top_frame, aoqi@0: bool stop_at_java_call_stub) : vframeStreamCommon(thread) { aoqi@0: _stop_at_java_call_stub = stop_at_java_call_stub; aoqi@0: aoqi@0: // skip top frame, as it may not be at safepoint aoqi@0: _frame = top_frame.sender(&_reg_map); aoqi@0: while (!fill_from_frame()) { aoqi@0: _frame = _frame.sender(&_reg_map); aoqi@0: } aoqi@0: } aoqi@0: aoqi@0: aoqi@0: // Step back n frames, skip any pseudo frames in between. aoqi@0: // This function is used in Class.forName, Class.newInstance, Method.Invoke, aoqi@0: // AccessController.doPrivileged. aoqi@0: void vframeStreamCommon::security_get_caller_frame(int depth) { aoqi@0: assert(depth >= 0, err_msg("invalid depth: %d", depth)); aoqi@0: for (int n = 0; !at_end(); security_next()) { aoqi@0: if (!method()->is_ignored_by_security_stack_walk()) { aoqi@0: if (n == depth) { aoqi@0: // We have reached the desired depth; return. aoqi@0: return; aoqi@0: } aoqi@0: n++; // this is a non-skipped frame; count it against the depth aoqi@0: } aoqi@0: } aoqi@0: // NOTE: At this point there were not enough frames on the stack aoqi@0: // to walk to depth. Callers of this method have to check for at_end. aoqi@0: } aoqi@0: aoqi@0: aoqi@0: void vframeStreamCommon::security_next() { aoqi@0: if (method()->is_prefixed_native()) { aoqi@0: skip_prefixed_method_and_wrappers(); // calls next() aoqi@0: } else { aoqi@0: next(); aoqi@0: } aoqi@0: } aoqi@0: aoqi@0: aoqi@0: void vframeStreamCommon::skip_prefixed_method_and_wrappers() { aoqi@0: ResourceMark rm; aoqi@0: HandleMark hm; aoqi@0: aoqi@0: int method_prefix_count = 0; aoqi@0: char** method_prefixes = JvmtiExport::get_all_native_method_prefixes(&method_prefix_count); aoqi@0: KlassHandle prefixed_klass(method()->method_holder()); aoqi@0: const char* prefixed_name = method()->name()->as_C_string(); aoqi@0: size_t prefixed_name_len = strlen(prefixed_name); aoqi@0: int prefix_index = method_prefix_count-1; aoqi@0: aoqi@0: while (!at_end()) { aoqi@0: next(); aoqi@0: if (method()->method_holder() != prefixed_klass()) { aoqi@0: break; // classes don't match, can't be a wrapper aoqi@0: } aoqi@0: const char* name = method()->name()->as_C_string(); aoqi@0: size_t name_len = strlen(name); aoqi@0: size_t prefix_len = prefixed_name_len - name_len; aoqi@0: if (prefix_len <= 0 || strcmp(name, prefixed_name + prefix_len) != 0) { aoqi@0: break; // prefixed name isn't prefixed version of method name, can't be a wrapper aoqi@0: } aoqi@0: for (; prefix_index >= 0; --prefix_index) { aoqi@0: const char* possible_prefix = method_prefixes[prefix_index]; aoqi@0: size_t possible_prefix_len = strlen(possible_prefix); aoqi@0: if (possible_prefix_len == prefix_len && aoqi@0: strncmp(possible_prefix, prefixed_name, prefix_len) == 0) { aoqi@0: break; // matching prefix found aoqi@0: } aoqi@0: } aoqi@0: if (prefix_index < 0) { aoqi@0: break; // didn't find the prefix, can't be a wrapper aoqi@0: } aoqi@0: prefixed_name = name; aoqi@0: prefixed_name_len = name_len; aoqi@0: } aoqi@0: } aoqi@0: aoqi@0: aoqi@0: void vframeStreamCommon::skip_reflection_related_frames() { aoqi@0: while (!at_end() && aoqi@0: (JDK_Version::is_gte_jdk14x_version() && UseNewReflection && aoqi@0: (method()->method_holder()->is_subclass_of(SystemDictionary::reflect_MethodAccessorImpl_klass()) || aoqi@0: method()->method_holder()->is_subclass_of(SystemDictionary::reflect_ConstructorAccessorImpl_klass())))) { aoqi@0: next(); aoqi@0: } aoqi@0: } aoqi@0: aoqi@0: aoqi@0: #ifndef PRODUCT aoqi@0: void vframe::print() { aoqi@0: if (WizardMode) _fr.print_value_on(tty,NULL); aoqi@0: } aoqi@0: aoqi@0: aoqi@0: void vframe::print_value() const { aoqi@0: ((vframe*)this)->print(); aoqi@0: } aoqi@0: aoqi@0: aoqi@0: void entryVFrame::print_value() const { aoqi@0: ((entryVFrame*)this)->print(); aoqi@0: } aoqi@0: aoqi@0: void entryVFrame::print() { aoqi@0: vframe::print(); aoqi@0: tty->print_cr("C Chunk inbetween Java"); aoqi@0: tty->print_cr("C link " INTPTR_FORMAT, _fr.link()); aoqi@0: } aoqi@0: aoqi@0: aoqi@0: // ------------- javaVFrame -------------- aoqi@0: aoqi@0: static void print_stack_values(const char* title, StackValueCollection* values) { aoqi@0: if (values->is_empty()) return; aoqi@0: tty->print_cr("\t%s:", title); aoqi@0: values->print(); aoqi@0: } aoqi@0: aoqi@0: aoqi@0: void javaVFrame::print() { aoqi@0: ResourceMark rm; aoqi@0: vframe::print(); aoqi@0: tty->print("\t"); aoqi@0: method()->print_value(); aoqi@0: tty->cr(); aoqi@0: tty->print_cr("\tbci: %d", bci()); aoqi@0: aoqi@0: print_stack_values("locals", locals()); aoqi@0: print_stack_values("expressions", expressions()); aoqi@0: aoqi@0: GrowableArray* list = monitors(); aoqi@0: if (list->is_empty()) return; aoqi@0: tty->print_cr("\tmonitor list:"); aoqi@0: for (int index = (list->length()-1); index >= 0; index--) { aoqi@0: MonitorInfo* monitor = list->at(index); aoqi@0: tty->print("\t obj\t"); aoqi@0: if (monitor->owner_is_scalar_replaced()) { aoqi@0: Klass* k = java_lang_Class::as_Klass(monitor->owner_klass()); aoqi@0: tty->print("( is scalar replaced %s)", k->external_name()); aoqi@0: } else if (monitor->owner() == NULL) { aoqi@0: tty->print("( null )"); aoqi@0: } else { aoqi@0: monitor->owner()->print_value(); drchase@7605: tty->print("(owner=" INTPTR_FORMAT ")", (address)monitor->owner()); aoqi@0: } drchase@7605: if (monitor->eliminated()) { drchase@7605: if(is_compiled_frame()) { drchase@7605: tty->print(" ( lock is eliminated in compiled frame )"); drchase@7605: } else { drchase@7605: tty->print(" ( lock is eliminated, frame not compiled )"); drchase@7605: } drchase@7605: } aoqi@0: tty->cr(); aoqi@0: tty->print("\t "); aoqi@0: monitor->lock()->print_on(tty); aoqi@0: tty->cr(); aoqi@0: } aoqi@0: } aoqi@0: aoqi@0: aoqi@0: void javaVFrame::print_value() const { aoqi@0: Method* m = method(); aoqi@0: InstanceKlass* k = m->method_holder(); aoqi@0: tty->print_cr("frame( sp=" INTPTR_FORMAT ", unextended_sp=" INTPTR_FORMAT ", fp=" INTPTR_FORMAT ", pc=" INTPTR_FORMAT ")", aoqi@0: _fr.sp(), _fr.unextended_sp(), _fr.fp(), _fr.pc()); aoqi@0: tty->print("%s.%s", k->internal_name(), m->name()->as_C_string()); aoqi@0: aoqi@0: if (!m->is_native()) { aoqi@0: Symbol* source_name = k->source_file_name(); aoqi@0: int line_number = m->line_number_from_bci(bci()); aoqi@0: if (source_name != NULL && (line_number != -1)) { aoqi@0: tty->print("(%s:%d)", source_name->as_C_string(), line_number); aoqi@0: } aoqi@0: } else { aoqi@0: tty->print("(Native Method)"); aoqi@0: } aoqi@0: // Check frame size and print warning if it looks suspiciously large aoqi@0: if (fr().sp() != NULL) { aoqi@0: RegisterMap map = *register_map(); aoqi@0: uint size = fr().frame_size(&map); aoqi@0: #ifdef _LP64 aoqi@0: if (size > 8*K) warning("SUSPICIOUSLY LARGE FRAME (%d)", size); aoqi@0: #else aoqi@0: if (size > 4*K) warning("SUSPICIOUSLY LARGE FRAME (%d)", size); aoqi@0: #endif aoqi@0: } aoqi@0: } aoqi@0: aoqi@0: aoqi@0: bool javaVFrame::structural_compare(javaVFrame* other) { aoqi@0: // Check static part aoqi@0: if (method() != other->method()) return false; aoqi@0: if (bci() != other->bci()) return false; aoqi@0: aoqi@0: // Check locals aoqi@0: StackValueCollection *locs = locals(); aoqi@0: StackValueCollection *other_locs = other->locals(); aoqi@0: assert(locs->size() == other_locs->size(), "sanity check"); aoqi@0: int i; aoqi@0: for(i = 0; i < locs->size(); i++) { aoqi@0: // it might happen the compiler reports a conflict and aoqi@0: // the interpreter reports a bogus int. aoqi@0: if ( is_compiled_frame() && locs->at(i)->type() == T_CONFLICT) continue; aoqi@0: if (other->is_compiled_frame() && other_locs->at(i)->type() == T_CONFLICT) continue; aoqi@0: aoqi@0: if (!locs->at(i)->equal(other_locs->at(i))) aoqi@0: return false; aoqi@0: } aoqi@0: aoqi@0: // Check expressions aoqi@0: StackValueCollection* exprs = expressions(); aoqi@0: StackValueCollection* other_exprs = other->expressions(); aoqi@0: assert(exprs->size() == other_exprs->size(), "sanity check"); aoqi@0: for(i = 0; i < exprs->size(); i++) { aoqi@0: if (!exprs->at(i)->equal(other_exprs->at(i))) aoqi@0: return false; aoqi@0: } aoqi@0: aoqi@0: return true; aoqi@0: } aoqi@0: aoqi@0: aoqi@0: void javaVFrame::print_activation(int index) const { aoqi@0: // frame number and method aoqi@0: tty->print("%2d - ", index); aoqi@0: ((vframe*)this)->print_value(); aoqi@0: tty->cr(); aoqi@0: aoqi@0: if (WizardMode) { aoqi@0: ((vframe*)this)->print(); aoqi@0: tty->cr(); aoqi@0: } aoqi@0: } aoqi@0: aoqi@0: aoqi@0: void javaVFrame::verify() const { aoqi@0: } aoqi@0: aoqi@0: aoqi@0: void interpretedVFrame::verify() const { aoqi@0: } aoqi@0: aoqi@0: aoqi@0: // ------------- externalVFrame -------------- aoqi@0: aoqi@0: void externalVFrame::print() { aoqi@0: _fr.print_value_on(tty,NULL); aoqi@0: } aoqi@0: aoqi@0: aoqi@0: void externalVFrame::print_value() const { aoqi@0: ((vframe*)this)->print(); aoqi@0: } aoqi@0: #endif // PRODUCT