< prev index next >
src/hotspot/share/oops/constantPool.cpp
Print this page
*** 198,220 ****
{
const int class_index = klass_index_at(i);
unresolved_klass_at_put(i, class_index, num_klasses++);
}
break;
- case JVM_CONSTANT_ValueIndex:
- {
- const int class_index = value_type_index_at(i);
- unresolved_value_type_at_put(i, class_index, num_klasses++);
- }
- break;
#ifndef PRODUCT
case JVM_CONSTANT_Class:
case JVM_CONSTANT_UnresolvedClass:
case JVM_CONSTANT_UnresolvedClassInError:
- case JVM_CONSTANT_Value:
- case JVM_CONSTANT_UnresolvedValue:
- case JVM_CONSTANT_UnresolvedValueInError:
// All of these should have been reverted back to Unresolved before calling
// this function.
ShouldNotReachHere();
#endif
}
--- 198,211 ----
*** 236,249 ****
OrderAccess::release_store(adr, k);
// The interpreter assumes when the tag is stored, the klass is resolved
// and the Klass* non-NULL, so we need hardware store ordering here.
if (k != NULL) {
! release_tag_at_put(class_index, (k->is_value() ? (jbyte)JVM_CONSTANT_Value : JVM_CONSTANT_Class));
} else {
! release_tag_at_put(class_index, (tag_at(class_index).is_value_type_or_reference() ?
! JVM_CONSTANT_UnresolvedValue : JVM_CONSTANT_UnresolvedClass));
}
}
// Anonymous class support:
void ConstantPool::klass_at_put(int class_index, Klass* k) {
--- 227,239 ----
OrderAccess::release_store(adr, k);
// The interpreter assumes when the tag is stored, the klass is resolved
// and the Klass* non-NULL, so we need hardware store ordering here.
if (k != NULL) {
! release_tag_at_put(class_index, JVM_CONSTANT_Class);
} else {
! release_tag_at_put(class_index, JVM_CONSTANT_UnresolvedClass);
}
}
// Anonymous class support:
void ConstantPool::klass_at_put(int class_index, Klass* k) {
*** 253,263 ****
Klass** adr = resolved_klasses()->adr_at(resolved_klass_index);
OrderAccess::release_store(adr, k);
// The interpreter assumes when the tag is stored, the klass is resolved
// and the Klass* non-NULL, so we need hardware store ordering here.
! release_tag_at_put(class_index, (k->is_value() ? (jbyte)JVM_CONSTANT_Value : JVM_CONSTANT_Class));
}
#if INCLUDE_CDS_JAVA_HEAP
// Archive the resolved references
void ConstantPool::archive_resolved_references(Thread* THREAD) {
--- 243,253 ----
Klass** adr = resolved_klasses()->adr_at(resolved_klass_index);
OrderAccess::release_store(adr, k);
// The interpreter assumes when the tag is stored, the klass is resolved
// and the Klass* non-NULL, so we need hardware store ordering here.
! release_tag_at_put(class_index, JVM_CONSTANT_Class);
}
#if INCLUDE_CDS_JAVA_HEAP
// Archive the resolved references
void ConstantPool::archive_resolved_references(Thread* THREAD) {
*** 452,469 ****
int resolved_klass_index = kslot.resolved_klass_index();
int name_index = kslot.name_index();
assert(this_cp->tag_at(name_index).is_symbol(), "sanity");
Klass* klass = this_cp->resolved_klasses()->at(resolved_klass_index);
-
if (klass != NULL) {
return klass;
}
// This tag doesn't change back to unresolved class unless at a safepoint.
! if (this_cp->tag_at(which).is_unresolved_klass_in_error() ||
! this_cp->tag_at(which).is_unresolved_value_type_in_error()) {
// The original attempt to resolve this constant pool entry failed so find the
// class of the original error and throw another error of the same class
// (JVMS 5.4.3).
// If there is a detail message, pass that detail message to the error.
// The JVMS does not strictly require us to duplicate the same detail message,
--- 442,457 ----
int resolved_klass_index = kslot.resolved_klass_index();
int name_index = kslot.name_index();
assert(this_cp->tag_at(name_index).is_symbol(), "sanity");
Klass* klass = this_cp->resolved_klasses()->at(resolved_klass_index);
if (klass != NULL) {
return klass;
}
// This tag doesn't change back to unresolved class unless at a safepoint.
! if (this_cp->tag_at(which).is_unresolved_klass_in_error()) {
// The original attempt to resolve this constant pool entry failed so find the
// class of the original error and throw another error of the same class
// (JVMS 5.4.3).
// If there is a detail message, pass that detail message to the error.
// The JVMS does not strictly require us to duplicate the same detail message,
*** 488,501 ****
// Failed to resolve class. We must record the errors so that subsequent attempts
// to resolve this constant pool entry fail with the same error (JVMS 5.4.3).
if (HAS_PENDING_EXCEPTION) {
if (save_resolution_error) {
! bool is_value_type_tag = this_cp->tag_at(which).is_value_type_or_reference();
! save_and_throw_exception(this_cp, which,
! constantTag((is_value_type_tag ? JVM_CONSTANT_UnresolvedValue : JVM_CONSTANT_UnresolvedClass)),
! CHECK_NULL);
// If CHECK_NULL above doesn't return the exception, that means that
// some other thread has beaten us and has resolved the class.
// To preserve old behavior, we return the resolved class.
klass = this_cp->resolved_klasses()->at(resolved_klass_index);
assert(klass != NULL, "must be resolved if exception was cleared");
--- 476,486 ----
// Failed to resolve class. We must record the errors so that subsequent attempts
// to resolve this constant pool entry fail with the same error (JVMS 5.4.3).
if (HAS_PENDING_EXCEPTION) {
if (save_resolution_error) {
! save_and_throw_exception(this_cp, which, constantTag(JVM_CONSTANT_UnresolvedClass), CHECK_NULL);
// If CHECK_NULL above doesn't return the exception, that means that
// some other thread has beaten us and has resolved the class.
// To preserve old behavior, we return the resolved class.
klass = this_cp->resolved_klasses()->at(resolved_klass_index);
assert(klass != NULL, "must be resolved if exception was cleared");
*** 516,526 ****
Klass** adr = this_cp->resolved_klasses()->adr_at(resolved_klass_index);
OrderAccess::release_store(adr, k);
// The interpreter assumes when the tag is stored, the klass is resolved
// and the Klass* stored in _resolved_klasses is non-NULL, so we need
// hardware store ordering here.
! this_cp->release_tag_at_put(which, (k->is_value() ? (jbyte)JVM_CONSTANT_Value : JVM_CONSTANT_Class));
return k;
}
// Does not update ConstantPool* - to avoid any exception throwing. Used
--- 501,511 ----
Klass** adr = this_cp->resolved_klasses()->adr_at(resolved_klass_index);
OrderAccess::release_store(adr, k);
// The interpreter assumes when the tag is stored, the klass is resolved
// and the Klass* stored in _resolved_klasses is non-NULL, so we need
// hardware store ordering here.
! this_cp->release_tag_at_put(which, JVM_CONSTANT_Class);
return k;
}
// Does not update ConstantPool* - to avoid any exception throwing. Used
*** 754,764 ****
}
// Return specific message for the tag
switch (tag.value()) {
case JVM_CONSTANT_UnresolvedClass:
- case JVM_CONSTANT_UnresolvedValue:
// return the class name in the error message
message = this_cp->klass_name_at(which);
break;
case JVM_CONSTANT_MethodHandle:
// return the method handle name in the error message
--- 739,748 ----
*** 809,819 ****
// this error, so it needs to get the same error if the error is first.
jbyte old_tag = Atomic::cmpxchg((jbyte)error_tag,
(jbyte*)this_cp->tag_addr_at(which), (jbyte)tag.value());
if (old_tag != error_tag && old_tag != tag.value()) {
// MethodHandles and MethodType doesn't change to resolved version.
! assert(this_cp->tag_at(which).is_klass() || this_cp->tag_at(which).is_value_type(), "Wrong tag value");
// Forget the exception and use the resolved class.
CLEAR_PENDING_EXCEPTION;
}
} else {
// some other thread put this in error state
--- 793,803 ----
// this error, so it needs to get the same error if the error is first.
jbyte old_tag = Atomic::cmpxchg((jbyte)error_tag,
(jbyte*)this_cp->tag_addr_at(which), (jbyte)tag.value());
if (old_tag != error_tag && old_tag != tag.value()) {
// MethodHandles and MethodType doesn't change to resolved version.
! assert(this_cp->tag_at(which).is_klass(), "Wrong tag value");
// Forget the exception and use the resolved class.
CLEAR_PENDING_EXCEPTION;
}
} else {
// some other thread put this in error state
*** 903,915 ****
switch (tag.value()) {
case JVM_CONSTANT_UnresolvedClass:
case JVM_CONSTANT_UnresolvedClassInError:
case JVM_CONSTANT_Class:
- case JVM_CONSTANT_UnresolvedValue:
- case JVM_CONSTANT_UnresolvedValueInError:
- case JVM_CONSTANT_Value:
{
assert(cache_index == _no_index_sentinel, "should not have been set");
Klass* resolved = klass_at_impl(this_cp, index, true, CHECK_NULL);
// ldc wants the java mirror.
result_oop = resolved->java_mirror();
--- 887,896 ----
*** 1312,1322 ****
return false;
}
switch (t1) {
case JVM_CONSTANT_Class:
- case JVM_CONSTANT_Value:
{
Klass* k1 = klass_at(index1, CHECK_false);
Klass* k2 = cp2->klass_at(index2, CHECK_false);
if (k1 == k2) {
return true;
--- 1293,1302 ----
*** 1331,1350 ****
if (match) {
return true;
}
} break;
- case JVM_CONSTANT_ValueIndex:
- {
- int recur1 = value_type_index_at(index1);
- int recur2 = cp2->value_type_index_at(index2);
- bool match = compare_entry_to(recur1, cp2, recur2, CHECK_false);
- if (match) {
- return true;
- }
- } break;
-
case JVM_CONSTANT_Double:
{
jdouble d1 = double_at(index1);
jdouble d2 = cp2->double_at(index2);
if (d1 == d2) {
--- 1311,1320 ----
*** 1420,1430 ****
return true;
}
} break;
case JVM_CONSTANT_UnresolvedClass:
- case JVM_CONSTANT_UnresolvedValue:
{
Symbol* k1 = klass_name_at(index1);
Symbol* k2 = cp2->klass_name_at(index2);
if (k1 == k2) {
return true;
--- 1390,1399 ----
*** 1690,1705 ****
{
jint ki = from_cp->klass_index_at(from_i);
to_cp->klass_index_at_put(to_i, ki);
} break;
- case JVM_CONSTANT_ValueIndex:
- {
- jint ki = from_cp->klass_index_at(from_i);
- to_cp->klass_index_at_put(to_i, ki);
- } break;
-
case JVM_CONSTANT_Double:
{
jdouble d = from_cp->double_at(from_i);
to_cp->double_at_put(to_i, d);
// double takes two constant pool entries so init second entry's tag
--- 1659,1668 ----
*** 1768,1787 ****
int name_index = from_cp->klass_slot_at(from_i).name_index();
assert(from_cp->tag_at(name_index).is_symbol(), "sanity");
to_cp->klass_index_at_put(to_i, name_index);
} break;
- case JVM_CONSTANT_Value:
- case JVM_CONSTANT_UnresolvedValue:
- case JVM_CONSTANT_UnresolvedValueInError:
- {
- // Revert to JVM_CONSTANT_ValueIndex
- int name_index = from_cp->klass_slot_at(from_i).name_index();
- assert(from_cp->tag_at(name_index).is_symbol(), "sanity");
- to_cp->value_type_index_at_put(to_i, name_index);
- } break;
-
case JVM_CONSTANT_String:
{
Symbol* s = from_cp->unresolved_string_at(from_i);
to_cp->unresolved_string_at_put(to_i, s);
} break;
--- 1731,1740 ----
*** 1902,1913 ****
constantTag tag = tag_at(which);
if (tag.is_string()) {
return string_at_noresolve(which);
! } else if (tag.is_klass() || tag.is_unresolved_klass() ||
! tag.is_value_type() || tag.is_unresolved_value_type()) {
return klass_name_at(which)->as_C_string();
} else if (tag.is_symbol()) {
return symbol_at(which)->as_C_string();
}
return "";
--- 1855,1865 ----
constantTag tag = tag_at(which);
if (tag.is_string()) {
return string_at_noresolve(which);
! } else if (tag.is_klass() || tag.is_unresolved_klass()) {
return klass_name_at(which)->as_C_string();
} else if (tag.is_symbol()) {
return symbol_at(which)->as_C_string();
}
return "";
*** 1985,2000 ****
idx1 = Bytes::get_Java_u2(bytes);
printf("class #%03d", idx1);
ent_size = 2;
break;
}
- case JVM_CONSTANT_Value: {
- idx1 = Bytes::get_Java_u2(bytes);
- printf("class #%03d", idx1);
- ent_size = 2;
- break;
- }
case JVM_CONSTANT_String: {
idx1 = Bytes::get_Java_u2(bytes);
printf("String #%03d", idx1);
ent_size = 2;
break;
--- 1937,1946 ----
*** 2037,2058 ****
}
case JVM_CONSTANT_UnresolvedClassInError: {
printf("UnresolvedClassInErr: %s", WARN_MSG);
break;
}
- case JVM_CONSTANT_ValueIndex: {
- printf("ValueIndex %s", WARN_MSG);
- break;
- }
- case JVM_CONSTANT_UnresolvedValue: {
- printf("UnresolvedValue: %s", WARN_MSG);
- break;
- }
- case JVM_CONSTANT_UnresolvedValueInError: {
- printf("UnresolvedValueInErr: %s", WARN_MSG);
- break;
- }
case JVM_CONSTANT_StringIndex: {
printf("StringIndex: %s", WARN_MSG);
break;
}
}
--- 1983,1992 ----
*** 2079,2092 ****
case JVM_CONSTANT_Class:
case JVM_CONSTANT_String:
case JVM_CONSTANT_ClassIndex:
case JVM_CONSTANT_UnresolvedClass:
case JVM_CONSTANT_UnresolvedClassInError:
- case JVM_CONSTANT_Value:
- case JVM_CONSTANT_ValueIndex:
- case JVM_CONSTANT_UnresolvedValue:
- case JVM_CONSTANT_UnresolvedValueInError:
case JVM_CONSTANT_StringIndex:
case JVM_CONSTANT_MethodType:
case JVM_CONSTANT_MethodTypeInError:
return 3;
--- 2013,2022 ----
*** 2141,2158 ****
Symbol* sym = klass_name_at(idx);
classmap->add_entry(sym, idx);
DBG(printf("adding class entry %s = %d\n", sym->as_utf8(), idx));
break;
}
- case JVM_CONSTANT_Value:
- case JVM_CONSTANT_UnresolvedValue:
- case JVM_CONSTANT_UnresolvedValueInError: {
- Symbol* sym = klass_name_at(idx);
- classmap->add_entry(sym, idx);
- DBG(printf("adding value type entry %s = %d\n", sym->as_utf8(), idx));
- break;
- }
case JVM_CONSTANT_Long:
case JVM_CONSTANT_Double: {
idx++; // Both Long and Double take two cpool slots
break;
}
--- 2071,2080 ----
*** 2236,2256 ****
assert(idx1 != 0, "Have not found a hashtable entry");
Bytes::put_Java_u2((address) (bytes+1), idx1);
DBG(printf("JVM_CONSTANT_Class: idx=#%03hd, %s", idx1, sym->as_utf8()));
break;
}
- case JVM_CONSTANT_Value:
- case JVM_CONSTANT_UnresolvedValue:
- case JVM_CONSTANT_UnresolvedValueInError: {
- *bytes = JVM_CONSTANT_Value;
- Symbol* sym = klass_name_at(idx);
- idx1 = tbl->symbol_to_value(sym);
- assert(idx1 != 0, "Have not found a hashtable entry");
- Bytes::put_Java_u2((address) (bytes+1), idx1);
- DBG(printf("JVM_CONSTANT_Value: idx=#%03hd, %s", idx1, sym->as_utf8()));
- break;
- }
case JVM_CONSTANT_String: {
*bytes = JVM_CONSTANT_String;
Symbol* sym = unresolved_string_at(idx);
idx1 = tbl->symbol_to_value(sym);
assert(idx1 != 0, "Have not found a hashtable entry");
--- 2158,2167 ----
*** 2281,2297 ****
idx1 = klass_index_at(idx);
Bytes::put_Java_u2((address) (bytes+1), idx1);
DBG(printf("JVM_CONSTANT_ClassIndex: %hd", idx1));
break;
}
- case JVM_CONSTANT_ValueIndex: {
- *bytes = JVM_CONSTANT_Value;
- idx1 = value_type_index_at(idx);
- Bytes::put_Java_u2((address) (bytes+1), idx1);
- DBG(printf("JVM_CONSTANT_ValueIndex: %hd", idx1));
- break;
- }
case JVM_CONSTANT_StringIndex: {
*bytes = JVM_CONSTANT_String;
idx1 = string_index_at(idx);
Bytes::put_Java_u2((address) (bytes+1), idx1);
DBG(printf("JVM_CONSTANT_StringIndex: %hd", idx1));
--- 2192,2201 ----
*** 2406,2417 ****
guarantee(obj->is_constantPool(), "object must be constant pool");
constantPoolHandle cp(THREAD, (ConstantPool*)obj);
guarantee(cp->pool_holder() != NULL, "must be fully loaded");
for (int i = 0; i< cp->length(); i++) {
! if (cp->tag_at(i).is_unresolved_klass() ||
! cp->tag_at(i).is_unresolved_value_type()) {
// This will force loading of the class
Klass* klass = cp->klass_at(i, CHECK);
if (klass->is_instance_klass()) {
// Force initialization of class
InstanceKlass::cast(klass)->initialize(CHECK);
--- 2310,2320 ----
guarantee(obj->is_constantPool(), "object must be constant pool");
constantPoolHandle cp(THREAD, (ConstantPool*)obj);
guarantee(cp->pool_holder() != NULL, "must be fully loaded");
for (int i = 0; i< cp->length(); i++) {
! if (cp->tag_at(i).is_unresolved_klass()) {
// This will force loading of the class
Klass* klass = cp->klass_at(i, CHECK);
if (klass->is_instance_klass()) {
// Force initialization of class
InstanceKlass::cast(klass)->initialize(CHECK);
*** 2466,2482 ****
guarantee(k != NULL, "need klass");
k->print_value_on(st);
st->print(" {" PTR_FORMAT "}", p2i(k));
}
break;
- case JVM_CONSTANT_Value :
- { Klass* k = klass_at(index, CATCH);
- guarantee(k != NULL, "need klass");
- k->print_value_on(st);
- st->print(" {" PTR_FORMAT "}", p2i(k));
- }
- break;
case JVM_CONSTANT_Fieldref :
case JVM_CONSTANT_Methodref :
case JVM_CONSTANT_InterfaceMethodref :
st->print("klass_index=%d", uncached_klass_ref_index_at(index));
st->print(" name_and_type_index=%d", uncached_name_and_type_ref_index_at(index));
--- 2369,2378 ----
*** 2507,2527 ****
st->print(" signature_index=%d", signature_ref_index_at(index));
break;
case JVM_CONSTANT_Utf8 :
symbol_at(index)->print_value_on(st);
break;
! case JVM_CONSTANT_ClassIndex:
! case JVM_CONSTANT_ValueIndex: {
int name_index = *int_at_addr(index);
st->print("klass_index=%d ", name_index);
symbol_at(name_index)->print_value_on(st);
}
break;
case JVM_CONSTANT_UnresolvedClass : // fall-through
! case JVM_CONSTANT_UnresolvedClassInError :
! case JVM_CONSTANT_UnresolvedValue :
! case JVM_CONSTANT_UnresolvedValueInError : {
CPKlassSlot kslot = klass_slot_at(index);
int resolved_klass_index = kslot.resolved_klass_index();
int name_index = kslot.name_index();
assert(tag_at(name_index).is_symbol(), "sanity");
--- 2403,2420 ----
st->print(" signature_index=%d", signature_ref_index_at(index));
break;
case JVM_CONSTANT_Utf8 :
symbol_at(index)->print_value_on(st);
break;
! case JVM_CONSTANT_ClassIndex: {
int name_index = *int_at_addr(index);
st->print("klass_index=%d ", name_index);
symbol_at(name_index)->print_value_on(st);
}
break;
case JVM_CONSTANT_UnresolvedClass : // fall-through
! case JVM_CONSTANT_UnresolvedClassInError: {
CPKlassSlot kslot = klass_slot_at(index);
int resolved_klass_index = kslot.resolved_klass_index();
int name_index = kslot.name_index();
assert(tag_at(name_index).is_symbol(), "sanity");
*** 2614,2625 ****
void ConstantPool::verify_on(outputStream* st) {
guarantee(is_constantPool(), "object must be constant pool");
for (int i = 0; i< length(); i++) {
constantTag tag = tag_at(i);
! if (tag.is_klass() || tag.is_unresolved_klass() ||
! tag.is_value_type() || tag.is_unresolved_value_type()) {
guarantee(klass_name_at(i)->refcount() != 0, "should have nonzero reference count");
} else if (tag.is_symbol()) {
CPSlot entry = slot_at(i);
guarantee(entry.get_symbol()->refcount() != 0, "should have nonzero reference count");
} else if (tag.is_string()) {
--- 2507,2517 ----
void ConstantPool::verify_on(outputStream* st) {
guarantee(is_constantPool(), "object must be constant pool");
for (int i = 0; i< length(); i++) {
constantTag tag = tag_at(i);
! if (tag.is_klass() || tag.is_unresolved_klass()) {
guarantee(klass_name_at(i)->refcount() != 0, "should have nonzero reference count");
} else if (tag.is_symbol()) {
CPSlot entry = slot_at(i);
guarantee(entry.get_symbol()->refcount() != 0, "should have nonzero reference count");
} else if (tag.is_string()) {
< prev index next >