cpCacheOop.cpp revision 844
844N/A * Copyright 1998-2009 Sun Microsystems, Inc. All Rights Reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 0N/A * published by the Free Software Foundation. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 0N/A * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 0N/A * CA 95054 USA or visit www.sun.com if you need additional information or 0N/A * have any questions. 0N/A#
include "incls/_precompiled.incl" 0N/A// Implememtation of ConstantPoolCacheEntry 726N/A // Hack: The rewriter is trying to say that this entry itself 726N/A // will be a secondary entry. 0N/A // Preserve existing flag bit values 0N/A "inconsistent cpCache flags state");
0N/A // Need to flush pending stores here before bytecode is written. 0N/A // Need to flush pending stores here before bytecode is written. 0N/A// It is possible to have two different dummy methodOops created 0N/A// when the resolve code for invoke interface executes concurrently 0N/A// Hence the assertion below is weakened a bit for the invokeinterface 0N/A// Note that concurrent update of both bytecodes can leave one of them 0N/A// reset to zero. This is harmless; the interpreter will simply re-resolve 0N/A// the damaged entry. More seriously, the memory synchronization is needed 0N/A// to flush other fields (f1, f2) completely to memory before the bytecodes 0N/A// are updated, lest other processors see a non-zero bytecode but zero f1/f2. 0N/A // The field index is used by jvm/ti and is the index into fields() array 0N/A // in holder instanceKlass. This is scaled by instanceKlass::next_offset. 0N/A "field index does not fit in low flag bits");
0N/A // Preserve the value of the vfinal flag on invokevirtual bytecode 0N/A // which may be shared with this constant pool cache entry. 0N/A // Note: byte_no also appears in TemplateTable::resolve. 0N/A // NOTE: THIS IS A HACK - BE VERY CAREFUL!!! 0N/A // Workaround for the case where we encounter an invokeinterface, but we 0N/A // should really have an _invokevirtual since the resolved method is a 0N/A // virtual method in java.lang.Object. This is a corner case in the spec 0N/A // but is presumably legal. javac does not generate this code. 0N/A // We set bytecode_1() to _invokeinterface, because that is the 0N/A // bytecode # used by the interpreter to see if it is resolved. 0N/A // We set bytecode_2() to _invokevirtual. 0N/A // Only set resolved for the invokeinterface case if method is public. 0N/A // Otherwise, the method needs to be reresolved with caller for each 726N/A // racing threads might be trying to install their own favorites 726N/A // do not do set_bytecode on a secondary CP cache entry 726N/A //set_bytecode_1(Bytecodes::_invokedynamic); 0N/A // field[1] is always oop or NULL 0N/A // field[1] is always oop or NULL 0N/A // field[1] is always oop or NULL 0N/A // field[1] is always oop or NULL 0N/A // field[1] is always oop or NULL 0N/A // field[1] is always oop or NULL 0N/A // field[1] is always oop or NULL 0N/A// RedefineClasses() API support: 0N/A// If this constantPoolCacheEntry refers to old_method then update it 0N/A// to refer to new_method. 0N/A // virtual and final so f2() contains method ptr instead of vtable index 0N/A // match old_method so need an update 0N/A // RC_TRACE_MESG macro has an embedded ResourceMark 0N/A // RC_TRACE macro has an embedded ResourceMark 0N/A // f1() is not used with virtual entries so bail out 0N/A // NULL f1() means this is a virtual entry so bail out 0N/A // We are assuming that the vtable index does not need change. 0N/A // RC_TRACE_MESG macro has an embedded ResourceMark 0N/A // RC_TRACE macro has an embedded ResourceMark 0N/A // not a method entry so not interesting by default 0N/A // virtual and final so _f2 contains method ptr instead of vtable index 0N/A // NULL _f1 means this is a virtual entry so also not interesting 0N/A // _f1 can also contain a klassOop for an interface 0N/A // robustness for above sanity checks or method is not in 0N/A // the interesting class 0N/A // the method is in the interesting class so the entry is interesting 0N/A // not implemented yet 0N/A// Implementation of ConstantPoolCache 0N/A// RedefineClasses() API support: 0N/A// If any entry of this constantPoolCache points to any of 0N/A// old_methods, replace it with the corresponding new_method. 0N/A // nothing to do if there are no methods 0N/A // get shorthand for the interesting class 0N/A // skip uninteresting methods 0N/A // The constantPoolCache contains entries for several different 0N/A // things, but we only care about methods. In fact, we only care 0N/A // about methods in the same class as the one that contains the 0N/A // old_methods. At this point, we have an interesting entry. 0N/A // current old_method matched this entry and we updated it so 0N/A // break out and get to the next interesting entry if there one