Sat, 02 Aug 2014 16:28:59 -0400
8051012: Regression in verifier for <init> method call from inside of a branch
Summary: Fix stackmap matching for branches.
Reviewed-by: coleenp, lfoltan, acorn
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@6063 | 30 | #include "prims/jvmtiImpl.hpp" |
coleenp@4490 | 31 | #include "runtime/synchronizer.hpp" |
coleenp@4490 | 32 | #include "runtime/thread.hpp" |
sla@6122 | 33 | #include "services/threadService.hpp" |
coleenp@4490 | 34 | #include "utilities/growableArray.hpp" |
coleenp@4490 | 35 | |
coleenp@4490 | 36 | |
coleenp@4490 | 37 | // Keep track of marked on-stack metadata so it can be cleared. |
coleenp@4490 | 38 | GrowableArray<Metadata*>* _marked_objects = NULL; |
coleenp@4490 | 39 | NOT_PRODUCT(bool MetadataOnStackMark::_is_active = false;) |
coleenp@4490 | 40 | |
coleenp@4490 | 41 | // Walk metadata on the stack and mark it so that redefinition doesn't delete |
coleenp@4490 | 42 | // it. Class unloading also walks the previous versions and might try to |
coleenp@4490 | 43 | // delete it, so this class is used by class unloading also. |
coleenp@4490 | 44 | MetadataOnStackMark::MetadataOnStackMark() { |
coleenp@4490 | 45 | assert(SafepointSynchronize::is_at_safepoint(), "sanity check"); |
coleenp@4490 | 46 | NOT_PRODUCT(_is_active = true;) |
coleenp@4490 | 47 | if (_marked_objects == NULL) { |
coleenp@4490 | 48 | _marked_objects = new (ResourceObj::C_HEAP, mtClass) GrowableArray<Metadata*>(1000, true); |
coleenp@4490 | 49 | } |
coleenp@4490 | 50 | Threads::metadata_do(Metadata::mark_on_stack); |
coleenp@4490 | 51 | CodeCache::alive_nmethods_do(nmethod::mark_on_stack); |
coleenp@4490 | 52 | CompileBroker::mark_on_stack(); |
coleenp@6063 | 53 | JvmtiCurrentBreakpoints::metadata_do(Metadata::mark_on_stack); |
sla@6122 | 54 | ThreadService::metadata_do(Metadata::mark_on_stack); |
coleenp@4490 | 55 | } |
coleenp@4490 | 56 | |
coleenp@4490 | 57 | MetadataOnStackMark::~MetadataOnStackMark() { |
coleenp@4490 | 58 | assert(SafepointSynchronize::is_at_safepoint(), "sanity check"); |
coleenp@4490 | 59 | // Unmark everything that was marked. Can't do the same walk because |
coleenp@4490 | 60 | // redefine classes messes up the code cache so the set of methods |
coleenp@4490 | 61 | // might not be the same. |
coleenp@4490 | 62 | for (int i = 0; i< _marked_objects->length(); i++) { |
coleenp@4490 | 63 | _marked_objects->at(i)->set_on_stack(false); |
coleenp@4490 | 64 | } |
coleenp@4490 | 65 | _marked_objects->clear(); // reuse growable array for next time. |
coleenp@4490 | 66 | NOT_PRODUCT(_is_active = false;) |
coleenp@4490 | 67 | } |
coleenp@4490 | 68 | |
coleenp@4490 | 69 | // Record which objects are marked so we can unmark the same objects. |
coleenp@4490 | 70 | void MetadataOnStackMark::record(Metadata* m) { |
coleenp@4490 | 71 | assert(_is_active, "metadata on stack marking is active"); |
coleenp@4490 | 72 | _marked_objects->push(m); |
coleenp@4490 | 73 | } |