Wed, 17 Jul 2013 18:06:29 -0400
8020309: Eliminate InstanceKlass::_cached_class_file_len.
Summary: Use JvmtiCachedClassFileData.
Reviewed-by: iklam, sspitsyn, dcubed
coleenp@4490 | 1 | /* |
coleenp@4490 | 2 | * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. |
coleenp@4490 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
coleenp@4490 | 4 | * |
coleenp@4490 | 5 | * This code is free software; you can redistribute it and/or modify it |
coleenp@4490 | 6 | * under the terms of the GNU General Public License version 2 only, as |
coleenp@4490 | 7 | * published by the Free Software Foundation. |
coleenp@4490 | 8 | * |
coleenp@4490 | 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
coleenp@4490 | 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
coleenp@4490 | 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
coleenp@4490 | 12 | * version 2 for more details (a copy is included in the LICENSE file that |
coleenp@4490 | 13 | * accompanied this code). |
coleenp@4490 | 14 | * |
coleenp@4490 | 15 | * You should have received a copy of the GNU General Public License version |
coleenp@4490 | 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
coleenp@4490 | 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
coleenp@4490 | 18 | * |
coleenp@4490 | 19 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
coleenp@4490 | 20 | * or visit www.oracle.com if you need additional information or have any |
coleenp@4490 | 21 | * questions. |
coleenp@4490 | 22 | * |
coleenp@4490 | 23 | */ |
coleenp@4490 | 24 | |
coleenp@4490 | 25 | #include "precompiled.hpp" |
coleenp@4490 | 26 | #include "classfile/metadataOnStackMark.hpp" |
coleenp@4490 | 27 | #include "code/codeCache.hpp" |
coleenp@4490 | 28 | #include "compiler/compileBroker.hpp" |
coleenp@4490 | 29 | #include "oops/metadata.hpp" |
coleenp@4490 | 30 | #include "runtime/synchronizer.hpp" |
coleenp@4490 | 31 | #include "runtime/thread.hpp" |
coleenp@4490 | 32 | #include "utilities/growableArray.hpp" |
coleenp@4490 | 33 | |
coleenp@4490 | 34 | |
coleenp@4490 | 35 | // Keep track of marked on-stack metadata so it can be cleared. |
coleenp@4490 | 36 | GrowableArray<Metadata*>* _marked_objects = NULL; |
coleenp@4490 | 37 | NOT_PRODUCT(bool MetadataOnStackMark::_is_active = false;) |
coleenp@4490 | 38 | |
coleenp@4490 | 39 | // Walk metadata on the stack and mark it so that redefinition doesn't delete |
coleenp@4490 | 40 | // it. Class unloading also walks the previous versions and might try to |
coleenp@4490 | 41 | // delete it, so this class is used by class unloading also. |
coleenp@4490 | 42 | MetadataOnStackMark::MetadataOnStackMark() { |
coleenp@4490 | 43 | assert(SafepointSynchronize::is_at_safepoint(), "sanity check"); |
coleenp@4490 | 44 | NOT_PRODUCT(_is_active = true;) |
coleenp@4490 | 45 | if (_marked_objects == NULL) { |
coleenp@4490 | 46 | _marked_objects = new (ResourceObj::C_HEAP, mtClass) GrowableArray<Metadata*>(1000, true); |
coleenp@4490 | 47 | } |
coleenp@4490 | 48 | Threads::metadata_do(Metadata::mark_on_stack); |
coleenp@4490 | 49 | CodeCache::alive_nmethods_do(nmethod::mark_on_stack); |
coleenp@4490 | 50 | CompileBroker::mark_on_stack(); |
coleenp@4490 | 51 | } |
coleenp@4490 | 52 | |
coleenp@4490 | 53 | MetadataOnStackMark::~MetadataOnStackMark() { |
coleenp@4490 | 54 | assert(SafepointSynchronize::is_at_safepoint(), "sanity check"); |
coleenp@4490 | 55 | // Unmark everything that was marked. Can't do the same walk because |
coleenp@4490 | 56 | // redefine classes messes up the code cache so the set of methods |
coleenp@4490 | 57 | // might not be the same. |
coleenp@4490 | 58 | for (int i = 0; i< _marked_objects->length(); i++) { |
coleenp@4490 | 59 | _marked_objects->at(i)->set_on_stack(false); |
coleenp@4490 | 60 | } |
coleenp@4490 | 61 | _marked_objects->clear(); // reuse growable array for next time. |
coleenp@4490 | 62 | NOT_PRODUCT(_is_active = false;) |
coleenp@4490 | 63 | } |
coleenp@4490 | 64 | |
coleenp@4490 | 65 | // Record which objects are marked so we can unmark the same objects. |
coleenp@4490 | 66 | void MetadataOnStackMark::record(Metadata* m) { |
coleenp@4490 | 67 | assert(_is_active, "metadata on stack marking is active"); |
coleenp@4490 | 68 | _marked_objects->push(m); |
coleenp@4490 | 69 | } |