Path: blob/master/src/hotspot/share/opto/buildOopMap.cpp
64441 views
/*1* Copyright (c) 2002, 2021, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*22*/2324#include "precompiled.hpp"25#include "code/vmreg.inline.hpp"26#include "compiler/oopMap.hpp"27#include "memory/resourceArea.hpp"28#include "opto/addnode.hpp"29#include "opto/callnode.hpp"30#include "opto/compile.hpp"31#include "opto/machnode.hpp"32#include "opto/matcher.hpp"33#include "opto/output.hpp"34#include "opto/phase.hpp"35#include "opto/regalloc.hpp"36#include "opto/rootnode.hpp"37#include "utilities/align.hpp"3839// The functions in this file builds OopMaps after all scheduling is done.40//41// OopMaps contain a list of all registers and stack-slots containing oops (so42// they can be updated by GC). OopMaps also contain a list of derived-pointer43// base-pointer pairs. When the base is moved, the derived pointer moves to44// follow it. Finally, any registers holding callee-save values are also45// recorded. These might contain oops, but only the caller knows.46//47// BuildOopMaps implements a simple forward reaching-defs solution. At each48// GC point we'll have the reaching-def Nodes. If the reaching Nodes are49// typed as pointers (no offset), then they are oops. Pointers+offsets are50// derived pointers, and bases can be found from them. Finally, we'll also51// track reaching callee-save values. Note that a copy of a callee-save value52// "kills" it's source, so that only 1 copy of a callee-save value is alive at53// a time.54//55// We run a simple bitvector liveness pass to help trim out dead oops. Due to56// irreducible loops, we can have a reaching def of an oop that only reaches57// along one path and no way to know if it's valid or not on the other path.58// The bitvectors are quite dense and the liveness pass is fast.59//60// At GC points, we consult this information to build OopMaps. All reaching61// defs typed as oops are added to the OopMap. Only 1 instance of a62// callee-save register can be recorded. For derived pointers, we'll have to63// find and record the register holding the base.64//65// The reaching def's is a simple 1-pass worklist approach. I tried a clever66// breadth-first approach but it was worse (showed O(n^2) in the67// pick-next-block code).68//69// The relevant data is kept in a struct of arrays (it could just as well be70// an array of structs, but the struct-of-arrays is generally a little more71// efficient). The arrays are indexed by register number (including72// stack-slots as registers) and so is bounded by 200 to 300 elements in73// practice. One array will map to a reaching def Node (or NULL for74// conflict/dead). The other array will map to a callee-saved register or75// OptoReg::Bad for not-callee-saved.767778// Structure to pass around79struct OopFlow : public ResourceObj {80short *_callees; // Array mapping register to callee-saved81Node **_defs; // array mapping register to reaching def82// or NULL if dead/conflict83// OopFlow structs, when not being actively modified, describe the _end_ of84// this block.85Block *_b; // Block for this struct86OopFlow *_next; // Next free OopFlow87// or NULL if dead/conflict88Compile* C;8990OopFlow( short *callees, Node **defs, Compile* c ) : _callees(callees), _defs(defs),91_b(NULL), _next(NULL), C(c) { }9293// Given reaching-defs for this block start, compute it for this block end94void compute_reach( PhaseRegAlloc *regalloc, int max_reg, Dict *safehash );9596// Merge these two OopFlows into the 'this' pointer.97void merge( OopFlow *flow, int max_reg );9899// Copy a 'flow' over an existing flow100void clone( OopFlow *flow, int max_size);101102// Make a new OopFlow from scratch103static OopFlow *make( Arena *A, int max_size, Compile* C );104105// Build an oopmap from the current flow info106OopMap *build_oop_map( Node *n, int max_reg, PhaseRegAlloc *regalloc, int* live );107};108109// Given reaching-defs for this block start, compute it for this block end110void OopFlow::compute_reach( PhaseRegAlloc *regalloc, int max_reg, Dict *safehash ) {111112for( uint i=0; i<_b->number_of_nodes(); i++ ) {113Node *n = _b->get_node(i);114115if( n->jvms() ) { // Build an OopMap here?116JVMState *jvms = n->jvms();117// no map needed for leaf calls118if( n->is_MachSafePoint() && !n->is_MachCallLeaf() ) {119int *live = (int*) (*safehash)[n];120assert( live, "must find live" );121n->as_MachSafePoint()->set_oop_map( build_oop_map(n,max_reg,regalloc, live) );122}123}124125// Assign new reaching def's.126// Note that I padded the _defs and _callees arrays so it's legal127// to index at _defs[OptoReg::Bad].128OptoReg::Name first = regalloc->get_reg_first(n);129OptoReg::Name second = regalloc->get_reg_second(n);130_defs[first] = n;131_defs[second] = n;132133// Pass callee-save info around copies134int idx = n->is_Copy();135if( idx ) { // Copies move callee-save info136OptoReg::Name old_first = regalloc->get_reg_first(n->in(idx));137OptoReg::Name old_second = regalloc->get_reg_second(n->in(idx));138int tmp_first = _callees[old_first];139int tmp_second = _callees[old_second];140_callees[old_first] = OptoReg::Bad; // callee-save is moved, dead in old location141_callees[old_second] = OptoReg::Bad;142_callees[first] = tmp_first;143_callees[second] = tmp_second;144} else if( n->is_Phi() ) { // Phis do not mod callee-saves145assert( _callees[first] == _callees[regalloc->get_reg_first(n->in(1))], "" );146assert( _callees[second] == _callees[regalloc->get_reg_second(n->in(1))], "" );147assert( _callees[first] == _callees[regalloc->get_reg_first(n->in(n->req()-1))], "" );148assert( _callees[second] == _callees[regalloc->get_reg_second(n->in(n->req()-1))], "" );149} else {150_callees[first] = OptoReg::Bad; // No longer holding a callee-save value151_callees[second] = OptoReg::Bad;152153// Find base case for callee saves154if( n->is_Proj() && n->in(0)->is_Start() ) {155if( OptoReg::is_reg(first) &&156regalloc->_matcher.is_save_on_entry(first) )157_callees[first] = first;158if( OptoReg::is_reg(second) &&159regalloc->_matcher.is_save_on_entry(second) )160_callees[second] = second;161}162}163}164}165166// Merge the given flow into the 'this' flow167void OopFlow::merge( OopFlow *flow, int max_reg ) {168assert( _b == NULL, "merging into a happy flow" );169assert( flow->_b, "this flow is still alive" );170assert( flow != this, "no self flow" );171172// Do the merge. If there are any differences, drop to 'bottom' which173// is OptoReg::Bad or NULL depending.174for( int i=0; i<max_reg; i++ ) {175// Merge the callee-save's176if( _callees[i] != flow->_callees[i] )177_callees[i] = OptoReg::Bad;178// Merge the reaching defs179if( _defs[i] != flow->_defs[i] )180_defs[i] = NULL;181}182183}184185void OopFlow::clone( OopFlow *flow, int max_size ) {186_b = flow->_b;187memcpy( _callees, flow->_callees, sizeof(short)*max_size);188memcpy( _defs , flow->_defs , sizeof(Node*)*max_size);189}190191OopFlow *OopFlow::make( Arena *A, int max_size, Compile* C ) {192short *callees = NEW_ARENA_ARRAY(A,short,max_size+1);193Node **defs = NEW_ARENA_ARRAY(A,Node*,max_size+1);194debug_only( memset(defs,0,(max_size+1)*sizeof(Node*)) );195OopFlow *flow = new (A) OopFlow(callees+1, defs+1, C);196assert( &flow->_callees[OptoReg::Bad] == callees, "Ok to index at OptoReg::Bad" );197assert( &flow->_defs [OptoReg::Bad] == defs , "Ok to index at OptoReg::Bad" );198return flow;199}200201static int get_live_bit( int *live, int reg ) {202return live[reg>>LogBitsPerInt] & (1<<(reg&(BitsPerInt-1))); }203static void set_live_bit( int *live, int reg ) {204live[reg>>LogBitsPerInt] |= (1<<(reg&(BitsPerInt-1))); }205static void clr_live_bit( int *live, int reg ) {206live[reg>>LogBitsPerInt] &= ~(1<<(reg&(BitsPerInt-1))); }207208// Build an oopmap from the current flow info209OopMap *OopFlow::build_oop_map( Node *n, int max_reg, PhaseRegAlloc *regalloc, int* live ) {210int framesize = regalloc->_framesize;211int max_inarg_slot = OptoReg::reg2stack(regalloc->_matcher._new_SP);212debug_only( char *dup_check = NEW_RESOURCE_ARRAY(char,OptoReg::stack0());213memset(dup_check,0,OptoReg::stack0()) );214215OopMap *omap = new OopMap( framesize, max_inarg_slot );216MachCallNode *mcall = n->is_MachCall() ? n->as_MachCall() : NULL;217JVMState* jvms = n->jvms();218219// For all registers do...220for( int reg=0; reg<max_reg; reg++ ) {221if( get_live_bit(live,reg) == 0 )222continue; // Ignore if not live223224// %%% C2 can use 2 OptoRegs when the physical register is only one 64bit225// register in that case we'll get an non-concrete register for the second226// half. We only need to tell the map the register once!227//228// However for the moment we disable this change and leave things as they229// were.230231VMReg r = OptoReg::as_VMReg(OptoReg::Name(reg), framesize, max_inarg_slot);232233// See if dead (no reaching def).234Node *def = _defs[reg]; // Get reaching def235assert( def, "since live better have reaching def" );236237// Classify the reaching def as oop, derived, callee-save, dead, or other238const Type *t = def->bottom_type();239if( t->isa_oop_ptr() ) { // Oop or derived?240assert( !OptoReg::is_valid(_callees[reg]), "oop can't be callee save" );241#ifdef _LP64242// 64-bit pointers record oop-ishness on 2 aligned adjacent registers.243// Make sure both are record from the same reaching def, but do not244// put both into the oopmap.245if( (reg&1) == 1 ) { // High half of oop-pair?246assert( _defs[reg-1] == _defs[reg], "both halves from same reaching def" );247continue; // Do not record high parts in oopmap248}249#endif250251// Check for a legal reg name in the oopMap and bailout if it is not.252if (!omap->legal_vm_reg_name(r)) {253regalloc->C->record_method_not_compilable("illegal oopMap register name");254continue;255}256if( t->is_ptr()->_offset == 0 ) { // Not derived?257if( mcall ) {258// Outgoing argument GC mask responsibility belongs to the callee,259// not the caller. Inspect the inputs to the call, to see if260// this live-range is one of them.261uint cnt = mcall->tf()->domain()->cnt();262uint j;263for( j = TypeFunc::Parms; j < cnt; j++)264if( mcall->in(j) == def )265break; // reaching def is an argument oop266if( j < cnt ) // arg oops dont go in GC map267continue; // Continue on to the next register268}269omap->set_oop(r);270} else { // Else it's derived.271// Find the base of the derived value.272uint i;273// Fast, common case, scan274for( i = jvms->oopoff(); i < n->req(); i+=2 )275if( n->in(i) == def ) break; // Common case276if( i == n->req() ) { // Missed, try a more generous scan277// Scan again, but this time peek through copies278for( i = jvms->oopoff(); i < n->req(); i+=2 ) {279Node *m = n->in(i); // Get initial derived value280while( 1 ) {281Node *d = def; // Get initial reaching def282while( 1 ) { // Follow copies of reaching def to end283if( m == d ) goto found; // breaks 3 loops284int idx = d->is_Copy();285if( !idx ) break;286d = d->in(idx); // Link through copy287}288int idx = m->is_Copy();289if( !idx ) break;290m = m->in(idx);291}292}293guarantee( 0, "must find derived/base pair" );294}295found: ;296Node *base = n->in(i+1); // Base is other half of pair297int breg = regalloc->get_reg_first(base);298VMReg b = OptoReg::as_VMReg(OptoReg::Name(breg), framesize, max_inarg_slot);299300// I record liveness at safepoints BEFORE I make the inputs301// live. This is because argument oops are NOT live at a302// safepoint (or at least they cannot appear in the oopmap).303// Thus bases of base/derived pairs might not be in the304// liveness data but they need to appear in the oopmap.305if( get_live_bit(live,breg) == 0 ) {// Not live?306// Flag it, so next derived pointer won't re-insert into oopmap307set_live_bit(live,breg);308// Already missed our turn?309if( breg < reg ) {310omap->set_oop(b);311}312}313omap->set_derived_oop(r, b);314}315316} else if( t->isa_narrowoop() ) {317assert( !OptoReg::is_valid(_callees[reg]), "oop can't be callee save" );318// Check for a legal reg name in the oopMap and bailout if it is not.319if (!omap->legal_vm_reg_name(r)) {320regalloc->C->record_method_not_compilable("illegal oopMap register name");321continue;322}323if( mcall ) {324// Outgoing argument GC mask responsibility belongs to the callee,325// not the caller. Inspect the inputs to the call, to see if326// this live-range is one of them.327uint cnt = mcall->tf()->domain()->cnt();328uint j;329for( j = TypeFunc::Parms; j < cnt; j++)330if( mcall->in(j) == def )331break; // reaching def is an argument oop332if( j < cnt ) // arg oops dont go in GC map333continue; // Continue on to the next register334}335omap->set_narrowoop(r);336} else if( OptoReg::is_valid(_callees[reg])) { // callee-save?337// It's a callee-save value338assert( dup_check[_callees[reg]]==0, "trying to callee save same reg twice" );339debug_only( dup_check[_callees[reg]]=1; )340VMReg callee = OptoReg::as_VMReg(OptoReg::Name(_callees[reg]));341omap->set_callee_saved(r, callee);342343} else {344// Other - some reaching non-oop value345#ifdef ASSERT346if( t->isa_rawptr() && C->cfg()->_raw_oops.member(def) ) {347def->dump();348n->dump();349assert(false, "there should be a oop in OopMap instead of a live raw oop at safepoint");350}351#endif352}353354}355356#ifdef ASSERT357/* Nice, Intel-only assert358int cnt_callee_saves=0;359int reg2 = 0;360while (OptoReg::is_reg(reg2)) {361if( dup_check[reg2] != 0) cnt_callee_saves++;362assert( cnt_callee_saves==3 || cnt_callee_saves==5, "missed some callee-save" );363reg2++;364}365*/366#endif367368#ifdef ASSERT369for( OopMapStream oms1(omap); !oms1.is_done(); oms1.next()) {370OopMapValue omv1 = oms1.current();371if (omv1.type() != OopMapValue::derived_oop_value) {372continue;373}374bool found = false;375for( OopMapStream oms2(omap); !oms2.is_done(); oms2.next()) {376OopMapValue omv2 = oms2.current();377if (omv2.type() != OopMapValue::oop_value) {378continue;379}380if( omv1.content_reg() == omv2.reg() ) {381found = true;382break;383}384}385assert( found, "derived with no base in oopmap" );386}387#endif388389return omap;390}391392// Compute backwards liveness on registers393static void do_liveness(PhaseRegAlloc* regalloc, PhaseCFG* cfg, Block_List* worklist, int max_reg_ints, Arena* A, Dict* safehash) {394int* live = NEW_ARENA_ARRAY(A, int, (cfg->number_of_blocks() + 1) * max_reg_ints);395int* tmp_live = &live[cfg->number_of_blocks() * max_reg_ints];396Node* root = cfg->get_root_node();397// On CISC platforms, get the node representing the stack pointer that regalloc398// used for spills399Node *fp = NodeSentinel;400if (UseCISCSpill && root->req() > 1) {401fp = root->in(1)->in(TypeFunc::FramePtr);402}403memset(live, 0, cfg->number_of_blocks() * (max_reg_ints << LogBytesPerInt));404// Push preds onto worklist405for (uint i = 1; i < root->req(); i++) {406Block* block = cfg->get_block_for_node(root->in(i));407worklist->push(block);408}409410// ZKM.jar includes tiny infinite loops which are unreached from below.411// If we missed any blocks, we'll retry here after pushing all missed412// blocks on the worklist. Normally this outer loop never trips more413// than once.414while (1) {415416while( worklist->size() ) { // Standard worklist algorithm417Block *b = worklist->rpop();418419// Copy first successor into my tmp_live space420int s0num = b->_succs[0]->_pre_order;421int *t = &live[s0num*max_reg_ints];422for( int i=0; i<max_reg_ints; i++ )423tmp_live[i] = t[i];424425// OR in the remaining live registers426for( uint j=1; j<b->_num_succs; j++ ) {427uint sjnum = b->_succs[j]->_pre_order;428int *t = &live[sjnum*max_reg_ints];429for( int i=0; i<max_reg_ints; i++ )430tmp_live[i] |= t[i];431}432433// Now walk tmp_live up the block backwards, computing live434for( int k=b->number_of_nodes()-1; k>=0; k-- ) {435Node *n = b->get_node(k);436// KILL def'd bits437int first = regalloc->get_reg_first(n);438int second = regalloc->get_reg_second(n);439if( OptoReg::is_valid(first) ) clr_live_bit(tmp_live,first);440if( OptoReg::is_valid(second) ) clr_live_bit(tmp_live,second);441442MachNode *m = n->is_Mach() ? n->as_Mach() : NULL;443444// Check if m is potentially a CISC alternate instruction (i.e, possibly445// synthesized by RegAlloc from a conventional instruction and a446// spilled input)447bool is_cisc_alternate = false;448if (UseCISCSpill && m) {449is_cisc_alternate = m->is_cisc_alternate();450}451452// GEN use'd bits453for( uint l=1; l<n->req(); l++ ) {454Node *def = n->in(l);455assert(def != 0, "input edge required");456int first = regalloc->get_reg_first(def);457int second = regalloc->get_reg_second(def);458if( OptoReg::is_valid(first) ) set_live_bit(tmp_live,first);459if( OptoReg::is_valid(second) ) set_live_bit(tmp_live,second);460// If we use the stack pointer in a cisc-alternative instruction,461// check for use as a memory operand. Then reconstruct the RegName462// for this stack location, and set the appropriate bit in the463// live vector 4987749.464if (is_cisc_alternate && def == fp) {465const TypePtr *adr_type = NULL;466intptr_t offset;467const Node* base = m->get_base_and_disp(offset, adr_type);468if (base == NodeSentinel) {469// Machnode has multiple memory inputs. We are unable to reason470// with these, but are presuming (with trepidation) that not any of471// them are oops. This can be fixed by making get_base_and_disp()472// look at a specific input instead of all inputs.473assert(!def->bottom_type()->isa_oop_ptr(), "expecting non-oop mem input");474} else if (base != fp || offset == Type::OffsetBot) {475// Do nothing: the fp operand is either not from a memory use476// (base == NULL) OR the fp is used in a non-memory context477// (base is some other register) OR the offset is not constant,478// so it is not a stack slot.479} else {480assert(offset >= 0, "unexpected negative offset");481offset -= (offset % jintSize); // count the whole word482int stack_reg = regalloc->offset2reg(offset);483if (OptoReg::is_stack(stack_reg)) {484set_live_bit(tmp_live, stack_reg);485} else {486assert(false, "stack_reg not on stack?");487}488}489}490}491492if( n->jvms() ) { // Record liveness at safepoint493494// This placement of this stanza means inputs to calls are495// considered live at the callsite's OopMap. Argument oops are496// hence live, but NOT included in the oopmap. See cutout in497// build_oop_map. Debug oops are live (and in OopMap).498int *n_live = NEW_ARENA_ARRAY(A, int, max_reg_ints);499for( int l=0; l<max_reg_ints; l++ )500n_live[l] = tmp_live[l];501safehash->Insert(n,n_live);502}503504}505506// Now at block top, see if we have any changes. If so, propagate507// to prior blocks.508int *old_live = &live[b->_pre_order*max_reg_ints];509int l;510for( l=0; l<max_reg_ints; l++ )511if( tmp_live[l] != old_live[l] )512break;513if( l<max_reg_ints ) { // Change!514// Copy in new value515for( l=0; l<max_reg_ints; l++ )516old_live[l] = tmp_live[l];517// Push preds onto worklist518for (l = 1; l < (int)b->num_preds(); l++) {519Block* block = cfg->get_block_for_node(b->pred(l));520worklist->push(block);521}522}523}524525// Scan for any missing safepoints. Happens to infinite loops526// ala ZKM.jar527uint i;528for (i = 1; i < cfg->number_of_blocks(); i++) {529Block* block = cfg->get_block(i);530uint j;531for (j = 1; j < block->number_of_nodes(); j++) {532if (block->get_node(j)->jvms() && (*safehash)[block->get_node(j)] == NULL) {533break;534}535}536if (j < block->number_of_nodes()) {537break;538}539}540if (i == cfg->number_of_blocks()) {541break; // Got 'em all542}543544if (PrintOpto && Verbose) {545tty->print_cr("retripping live calc");546}547548// Force the issue (expensively): recheck everybody549for (i = 1; i < cfg->number_of_blocks(); i++) {550worklist->push(cfg->get_block(i));551}552}553}554555// Collect GC mask info - where are all the OOPs?556void PhaseOutput::BuildOopMaps() {557Compile::TracePhase tp("bldOopMaps", &timers[_t_buildOopMaps]);558// Can't resource-mark because I need to leave all those OopMaps around,559// or else I need to resource-mark some arena other than the default.560// ResourceMark rm; // Reclaim all OopFlows when done561int max_reg = C->regalloc()->_max_reg; // Current array extent562563Arena *A = Thread::current()->resource_area();564Block_List worklist; // Worklist of pending blocks565566int max_reg_ints = align_up(max_reg, BitsPerInt)>>LogBitsPerInt;567Dict *safehash = NULL; // Used for assert only568// Compute a backwards liveness per register. Needs a bitarray of569// #blocks x (#registers, rounded up to ints)570safehash = new Dict(cmpkey,hashkey,A);571do_liveness( C->regalloc(), C->cfg(), &worklist, max_reg_ints, A, safehash );572OopFlow *free_list = NULL; // Free, unused573574// Array mapping blocks to completed oopflows575OopFlow **flows = NEW_ARENA_ARRAY(A, OopFlow*, C->cfg()->number_of_blocks());576memset( flows, 0, C->cfg()->number_of_blocks() * sizeof(OopFlow*) );577578579// Do the first block 'by hand' to prime the worklist580Block *entry = C->cfg()->get_block(1);581OopFlow *rootflow = OopFlow::make(A,max_reg,C);582// Initialize to 'bottom' (not 'top')583memset( rootflow->_callees, OptoReg::Bad, max_reg*sizeof(short) );584memset( rootflow->_defs , 0, max_reg*sizeof(Node*) );585flows[entry->_pre_order] = rootflow;586587// Do the first block 'by hand' to prime the worklist588rootflow->_b = entry;589rootflow->compute_reach( C->regalloc(), max_reg, safehash );590for( uint i=0; i<entry->_num_succs; i++ )591worklist.push(entry->_succs[i]);592593// Now worklist contains blocks which have some, but perhaps not all,594// predecessors visited.595while( worklist.size() ) {596// Scan for a block with all predecessors visited, or any randoms slob597// otherwise. All-preds-visited order allows me to recycle OopFlow598// structures rapidly and cut down on the memory footprint.599// Note: not all predecessors might be visited yet (must happen for600// irreducible loops). This is OK, since every live value must have the601// SAME reaching def for the block, so any reaching def is OK.602uint i;603604Block *b = worklist.pop();605// Ignore root block606if (b == C->cfg()->get_root_block()) {607continue;608}609// Block is already done? Happens if block has several predecessors,610// he can get on the worklist more than once.611if( flows[b->_pre_order] ) continue;612613// If this block has a visited predecessor AND that predecessor has this614// last block as his only undone child, we can move the OopFlow from the615// pred to this block. Otherwise we have to grab a new OopFlow.616OopFlow *flow = NULL; // Flag for finding optimized flow617Block *pred = (Block*)((intptr_t)0xdeadbeef);618// Scan this block's preds to find a done predecessor619for (uint j = 1; j < b->num_preds(); j++) {620Block* p = C->cfg()->get_block_for_node(b->pred(j));621OopFlow *p_flow = flows[p->_pre_order];622if( p_flow ) { // Predecessor is done623assert( p_flow->_b == p, "cross check" );624pred = p; // Record some predecessor625// If all successors of p are done except for 'b', then we can carry626// p_flow forward to 'b' without copying, otherwise we have to draw627// from the free_list and clone data.628uint k;629for( k=0; k<p->_num_succs; k++ )630if( !flows[p->_succs[k]->_pre_order] &&631p->_succs[k] != b )632break;633634// Either carry-forward the now-unused OopFlow for b's use635// or draw a new one from the free list636if( k==p->_num_succs ) {637flow = p_flow;638break; // Found an ideal pred, use him639}640}641}642643if( flow ) {644// We have an OopFlow that's the last-use of a predecessor.645// Carry it forward.646} else { // Draw a new OopFlow from the freelist647if( !free_list )648free_list = OopFlow::make(A,max_reg,C);649flow = free_list;650assert( flow->_b == NULL, "oopFlow is not free" );651free_list = flow->_next;652flow->_next = NULL;653654// Copy/clone over the data655flow->clone(flows[pred->_pre_order], max_reg);656}657658// Mark flow for block. Blocks can only be flowed over once,659// because after the first time they are guarded from entering660// this code again.661assert( flow->_b == pred, "have some prior flow" );662flow->_b = NULL;663664// Now push flow forward665flows[b->_pre_order] = flow;// Mark flow for this block666flow->_b = b;667flow->compute_reach( C->regalloc(), max_reg, safehash );668669// Now push children onto worklist670for( i=0; i<b->_num_succs; i++ )671worklist.push(b->_succs[i]);672673}674}675676677