void block_do(BlockBegin* from) { int n = from->end()->number_of_sux(); int tag = _tags->at(from->block_id()); for (int i = 0; i < n; i++) { BlockBegin* to = from->end()->sux_at(i); if (tag != _tags->at(to->block_id())) { // this edge is a transition between two different // caching regions, so we need to insert a CachingChange _pairs->append(new BlockPair(from, to)); } } }
// add a new entries to the resolved_references map (for invokedynamic and invokehandle only) int add_invokedynamic_resolved_references_entries(int cp_index, int cache_index) { assert(_resolved_reference_limit >= 0, "must add indy refs after first iteration"); int ref_index = -1; for (int entry = 0; entry < ConstantPoolCacheEntry::_indy_resolved_references_entries; entry++) { const int index = _resolved_references_map.append(cp_index); // many-to-one assert(index >= _resolved_reference_limit, ""); if (entry == 0) { ref_index = index; } assert((index - entry) == ref_index, "entries must be consecutive"); _invokedynamic_references_map.at_put_grow(index, cache_index, -1); } return ref_index; }
// add a new CP cache entry beyond the normal cache for the special case of // invokespecial with InterfaceMethodref as cpool operand. int add_invokespecial_cp_cache_entry(int cp_index) { assert(_first_iteration_cp_cache_limit >= 0, "add these special cache entries after first iteration"); // Don't add InterfaceMethodref if it already exists at the end. for (int i = _first_iteration_cp_cache_limit; i < _cp_cache_map.length(); i++) { if (cp_cache_entry_pool_index(i) == cp_index) { return i; } } int cache_index = _cp_cache_map.append(cp_index); assert(cache_index >= _first_iteration_cp_cache_limit, ""); // do not update _cp_map, since the mapping is one-to-many assert(cp_cache_entry_pool_index(cache_index) == cp_index, ""); return cache_index; }
void init_maps(int length) { _cp_map.initialize(length, -1); // Choose an initial value large enough that we don't get frequent // calls to grow(). _cp_cache_map.initialize(length/2); // Also cache resolved objects, in another different cache. _reference_map.initialize(length, -1); _resolved_references_map.initialize(length/2); _invokedynamic_references_map.initialize(length/2); _resolved_reference_limit = -1; _first_iteration_cp_cache_limit = -1; // invokedynamic specific fields _invokedynamic_cp_cache_map.initialize(length/4); _patch_invokedynamic_bcps = new GrowableArray<address>(length/4); _patch_invokedynamic_refs = new GrowableArray<int>(length/4); }
int add_cp_cache_entry(int cp_index) { assert((cp_index & _secondary_entry_tag) == 0, "bad tag"); assert(_cp_map[cp_index] == -1, "not twice on same cp_index"); int cache_index = _cp_cache_map.append(cp_index); _cp_map.at_put(cp_index, cache_index); assert(cp_entry_to_cp_cache(cp_index) == cache_index, ""); return cache_index; }
int add_invokedynamic_cp_cache_entry(int cp_index) { assert(_pool->tag_at(cp_index).value() == JVM_CONSTANT_InvokeDynamic, "use non-indy version"); assert(_first_iteration_cp_cache_limit >= 0, "add indy cache entries after first iteration"); // add to the invokedynamic index map. int cache_index = _invokedynamic_cp_cache_map.append(cp_index); // do not update _cp_map, since the mapping is one-to-many assert(invokedynamic_cp_cache_entry_pool_index(cache_index) == cp_index, ""); // this index starts at one but in the bytecode it's appended to the end. return cache_index + _first_iteration_cp_cache_limit; }
virtual void block_do(BlockBegin* block) { assert(_tags->at_grow(block->block_id(), -1) == -1 || _tags->at_grow(block->block_id(), -1) == _tag, "this block is part of two loops"); _tags->at_put_grow(block->block_id(), _tag, -1); }
void spop() { assert(_stack.is_empty() || _stack.top() == -1, ""); raw_pop(); }
int raw_pop() { return _stack.is_empty() ? -1 : _stack.pop(); }
void raw_push(int i) { _stack.push(i); }
int cp_cache_delta() { // How many cp cache entries were added since recording map limits after // cp cache initialization? assert(_first_iteration_cp_cache_limit != -1, "only valid after first iteration"); return _cp_cache_map.length() - _first_iteration_cp_cache_limit; }
void record_map_limits() { // Record initial size of the two arrays generated for the CP cache // relative to walking the constant pool. _first_iteration_cp_cache_limit = _cp_cache_map.length(); _resolved_reference_limit = _resolved_references_map.length(); }
int add_secondary_cp_cache_entry(int main_cpc_entry) { assert(main_cpc_entry < _cp_cache_map.length(), "must be earlier CP cache entry"); int cache_index = _cp_cache_map.append(main_cpc_entry | _secondary_entry_tag); return cache_index; }
void init_cp_map(int length) { _cp_map.initialize(length, -1); // Choose an initial value large enough that we don't get frequent // calls to grow(). _cp_cache_map.initialize(length / 2); }