src/share/vm/runtime/vframe.cpp

Fri, 21 Nov 2008 08:09:11 -0800

author
coleenp
date
Fri, 21 Nov 2008 08:09:11 -0800
changeset 882
2b42b31e7928
parent 631
d1605aabd0a1
child 1228
eacd97c88873
permissions
-rw-r--r--

6676175: BigApps crash JVM Client VM (build 10.0-b22, mixed mode, sharing) with SIGSEGV (0xb)
Summary: Add test for biased locking epoch before walking own thread stack in case of rare race
Reviewed-by: phh, never

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

mercurial