Mercurial > hg > truffle
comparison src/share/vm/oops/cpCache.cpp @ 8025:461a3adac4d1
Merge
author | sspitsyn |
---|---|
date | Fri, 08 Feb 2013 09:14:06 -0800 |
parents | db9981fd3124 8d9fc28831cc |
children | 3efdfd6ddbf2 |
comparison
equal
deleted
inserted
replaced
8016:1135141fb97e | 8025:461a3adac4d1 |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. | 2 * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | 4 * |
5 * This code is free software; you can redistribute it and/or modify it | 5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as | 6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
400 objArrayOop resolved_references = cpool->resolved_references(); | 400 objArrayOop resolved_references = cpool->resolved_references(); |
401 return resolved_references->obj_at(ref_index); | 401 return resolved_references->obj_at(ref_index); |
402 } | 402 } |
403 | 403 |
404 | 404 |
405 #if INCLUDE_JVMTI | |
405 // RedefineClasses() API support: | 406 // RedefineClasses() API support: |
406 // If this constantPoolCacheEntry refers to old_method then update it | 407 // If this ConstantPoolCacheEntry refers to old_method then update it |
407 // to refer to new_method. | 408 // to refer to new_method. |
408 bool ConstantPoolCacheEntry::adjust_method_entry(Method* old_method, | 409 bool ConstantPoolCacheEntry::adjust_method_entry(Method* old_method, |
409 Method* new_method, bool * trace_name_printed) { | 410 Method* new_method, bool * trace_name_printed) { |
410 | 411 |
411 if (is_vfinal()) { | 412 if (is_vfinal()) { |
459 } | 460 } |
460 | 461 |
461 return false; | 462 return false; |
462 } | 463 } |
463 | 464 |
464 #ifndef PRODUCT | 465 // a constant pool cache entry should never contain old or obsolete methods |
465 bool ConstantPoolCacheEntry::check_no_old_entries() { | 466 bool ConstantPoolCacheEntry::check_no_old_or_obsolete_entries() { |
466 if (is_vfinal()) { | 467 if (is_vfinal()) { |
468 // virtual and final so _f2 contains method ptr instead of vtable index | |
467 Metadata* f2 = (Metadata*)_f2; | 469 Metadata* f2 = (Metadata*)_f2; |
468 return (f2->is_valid() && f2->is_method() && !((Method*)f2)->is_old()); | 470 // Return false if _f2 refers to an old or an obsolete method. |
469 } else { | 471 // _f2 == NULL || !_f2->is_method() are just as unexpected here. |
470 return (_f1 == NULL || (_f1->is_valid() && _f1->is_method() && !((Method*)_f1)->is_old())); | 472 return (f2 != NULL NOT_PRODUCT(&& f2->is_valid()) && f2->is_method() && |
471 } | 473 !((Method*)f2)->is_old() && !((Method*)f2)->is_obsolete()); |
472 } | 474 } else if (_f1 == NULL || |
473 #endif | 475 (NOT_PRODUCT(_f1->is_valid() &&) !_f1->is_method())) { |
476 // _f1 == NULL || !_f1->is_method() are OK here | |
477 return true; | |
478 } | |
479 // return false if _f1 refers to an old or an obsolete method | |
480 return (NOT_PRODUCT(_f1->is_valid() &&) _f1->is_method() && | |
481 !((Method*)_f1)->is_old() && !((Method*)_f1)->is_obsolete()); | |
482 } | |
474 | 483 |
475 bool ConstantPoolCacheEntry::is_interesting_method_entry(Klass* k) { | 484 bool ConstantPoolCacheEntry::is_interesting_method_entry(Klass* k) { |
476 if (!is_method_entry()) { | 485 if (!is_method_entry()) { |
477 // not a method entry so not interesting by default | 486 // not a method entry so not interesting by default |
478 return false; | 487 return false; |
501 } | 510 } |
502 | 511 |
503 // the method is in the interesting class so the entry is interesting | 512 // the method is in the interesting class so the entry is interesting |
504 return true; | 513 return true; |
505 } | 514 } |
515 #endif // INCLUDE_JVMTI | |
506 | 516 |
507 void ConstantPoolCacheEntry::print(outputStream* st, int index) const { | 517 void ConstantPoolCacheEntry::print(outputStream* st, int index) const { |
508 // print separator | 518 // print separator |
509 if (index == 0) st->print_cr(" -------------"); | 519 if (index == 0) st->print_cr(" -------------"); |
510 // print entry | 520 // print entry |
511 st->print("%3d ("PTR_FORMAT") ", index, (intptr_t)this); | 521 st->print("%3d ("PTR_FORMAT") ", index, (intptr_t)this); |
512 st->print_cr("[%02x|%02x|%5d]", bytecode_2(), bytecode_1(), constant_pool_index()); | 522 st->print_cr("[%02x|%02x|%5d]", bytecode_2(), bytecode_1(), |
523 constant_pool_index()); | |
513 st->print_cr(" [ "PTR_FORMAT"]", (intptr_t)_f1); | 524 st->print_cr(" [ "PTR_FORMAT"]", (intptr_t)_f1); |
514 st->print_cr(" [ "PTR_FORMAT"]", (intptr_t)_f2); | 525 st->print_cr(" [ "PTR_FORMAT"]", (intptr_t)_f2); |
515 st->print_cr(" [ "PTR_FORMAT"]", (intptr_t)_flags); | 526 st->print_cr(" [ "PTR_FORMAT"]", (intptr_t)_flags); |
516 st->print_cr(" -------------"); | 527 st->print_cr(" -------------"); |
517 } | 528 } |
551 ref += ConstantPoolCacheEntry::_indy_resolved_references_entries - 1; // skip extra entries | 562 ref += ConstantPoolCacheEntry::_indy_resolved_references_entries - 1; // skip extra entries |
552 } | 563 } |
553 } | 564 } |
554 } | 565 } |
555 | 566 |
567 #if INCLUDE_JVMTI | |
556 // RedefineClasses() API support: | 568 // RedefineClasses() API support: |
557 // If any entry of this constantPoolCache points to any of | 569 // If any entry of this ConstantPoolCache points to any of |
558 // old_methods, replace it with the corresponding new_method. | 570 // old_methods, replace it with the corresponding new_method. |
559 void ConstantPoolCache::adjust_method_entries(Method** old_methods, Method** new_methods, | 571 void ConstantPoolCache::adjust_method_entries(Method** old_methods, Method** new_methods, |
560 int methods_length, bool * trace_name_printed) { | 572 int methods_length, bool * trace_name_printed) { |
561 | 573 |
562 if (methods_length == 0) { | 574 if (methods_length == 0) { |
571 if (!entry_at(i)->is_interesting_method_entry(old_holder)) { | 583 if (!entry_at(i)->is_interesting_method_entry(old_holder)) { |
572 // skip uninteresting methods | 584 // skip uninteresting methods |
573 continue; | 585 continue; |
574 } | 586 } |
575 | 587 |
576 // The constantPoolCache contains entries for several different | 588 // The ConstantPoolCache contains entries for several different |
577 // things, but we only care about methods. In fact, we only care | 589 // things, but we only care about methods. In fact, we only care |
578 // about methods in the same class as the one that contains the | 590 // about methods in the same class as the one that contains the |
579 // old_methods. At this point, we have an interesting entry. | 591 // old_methods. At this point, we have an interesting entry. |
580 | 592 |
581 for (int j = 0; j < methods_length; j++) { | 593 for (int j = 0; j < methods_length; j++) { |
590 } | 602 } |
591 } | 603 } |
592 } | 604 } |
593 } | 605 } |
594 | 606 |
595 #ifndef PRODUCT | 607 // the constant pool cache should never contain old or obsolete methods |
596 bool ConstantPoolCache::check_no_old_entries() { | 608 bool ConstantPoolCache::check_no_old_or_obsolete_entries() { |
597 for (int i = 1; i < length(); i++) { | 609 for (int i = 1; i < length(); i++) { |
598 if (entry_at(i)->is_interesting_method_entry(NULL) && | 610 if (entry_at(i)->is_interesting_method_entry(NULL) && |
599 !entry_at(i)->check_no_old_entries()) { | 611 !entry_at(i)->check_no_old_or_obsolete_entries()) { |
600 return false; | 612 return false; |
601 } | 613 } |
602 } | 614 } |
603 return true; | 615 return true; |
604 } | 616 } |
605 #endif // PRODUCT | 617 |
618 void ConstantPoolCache::dump_cache() { | |
619 for (int i = 1; i < length(); i++) { | |
620 if (entry_at(i)->is_interesting_method_entry(NULL)) { | |
621 entry_at(i)->print(tty, i); | |
622 } | |
623 } | |
624 } | |
625 #endif // INCLUDE_JVMTI | |
606 | 626 |
607 | 627 |
608 // Printing | 628 // Printing |
609 | 629 |
610 void ConstantPoolCache::print_on(outputStream* st) const { | 630 void ConstantPoolCache::print_on(outputStream* st) const { |