Skip to content
Permalink
Browse files
8258075: Use auto variable declarations for enum iteration
Reviewed-by: jrose, ccheung
  • Loading branch information
iklam committed Dec 16, 2020
1 parent 330ce86 commit 59f4c4aad5d92d33080026e84b5003e597e289a6
@@ -123,15 +123,15 @@ void ciObjectFactory::init_shared_objects() {

{
// Create the shared symbols, but not in _shared_ci_metadata.
for (vmSymbolID index : EnumRange<vmSymbolID>{}) {
for (auto index : EnumRange<vmSymbolID>{}) {
Symbol* vmsym = vmSymbols::symbol_at(index);
assert(vmSymbols::find_sid(vmsym) == index, "1-1 mapping");
ciSymbol* sym = new (_arena) ciSymbol(vmsym, index);
init_ident_of(sym);
_shared_ci_symbols[vmSymbols::as_int(index)] = sym;
}
#ifdef ASSERT
for (vmSymbolID index : EnumRange<vmSymbolID>{}) {
for (auto index : EnumRange<vmSymbolID>{}) {
Symbol* vmsym = vmSymbols::symbol_at(index);
ciSymbol* sym = vm_symbol_at(index);
assert(sym->get_symbol() == vmsym, "oop must match");
@@ -5302,7 +5302,7 @@ static void check_methods_for_intrinsics(const InstanceKlass* ik,
// The check is potentially expensive, therefore it is available
// only in debug builds.

for (vmIntrinsicID id : EnumRange<vmIntrinsicID>{}) {
for (auto id : EnumRange<vmIntrinsicID>{}) {
if (vmIntrinsics::_compiledLambdaForm == id) {
// The _compiledLamdbdaForm intrinsic is a special marker for bytecode
// generated for the JVM from a LambdaForm and therefore no method
@@ -574,7 +574,7 @@ void vmIntrinsics::init_vm_intrinsic_name_table() {
const char** nt = &vm_intrinsic_name_table[0];
char* string = (char*) &vm_intrinsic_name_bodies[0];

for (vmIntrinsicID index : EnumRange<vmIntrinsicID>{}) {
for (auto index : EnumRange<vmIntrinsicID>{}) {
nt[as_int(index)] = string;
string += strlen(string); // skip string body
string += 1; // skip trailing null
@@ -601,7 +601,7 @@ vmIntrinsics::ID vmIntrinsics::find_id(const char* name) {
init_vm_intrinsic_name_table();
}

for (vmIntrinsicID index : EnumRange<vmIntrinsicID>{}) {
for (auto index : EnumRange<vmIntrinsicID>{}) {
if (0 == strcmp(name, nt[as_int(index)])) {
return index;
}
@@ -83,7 +83,7 @@ void vmSymbols::initialize(TRAPS) {

if (!UseSharedSpaces) {
const char* string = &vm_symbol_bodies[0];
for (vmSymbolID index : EnumRange<vmSymbolID>{}) {
for (auto index : EnumRange<vmSymbolID>{}) {
Symbol* sym = SymbolTable::new_permanent_symbol(string);
Symbol::_vm_symbols[as_int(index)] = sym;
string += strlen(string); // skip string body
@@ -113,9 +113,9 @@ void vmSymbols::initialize(TRAPS) {
#ifdef ASSERT
// Check for duplicates:

for (vmSymbolID i1 : EnumRange<vmSymbolID>{}) {
for (auto i1 : EnumRange<vmSymbolID>{}) {
Symbol* sym = symbol_at(i1);
for (vmSymbolID i2 : EnumRange<vmSymbolID>{vmSymbolID::FIRST_SID, i1}) {
for (auto i2 : EnumRange<vmSymbolID>{vmSymbolID::FIRST_SID, i1}) {
if (i2 != i1 && symbol_at(i2) == sym) {
tty->print("*** Duplicate VM symbol SIDs %s(%d) and %s(%d): \"",
vm_symbol_enum_name(i2), as_int(i2),
@@ -129,7 +129,7 @@ void vmSymbols::initialize(TRAPS) {

// Create an index for find_id:
{
for (vmSymbolID index : EnumRange<vmSymbolID>{}) {
for (auto index : EnumRange<vmSymbolID>{}) {
vm_symbol_index[as_int(index)] = index;
}
int num_sids = SID_LIMIT-FIRST_SID;
@@ -150,7 +150,7 @@ void vmSymbols::initialize(TRAPS) {
assert(symbol_at(sid) == jlo, "");

// Make sure find_sid produces the right answer in each case.
for (vmSymbolID index : EnumRange<vmSymbolID>{}) {
for (auto index : EnumRange<vmSymbolID>{}) {
Symbol* sym = symbol_at(index);
sid = find_sid(sym);
assert(sid == index, "symbol index works");
@@ -174,7 +174,7 @@ const char* vmSymbols::name_for(vmSymbolID sid) {
if (sid == vmSymbolID::NO_SID)
return "NO_SID";
const char* string = &vm_symbol_bodies[0];
for (vmSymbolID index : EnumRange<vmSymbolID>{}) {
for (auto index : EnumRange<vmSymbolID>{}) {
if (index == sid)
return string;
string += strlen(string); // skip string body
@@ -187,7 +187,7 @@ const char* vmSymbols::name_for(vmSymbolID sid) {


void vmSymbols::symbols_do(SymbolClosure* f) {
for (vmSymbolID index : EnumRange<vmSymbolID>{}) {
for (auto index : EnumRange<vmSymbolID>{}) {
f->do_symbol(&Symbol::_vm_symbols[as_int(index)]);
}
for (int i = 0; i < T_VOID+1; i++) {
@@ -196,7 +196,7 @@ void vmSymbols::symbols_do(SymbolClosure* f) {
}

void vmSymbols::metaspace_pointers_do(MetaspaceClosure *closure) {
for (vmSymbolID index : EnumRange<vmSymbolID>{}) {
for (auto index : EnumRange<vmSymbolID>{}) {
closure->push(&Symbol::_vm_symbols[as_int(index)]);
}
for (int i = 0; i < T_VOID+1; i++) {
@@ -274,7 +274,7 @@ vmSymbolID vmSymbols::find_sid(const Symbol* symbol) {
// Make sure this is the right answer, using linear search.
// (We have already proven that there are no duplicates in the list.)
vmSymbolID sid2 = vmSymbolID::NO_SID;
for (vmSymbolID index : EnumRange<vmSymbolID>{}) {
for (auto index : EnumRange<vmSymbolID>{}) {
Symbol* sym2 = symbol_at(index);
if (sym2 == symbol) {
sid2 = index;
@@ -234,7 +234,7 @@ void Compile::print_intrinsic_statistics() {
if (total == 0) total = 1; // avoid div0 in case of no successes
#define PRINT_STAT_LINE(name, c, f) \
tty->print_cr(" %4d (%4.1f%%) %s (%s)", (int)(c), ((c) * 100.0) / total, name, f);
for (vmIntrinsicID id : EnumRange<vmIntrinsicID>{}) {
for (auto id : EnumRange<vmIntrinsicID>{}) {
int flags = _intrinsic_hist_flags[as_int(id)];
juint count = _intrinsic_hist_count[as_int(id)];
if ((flags | count) != 0) {
@@ -59,7 +59,7 @@
// Example:
//
// /* With range-base for (recommended) */
// for (vmSymbolID index : EnumRange<vmSymbolID>{}) {
// for (auto index : EnumRange<vmSymbolID>{}) {
// ....
// }
//

1 comment on commit 59f4c4a

@openjdk-notifier

This comment has been minimized.

Copy link

@openjdk-notifier openjdk-notifier bot commented on 59f4c4a Dec 16, 2020

Please sign in to comment.