Creation of RelocIterators show up high in profiles of the remark phase, in the G1 Class Unloading project.
There's a pattern in the nmethod/codecache code to create a RelocIterator and then materialize a CompiledIC:
RelocIterator iter(this, low_boundary);
while(iter.next()) {
if (iter.type() == relocInfo::virtual_call_type) {
CompiledIC *ic = CompiledIC_at(iter.reloc());
CompiledIC_at is implemented as:
new CompiledIC(call_site->code(), nativeCall_at(call_site->addr()));
And one of the first thing CompiledIC::CompiledIC(const nmethod* nm, NativeCall* call) does is to create a new RelocIterator:
...
address ic_call = call->instruction_address();
...
RelocIterator iter(nm, ic_call, ic_call+1);
bool ret = iter.next();
assert(ret == true, "relocInfo must exist at this address");
assert(iter.addr() == ic_call, "must find ic_call");
I would like to propose that we pass down the RelocIterator that we already have, instead of creating a new.