src/share/vm/runtime/vframe.cpp

Fri, 28 Mar 2014 10:12:48 -0700

author
vlivanov
date
Fri, 28 Mar 2014 10:12:48 -0700
changeset 6527
f47fa50d9b9c
parent 6198
55fb97c4c58d
child 6680
78bbf4d43a14
permissions
-rw-r--r--

8035887: VM crashes trying to force inlining the recursive call
Reviewed-by: kvn, twisti

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

mercurial