Path: blob/master/src/hotspot/share/opto/chaitin.cpp
40930 views
/*1* Copyright (c) 2000, 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 "compiler/compileLog.hpp"26#include "compiler/oopMap.hpp"27#include "memory/allocation.inline.hpp"28#include "memory/resourceArea.hpp"29#include "opto/addnode.hpp"30#include "opto/block.hpp"31#include "opto/callnode.hpp"32#include "opto/cfgnode.hpp"33#include "opto/chaitin.hpp"34#include "opto/coalesce.hpp"35#include "opto/connode.hpp"36#include "opto/idealGraphPrinter.hpp"37#include "opto/indexSet.hpp"38#include "opto/machnode.hpp"39#include "opto/memnode.hpp"40#include "opto/movenode.hpp"41#include "opto/opcodes.hpp"42#include "opto/rootnode.hpp"43#include "utilities/align.hpp"4445#ifndef PRODUCT46void LRG::dump() const {47ttyLocker ttyl;48tty->print("%d ",num_regs());49_mask.dump();50if( _msize_valid ) {51if( mask_size() == compute_mask_size() ) tty->print(", #%d ",_mask_size);52else tty->print(", #!!!_%d_vs_%d ",_mask_size,_mask.Size());53} else {54tty->print(", #?(%d) ",_mask.Size());55}5657tty->print("EffDeg: ");58if( _degree_valid ) tty->print( "%d ", _eff_degree );59else tty->print("? ");6061if( is_multidef() ) {62tty->print("MultiDef ");63if (_defs != NULL) {64tty->print("(");65for (int i = 0; i < _defs->length(); i++) {66tty->print("N%d ", _defs->at(i)->_idx);67}68tty->print(") ");69}70}71else if( _def == 0 ) tty->print("Dead ");72else tty->print("Def: N%d ",_def->_idx);7374tty->print("Cost:%4.2g Area:%4.2g Score:%4.2g ",_cost,_area, score());75// Flags76if( _is_oop ) tty->print("Oop ");77if( _is_float ) tty->print("Float ");78if( _is_vector ) tty->print("Vector ");79if( _is_scalable ) tty->print("Scalable ");80if( _was_spilled1 ) tty->print("Spilled ");81if( _was_spilled2 ) tty->print("Spilled2 ");82if( _direct_conflict ) tty->print("Direct_conflict ");83if( _fat_proj ) tty->print("Fat ");84if( _was_lo ) tty->print("Lo ");85if( _has_copy ) tty->print("Copy ");86if( _at_risk ) tty->print("Risk ");8788if( _must_spill ) tty->print("Must_spill ");89if( _is_bound ) tty->print("Bound ");90if( _msize_valid ) {91if( _degree_valid && lo_degree() ) tty->print("Trivial ");92}9394tty->cr();95}96#endif9798// Compute score from cost and area. Low score is best to spill.99static double raw_score( double cost, double area ) {100return cost - (area*RegisterCostAreaRatio) * 1.52588e-5;101}102103double LRG::score() const {104// Scale _area by RegisterCostAreaRatio/64K then subtract from cost.105// Bigger area lowers score, encourages spilling this live range.106// Bigger cost raise score, prevents spilling this live range.107// (Note: 1/65536 is the magic constant below; I dont trust the C optimizer108// to turn a divide by a constant into a multiply by the reciprical).109double score = raw_score( _cost, _area);110111// Account for area. Basically, LRGs covering large areas are better112// to spill because more other LRGs get freed up.113if( _area == 0.0 ) // No area? Then no progress to spill114return 1e35;115116if( _was_spilled2 ) // If spilled once before, we are unlikely117return score + 1e30; // to make progress again.118119if( _cost >= _area*3.0 ) // Tiny area relative to cost120return score + 1e17; // Probably no progress to spill121122if( (_cost+_cost) >= _area*3.0 ) // Small area relative to cost123return score + 1e10; // Likely no progress to spill124125return score;126}127128#define NUMBUCKS 3129130// Straight out of Tarjan's union-find algorithm131uint LiveRangeMap::find_compress(uint lrg) {132uint cur = lrg;133uint next = _uf_map.at(cur);134while (next != cur) { // Scan chain of equivalences135assert( next < cur, "always union smaller");136cur = next; // until find a fixed-point137next = _uf_map.at(cur);138}139140// Core of union-find algorithm: update chain of141// equivalences to be equal to the root.142while (lrg != next) {143uint tmp = _uf_map.at(lrg);144_uf_map.at_put(lrg, next);145lrg = tmp;146}147return lrg;148}149150// Reset the Union-Find map to identity151void LiveRangeMap::reset_uf_map(uint max_lrg_id) {152_max_lrg_id= max_lrg_id;153// Force the Union-Find mapping to be at least this large154_uf_map.at_put_grow(_max_lrg_id, 0);155// Initialize it to be the ID mapping.156for (uint i = 0; i < _max_lrg_id; ++i) {157_uf_map.at_put(i, i);158}159}160161// Make all Nodes map directly to their final live range; no need for162// the Union-Find mapping after this call.163void LiveRangeMap::compress_uf_map_for_nodes() {164// For all Nodes, compress mapping165uint unique = _names.length();166for (uint i = 0; i < unique; ++i) {167uint lrg = _names.at(i);168uint compressed_lrg = find(lrg);169if (lrg != compressed_lrg) {170_names.at_put(i, compressed_lrg);171}172}173}174175// Like Find above, but no path compress, so bad asymptotic behavior176uint LiveRangeMap::find_const(uint lrg) const {177if (!lrg) {178return lrg; // Ignore the zero LRG179}180181// Off the end? This happens during debugging dumps when you got182// brand new live ranges but have not told the allocator yet.183if (lrg >= _max_lrg_id) {184return lrg;185}186187uint next = _uf_map.at(lrg);188while (next != lrg) { // Scan chain of equivalences189assert(next < lrg, "always union smaller");190lrg = next; // until find a fixed-point191next = _uf_map.at(lrg);192}193return next;194}195196PhaseChaitin::PhaseChaitin(uint unique, PhaseCFG &cfg, Matcher &matcher, bool scheduling_info_generated)197: PhaseRegAlloc(unique, cfg, matcher,198#ifndef PRODUCT199print_chaitin_statistics200#else201NULL202#endif203)204, _live(0)205, _lo_degree(0), _lo_stk_degree(0), _hi_degree(0), _simplified(0)206, _oldphi(unique)207#ifndef PRODUCT208, _trace_spilling(C->directive()->TraceSpillingOption)209#endif210, _lrg_map(Thread::current()->resource_area(), unique)211, _scheduling_info_generated(scheduling_info_generated)212, _sched_int_pressure(0, INTPRESSURE)213, _sched_float_pressure(0, FLOATPRESSURE)214, _scratch_int_pressure(0, INTPRESSURE)215, _scratch_float_pressure(0, FLOATPRESSURE)216{217Compile::TracePhase tp("ctorChaitin", &timers[_t_ctorChaitin]);218219_high_frequency_lrg = MIN2(double(OPTO_LRG_HIGH_FREQ), _cfg.get_outer_loop_frequency());220221// Build a list of basic blocks, sorted by frequency222_blks = NEW_RESOURCE_ARRAY(Block *, _cfg.number_of_blocks());223// Experiment with sorting strategies to speed compilation224double cutoff = BLOCK_FREQUENCY(1.0); // Cutoff for high frequency bucket225Block **buckets[NUMBUCKS]; // Array of buckets226uint buckcnt[NUMBUCKS]; // Array of bucket counters227double buckval[NUMBUCKS]; // Array of bucket value cutoffs228for (uint i = 0; i < NUMBUCKS; i++) {229buckets[i] = NEW_RESOURCE_ARRAY(Block *, _cfg.number_of_blocks());230buckcnt[i] = 0;231// Bump by three orders of magnitude each time232cutoff *= 0.001;233buckval[i] = cutoff;234for (uint j = 0; j < _cfg.number_of_blocks(); j++) {235buckets[i][j] = NULL;236}237}238// Sort blocks into buckets239for (uint i = 0; i < _cfg.number_of_blocks(); i++) {240for (uint j = 0; j < NUMBUCKS; j++) {241if ((j == NUMBUCKS - 1) || (_cfg.get_block(i)->_freq > buckval[j])) {242// Assign block to end of list for appropriate bucket243buckets[j][buckcnt[j]++] = _cfg.get_block(i);244break; // kick out of inner loop245}246}247}248// Dump buckets into final block array249uint blkcnt = 0;250for (uint i = 0; i < NUMBUCKS; i++) {251for (uint j = 0; j < buckcnt[i]; j++) {252_blks[blkcnt++] = buckets[i][j];253}254}255256assert(blkcnt == _cfg.number_of_blocks(), "Block array not totally filled");257}258259// union 2 sets together.260void PhaseChaitin::Union( const Node *src_n, const Node *dst_n ) {261uint src = _lrg_map.find(src_n);262uint dst = _lrg_map.find(dst_n);263assert(src, "");264assert(dst, "");265assert(src < _lrg_map.max_lrg_id(), "oob");266assert(dst < _lrg_map.max_lrg_id(), "oob");267assert(src < dst, "always union smaller");268_lrg_map.uf_map(dst, src);269}270271void PhaseChaitin::new_lrg(const Node *x, uint lrg) {272// Make the Node->LRG mapping273_lrg_map.extend(x->_idx,lrg);274// Make the Union-Find mapping an identity function275_lrg_map.uf_extend(lrg, lrg);276}277278279int PhaseChaitin::clone_projs(Block* b, uint idx, Node* orig, Node* copy, uint& max_lrg_id) {280assert(b->find_node(copy) == (idx - 1), "incorrect insert index for copy kill projections");281DEBUG_ONLY( Block* borig = _cfg.get_block_for_node(orig); )282int found_projs = 0;283uint cnt = orig->outcnt();284for (uint i = 0; i < cnt; i++) {285Node* proj = orig->raw_out(i);286if (proj->is_MachProj()) {287assert(proj->outcnt() == 0, "only kill projections are expected here");288assert(_cfg.get_block_for_node(proj) == borig, "incorrect block for kill projections");289found_projs++;290// Copy kill projections after the cloned node291Node* kills = proj->clone();292kills->set_req(0, copy);293b->insert_node(kills, idx++);294_cfg.map_node_to_block(kills, b);295new_lrg(kills, max_lrg_id++);296}297}298return found_projs;299}300301// Renumber the live ranges to compact them. Makes the IFG smaller.302void PhaseChaitin::compact() {303Compile::TracePhase tp("chaitinCompact", &timers[_t_chaitinCompact]);304305// Current the _uf_map contains a series of short chains which are headed306// by a self-cycle. All the chains run from big numbers to little numbers.307// The Find() call chases the chains & shortens them for the next Find call.308// We are going to change this structure slightly. Numbers above a moving309// wave 'i' are unchanged. Numbers below 'j' point directly to their310// compacted live range with no further chaining. There are no chains or311// cycles below 'i', so the Find call no longer works.312uint j=1;313uint i;314for (i = 1; i < _lrg_map.max_lrg_id(); i++) {315uint lr = _lrg_map.uf_live_range_id(i);316// Ignore unallocated live ranges317if (!lr) {318continue;319}320assert(lr <= i, "");321_lrg_map.uf_map(i, ( lr == i ) ? j++ : _lrg_map.uf_live_range_id(lr));322}323// Now change the Node->LR mapping to reflect the compacted names324uint unique = _lrg_map.size();325for (i = 0; i < unique; i++) {326uint lrg_id = _lrg_map.live_range_id(i);327_lrg_map.map(i, _lrg_map.uf_live_range_id(lrg_id));328}329330// Reset the Union-Find mapping331_lrg_map.reset_uf_map(j);332}333334void PhaseChaitin::Register_Allocate() {335336// Above the OLD FP (and in registers) are the incoming arguments. Stack337// slots in this area are called "arg_slots". Above the NEW FP (and in338// registers) is the outgoing argument area; above that is the spill/temp339// area. These are all "frame_slots". Arg_slots start at the zero340// stack_slots and count up to the known arg_size. Frame_slots start at341// the stack_slot #arg_size and go up. After allocation I map stack342// slots to actual offsets. Stack-slots in the arg_slot area are biased343// by the frame_size; stack-slots in the frame_slot area are biased by 0.344345_trip_cnt = 0;346_alternate = 0;347_matcher._allocation_started = true;348349ResourceArea split_arena(mtCompiler); // Arena for Split local resources350ResourceArea live_arena(mtCompiler); // Arena for liveness & IFG info351ResourceMark rm(&live_arena);352353// Need live-ness for the IFG; need the IFG for coalescing. If the354// liveness is JUST for coalescing, then I can get some mileage by renaming355// all copy-related live ranges low and then using the max copy-related356// live range as a cut-off for LIVE and the IFG. In other words, I can357// build a subset of LIVE and IFG just for copies.358PhaseLive live(_cfg, _lrg_map.names(), &live_arena, false);359360// Need IFG for coalescing and coloring361PhaseIFG ifg(&live_arena);362_ifg = &ifg;363364// Come out of SSA world to the Named world. Assign (virtual) registers to365// Nodes. Use the same register for all inputs and the output of PhiNodes366// - effectively ending SSA form. This requires either coalescing live367// ranges or inserting copies. For the moment, we insert "virtual copies"368// - we pretend there is a copy prior to each Phi in predecessor blocks.369// We will attempt to coalesce such "virtual copies" before we manifest370// them for real.371de_ssa();372373#ifdef ASSERT374// Veify the graph before RA.375verify(&live_arena);376#endif377378{379Compile::TracePhase tp("computeLive", &timers[_t_computeLive]);380_live = NULL; // Mark live as being not available381rm.reset_to_mark(); // Reclaim working storage382IndexSet::reset_memory(C, &live_arena);383ifg.init(_lrg_map.max_lrg_id()); // Empty IFG384gather_lrg_masks( false ); // Collect LRG masks385live.compute(_lrg_map.max_lrg_id()); // Compute liveness386_live = &live; // Mark LIVE as being available387}388389// Base pointers are currently "used" by instructions which define new390// derived pointers. This makes base pointers live up to the where the391// derived pointer is made, but not beyond. Really, they need to be live392// across any GC point where the derived value is live. So this code looks393// at all the GC points, and "stretches" the live range of any base pointer394// to the GC point.395if (stretch_base_pointer_live_ranges(&live_arena)) {396Compile::TracePhase tp("computeLive (sbplr)", &timers[_t_computeLive]);397// Since some live range stretched, I need to recompute live398_live = NULL;399rm.reset_to_mark(); // Reclaim working storage400IndexSet::reset_memory(C, &live_arena);401ifg.init(_lrg_map.max_lrg_id());402gather_lrg_masks(false);403live.compute(_lrg_map.max_lrg_id());404_live = &live;405}406// Create the interference graph using virtual copies407build_ifg_virtual(); // Include stack slots this time408409// The IFG is/was triangular. I am 'squaring it up' so Union can run410// faster. Union requires a 'for all' operation which is slow on the411// triangular adjacency matrix (quick reminder: the IFG is 'sparse' -412// meaning I can visit all the Nodes neighbors less than a Node in time413// O(# of neighbors), but I have to visit all the Nodes greater than a414// given Node and search them for an instance, i.e., time O(#MaxLRG)).415_ifg->SquareUp();416417// Aggressive (but pessimistic) copy coalescing.418// This pass works on virtual copies. Any virtual copies which are not419// coalesced get manifested as actual copies420{421Compile::TracePhase tp("chaitinCoalesce1", &timers[_t_chaitinCoalesce1]);422423PhaseAggressiveCoalesce coalesce(*this);424coalesce.coalesce_driver();425// Insert un-coalesced copies. Visit all Phis. Where inputs to a Phi do426// not match the Phi itself, insert a copy.427coalesce.insert_copies(_matcher);428if (C->failing()) {429return;430}431}432433// After aggressive coalesce, attempt a first cut at coloring.434// To color, we need the IFG and for that we need LIVE.435{436Compile::TracePhase tp("computeLive", &timers[_t_computeLive]);437_live = NULL;438rm.reset_to_mark(); // Reclaim working storage439IndexSet::reset_memory(C, &live_arena);440ifg.init(_lrg_map.max_lrg_id());441gather_lrg_masks( true );442live.compute(_lrg_map.max_lrg_id());443_live = &live;444}445446// Build physical interference graph447uint must_spill = 0;448must_spill = build_ifg_physical(&live_arena);449// If we have a guaranteed spill, might as well spill now450if (must_spill) {451if(!_lrg_map.max_lrg_id()) {452return;453}454// Bail out if unique gets too large (ie - unique > MaxNodeLimit)455C->check_node_count(10*must_spill, "out of nodes before split");456if (C->failing()) {457return;458}459460uint new_max_lrg_id = Split(_lrg_map.max_lrg_id(), &split_arena); // Split spilling LRG everywhere461_lrg_map.set_max_lrg_id(new_max_lrg_id);462// Bail out if unique gets too large (ie - unique > MaxNodeLimit - 2*NodeLimitFudgeFactor)463// or we failed to split464C->check_node_count(2*NodeLimitFudgeFactor, "out of nodes after physical split");465if (C->failing()) {466return;467}468469NOT_PRODUCT(C->verify_graph_edges();)470471compact(); // Compact LRGs; return new lower max lrg472473{474Compile::TracePhase tp("computeLive", &timers[_t_computeLive]);475_live = NULL;476rm.reset_to_mark(); // Reclaim working storage477IndexSet::reset_memory(C, &live_arena);478ifg.init(_lrg_map.max_lrg_id()); // Build a new interference graph479gather_lrg_masks( true ); // Collect intersect mask480live.compute(_lrg_map.max_lrg_id()); // Compute LIVE481_live = &live;482}483build_ifg_physical(&live_arena);484_ifg->SquareUp();485_ifg->Compute_Effective_Degree();486// Only do conservative coalescing if requested487if (OptoCoalesce) {488Compile::TracePhase tp("chaitinCoalesce2", &timers[_t_chaitinCoalesce2]);489// Conservative (and pessimistic) copy coalescing of those spills490PhaseConservativeCoalesce coalesce(*this);491// If max live ranges greater than cutoff, don't color the stack.492// This cutoff can be larger than below since it is only done once.493coalesce.coalesce_driver();494}495_lrg_map.compress_uf_map_for_nodes();496497#ifdef ASSERT498verify(&live_arena, true);499#endif500} else {501ifg.SquareUp();502ifg.Compute_Effective_Degree();503#ifdef ASSERT504set_was_low();505#endif506}507508// Prepare for Simplify & Select509cache_lrg_info(); // Count degree of LRGs510511// Simplify the InterFerence Graph by removing LRGs of low degree.512// LRGs of low degree are trivially colorable.513Simplify();514515// Select colors by re-inserting LRGs back into the IFG in reverse order.516// Return whether or not something spills.517uint spills = Select( );518519// If we spill, split and recycle the entire thing520while( spills ) {521if( _trip_cnt++ > 24 ) {522DEBUG_ONLY( dump_for_spill_split_recycle(); )523if( _trip_cnt > 27 ) {524C->record_method_not_compilable("failed spill-split-recycle sanity check");525return;526}527}528529if (!_lrg_map.max_lrg_id()) {530return;531}532uint new_max_lrg_id = Split(_lrg_map.max_lrg_id(), &split_arena); // Split spilling LRG everywhere533_lrg_map.set_max_lrg_id(new_max_lrg_id);534// Bail out if unique gets too large (ie - unique > MaxNodeLimit - 2*NodeLimitFudgeFactor)535C->check_node_count(2 * NodeLimitFudgeFactor, "out of nodes after split");536if (C->failing()) {537return;538}539540compact(); // Compact LRGs; return new lower max lrg541542// Nuke the live-ness and interference graph and LiveRanGe info543{544Compile::TracePhase tp("computeLive", &timers[_t_computeLive]);545_live = NULL;546rm.reset_to_mark(); // Reclaim working storage547IndexSet::reset_memory(C, &live_arena);548ifg.init(_lrg_map.max_lrg_id());549550// Create LiveRanGe array.551// Intersect register masks for all USEs and DEFs552gather_lrg_masks(true);553live.compute(_lrg_map.max_lrg_id());554_live = &live;555}556must_spill = build_ifg_physical(&live_arena);557_ifg->SquareUp();558_ifg->Compute_Effective_Degree();559560// Only do conservative coalescing if requested561if (OptoCoalesce) {562Compile::TracePhase tp("chaitinCoalesce3", &timers[_t_chaitinCoalesce3]);563// Conservative (and pessimistic) copy coalescing564PhaseConservativeCoalesce coalesce(*this);565// Check for few live ranges determines how aggressive coalesce is.566coalesce.coalesce_driver();567}568_lrg_map.compress_uf_map_for_nodes();569#ifdef ASSERT570verify(&live_arena, true);571#endif572cache_lrg_info(); // Count degree of LRGs573574// Simplify the InterFerence Graph by removing LRGs of low degree.575// LRGs of low degree are trivially colorable.576Simplify();577578// Select colors by re-inserting LRGs back into the IFG in reverse order.579// Return whether or not something spills.580spills = Select();581}582583// Count number of Simplify-Select trips per coloring success.584_allocator_attempts += _trip_cnt + 1;585_allocator_successes += 1;586587// Peephole remove copies588post_allocate_copy_removal();589590// Merge multidefs if multiple defs representing the same value are used in a single block.591merge_multidefs();592593#ifdef ASSERT594// Veify the graph after RA.595verify(&live_arena);596#endif597598// max_reg is past the largest *register* used.599// Convert that to a frame_slot number.600if (_max_reg <= _matcher._new_SP) {601_framesize = C->out_preserve_stack_slots();602}603else {604_framesize = _max_reg -_matcher._new_SP;605}606assert((int)(_matcher._new_SP+_framesize) >= (int)_matcher._out_arg_limit, "framesize must be large enough");607608// This frame must preserve the required fp alignment609_framesize = align_up(_framesize, Matcher::stack_alignment_in_slots());610assert(_framesize <= 1000000, "sanity check");611#ifndef PRODUCT612_total_framesize += _framesize;613if ((int)_framesize > _max_framesize) {614_max_framesize = _framesize;615}616#endif617618// Convert CISC spills619fixup_spills();620621// Log regalloc results622CompileLog* log = Compile::current()->log();623if (log != NULL) {624log->elem("regalloc attempts='%d' success='%d'", _trip_cnt, !C->failing());625}626627if (C->failing()) {628return;629}630631NOT_PRODUCT(C->verify_graph_edges();)632633// Move important info out of the live_arena to longer lasting storage.634alloc_node_regs(_lrg_map.size());635for (uint i=0; i < _lrg_map.size(); i++) {636if (_lrg_map.live_range_id(i)) { // Live range associated with Node?637LRG &lrg = lrgs(_lrg_map.live_range_id(i));638if (!lrg.alive()) {639set_bad(i);640} else if (lrg.num_regs() == 1) {641set1(i, lrg.reg());642} else { // Must be a register-set643if (!lrg._fat_proj) { // Must be aligned adjacent register set644// Live ranges record the highest register in their mask.645// We want the low register for the AD file writer's convenience.646OptoReg::Name hi = lrg.reg(); // Get hi register647int num_regs = lrg.num_regs();648if (lrg.is_scalable() && OptoReg::is_stack(hi)) {649// For scalable vector registers, when they are allocated in physical650// registers, num_regs is RegMask::SlotsPerVecA for reg mask of scalable651// vector. If they are allocated on stack, we need to get the actual652// num_regs, which reflects the physical length of scalable registers.653num_regs = lrg.scalable_reg_slots();654}655OptoReg::Name lo = OptoReg::add(hi, (1-num_regs)); // Find lo656// We have to use pair [lo,lo+1] even for wide vectors because657// the rest of code generation works only with pairs. It is safe658// since for registers encoding only 'lo' is used.659// Second reg from pair is used in ScheduleAndBundle on SPARC where660// vector max size is 8 which corresponds to registers pair.661// It is also used in BuildOopMaps but oop operations are not662// vectorized.663set2(i, lo);664} else { // Misaligned; extract 2 bits665OptoReg::Name hi = lrg.reg(); // Get hi register666lrg.Remove(hi); // Yank from mask667int lo = lrg.mask().find_first_elem(); // Find lo668set_pair(i, hi, lo);669}670}671if( lrg._is_oop ) _node_oops.set(i);672} else {673set_bad(i);674}675}676677// Done!678_live = NULL;679_ifg = NULL;680C->set_indexSet_arena(NULL); // ResourceArea is at end of scope681}682683void PhaseChaitin::de_ssa() {684// Set initial Names for all Nodes. Most Nodes get the virtual register685// number. A few get the ZERO live range number. These do not686// get allocated, but instead rely on correct scheduling to ensure that687// only one instance is simultaneously live at a time.688uint lr_counter = 1;689for( uint i = 0; i < _cfg.number_of_blocks(); i++ ) {690Block* block = _cfg.get_block(i);691uint cnt = block->number_of_nodes();692693// Handle all the normal Nodes in the block694for( uint j = 0; j < cnt; j++ ) {695Node *n = block->get_node(j);696// Pre-color to the zero live range, or pick virtual register697const RegMask &rm = n->out_RegMask();698_lrg_map.map(n->_idx, rm.is_NotEmpty() ? lr_counter++ : 0);699}700}701702// Reset the Union-Find mapping to be identity703_lrg_map.reset_uf_map(lr_counter);704}705706void PhaseChaitin::mark_ssa() {707// Use ssa names to populate the live range maps or if no mask708// is available, use the 0 entry.709uint max_idx = 0;710for ( uint i = 0; i < _cfg.number_of_blocks(); i++ ) {711Block* block = _cfg.get_block(i);712uint cnt = block->number_of_nodes();713714// Handle all the normal Nodes in the block715for ( uint j = 0; j < cnt; j++ ) {716Node *n = block->get_node(j);717// Pre-color to the zero live range, or pick virtual register718const RegMask &rm = n->out_RegMask();719_lrg_map.map(n->_idx, rm.is_NotEmpty() ? n->_idx : 0);720max_idx = (n->_idx > max_idx) ? n->_idx : max_idx;721}722}723_lrg_map.set_max_lrg_id(max_idx+1);724725// Reset the Union-Find mapping to be identity726_lrg_map.reset_uf_map(max_idx+1);727}728729730// Gather LiveRanGe information, including register masks. Modification of731// cisc spillable in_RegMasks should not be done before AggressiveCoalesce.732void PhaseChaitin::gather_lrg_masks( bool after_aggressive ) {733734// Nail down the frame pointer live range735uint fp_lrg = _lrg_map.live_range_id(_cfg.get_root_node()->in(1)->in(TypeFunc::FramePtr));736lrgs(fp_lrg)._cost += 1e12; // Cost is infinite737738// For all blocks739for (uint i = 0; i < _cfg.number_of_blocks(); i++) {740Block* block = _cfg.get_block(i);741742// For all instructions743for (uint j = 1; j < block->number_of_nodes(); j++) {744Node* n = block->get_node(j);745uint input_edge_start =1; // Skip control most nodes746bool is_machine_node = false;747if (n->is_Mach()) {748is_machine_node = true;749input_edge_start = n->as_Mach()->oper_input_base();750}751uint idx = n->is_Copy();752753// Get virtual register number, same as LiveRanGe index754uint vreg = _lrg_map.live_range_id(n);755LRG& lrg = lrgs(vreg);756if (vreg) { // No vreg means un-allocable (e.g. memory)757758// Check for float-vs-int live range (used in register-pressure759// calculations)760const Type *n_type = n->bottom_type();761if (n_type->is_floatingpoint()) {762lrg._is_float = 1;763}764765// Check for twice prior spilling. Once prior spilling might have766// spilled 'soft', 2nd prior spill should have spilled 'hard' and767// further spilling is unlikely to make progress.768if (_spilled_once.test(n->_idx)) {769lrg._was_spilled1 = 1;770if (_spilled_twice.test(n->_idx)) {771lrg._was_spilled2 = 1;772}773}774775#ifndef PRODUCT776// Collect bits not used by product code, but which may be useful for777// debugging.778779// Collect has-copy bit780if (idx) {781lrg._has_copy = 1;782uint clidx = _lrg_map.live_range_id(n->in(idx));783LRG& copy_src = lrgs(clidx);784copy_src._has_copy = 1;785}786787if (trace_spilling() && lrg._def != NULL) {788// collect defs for MultiDef printing789if (lrg._defs == NULL) {790lrg._defs = new (_ifg->_arena) GrowableArray<Node*>(_ifg->_arena, 2, 0, NULL);791lrg._defs->append(lrg._def);792}793lrg._defs->append(n);794}795#endif796797// Check for a single def LRG; these can spill nicely798// via rematerialization. Flag as NULL for no def found799// yet, or 'n' for single def or -1 for many defs.800lrg._def = lrg._def ? NodeSentinel : n;801802// Limit result register mask to acceptable registers803const RegMask &rm = n->out_RegMask();804lrg.AND( rm );805806uint ireg = n->ideal_reg();807assert( !n->bottom_type()->isa_oop_ptr() || ireg == Op_RegP,808"oops must be in Op_RegP's" );809810// Check for vector live range (only if vector register is used).811// On SPARC vector uses RegD which could be misaligned so it is not812// processes as vector in RA.813if (RegMask::is_vector(ireg)) {814lrg._is_vector = 1;815if (Matcher::implements_scalable_vector && ireg == Op_VecA) {816assert(Matcher::supports_scalable_vector(), "scalable vector should be supported");817lrg._is_scalable = 1;818// For scalable vector, when it is allocated in physical register,819// num_regs is RegMask::SlotsPerVecA for reg mask,820// which may not be the actual physical register size.821// If it is allocated in stack, we need to get the actual822// physical length of scalable vector register.823lrg.set_scalable_reg_slots(Matcher::scalable_vector_reg_size(T_FLOAT));824}825}826assert(n_type->isa_vect() == NULL || lrg._is_vector ||827ireg == Op_RegD || ireg == Op_RegL || ireg == Op_RegVectMask,828"vector must be in vector registers");829830// Check for bound register masks831const RegMask &lrgmask = lrg.mask();832if (lrgmask.is_bound(ireg)) {833lrg._is_bound = 1;834}835836// Check for maximum frequency value837if (lrg._maxfreq < block->_freq) {838lrg._maxfreq = block->_freq;839}840841// Check for oop-iness, or long/double842// Check for multi-kill projection843switch (ireg) {844case MachProjNode::fat_proj:845// Fat projections have size equal to number of registers killed846lrg.set_num_regs(rm.Size());847lrg.set_reg_pressure(lrg.num_regs());848lrg._fat_proj = 1;849lrg._is_bound = 1;850break;851case Op_RegP:852#ifdef _LP64853lrg.set_num_regs(2); // Size is 2 stack words854#else855lrg.set_num_regs(1); // Size is 1 stack word856#endif857// Register pressure is tracked relative to the maximum values858// suggested for that platform, INTPRESSURE and FLOATPRESSURE,859// and relative to other types which compete for the same regs.860//861// The following table contains suggested values based on the862// architectures as defined in each .ad file.863// INTPRESSURE and FLOATPRESSURE may be tuned differently for864// compile-speed or performance.865// Note1:866// SPARC and SPARCV9 reg_pressures are at 2 instead of 1867// since .ad registers are defined as high and low halves.868// These reg_pressure values remain compatible with the code869// in is_high_pressure() which relates get_invalid_mask_size(),870// Block::_reg_pressure and INTPRESSURE, FLOATPRESSURE.871// Note2:872// SPARC -d32 has 24 registers available for integral values,873// but only 10 of these are safe for 64-bit longs.874// Using set_reg_pressure(2) for both int and long means875// the allocator will believe it can fit 26 longs into876// registers. Using 2 for longs and 1 for ints means the877// allocator will attempt to put 52 integers into registers.878// The settings below limit this problem to methods with879// many long values which are being run on 32-bit SPARC.880//881// ------------------- reg_pressure --------------------882// Each entry is reg_pressure_per_value,number_of_regs883// RegL RegI RegFlags RegF RegD INTPRESSURE FLOATPRESSURE884// IA32 2 1 1 1 1 6 6885// IA64 1 1 1 1 1 50 41886// SPARC 2 2 2 2 2 48 (24) 52 (26)887// SPARCV9 2 2 2 2 2 48 (24) 52 (26)888// AMD64 1 1 1 1 1 14 15889// -----------------------------------------------------890lrg.set_reg_pressure(1); // normally one value per register891if( n_type->isa_oop_ptr() ) {892lrg._is_oop = 1;893}894break;895case Op_RegL: // Check for long or double896case Op_RegD:897lrg.set_num_regs(2);898// Define platform specific register pressure899#if defined(ARM32)900lrg.set_reg_pressure(2);901#elif defined(IA32)902if( ireg == Op_RegL ) {903lrg.set_reg_pressure(2);904} else {905lrg.set_reg_pressure(1);906}907#else908lrg.set_reg_pressure(1); // normally one value per register909#endif910// If this def of a double forces a mis-aligned double,911// flag as '_fat_proj' - really flag as allowing misalignment912// AND changes how we count interferences. A mis-aligned913// double can interfere with TWO aligned pairs, or effectively914// FOUR registers!915if (rm.is_misaligned_pair()) {916lrg._fat_proj = 1;917lrg._is_bound = 1;918}919break;920case Op_RegVectMask:921lrg.set_num_regs(RegMask::SlotsPerRegVectMask);922lrg.set_reg_pressure(1);923break;924case Op_RegF:925case Op_RegI:926case Op_RegN:927case Op_RegFlags:928case 0: // not an ideal register929lrg.set_num_regs(1);930lrg.set_reg_pressure(1);931break;932case Op_VecA:933assert(Matcher::supports_scalable_vector(), "does not support scalable vector");934assert(RegMask::num_registers(Op_VecA) == RegMask::SlotsPerVecA, "sanity");935assert(lrgmask.is_aligned_sets(RegMask::SlotsPerVecA), "vector should be aligned");936lrg.set_num_regs(RegMask::SlotsPerVecA);937lrg.set_reg_pressure(1);938break;939case Op_VecS:940assert(Matcher::vector_size_supported(T_BYTE,4), "sanity");941assert(RegMask::num_registers(Op_VecS) == RegMask::SlotsPerVecS, "sanity");942lrg.set_num_regs(RegMask::SlotsPerVecS);943lrg.set_reg_pressure(1);944break;945case Op_VecD:946assert(Matcher::vector_size_supported(T_FLOAT,RegMask::SlotsPerVecD), "sanity");947assert(RegMask::num_registers(Op_VecD) == RegMask::SlotsPerVecD, "sanity");948assert(lrgmask.is_aligned_sets(RegMask::SlotsPerVecD), "vector should be aligned");949lrg.set_num_regs(RegMask::SlotsPerVecD);950lrg.set_reg_pressure(1);951break;952case Op_VecX:953assert(Matcher::vector_size_supported(T_FLOAT,RegMask::SlotsPerVecX), "sanity");954assert(RegMask::num_registers(Op_VecX) == RegMask::SlotsPerVecX, "sanity");955assert(lrgmask.is_aligned_sets(RegMask::SlotsPerVecX), "vector should be aligned");956lrg.set_num_regs(RegMask::SlotsPerVecX);957lrg.set_reg_pressure(1);958break;959case Op_VecY:960assert(Matcher::vector_size_supported(T_FLOAT,RegMask::SlotsPerVecY), "sanity");961assert(RegMask::num_registers(Op_VecY) == RegMask::SlotsPerVecY, "sanity");962assert(lrgmask.is_aligned_sets(RegMask::SlotsPerVecY), "vector should be aligned");963lrg.set_num_regs(RegMask::SlotsPerVecY);964lrg.set_reg_pressure(1);965break;966case Op_VecZ:967assert(Matcher::vector_size_supported(T_FLOAT,RegMask::SlotsPerVecZ), "sanity");968assert(RegMask::num_registers(Op_VecZ) == RegMask::SlotsPerVecZ, "sanity");969assert(lrgmask.is_aligned_sets(RegMask::SlotsPerVecZ), "vector should be aligned");970lrg.set_num_regs(RegMask::SlotsPerVecZ);971lrg.set_reg_pressure(1);972break;973default:974ShouldNotReachHere();975}976}977978// Now do the same for inputs979uint cnt = n->req();980// Setup for CISC SPILLING981uint inp = (uint)AdlcVMDeps::Not_cisc_spillable;982if( UseCISCSpill && after_aggressive ) {983inp = n->cisc_operand();984if( inp != (uint)AdlcVMDeps::Not_cisc_spillable )985// Convert operand number to edge index number986inp = n->as_Mach()->operand_index(inp);987}988989// Prepare register mask for each input990for( uint k = input_edge_start; k < cnt; k++ ) {991uint vreg = _lrg_map.live_range_id(n->in(k));992if (!vreg) {993continue;994}995996// If this instruction is CISC Spillable, add the flags997// bit to its appropriate input998if( UseCISCSpill && after_aggressive && inp == k ) {999#ifndef PRODUCT1000if( TraceCISCSpill ) {1001tty->print(" use_cisc_RegMask: ");1002n->dump();1003}1004#endif1005n->as_Mach()->use_cisc_RegMask();1006}10071008if (is_machine_node && _scheduling_info_generated) {1009MachNode* cur_node = n->as_Mach();1010// this is cleaned up by register allocation1011if (k >= cur_node->num_opnds()) continue;1012}10131014LRG &lrg = lrgs(vreg);1015// // Testing for floating point code shape1016// Node *test = n->in(k);1017// if( test->is_Mach() ) {1018// MachNode *m = test->as_Mach();1019// int op = m->ideal_Opcode();1020// if (n->is_Call() && (op == Op_AddF || op == Op_MulF) ) {1021// int zzz = 1;1022// }1023// }10241025// Limit result register mask to acceptable registers.1026// Do not limit registers from uncommon uses before1027// AggressiveCoalesce. This effectively pre-virtual-splits1028// around uncommon uses of common defs.1029const RegMask &rm = n->in_RegMask(k);1030if (!after_aggressive && _cfg.get_block_for_node(n->in(k))->_freq > 1000 * block->_freq) {1031// Since we are BEFORE aggressive coalesce, leave the register1032// mask untrimmed by the call. This encourages more coalescing.1033// Later, AFTER aggressive, this live range will have to spill1034// but the spiller handles slow-path calls very nicely.1035} else {1036lrg.AND( rm );1037}10381039// Check for bound register masks1040const RegMask &lrgmask = lrg.mask();1041uint kreg = n->in(k)->ideal_reg();1042bool is_vect = RegMask::is_vector(kreg);1043assert(n->in(k)->bottom_type()->isa_vect() == NULL || is_vect ||1044kreg == Op_RegD || kreg == Op_RegL || kreg == Op_RegVectMask,1045"vector must be in vector registers");1046if (lrgmask.is_bound(kreg))1047lrg._is_bound = 1;10481049// If this use of a double forces a mis-aligned double,1050// flag as '_fat_proj' - really flag as allowing misalignment1051// AND changes how we count interferences. A mis-aligned1052// double can interfere with TWO aligned pairs, or effectively1053// FOUR registers!1054#ifdef ASSERT1055if (is_vect && !_scheduling_info_generated) {1056if (lrg.num_regs() != 0) {1057assert(lrgmask.is_aligned_sets(lrg.num_regs()), "vector should be aligned");1058assert(!lrg._fat_proj, "sanity");1059assert(RegMask::num_registers(kreg) == lrg.num_regs(), "sanity");1060} else {1061assert(n->is_Phi(), "not all inputs processed only if Phi");1062}1063}1064#endif1065if (!is_vect && lrg.num_regs() == 2 && !lrg._fat_proj && rm.is_misaligned_pair()) {1066lrg._fat_proj = 1;1067lrg._is_bound = 1;1068}1069// if the LRG is an unaligned pair, we will have to spill1070// so clear the LRG's register mask if it is not already spilled1071if (!is_vect && !n->is_SpillCopy() &&1072(lrg._def == NULL || lrg.is_multidef() || !lrg._def->is_SpillCopy()) &&1073lrgmask.is_misaligned_pair()) {1074lrg.Clear();1075}10761077// Check for maximum frequency value1078if (lrg._maxfreq < block->_freq) {1079lrg._maxfreq = block->_freq;1080}10811082} // End for all allocated inputs1083} // end for all instructions1084} // end for all blocks10851086// Final per-liverange setup1087for (uint i2 = 0; i2 < _lrg_map.max_lrg_id(); i2++) {1088LRG &lrg = lrgs(i2);1089assert(!lrg._is_vector || !lrg._fat_proj, "sanity");1090if (lrg.num_regs() > 1 && !lrg._fat_proj) {1091lrg.clear_to_sets();1092}1093lrg.compute_set_mask_size();1094if (lrg.not_free()) { // Handle case where we lose from the start1095lrg.set_reg(OptoReg::Name(LRG::SPILL_REG));1096lrg._direct_conflict = 1;1097}1098lrg.set_degree(0); // no neighbors in IFG yet1099}1100}11011102// Set the was-lo-degree bit. Conservative coalescing should not change the1103// colorability of the graph. If any live range was of low-degree before1104// coalescing, it should Simplify. This call sets the was-lo-degree bit.1105// The bit is checked in Simplify.1106void PhaseChaitin::set_was_low() {1107#ifdef ASSERT1108for (uint i = 1; i < _lrg_map.max_lrg_id(); i++) {1109int size = lrgs(i).num_regs();1110uint old_was_lo = lrgs(i)._was_lo;1111lrgs(i)._was_lo = 0;1112if( lrgs(i).lo_degree() ) {1113lrgs(i)._was_lo = 1; // Trivially of low degree1114} else { // Else check the Brigg's assertion1115// Brigg's observation is that the lo-degree neighbors of a1116// hi-degree live range will not interfere with the color choices1117// of said hi-degree live range. The Simplify reverse-stack-coloring1118// order takes care of the details. Hence you do not have to count1119// low-degree neighbors when determining if this guy colors.1120int briggs_degree = 0;1121IndexSet *s = _ifg->neighbors(i);1122IndexSetIterator elements(s);1123uint lidx;1124while((lidx = elements.next()) != 0) {1125if( !lrgs(lidx).lo_degree() )1126briggs_degree += MAX2(size,lrgs(lidx).num_regs());1127}1128if( briggs_degree < lrgs(i).degrees_of_freedom() )1129lrgs(i)._was_lo = 1; // Low degree via the briggs assertion1130}1131assert(old_was_lo <= lrgs(i)._was_lo, "_was_lo may not decrease");1132}1133#endif1134}11351136// Compute cost/area ratio, in case we spill. Build the lo-degree list.1137void PhaseChaitin::cache_lrg_info( ) {1138Compile::TracePhase tp("chaitinCacheLRG", &timers[_t_chaitinCacheLRG]);11391140for (uint i = 1; i < _lrg_map.max_lrg_id(); i++) {1141LRG &lrg = lrgs(i);11421143// Check for being of low degree: means we can be trivially colored.1144// Low degree, dead or must-spill guys just get to simplify right away1145if( lrg.lo_degree() ||1146!lrg.alive() ||1147lrg._must_spill ) {1148// Split low degree list into those guys that must get a1149// register and those that can go to register or stack.1150// The idea is LRGs that can go register or stack color first when1151// they have a good chance of getting a register. The register-only1152// lo-degree live ranges always get a register.1153OptoReg::Name hi_reg = lrg.mask().find_last_elem();1154if( OptoReg::is_stack(hi_reg)) { // Can go to stack?1155lrg._next = _lo_stk_degree;1156_lo_stk_degree = i;1157} else {1158lrg._next = _lo_degree;1159_lo_degree = i;1160}1161} else { // Else high degree1162lrgs(_hi_degree)._prev = i;1163lrg._next = _hi_degree;1164lrg._prev = 0;1165_hi_degree = i;1166}1167}1168}11691170// Simplify the IFG by removing LRGs of low degree.1171void PhaseChaitin::Simplify( ) {1172Compile::TracePhase tp("chaitinSimplify", &timers[_t_chaitinSimplify]);11731174while( 1 ) { // Repeat till simplified it all1175// May want to explore simplifying lo_degree before _lo_stk_degree.1176// This might result in more spills coloring into registers during1177// Select().1178while( _lo_degree || _lo_stk_degree ) {1179// If possible, pull from lo_stk first1180uint lo;1181if( _lo_degree ) {1182lo = _lo_degree;1183_lo_degree = lrgs(lo)._next;1184} else {1185lo = _lo_stk_degree;1186_lo_stk_degree = lrgs(lo)._next;1187}11881189// Put the simplified guy on the simplified list.1190lrgs(lo)._next = _simplified;1191_simplified = lo;1192// If this guy is "at risk" then mark his current neighbors1193if (lrgs(lo)._at_risk && !_ifg->neighbors(lo)->is_empty()) {1194IndexSetIterator elements(_ifg->neighbors(lo));1195uint datum;1196while ((datum = elements.next()) != 0) {1197lrgs(datum)._risk_bias = lo;1198}1199}12001201// Yank this guy from the IFG.1202IndexSet *adj = _ifg->remove_node(lo);1203if (adj->is_empty()) {1204continue;1205}12061207// If any neighbors' degrees fall below their number of1208// allowed registers, then put that neighbor on the low degree1209// list. Note that 'degree' can only fall and 'numregs' is1210// unchanged by this action. Thus the two are equal at most once,1211// so LRGs hit the lo-degree worklist at most once.1212IndexSetIterator elements(adj);1213uint neighbor;1214while ((neighbor = elements.next()) != 0) {1215LRG *n = &lrgs(neighbor);1216#ifdef ASSERT1217if (VerifyRegisterAllocator) {1218assert( _ifg->effective_degree(neighbor) == n->degree(), "" );1219}1220#endif12211222// Check for just becoming of-low-degree just counting registers.1223// _must_spill live ranges are already on the low degree list.1224if (n->just_lo_degree() && !n->_must_spill) {1225assert(!_ifg->_yanked->test(neighbor), "Cannot move to lo degree twice");1226// Pull from hi-degree list1227uint prev = n->_prev;1228uint next = n->_next;1229if (prev) {1230lrgs(prev)._next = next;1231} else {1232_hi_degree = next;1233}1234lrgs(next)._prev = prev;1235n->_next = _lo_degree;1236_lo_degree = neighbor;1237}1238}1239} // End of while lo-degree/lo_stk_degree worklist not empty12401241// Check for got everything: is hi-degree list empty?1242if (!_hi_degree) break;12431244// Time to pick a potential spill guy1245uint lo_score = _hi_degree;1246double score = lrgs(lo_score).score();1247double area = lrgs(lo_score)._area;1248double cost = lrgs(lo_score)._cost;1249bool bound = lrgs(lo_score)._is_bound;12501251// Find cheapest guy1252debug_only( int lo_no_simplify=0; );1253for (uint i = _hi_degree; i; i = lrgs(i)._next) {1254assert(!_ifg->_yanked->test(i), "");1255// It's just vaguely possible to move hi-degree to lo-degree without1256// going through a just-lo-degree stage: If you remove a double from1257// a float live range it's degree will drop by 2 and you can skip the1258// just-lo-degree stage. It's very rare (shows up after 5000+ methods1259// in -Xcomp of Java2Demo). So just choose this guy to simplify next.1260if( lrgs(i).lo_degree() ) {1261lo_score = i;1262break;1263}1264debug_only( if( lrgs(i)._was_lo ) lo_no_simplify=i; );1265double iscore = lrgs(i).score();1266double iarea = lrgs(i)._area;1267double icost = lrgs(i)._cost;1268bool ibound = lrgs(i)._is_bound;12691270// Compare cost/area of i vs cost/area of lo_score. Smaller cost/area1271// wins. Ties happen because all live ranges in question have spilled1272// a few times before and the spill-score adds a huge number which1273// washes out the low order bits. We are choosing the lesser of 21274// evils; in this case pick largest area to spill.1275// Ties also happen when live ranges are defined and used only inside1276// one block. In which case their area is 0 and score set to max.1277// In such case choose bound live range over unbound to free registers1278// or with smaller cost to spill.1279if ( iscore < score ||1280(iscore == score && iarea > area && lrgs(lo_score)._was_spilled2) ||1281(iscore == score && iarea == area &&1282( (ibound && !bound) || (ibound == bound && (icost < cost)) )) ) {1283lo_score = i;1284score = iscore;1285area = iarea;1286cost = icost;1287bound = ibound;1288}1289}1290LRG *lo_lrg = &lrgs(lo_score);1291// The live range we choose for spilling is either hi-degree, or very1292// rarely it can be low-degree. If we choose a hi-degree live range1293// there better not be any lo-degree choices.1294assert( lo_lrg->lo_degree() || !lo_no_simplify, "Live range was lo-degree before coalesce; should simplify" );12951296// Pull from hi-degree list1297uint prev = lo_lrg->_prev;1298uint next = lo_lrg->_next;1299if( prev ) lrgs(prev)._next = next;1300else _hi_degree = next;1301lrgs(next)._prev = prev;1302// Jam him on the lo-degree list, despite his high degree.1303// Maybe he'll get a color, and maybe he'll spill.1304// Only Select() will know.1305lrgs(lo_score)._at_risk = true;1306_lo_degree = lo_score;1307lo_lrg->_next = 0;13081309} // End of while not simplified everything13101311}13121313// Is 'reg' register legal for 'lrg'?1314static bool is_legal_reg(LRG &lrg, OptoReg::Name reg, int chunk) {1315if (reg >= chunk && reg < (chunk + RegMask::CHUNK_SIZE) &&1316lrg.mask().Member(OptoReg::add(reg,-chunk))) {1317// RA uses OptoReg which represent the highest element of a registers set.1318// For example, vectorX (128bit) on x86 uses [XMM,XMMb,XMMc,XMMd] set1319// in which XMMd is used by RA to represent such vectors. A double value1320// uses [XMM,XMMb] pairs and XMMb is used by RA for it.1321// The register mask uses largest bits set of overlapping register sets.1322// On x86 with AVX it uses 8 bits for each XMM registers set.1323//1324// The 'lrg' already has cleared-to-set register mask (done in Select()1325// before calling choose_color()). Passing mask.Member(reg) check above1326// indicates that the size (num_regs) of 'reg' set is less or equal to1327// 'lrg' set size.1328// For set size 1 any register which is member of 'lrg' mask is legal.1329if (lrg.num_regs()==1)1330return true;1331// For larger sets only an aligned register with the same set size is legal.1332int mask = lrg.num_regs()-1;1333if ((reg&mask) == mask)1334return true;1335}1336return false;1337}13381339static OptoReg::Name find_first_set(LRG &lrg, RegMask mask, int chunk) {1340int num_regs = lrg.num_regs();1341OptoReg::Name assigned = mask.find_first_set(lrg, num_regs);13421343if (lrg.is_scalable()) {1344// a physical register is found1345if (chunk == 0 && OptoReg::is_reg(assigned)) {1346return assigned;1347}13481349// find available stack slots for scalable register1350if (lrg._is_vector) {1351num_regs = lrg.scalable_reg_slots();1352// if actual scalable vector register is exactly SlotsPerVecA * 32 bits1353if (num_regs == RegMask::SlotsPerVecA) {1354return assigned;1355}13561357// mask has been cleared out by clear_to_sets(SlotsPerVecA) before choose_color, but it1358// does not work for scalable size. We have to find adjacent scalable_reg_slots() bits1359// instead of SlotsPerVecA bits.1360assigned = mask.find_first_set(lrg, num_regs); // find highest valid reg1361while (OptoReg::is_valid(assigned) && RegMask::can_represent(assigned)) {1362// Verify the found reg has scalable_reg_slots() bits set.1363if (mask.is_valid_reg(assigned, num_regs)) {1364return assigned;1365} else {1366// Remove more for each iteration1367mask.Remove(assigned - num_regs + 1); // Unmask the lowest reg1368mask.clear_to_sets(RegMask::SlotsPerVecA); // Align by SlotsPerVecA bits1369assigned = mask.find_first_set(lrg, num_regs);1370}1371}1372return OptoReg::Bad; // will cause chunk change, and retry next chunk1373}1374}13751376return assigned;1377}13781379// Choose a color using the biasing heuristic1380OptoReg::Name PhaseChaitin::bias_color( LRG &lrg, int chunk ) {13811382// Check for "at_risk" LRG's1383uint risk_lrg = _lrg_map.find(lrg._risk_bias);1384if (risk_lrg != 0 && !_ifg->neighbors(risk_lrg)->is_empty()) {1385// Walk the colored neighbors of the "at_risk" candidate1386// Choose a color which is both legal and already taken by a neighbor1387// of the "at_risk" candidate in order to improve the chances of the1388// "at_risk" candidate of coloring1389IndexSetIterator elements(_ifg->neighbors(risk_lrg));1390uint datum;1391while ((datum = elements.next()) != 0) {1392OptoReg::Name reg = lrgs(datum).reg();1393// If this LRG's register is legal for us, choose it1394if (is_legal_reg(lrg, reg, chunk))1395return reg;1396}1397}13981399uint copy_lrg = _lrg_map.find(lrg._copy_bias);1400if (copy_lrg != 0) {1401// If he has a color,1402if(!_ifg->_yanked->test(copy_lrg)) {1403OptoReg::Name reg = lrgs(copy_lrg).reg();1404// And it is legal for you,1405if (is_legal_reg(lrg, reg, chunk))1406return reg;1407} else if( chunk == 0 ) {1408// Choose a color which is legal for him1409RegMask tempmask = lrg.mask();1410tempmask.AND(lrgs(copy_lrg).mask());1411tempmask.clear_to_sets(lrg.num_regs());1412OptoReg::Name reg = find_first_set(lrg, tempmask, chunk);1413if (OptoReg::is_valid(reg))1414return reg;1415}1416}14171418// If no bias info exists, just go with the register selection ordering1419if (lrg._is_vector || lrg.num_regs() == 2) {1420// Find an aligned set1421return OptoReg::add(find_first_set(lrg, lrg.mask(), chunk), chunk);1422}14231424// CNC - Fun hack. Alternate 1st and 2nd selection. Enables post-allocate1425// copy removal to remove many more copies, by preventing a just-assigned1426// register from being repeatedly assigned.1427OptoReg::Name reg = lrg.mask().find_first_elem();1428if( (++_alternate & 1) && OptoReg::is_valid(reg) ) {1429// This 'Remove; find; Insert' idiom is an expensive way to find the1430// SECOND element in the mask.1431lrg.Remove(reg);1432OptoReg::Name reg2 = lrg.mask().find_first_elem();1433lrg.Insert(reg);1434if( OptoReg::is_reg(reg2))1435reg = reg2;1436}1437return OptoReg::add( reg, chunk );1438}14391440// Choose a color in the current chunk1441OptoReg::Name PhaseChaitin::choose_color( LRG &lrg, int chunk ) {1442assert( C->in_preserve_stack_slots() == 0 || chunk != 0 || lrg._is_bound || lrg.mask().is_bound1() || !lrg.mask().Member(OptoReg::Name(_matcher._old_SP-1)), "must not allocate stack0 (inside preserve area)");1443assert(C->out_preserve_stack_slots() == 0 || chunk != 0 || lrg._is_bound || lrg.mask().is_bound1() || !lrg.mask().Member(OptoReg::Name(_matcher._old_SP+0)), "must not allocate stack0 (inside preserve area)");14441445if( lrg.num_regs() == 1 || // Common Case1446!lrg._fat_proj ) // Aligned+adjacent pairs ok1447// Use a heuristic to "bias" the color choice1448return bias_color(lrg, chunk);14491450assert(!lrg._is_vector, "should be not vector here" );1451assert( lrg.num_regs() >= 2, "dead live ranges do not color" );14521453// Fat-proj case or misaligned double argument.1454assert(lrg.compute_mask_size() == lrg.num_regs() ||1455lrg.num_regs() == 2,"fat projs exactly color" );1456assert( !chunk, "always color in 1st chunk" );1457// Return the highest element in the set.1458return lrg.mask().find_last_elem();1459}14601461// Select colors by re-inserting LRGs back into the IFG. LRGs are re-inserted1462// in reverse order of removal. As long as nothing of hi-degree was yanked,1463// everything going back is guaranteed a color. Select that color. If some1464// hi-degree LRG cannot get a color then we record that we must spill.1465uint PhaseChaitin::Select( ) {1466Compile::TracePhase tp("chaitinSelect", &timers[_t_chaitinSelect]);14671468uint spill_reg = LRG::SPILL_REG;1469_max_reg = OptoReg::Name(0); // Past max register used1470while( _simplified ) {1471// Pull next LRG from the simplified list - in reverse order of removal1472uint lidx = _simplified;1473LRG *lrg = &lrgs(lidx);1474_simplified = lrg->_next;14751476#ifndef PRODUCT1477if (trace_spilling()) {1478ttyLocker ttyl;1479tty->print_cr("L%d selecting degree %d degrees_of_freedom %d", lidx, lrg->degree(),1480lrg->degrees_of_freedom());1481lrg->dump();1482}1483#endif14841485// Re-insert into the IFG1486_ifg->re_insert(lidx);1487if( !lrg->alive() ) continue;1488// capture allstackedness flag before mask is hacked1489const int is_allstack = lrg->mask().is_AllStack();14901491// Yeah, yeah, yeah, I know, I know. I can refactor this1492// to avoid the GOTO, although the refactored code will not1493// be much clearer. We arrive here IFF we have a stack-based1494// live range that cannot color in the current chunk, and it1495// has to move into the next free stack chunk.1496int chunk = 0; // Current chunk is first chunk1497retry_next_chunk:14981499// Remove neighbor colors1500IndexSet *s = _ifg->neighbors(lidx);1501debug_only(RegMask orig_mask = lrg->mask();)15021503if (!s->is_empty()) {1504IndexSetIterator elements(s);1505uint neighbor;1506while ((neighbor = elements.next()) != 0) {1507// Note that neighbor might be a spill_reg. In this case, exclusion1508// of its color will be a no-op, since the spill_reg chunk is in outer1509// space. Also, if neighbor is in a different chunk, this exclusion1510// will be a no-op. (Later on, if lrg runs out of possible colors in1511// its chunk, a new chunk of color may be tried, in which case1512// examination of neighbors is started again, at retry_next_chunk.)1513LRG &nlrg = lrgs(neighbor);1514OptoReg::Name nreg = nlrg.reg();1515// Only subtract masks in the same chunk1516if (nreg >= chunk && nreg < chunk + RegMask::CHUNK_SIZE) {1517#ifndef PRODUCT1518uint size = lrg->mask().Size();1519RegMask rm = lrg->mask();1520#endif1521lrg->SUBTRACT(nlrg.mask());1522#ifndef PRODUCT1523if (trace_spilling() && lrg->mask().Size() != size) {1524ttyLocker ttyl;1525tty->print("L%d ", lidx);1526rm.dump();1527tty->print(" intersected L%d ", neighbor);1528nlrg.mask().dump();1529tty->print(" removed ");1530rm.SUBTRACT(lrg->mask());1531rm.dump();1532tty->print(" leaving ");1533lrg->mask().dump();1534tty->cr();1535}1536#endif1537}1538}1539}1540//assert(is_allstack == lrg->mask().is_AllStack(), "nbrs must not change AllStackedness");1541// Aligned pairs need aligned masks1542assert(!lrg->_is_vector || !lrg->_fat_proj, "sanity");1543if (lrg->num_regs() > 1 && !lrg->_fat_proj) {1544lrg->clear_to_sets();1545}15461547// Check if a color is available and if so pick the color1548OptoReg::Name reg = choose_color( *lrg, chunk );15491550//---------------1551// If we fail to color and the AllStack flag is set, trigger1552// a chunk-rollover event1553if(!OptoReg::is_valid(OptoReg::add(reg,-chunk)) && is_allstack) {1554// Bump register mask up to next stack chunk1555chunk += RegMask::CHUNK_SIZE;1556lrg->Set_All();1557goto retry_next_chunk;1558}15591560//---------------1561// Did we get a color?1562else if( OptoReg::is_valid(reg)) {1563#ifndef PRODUCT1564RegMask avail_rm = lrg->mask();1565#endif15661567// Record selected register1568lrg->set_reg(reg);15691570if( reg >= _max_reg ) // Compute max register limit1571_max_reg = OptoReg::add(reg,1);1572// Fold reg back into normal space1573reg = OptoReg::add(reg,-chunk);15741575// If the live range is not bound, then we actually had some choices1576// to make. In this case, the mask has more bits in it than the colors1577// chosen. Restrict the mask to just what was picked.1578int n_regs = lrg->num_regs();1579assert(!lrg->_is_vector || !lrg->_fat_proj, "sanity");1580if (n_regs == 1 || !lrg->_fat_proj) {1581if (Matcher::supports_scalable_vector()) {1582assert(!lrg->_is_vector || n_regs <= RegMask::SlotsPerVecA, "sanity");1583} else {1584assert(!lrg->_is_vector || n_regs <= RegMask::SlotsPerVecZ, "sanity");1585}1586lrg->Clear(); // Clear the mask1587lrg->Insert(reg); // Set regmask to match selected reg1588// For vectors and pairs, also insert the low bit of the pair1589// We always choose the high bit, then mask the low bits by register size1590if (lrg->is_scalable() && OptoReg::is_stack(lrg->reg())) { // stack1591n_regs = lrg->scalable_reg_slots();1592}1593for (int i = 1; i < n_regs; i++) {1594lrg->Insert(OptoReg::add(reg,-i));1595}1596lrg->set_mask_size(n_regs);1597} else { // Else fatproj1598// mask must be equal to fatproj bits, by definition1599}1600#ifndef PRODUCT1601if (trace_spilling()) {1602ttyLocker ttyl;1603tty->print("L%d selected ", lidx);1604lrg->mask().dump();1605tty->print(" from ");1606avail_rm.dump();1607tty->cr();1608}1609#endif1610// Note that reg is the highest-numbered register in the newly-bound mask.1611} // end color available case16121613//---------------1614// Live range is live and no colors available1615else {1616assert( lrg->alive(), "" );1617assert( !lrg->_fat_proj || lrg->is_multidef() ||1618lrg->_def->outcnt() > 0, "fat_proj cannot spill");1619assert( !orig_mask.is_AllStack(), "All Stack does not spill" );16201621// Assign the special spillreg register1622lrg->set_reg(OptoReg::Name(spill_reg++));1623// Do not empty the regmask; leave mask_size lying around1624// for use during Spilling1625#ifndef PRODUCT1626if( trace_spilling() ) {1627ttyLocker ttyl;1628tty->print("L%d spilling with neighbors: ", lidx);1629s->dump();1630debug_only(tty->print(" original mask: "));1631debug_only(orig_mask.dump());1632dump_lrg(lidx);1633}1634#endif1635} // end spill case16361637}16381639return spill_reg-LRG::SPILL_REG; // Return number of spills1640}16411642// Set the 'spilled_once' or 'spilled_twice' flag on a node.1643void PhaseChaitin::set_was_spilled( Node *n ) {1644if( _spilled_once.test_set(n->_idx) )1645_spilled_twice.set(n->_idx);1646}16471648// Convert Ideal spill instructions into proper FramePtr + offset Loads and1649// Stores. Use-def chains are NOT preserved, but Node->LRG->reg maps are.1650void PhaseChaitin::fixup_spills() {1651// This function does only cisc spill work.1652if( !UseCISCSpill ) return;16531654Compile::TracePhase tp("fixupSpills", &timers[_t_fixupSpills]);16551656// Grab the Frame Pointer1657Node *fp = _cfg.get_root_block()->head()->in(1)->in(TypeFunc::FramePtr);16581659// For all blocks1660for (uint i = 0; i < _cfg.number_of_blocks(); i++) {1661Block* block = _cfg.get_block(i);16621663// For all instructions in block1664uint last_inst = block->end_idx();1665for (uint j = 1; j <= last_inst; j++) {1666Node* n = block->get_node(j);16671668// Dead instruction???1669assert( n->outcnt() != 0 ||// Nothing dead after post alloc1670C->top() == n || // Or the random TOP node1671n->is_Proj(), // Or a fat-proj kill node1672"No dead instructions after post-alloc" );16731674int inp = n->cisc_operand();1675if( inp != AdlcVMDeps::Not_cisc_spillable ) {1676// Convert operand number to edge index number1677MachNode *mach = n->as_Mach();1678inp = mach->operand_index(inp);1679Node *src = n->in(inp); // Value to load or store1680LRG &lrg_cisc = lrgs(_lrg_map.find_const(src));1681OptoReg::Name src_reg = lrg_cisc.reg();1682// Doubles record the HIGH register of an adjacent pair.1683src_reg = OptoReg::add(src_reg,1-lrg_cisc.num_regs());1684if( OptoReg::is_stack(src_reg) ) { // If input is on stack1685// This is a CISC Spill, get stack offset and construct new node1686#ifndef PRODUCT1687if( TraceCISCSpill ) {1688tty->print(" reg-instr: ");1689n->dump();1690}1691#endif1692int stk_offset = reg2offset(src_reg);1693// Bailout if we might exceed node limit when spilling this instruction1694C->check_node_count(0, "out of nodes fixing spills");1695if (C->failing()) return;1696// Transform node1697MachNode *cisc = mach->cisc_version(stk_offset)->as_Mach();1698cisc->set_req(inp,fp); // Base register is frame pointer1699if( cisc->oper_input_base() > 1 && mach->oper_input_base() <= 1 ) {1700assert( cisc->oper_input_base() == 2, "Only adding one edge");1701cisc->ins_req(1,src); // Requires a memory edge1702}1703block->map_node(cisc, j); // Insert into basic block1704n->subsume_by(cisc, C); // Correct graph1705//1706++_used_cisc_instructions;1707#ifndef PRODUCT1708if( TraceCISCSpill ) {1709tty->print(" cisc-instr: ");1710cisc->dump();1711}1712#endif1713} else {1714#ifndef PRODUCT1715if( TraceCISCSpill ) {1716tty->print(" using reg-instr: ");1717n->dump();1718}1719#endif1720++_unused_cisc_instructions; // input can be on stack1721}1722}17231724} // End of for all instructions17251726} // End of for all blocks1727}17281729// Helper to stretch above; recursively discover the base Node for a1730// given derived Node. Easy for AddP-related machine nodes, but needs1731// to be recursive for derived Phis.1732Node *PhaseChaitin::find_base_for_derived( Node **derived_base_map, Node *derived, uint &maxlrg ) {1733// See if already computed; if so return it1734if( derived_base_map[derived->_idx] )1735return derived_base_map[derived->_idx];17361737// See if this happens to be a base.1738// NOTE: we use TypePtr instead of TypeOopPtr because we can have1739// pointers derived from NULL! These are always along paths that1740// can't happen at run-time but the optimizer cannot deduce it so1741// we have to handle it gracefully.1742assert(!derived->bottom_type()->isa_narrowoop() ||1743derived->bottom_type()->make_ptr()->is_ptr()->_offset == 0, "sanity");1744const TypePtr *tj = derived->bottom_type()->isa_ptr();1745// If its an OOP with a non-zero offset, then it is derived.1746if( tj == NULL || tj->_offset == 0 ) {1747derived_base_map[derived->_idx] = derived;1748return derived;1749}1750// Derived is NULL+offset? Base is NULL!1751if( derived->is_Con() ) {1752Node *base = _matcher.mach_null();1753assert(base != NULL, "sanity");1754if (base->in(0) == NULL) {1755// Initialize it once and make it shared:1756// set control to _root and place it into Start block1757// (where top() node is placed).1758base->init_req(0, _cfg.get_root_node());1759Block *startb = _cfg.get_block_for_node(C->top());1760uint node_pos = startb->find_node(C->top());1761startb->insert_node(base, node_pos);1762_cfg.map_node_to_block(base, startb);1763assert(_lrg_map.live_range_id(base) == 0, "should not have LRG yet");17641765// The loadConP0 might have projection nodes depending on architecture1766// Add the projection nodes to the CFG1767for (DUIterator_Fast imax, i = base->fast_outs(imax); i < imax; i++) {1768Node* use = base->fast_out(i);1769if (use->is_MachProj()) {1770startb->insert_node(use, ++node_pos);1771_cfg.map_node_to_block(use, startb);1772new_lrg(use, maxlrg++);1773}1774}1775}1776if (_lrg_map.live_range_id(base) == 0) {1777new_lrg(base, maxlrg++);1778}1779assert(base->in(0) == _cfg.get_root_node() && _cfg.get_block_for_node(base) == _cfg.get_block_for_node(C->top()), "base NULL should be shared");1780derived_base_map[derived->_idx] = base;1781return base;1782}17831784// Check for AddP-related opcodes1785if (!derived->is_Phi()) {1786assert(derived->as_Mach()->ideal_Opcode() == Op_AddP, "but is: %s", derived->Name());1787Node *base = derived->in(AddPNode::Base);1788derived_base_map[derived->_idx] = base;1789return base;1790}17911792// Recursively find bases for Phis.1793// First check to see if we can avoid a base Phi here.1794Node *base = find_base_for_derived( derived_base_map, derived->in(1),maxlrg);1795uint i;1796for( i = 2; i < derived->req(); i++ )1797if( base != find_base_for_derived( derived_base_map,derived->in(i),maxlrg))1798break;1799// Went to the end without finding any different bases?1800if( i == derived->req() ) { // No need for a base Phi here1801derived_base_map[derived->_idx] = base;1802return base;1803}18041805// Now we see we need a base-Phi here to merge the bases1806const Type *t = base->bottom_type();1807base = new PhiNode( derived->in(0), t );1808for( i = 1; i < derived->req(); i++ ) {1809base->init_req(i, find_base_for_derived(derived_base_map, derived->in(i), maxlrg));1810t = t->meet(base->in(i)->bottom_type());1811}1812base->as_Phi()->set_type(t);18131814// Search the current block for an existing base-Phi1815Block *b = _cfg.get_block_for_node(derived);1816for( i = 1; i <= b->end_idx(); i++ ) {// Search for matching Phi1817Node *phi = b->get_node(i);1818if( !phi->is_Phi() ) { // Found end of Phis with no match?1819b->insert_node(base, i); // Must insert created Phi here as base1820_cfg.map_node_to_block(base, b);1821new_lrg(base,maxlrg++);1822break;1823}1824// See if Phi matches.1825uint j;1826for( j = 1; j < base->req(); j++ )1827if( phi->in(j) != base->in(j) &&1828!(phi->in(j)->is_Con() && base->in(j)->is_Con()) ) // allow different NULLs1829break;1830if( j == base->req() ) { // All inputs match?1831base = phi; // Then use existing 'phi' and drop 'base'1832break;1833}1834}183518361837// Cache info for later passes1838derived_base_map[derived->_idx] = base;1839return base;1840}18411842// At each Safepoint, insert extra debug edges for each pair of derived value/1843// base pointer that is live across the Safepoint for oopmap building. The1844// edge pairs get added in after sfpt->jvmtail()->oopoff(), but are in the1845// required edge set.1846bool PhaseChaitin::stretch_base_pointer_live_ranges(ResourceArea *a) {1847int must_recompute_live = false;1848uint maxlrg = _lrg_map.max_lrg_id();1849Node **derived_base_map = (Node**)a->Amalloc(sizeof(Node*)*C->unique());1850memset( derived_base_map, 0, sizeof(Node*)*C->unique() );18511852// For all blocks in RPO do...1853for (uint i = 0; i < _cfg.number_of_blocks(); i++) {1854Block* block = _cfg.get_block(i);1855// Note use of deep-copy constructor. I cannot hammer the original1856// liveout bits, because they are needed by the following coalesce pass.1857IndexSet liveout(_live->live(block));18581859for (uint j = block->end_idx() + 1; j > 1; j--) {1860Node* n = block->get_node(j - 1);18611862// Pre-split compares of loop-phis. Loop-phis form a cycle we would1863// like to see in the same register. Compare uses the loop-phi and so1864// extends its live range BUT cannot be part of the cycle. If this1865// extended live range overlaps with the update of the loop-phi value1866// we need both alive at the same time -- which requires at least 11867// copy. But because Intel has only 2-address registers we end up with1868// at least 2 copies, one before the loop-phi update instruction and1869// one after. Instead we split the input to the compare just after the1870// phi.1871if( n->is_Mach() && n->as_Mach()->ideal_Opcode() == Op_CmpI ) {1872Node *phi = n->in(1);1873if( phi->is_Phi() && phi->as_Phi()->region()->is_Loop() ) {1874Block *phi_block = _cfg.get_block_for_node(phi);1875if (_cfg.get_block_for_node(phi_block->pred(2)) == block) {1876const RegMask *mask = C->matcher()->idealreg2spillmask[Op_RegI];1877Node *spill = new MachSpillCopyNode(MachSpillCopyNode::LoopPhiInput, phi, *mask, *mask);1878insert_proj( phi_block, 1, spill, maxlrg++ );1879n->set_req(1,spill);1880must_recompute_live = true;1881}1882}1883}18841885// Get value being defined1886uint lidx = _lrg_map.live_range_id(n);1887// Ignore the occasional brand-new live range1888if (lidx && lidx < _lrg_map.max_lrg_id()) {1889// Remove from live-out set1890liveout.remove(lidx);18911892// Copies do not define a new value and so do not interfere.1893// Remove the copies source from the liveout set before interfering.1894uint idx = n->is_Copy();1895if (idx) {1896liveout.remove(_lrg_map.live_range_id(n->in(idx)));1897}1898}18991900// Found a safepoint?1901JVMState *jvms = n->jvms();1902if (jvms && !liveout.is_empty()) {1903// Now scan for a live derived pointer1904IndexSetIterator elements(&liveout);1905uint neighbor;1906while ((neighbor = elements.next()) != 0) {1907// Find reaching DEF for base and derived values1908// This works because we are still in SSA during this call.1909Node *derived = lrgs(neighbor)._def;1910const TypePtr *tj = derived->bottom_type()->isa_ptr();1911assert(!derived->bottom_type()->isa_narrowoop() ||1912derived->bottom_type()->make_ptr()->is_ptr()->_offset == 0, "sanity");1913// If its an OOP with a non-zero offset, then it is derived.1914if( tj && tj->_offset != 0 && tj->isa_oop_ptr() ) {1915Node *base = find_base_for_derived(derived_base_map, derived, maxlrg);1916assert(base->_idx < _lrg_map.size(), "");1917// Add reaching DEFs of derived pointer and base pointer as a1918// pair of inputs1919n->add_req(derived);1920n->add_req(base);19211922// See if the base pointer is already live to this point.1923// Since I'm working on the SSA form, live-ness amounts to1924// reaching def's. So if I find the base's live range then1925// I know the base's def reaches here.1926if ((_lrg_map.live_range_id(base) >= _lrg_map.max_lrg_id() || // (Brand new base (hence not live) or1927!liveout.member(_lrg_map.live_range_id(base))) && // not live) AND1928(_lrg_map.live_range_id(base) > 0) && // not a constant1929_cfg.get_block_for_node(base) != block) { // base not def'd in blk)1930// Base pointer is not currently live. Since I stretched1931// the base pointer to here and it crosses basic-block1932// boundaries, the global live info is now incorrect.1933// Recompute live.1934must_recompute_live = true;1935} // End of if base pointer is not live to debug info1936}1937} // End of scan all live data for derived ptrs crossing GC point1938} // End of if found a GC point19391940// Make all inputs live1941if (!n->is_Phi()) { // Phi function uses come from prior block1942for (uint k = 1; k < n->req(); k++) {1943uint lidx = _lrg_map.live_range_id(n->in(k));1944if (lidx < _lrg_map.max_lrg_id()) {1945liveout.insert(lidx);1946}1947}1948}19491950} // End of forall instructions in block1951liveout.clear(); // Free the memory used by liveout.19521953} // End of forall blocks1954_lrg_map.set_max_lrg_id(maxlrg);19551956// If I created a new live range I need to recompute live1957if (maxlrg != _ifg->_maxlrg) {1958must_recompute_live = true;1959}19601961return must_recompute_live != 0;1962}19631964// Extend the node to LRG mapping19651966void PhaseChaitin::add_reference(const Node *node, const Node *old_node) {1967_lrg_map.extend(node->_idx, _lrg_map.live_range_id(old_node));1968}19691970#ifndef PRODUCT1971void PhaseChaitin::dump(const Node* n) const {1972uint r = (n->_idx < _lrg_map.size()) ? _lrg_map.find_const(n) : 0;1973tty->print("L%d",r);1974if (r && n->Opcode() != Op_Phi) {1975if( _node_regs ) { // Got a post-allocation copy of allocation?1976tty->print("[");1977OptoReg::Name second = get_reg_second(n);1978if( OptoReg::is_valid(second) ) {1979if( OptoReg::is_reg(second) )1980tty->print("%s:",Matcher::regName[second]);1981else1982tty->print("%s+%d:",OptoReg::regname(OptoReg::c_frame_pointer), reg2offset_unchecked(second));1983}1984OptoReg::Name first = get_reg_first(n);1985if( OptoReg::is_reg(first) )1986tty->print("%s]",Matcher::regName[first]);1987else1988tty->print("%s+%d]",OptoReg::regname(OptoReg::c_frame_pointer), reg2offset_unchecked(first));1989} else1990n->out_RegMask().dump();1991}1992tty->print("/N%d\t",n->_idx);1993tty->print("%s === ", n->Name());1994uint k;1995for (k = 0; k < n->req(); k++) {1996Node *m = n->in(k);1997if (!m) {1998tty->print("_ ");1999}2000else {2001uint r = (m->_idx < _lrg_map.size()) ? _lrg_map.find_const(m) : 0;2002tty->print("L%d",r);2003// Data MultiNode's can have projections with no real registers.2004// Don't die while dumping them.2005int op = n->Opcode();2006if( r && op != Op_Phi && op != Op_Proj && op != Op_SCMemProj) {2007if( _node_regs ) {2008tty->print("[");2009OptoReg::Name second = get_reg_second(n->in(k));2010if( OptoReg::is_valid(second) ) {2011if( OptoReg::is_reg(second) )2012tty->print("%s:",Matcher::regName[second]);2013else2014tty->print("%s+%d:",OptoReg::regname(OptoReg::c_frame_pointer),2015reg2offset_unchecked(second));2016}2017OptoReg::Name first = get_reg_first(n->in(k));2018if( OptoReg::is_reg(first) )2019tty->print("%s]",Matcher::regName[first]);2020else2021tty->print("%s+%d]",OptoReg::regname(OptoReg::c_frame_pointer),2022reg2offset_unchecked(first));2023} else2024n->in_RegMask(k).dump();2025}2026tty->print("/N%d ",m->_idx);2027}2028}2029if( k < n->len() && n->in(k) ) tty->print("| ");2030for( ; k < n->len(); k++ ) {2031Node *m = n->in(k);2032if(!m) {2033break;2034}2035uint r = (m->_idx < _lrg_map.size()) ? _lrg_map.find_const(m) : 0;2036tty->print("L%d",r);2037tty->print("/N%d ",m->_idx);2038}2039if( n->is_Mach() ) n->as_Mach()->dump_spec(tty);2040else n->dump_spec(tty);2041if( _spilled_once.test(n->_idx ) ) {2042tty->print(" Spill_1");2043if( _spilled_twice.test(n->_idx ) )2044tty->print(" Spill_2");2045}2046tty->print("\n");2047}20482049void PhaseChaitin::dump(const Block* b) const {2050b->dump_head(&_cfg);20512052// For all instructions2053for( uint j = 0; j < b->number_of_nodes(); j++ )2054dump(b->get_node(j));2055// Print live-out info at end of block2056if( _live ) {2057tty->print("Liveout: ");2058IndexSet *live = _live->live(b);2059IndexSetIterator elements(live);2060tty->print("{");2061uint i;2062while ((i = elements.next()) != 0) {2063tty->print("L%d ", _lrg_map.find_const(i));2064}2065tty->print_cr("}");2066}2067tty->print("\n");2068}20692070void PhaseChaitin::dump() const {2071tty->print( "--- Chaitin -- argsize: %d framesize: %d ---\n",2072_matcher._new_SP, _framesize );20732074// For all blocks2075for (uint i = 0; i < _cfg.number_of_blocks(); i++) {2076dump(_cfg.get_block(i));2077}2078// End of per-block dump2079tty->print("\n");20802081if (!_ifg) {2082tty->print("(No IFG.)\n");2083return;2084}20852086// Dump LRG array2087tty->print("--- Live RanGe Array ---\n");2088for (uint i2 = 1; i2 < _lrg_map.max_lrg_id(); i2++) {2089tty->print("L%d: ",i2);2090if (i2 < _ifg->_maxlrg) {2091lrgs(i2).dump();2092}2093else {2094tty->print_cr("new LRG");2095}2096}2097tty->cr();20982099// Dump lo-degree list2100tty->print("Lo degree: ");2101for(uint i3 = _lo_degree; i3; i3 = lrgs(i3)._next )2102tty->print("L%d ",i3);2103tty->cr();21042105// Dump lo-stk-degree list2106tty->print("Lo stk degree: ");2107for(uint i4 = _lo_stk_degree; i4; i4 = lrgs(i4)._next )2108tty->print("L%d ",i4);2109tty->cr();21102111// Dump lo-degree list2112tty->print("Hi degree: ");2113for(uint i5 = _hi_degree; i5; i5 = lrgs(i5)._next )2114tty->print("L%d ",i5);2115tty->cr();2116}21172118void PhaseChaitin::dump_degree_lists() const {2119// Dump lo-degree list2120tty->print("Lo degree: ");2121for( uint i = _lo_degree; i; i = lrgs(i)._next )2122tty->print("L%d ",i);2123tty->cr();21242125// Dump lo-stk-degree list2126tty->print("Lo stk degree: ");2127for(uint i2 = _lo_stk_degree; i2; i2 = lrgs(i2)._next )2128tty->print("L%d ",i2);2129tty->cr();21302131// Dump lo-degree list2132tty->print("Hi degree: ");2133for(uint i3 = _hi_degree; i3; i3 = lrgs(i3)._next )2134tty->print("L%d ",i3);2135tty->cr();2136}21372138void PhaseChaitin::dump_simplified() const {2139tty->print("Simplified: ");2140for( uint i = _simplified; i; i = lrgs(i)._next )2141tty->print("L%d ",i);2142tty->cr();2143}21442145static char *print_reg(OptoReg::Name reg, const PhaseChaitin* pc, char* buf) {2146if ((int)reg < 0)2147sprintf(buf, "<OptoReg::%d>", (int)reg);2148else if (OptoReg::is_reg(reg))2149strcpy(buf, Matcher::regName[reg]);2150else2151sprintf(buf,"%s + #%d",OptoReg::regname(OptoReg::c_frame_pointer),2152pc->reg2offset(reg));2153return buf+strlen(buf);2154}21552156// Dump a register name into a buffer. Be intelligent if we get called2157// before allocation is complete.2158char *PhaseChaitin::dump_register(const Node* n, char* buf) const {2159if( _node_regs ) {2160// Post allocation, use direct mappings, no LRG info available2161print_reg( get_reg_first(n), this, buf );2162} else {2163uint lidx = _lrg_map.find_const(n); // Grab LRG number2164if( !_ifg ) {2165sprintf(buf,"L%d",lidx); // No register binding yet2166} else if( !lidx ) { // Special, not allocated value2167strcpy(buf,"Special");2168} else {2169if (lrgs(lidx)._is_vector) {2170if (lrgs(lidx).mask().is_bound_set(lrgs(lidx).num_regs()))2171print_reg( lrgs(lidx).reg(), this, buf ); // a bound machine register2172else2173sprintf(buf,"L%d",lidx); // No register binding yet2174} else if( (lrgs(lidx).num_regs() == 1)2175? lrgs(lidx).mask().is_bound1()2176: lrgs(lidx).mask().is_bound_pair() ) {2177// Hah! We have a bound machine register2178print_reg( lrgs(lidx).reg(), this, buf );2179} else {2180sprintf(buf,"L%d",lidx); // No register binding yet2181}2182}2183}2184return buf+strlen(buf);2185}21862187void PhaseChaitin::dump_for_spill_split_recycle() const {2188if( WizardMode && (PrintCompilation || PrintOpto) ) {2189// Display which live ranges need to be split and the allocator's state2190tty->print_cr("Graph-Coloring Iteration %d will split the following live ranges", _trip_cnt);2191for (uint bidx = 1; bidx < _lrg_map.max_lrg_id(); bidx++) {2192if( lrgs(bidx).alive() && lrgs(bidx).reg() >= LRG::SPILL_REG ) {2193tty->print("L%d: ", bidx);2194lrgs(bidx).dump();2195}2196}2197tty->cr();2198dump();2199}2200}22012202void PhaseChaitin::dump_frame() const {2203const char *fp = OptoReg::regname(OptoReg::c_frame_pointer);2204const TypeTuple *domain = C->tf()->domain();2205const int argcnt = domain->cnt() - TypeFunc::Parms;22062207// Incoming arguments in registers dump2208for( int k = 0; k < argcnt; k++ ) {2209OptoReg::Name parmreg = _matcher._parm_regs[k].first();2210if( OptoReg::is_reg(parmreg)) {2211const char *reg_name = OptoReg::regname(parmreg);2212tty->print("#r%3.3d %s", parmreg, reg_name);2213parmreg = _matcher._parm_regs[k].second();2214if( OptoReg::is_reg(parmreg)) {2215tty->print(":%s", OptoReg::regname(parmreg));2216}2217tty->print(" : parm %d: ", k);2218domain->field_at(k + TypeFunc::Parms)->dump();2219tty->cr();2220}2221}22222223// Check for un-owned padding above incoming args2224OptoReg::Name reg = _matcher._new_SP;2225if( reg > _matcher._in_arg_limit ) {2226reg = OptoReg::add(reg, -1);2227tty->print_cr("#r%3.3d %s+%2d: pad0, owned by CALLER", reg, fp, reg2offset_unchecked(reg));2228}22292230// Incoming argument area dump2231OptoReg::Name begin_in_arg = OptoReg::add(_matcher._old_SP,C->out_preserve_stack_slots());2232while( reg > begin_in_arg ) {2233reg = OptoReg::add(reg, -1);2234tty->print("#r%3.3d %s+%2d: ",reg,fp,reg2offset_unchecked(reg));2235int j;2236for( j = 0; j < argcnt; j++) {2237if( _matcher._parm_regs[j].first() == reg ||2238_matcher._parm_regs[j].second() == reg ) {2239tty->print("parm %d: ",j);2240domain->field_at(j + TypeFunc::Parms)->dump();2241tty->cr();2242break;2243}2244}2245if( j >= argcnt )2246tty->print_cr("HOLE, owned by SELF");2247}22482249// Old outgoing preserve area2250while( reg > _matcher._old_SP ) {2251reg = OptoReg::add(reg, -1);2252tty->print_cr("#r%3.3d %s+%2d: old out preserve",reg,fp,reg2offset_unchecked(reg));2253}22542255// Old SP2256tty->print_cr("# -- Old %s -- Framesize: %d --",fp,2257reg2offset_unchecked(OptoReg::add(_matcher._old_SP,-1)) - reg2offset_unchecked(_matcher._new_SP)+jintSize);22582259// Preserve area dump2260int fixed_slots = C->fixed_slots();2261OptoReg::Name begin_in_preserve = OptoReg::add(_matcher._old_SP, -(int)C->in_preserve_stack_slots());2262OptoReg::Name return_addr = _matcher.return_addr();22632264reg = OptoReg::add(reg, -1);2265while (OptoReg::is_stack(reg)) {2266tty->print("#r%3.3d %s+%2d: ",reg,fp,reg2offset_unchecked(reg));2267if (return_addr == reg) {2268tty->print_cr("return address");2269} else if (reg >= begin_in_preserve) {2270// Preserved slots are present on x862271if (return_addr == OptoReg::add(reg, VMRegImpl::slots_per_word))2272tty->print_cr("saved fp register");2273else if (return_addr == OptoReg::add(reg, 2*VMRegImpl::slots_per_word) &&2274VerifyStackAtCalls)2275tty->print_cr("0xBADB100D +VerifyStackAtCalls");2276else2277tty->print_cr("in_preserve");2278} else if ((int)OptoReg::reg2stack(reg) < fixed_slots) {2279tty->print_cr("Fixed slot %d", OptoReg::reg2stack(reg));2280} else {2281tty->print_cr("pad2, stack alignment");2282}2283reg = OptoReg::add(reg, -1);2284}22852286// Spill area dump2287reg = OptoReg::add(_matcher._new_SP, _framesize );2288while( reg > _matcher._out_arg_limit ) {2289reg = OptoReg::add(reg, -1);2290tty->print_cr("#r%3.3d %s+%2d: spill",reg,fp,reg2offset_unchecked(reg));2291}22922293// Outgoing argument area dump2294while( reg > OptoReg::add(_matcher._new_SP, C->out_preserve_stack_slots()) ) {2295reg = OptoReg::add(reg, -1);2296tty->print_cr("#r%3.3d %s+%2d: outgoing argument",reg,fp,reg2offset_unchecked(reg));2297}22982299// Outgoing new preserve area2300while( reg > _matcher._new_SP ) {2301reg = OptoReg::add(reg, -1);2302tty->print_cr("#r%3.3d %s+%2d: new out preserve",reg,fp,reg2offset_unchecked(reg));2303}2304tty->print_cr("#");2305}23062307void PhaseChaitin::dump_bb(uint pre_order) const {2308tty->print_cr("---dump of B%d---",pre_order);2309for (uint i = 0; i < _cfg.number_of_blocks(); i++) {2310Block* block = _cfg.get_block(i);2311if (block->_pre_order == pre_order) {2312dump(block);2313}2314}2315}23162317void PhaseChaitin::dump_lrg(uint lidx, bool defs_only) const {2318tty->print_cr("---dump of L%d---",lidx);23192320if (_ifg) {2321if (lidx >= _lrg_map.max_lrg_id()) {2322tty->print("Attempt to print live range index beyond max live range.\n");2323return;2324}2325tty->print("L%d: ",lidx);2326if (lidx < _ifg->_maxlrg) {2327lrgs(lidx).dump();2328} else {2329tty->print_cr("new LRG");2330}2331}2332if( _ifg && lidx < _ifg->_maxlrg) {2333tty->print("Neighbors: %d - ", _ifg->neighbor_cnt(lidx));2334_ifg->neighbors(lidx)->dump();2335tty->cr();2336}2337// For all blocks2338for (uint i = 0; i < _cfg.number_of_blocks(); i++) {2339Block* block = _cfg.get_block(i);2340int dump_once = 0;23412342// For all instructions2343for( uint j = 0; j < block->number_of_nodes(); j++ ) {2344Node *n = block->get_node(j);2345if (_lrg_map.find_const(n) == lidx) {2346if (!dump_once++) {2347tty->cr();2348block->dump_head(&_cfg);2349}2350dump(n);2351continue;2352}2353if (!defs_only) {2354uint cnt = n->req();2355for( uint k = 1; k < cnt; k++ ) {2356Node *m = n->in(k);2357if (!m) {2358continue; // be robust in the dumper2359}2360if (_lrg_map.find_const(m) == lidx) {2361if (!dump_once++) {2362tty->cr();2363block->dump_head(&_cfg);2364}2365dump(n);2366}2367}2368}2369}2370} // End of per-block dump2371tty->cr();2372}2373#endif // not PRODUCT23742375#ifdef ASSERT2376// Verify that base pointers and derived pointers are still sane.2377void PhaseChaitin::verify_base_ptrs(ResourceArea* a) const {2378Unique_Node_List worklist(a);2379for (uint i = 0; i < _cfg.number_of_blocks(); i++) {2380Block* block = _cfg.get_block(i);2381for (uint j = block->end_idx() + 1; j > 1; j--) {2382Node* n = block->get_node(j-1);2383if (n->is_Phi()) {2384break;2385}2386// Found a safepoint?2387if (n->is_MachSafePoint()) {2388MachSafePointNode* sfpt = n->as_MachSafePoint();2389JVMState* jvms = sfpt->jvms();2390if (jvms != NULL) {2391// Now scan for a live derived pointer2392if (jvms->oopoff() < sfpt->req()) {2393// Check each derived/base pair2394for (uint idx = jvms->oopoff(); idx < sfpt->req(); idx++) {2395Node* check = sfpt->in(idx);2396bool is_derived = ((idx - jvms->oopoff()) & 1) == 0;2397// search upwards through spills and spill phis for AddP2398worklist.clear();2399worklist.push(check);2400uint k = 0;2401while (k < worklist.size()) {2402check = worklist.at(k);2403assert(check, "Bad base or derived pointer");2404// See PhaseChaitin::find_base_for_derived() for all cases.2405int isc = check->is_Copy();2406if (isc) {2407worklist.push(check->in(isc));2408} else if (check->is_Phi()) {2409for (uint m = 1; m < check->req(); m++) {2410worklist.push(check->in(m));2411}2412} else if (check->is_Con()) {2413if (is_derived && check->bottom_type()->is_ptr()->_offset != 0) {2414// Derived is NULL+non-zero offset, base must be NULL.2415assert(check->bottom_type()->is_ptr()->ptr() == TypePtr::Null, "Bad derived pointer");2416} else {2417assert(check->bottom_type()->is_ptr()->_offset == 0, "Bad base pointer");2418// Base either ConP(NULL) or loadConP2419if (check->is_Mach()) {2420assert(check->as_Mach()->ideal_Opcode() == Op_ConP, "Bad base pointer");2421} else {2422assert(check->Opcode() == Op_ConP &&2423check->bottom_type()->is_ptr()->ptr() == TypePtr::Null, "Bad base pointer");2424}2425}2426} else if (check->bottom_type()->is_ptr()->_offset == 0) {2427if (check->is_Proj() || (check->is_Mach() &&2428(check->as_Mach()->ideal_Opcode() == Op_CreateEx ||2429check->as_Mach()->ideal_Opcode() == Op_ThreadLocal ||2430check->as_Mach()->ideal_Opcode() == Op_CMoveP ||2431check->as_Mach()->ideal_Opcode() == Op_CheckCastPP ||2432#ifdef _LP642433(UseCompressedOops && check->as_Mach()->ideal_Opcode() == Op_CastPP) ||2434(UseCompressedOops && check->as_Mach()->ideal_Opcode() == Op_DecodeN) ||2435(UseCompressedClassPointers && check->as_Mach()->ideal_Opcode() == Op_DecodeNKlass) ||2436#endif // _LP642437check->as_Mach()->ideal_Opcode() == Op_LoadP ||2438check->as_Mach()->ideal_Opcode() == Op_LoadKlass))) {2439// Valid nodes2440} else {2441check->dump();2442assert(false, "Bad base or derived pointer");2443}2444} else {2445assert(is_derived, "Bad base pointer");2446assert(check->is_Mach() && check->as_Mach()->ideal_Opcode() == Op_AddP, "Bad derived pointer");2447}2448k++;2449assert(k < 100000, "Derived pointer checking in infinite loop");2450} // End while2451}2452} // End of check for derived pointers2453} // End of Kcheck for debug info2454} // End of if found a safepoint2455} // End of forall instructions in block2456} // End of forall blocks2457}24582459// Verify that graphs and base pointers are still sane.2460void PhaseChaitin::verify(ResourceArea* a, bool verify_ifg) const {2461if (VerifyRegisterAllocator) {2462_cfg.verify();2463verify_base_ptrs(a);2464if (verify_ifg) {2465_ifg->verify(this);2466}2467}2468}2469#endif // ASSERT24702471int PhaseChaitin::_final_loads = 0;2472int PhaseChaitin::_final_stores = 0;2473int PhaseChaitin::_final_memoves= 0;2474int PhaseChaitin::_final_copies = 0;2475double PhaseChaitin::_final_load_cost = 0;2476double PhaseChaitin::_final_store_cost = 0;2477double PhaseChaitin::_final_memove_cost= 0;2478double PhaseChaitin::_final_copy_cost = 0;2479int PhaseChaitin::_conserv_coalesce = 0;2480int PhaseChaitin::_conserv_coalesce_pair = 0;2481int PhaseChaitin::_conserv_coalesce_trie = 0;2482int PhaseChaitin::_conserv_coalesce_quad = 0;2483int PhaseChaitin::_post_alloc = 0;2484int PhaseChaitin::_lost_opp_pp_coalesce = 0;2485int PhaseChaitin::_lost_opp_cflow_coalesce = 0;2486int PhaseChaitin::_used_cisc_instructions = 0;2487int PhaseChaitin::_unused_cisc_instructions = 0;2488int PhaseChaitin::_allocator_attempts = 0;2489int PhaseChaitin::_allocator_successes = 0;24902491#ifndef PRODUCT2492uint PhaseChaitin::_high_pressure = 0;2493uint PhaseChaitin::_low_pressure = 0;24942495void PhaseChaitin::print_chaitin_statistics() {2496tty->print_cr("Inserted %d spill loads, %d spill stores, %d mem-mem moves and %d copies.", _final_loads, _final_stores, _final_memoves, _final_copies);2497tty->print_cr("Total load cost= %6.0f, store cost = %6.0f, mem-mem cost = %5.2f, copy cost = %5.0f.", _final_load_cost, _final_store_cost, _final_memove_cost, _final_copy_cost);2498tty->print_cr("Adjusted spill cost = %7.0f.",2499_final_load_cost*4.0 + _final_store_cost * 2.0 +2500_final_copy_cost*1.0 + _final_memove_cost*12.0);2501tty->print("Conservatively coalesced %d copies, %d pairs",2502_conserv_coalesce, _conserv_coalesce_pair);2503if( _conserv_coalesce_trie || _conserv_coalesce_quad )2504tty->print(", %d tries, %d quads", _conserv_coalesce_trie, _conserv_coalesce_quad);2505tty->print_cr(", %d post alloc.", _post_alloc);2506if( _lost_opp_pp_coalesce || _lost_opp_cflow_coalesce )2507tty->print_cr("Lost coalesce opportunity, %d private-private, and %d cflow interfered.",2508_lost_opp_pp_coalesce, _lost_opp_cflow_coalesce );2509if( _used_cisc_instructions || _unused_cisc_instructions )2510tty->print_cr("Used cisc instruction %d, remained in register %d",2511_used_cisc_instructions, _unused_cisc_instructions);2512if( _allocator_successes != 0 )2513tty->print_cr("Average allocation trips %f", (float)_allocator_attempts/(float)_allocator_successes);2514tty->print_cr("High Pressure Blocks = %d, Low Pressure Blocks = %d", _high_pressure, _low_pressure);2515}2516#endif // not PRODUCT251725182519