comparison src/share/vm/classfile/classLoaderData.cpp @ 17677:51e1bb81df86 jdk8u20-b03

Merge
author amurillo
date Tue, 25 Feb 2014 13:02:52 -0800
parents 85318d1fe8fe
children f460c6926af7 7384f6a12fc1
comparison
equal deleted inserted replaced
17660:9a93fe1babdc 17677:51e1bb81df86
1 /* 1 /*
2 * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. 2 * Copyright (c) 2012, 2014, 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.
518 k->verify(); 518 k->verify();
519 assert(k != k->next_link(), "no loops!"); 519 assert(k != k->next_link(), "no loops!");
520 } 520 }
521 } 521 }
522 522
523 bool ClassLoaderData::contains_klass(Klass* klass) {
524 for (Klass* k = _klasses; k != NULL; k = k->next_link()) {
525 if (k == klass) return true;
526 }
527 return false;
528 }
529
523 530
524 // GC root of class loader data created. 531 // GC root of class loader data created.
525 ClassLoaderData* ClassLoaderDataGraph::_head = NULL; 532 ClassLoaderData* ClassLoaderDataGraph::_head = NULL;
526 ClassLoaderData* ClassLoaderDataGraph::_unloading = NULL; 533 ClassLoaderData* ClassLoaderDataGraph::_unloading = NULL;
527 ClassLoaderData* ClassLoaderDataGraph::_saved_head = NULL; 534 ClassLoaderData* ClassLoaderDataGraph::_saved_head = NULL;
646 } 653 }
647 654
648 return array; 655 return array;
649 } 656 }
650 657
651 #ifndef PRODUCT 658 // For profiling and hsfind() only. Otherwise, this is unsafe (and slow). This
652 // for debugging and hsfind(x) 659 // is done lock free to avoid lock inversion problems. It is safe because
653 bool ClassLoaderDataGraph::contains(address x) { 660 // new ClassLoaderData are added to the end of the CLDG, and only removed at
654 // I think we need the _metaspace_lock taken here because the class loader 661 // safepoint. The _unloading list can be deallocated concurrently with CMS so
655 // data graph could be changing while we are walking it (new entries added, 662 // this doesn't look in metaspace for classes that have been unloaded.
656 // new entries being unloaded, etc). 663 bool ClassLoaderDataGraph::contains(const void* x) {
657 if (DumpSharedSpaces) { 664 if (DumpSharedSpaces) {
658 // There are only two metaspaces to worry about. 665 // There are only two metaspaces to worry about.
659 ClassLoaderData* ncld = ClassLoaderData::the_null_class_loader_data(); 666 ClassLoaderData* ncld = ClassLoaderData::the_null_class_loader_data();
660 return (ncld->ro_metaspace()->contains(x) || ncld->rw_metaspace()->contains(x)); 667 return (ncld->ro_metaspace()->contains(x) || ncld->rw_metaspace()->contains(x));
661 } 668 }
668 if (cld->metaspace_or_null() != NULL && cld->metaspace_or_null()->contains(x)) { 675 if (cld->metaspace_or_null() != NULL && cld->metaspace_or_null()->contains(x)) {
669 return true; 676 return true;
670 } 677 }
671 } 678 }
672 679
673 // Could also be on an unloading list which is okay, ie. still allocated 680 // Do not check unloading list because deallocation can be concurrent.
674 // for a little while.
675 for (ClassLoaderData* ucld = _unloading; ucld != NULL; ucld = ucld->next()) {
676 if (ucld->metaspace_or_null() != NULL && ucld->metaspace_or_null()->contains(x)) {
677 return true;
678 }
679 }
680 return false; 681 return false;
681 } 682 }
682 683
684 #ifndef PRODUCT
683 bool ClassLoaderDataGraph::contains_loader_data(ClassLoaderData* loader_data) { 685 bool ClassLoaderDataGraph::contains_loader_data(ClassLoaderData* loader_data) {
684 for (ClassLoaderData* data = _head; data != NULL; data = data->next()) { 686 for (ClassLoaderData* data = _head; data != NULL; data = data->next()) {
685 if (loader_data == data) { 687 if (loader_data == data) {
686 return true; 688 return true;
687 } 689 }