src/share/vm/runtime/vframe.cpp

Fri, 24 Jun 2016 17:12:13 +0800

author
aoqi<aoqi@loongson.cn>
date
Fri, 24 Jun 2016 17:12:13 +0800
changeset 25
873fd82b133d
parent 0
f90c822e73f8
child 6876
710a3c8b516e
permissions
-rw-r--r--

[Code Reorganization] Removed GC related modifications made by Loongson, for example, UseOldNUMA.

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

mercurial