cpCacheOop.cpp revision 113
/*
* Copyright 1998-2006 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*
*/
#include "incls/_precompiled.incl"
#include "incls/_cpCacheOop.cpp.incl"
// Implememtation of ConstantPoolCacheEntry
}
bool is_vfinal, bool is_volatile,
bool is_method_interface, bool is_method) {
int f = state;
f <<= 1;
if (is_final) f |= 1;
f <<= 1;
if (is_vfinal) f |= 1;
f <<= 1;
if (is_volatile) f |= 1;
f <<= 1;
if (is_method_interface) f |= 1;
f <<= 1;
if (is_method) f |= 1;
f <<= ConstantPoolCacheEntry::hotSwapBit;
// Preserve existing flag bit values
#ifdef ASSERT
"inconsistent cpCache flags state");
#endif
return (_flags | f) ;
}
#ifdef ASSERT
// Read once.
#endif
// Need to flush pending stores here before bytecode is written.
}
#ifdef ASSERT
// Read once.
#endif
// Need to flush pending stores here before bytecode is written.
}
#ifdef ASSERT
// It is possible to have two different dummy methodOops created
// when the resolve code for invoke interface executes concurrently
// Hence the assertion below is weakened a bit for the invokeinterface
// case.
}
#endif
// Note that concurrent update of both bytecodes can leave one of them
// reset to zero. This is harmless; the interpreter will simply re-resolve
// the damaged entry. More seriously, the memory synchronization is needed
// to flush other fields (f1, f2) completely to memory before the bytecodes
int orig_field_index,
int field_offset,
bool is_final,
bool is_volatile) {
set_f1(field_holder());
// in holder instanceKlass. This is scaled by instanceKlass::next_offset.
"field index does not fit in low flag bits");
(field_index & field_index_mask));
}
int ConstantPoolCacheEntry::field_index() const {
}
int vtable_index) {
int byte_no = -1;
bool needs_vfinal_flag = false;
switch (invoke_code) {
case Bytecodes::_invokevirtual:
case Bytecodes::_invokeinterface: {
if (method->can_be_statically_bound()) {
needs_vfinal_flag = true;
} else {
}
byte_no = 2;
break;
}
case Bytecodes::_invokespecial:
// Preserve the value of the vfinal flag on invokevirtual bytecode
// which may be shared with this constant pool cache entry.
// fall through
case Bytecodes::_invokestatic:
byte_no = 1;
break;
default:
break;
}
false,
true)|
method()->size_of_parameters());
// Note: byte_no also appears in TemplateTable::resolve.
if (byte_no == 1) {
} else if (byte_no == 2) {
if (change_to_virtual) {
// NOTE: THIS IS A HACK - BE VERY CAREFUL!!!
//
// Workaround for the case where we encounter an invokeinterface, but we
// should really have an _invokevirtual since the resolved method is a
// virtual method in java.lang.Object. This is a corner case in the spec
// but is presumably legal. javac does not generate this code.
//
// We set bytecode_1() to _invokeinterface, because that is the
// bytecode # used by the interpreter to see if it is resolved.
// We set bytecode_2() to _invokevirtual.
// See also interpreterRuntime.cpp. (8/25/2000)
// Only set resolved for the invokeinterface case if method is public.
// Otherwise, the method needs to be reresolved with caller for each
// interface call.
} else {
}
} else {
}
}
set_flags(as_flags(as_TosState(method->result_type()), method->is_final_method(), false, false, false, true) | method()->size_of_parameters());
}
class LocalOopClosure: public OopClosure {
private:
public:
};
LocalOopClosure blk(f);
oop_iterate(&blk);
}
// field[1] is always oop or NULL
if (is_vfinal()) {
}
}
// field[1] is always oop or NULL
if (is_vfinal()) {
}
}
void ConstantPoolCacheEntry::follow_contents() {
// field[1] is always oop or NULL
if (is_vfinal()) {
}
}
#ifndef SERIALGC
// field[1] is always oop or NULL
if (is_vfinal()) {
}
}
#endif // SERIALGC
void ConstantPoolCacheEntry::adjust_pointers() {
// field[1] is always oop or NULL
if (is_vfinal()) {
}
}
#ifndef SERIALGC
void ConstantPoolCacheEntry::update_pointers() {
// field[1] is always oop or NULL
if (is_vfinal()) {
}
}
// field[1] is always oop or NULL
if (is_vfinal()) {
}
}
#endif // SERIALGC
// RedefineClasses() API support:
// If this constantPoolCacheEntry refers to old_method then update it
// to refer to new_method.
if (is_vfinal()) {
// virtual and final so f2() contains method ptr instead of vtable index
// match old_method so need an update
if (!(*trace_name_printed)) {
// RC_TRACE_MESG macro has an embedded ResourceMark
RC_TRACE_MESG(("adjust: name=%s",
*trace_name_printed = true;
}
// RC_TRACE macro has an embedded ResourceMark
}
return true;
}
// f1() is not used with virtual entries so bail out
return false;
}
// NULL f1() means this is a virtual entry so bail out
// We are assuming that the vtable index does not need change.
return false;
}
_f1 = new_method;
if (!(*trace_name_printed)) {
// RC_TRACE_MESG macro has an embedded ResourceMark
RC_TRACE_MESG(("adjust: name=%s",
*trace_name_printed = true;
}
// RC_TRACE macro has an embedded ResourceMark
}
return true;
}
return false;
}
if (!is_method_entry()) {
// not a method entry so not interesting by default
return false;
}
if (is_vfinal()) {
// virtual and final so _f2 contains method ptr instead of vtable index
// NULL _f1 means this is a virtual entry so also not interesting
return false;
} else {
// _f1 can also contain a klassOop for an interface
return false;
}
}
// robustness for above sanity checks or method is not in
// the interesting class
return false;
}
// the method is in the interesting class so the entry is interesting
return true;
}
// print separator
// print entry
tty->print_cr("%3d (%08x) [%02x|%02x|%5d]", index, this, bytecode_2(), bytecode_1(), constant_pool_index());
}
// not implemented yet
}
// Implementation of ConstantPoolCache
}
// RedefineClasses() API support:
// If any entry of this constantPoolCache points to any of
// old_methods, replace it with the corresponding new_method.
void constantPoolCacheOopDesc::adjust_method_entries(methodOop* old_methods, methodOop* new_methods,
int methods_length, bool * trace_name_printed) {
if (methods_length == 0) {
// nothing to do if there are no methods
return;
}
// get shorthand for the interesting class
for (int i = 0; i < length(); i++) {
// skip uninteresting methods
continue;
}
// The constantPoolCache contains entries for several different
// things, but we only care about methods. In fact, we only care
// about methods in the same class as the one that contains the
// old_methods. At this point, we have an interesting entry.
for (int j = 0; j < methods_length; j++) {
// current old_method matched this entry and we updated it so
// break out and get to the next interesting entry if there one
break;
}
}
}
}