#define DERIVED 0
bool nullcheck = false;
if( n->is_MachNullCheck() )
nullcheck = true;
if( !nullcheck ) {
JVMState* jvms = n->jvms();
uint oopoff = jvms ? jvms->oopoff() : cnt;
uint old_last = cnt - 1;
for( inpidx = 1; inpidx < cnt; inpidx++ ) {
if (inpidx > old_last && ((inpidx - oopoff) & 1) == DERIVED) {
continue; // skip derived_debug added below
}
uint useidx = _lrg_map.find_id(n->in(inpidx));
if (useidx < _lrg_map.max_lrg_id() && lrgs(useidx).reg() >= LRG::SPILL_REG) {
slidx = lrg2reach[useidx];
Node *def = Reachblock[slidx];
assert( def != NULL, "Using Undefined Value in Split()\n");
if ( jvms && jvms->is_monitor_use(inpidx) ) {
def = clone_node(def, b, C);
if (def == NULL || C->check_node_count(NodeLimitFudgeFactor, out_of_nodes)) {
return 0;
}
_lrg_map.extend(def->_idx, 0);
_cfg.map_node_to_block(def, b);
n->set_req(inpidx, def);
continue;
}
if( def->rematerialize() ) {
int old_size = b->number_of_nodes();
def = split_Rematerialize( def, b, insidx, maxlrg, splits, slidx, lrg2reach, Reachblock, true );
if( !def ) return 0; // Bail out
insidx += b->number_of_nodes()-old_size;
}
MachNode *mach = n->is_Mach() ? n->as_Mach() : NULL;
if ((inpidx >= oopoff) ||
(mach && mach->ideal_Opcode() == Op_AddP && inpidx == AddPNode::Base)) {
if (def->rematerialize() && lrgs(useidx)._was_spilled2) {
maxlrg = split_USE(def,b,n,inpidx,maxlrg,false,false,splits,slidx);
if (!maxlrg) {
return 0;
}
insidx++; // Reset iterator to skip USE side split
} else {
n->set_req(inpidx, def);
}
if (inpidx >= oopoff) {
Node *derived_debug = debug_defs[slidx];
if( ((inpidx - oopoff) & 1) == DERIVED && // derived vs base?
mach && mach->ideal_Opcode() != Op_Halt &&
derived_debug != NULL &&
derived_debug != def ) { // Actual 2nd value appears
uint k;
for( k = oopoff; k < cnt; k += 2 )
if( n->in(k) == derived_debug )
break; // Found an instance of debug derived
if( k == cnt ) {// No instance of debug_defs[slidx]
assert(((n->req() - oopoff) & 1) == DERIVED,
"must match skip condition above");
n->add_req( derived_debug ); // this will be skipped above
n->add_req( n->in(inpidx+1) ); // this will be processed
cnt += 2;
}
}
}
continue;
}
if( jvms && b->_freq > BLOCK_FREQUENCY(0.5) ) {
uint debug_start = jvms->debug_start();
if ((debug_start <= inpidx) && (debug_defs[slidx] != NULL)) {
assert(inpidx < oopoff, "handle only debug info here");
n->set_req(inpidx, debug_defs[slidx]);
continue;
}
}
const RegMask &dmask = def->out_RegMask();
const RegMask &umask = n->in_RegMask(inpidx);
bool is_vect = RegMask::is_vector(def->ideal_reg());
assert(inpidx < oopoff, "cannot use-split oop map info");
bool dup = UPblock[slidx];
bool uup = umask.is_UP();
if( !umask.is_AllStack() &&
(int)umask.Size() <= lrgs(useidx).num_regs() &&
(!def->rematerialize() ||
!is_vect && umask.is_misaligned_pair())) {
maxlrg = split_USE(def,b,n,inpidx,maxlrg,dup,false, splits,slidx);
if (!maxlrg) {
return 0;
}
insidx++; // Reset iterator to skip USE side split
continue;
}
if (UseFPUForSpilling && n->is_MachCall() && !uup && !dup ) {
maxlrg = split_USE(def,b,n,inpidx,maxlrg,dup,false, splits,slidx);
if (!maxlrg) {
return 0;
}
insidx++; // Reset iterator to skip USE side split
continue;
}
if( dup == uup ) {
if( dmask.overlap(umask) ) {
n->set_req(inpidx, def);
}
else { // Both are either up or down, and there is no overlap
if( dup ) { // If UP, reg->reg copy
maxlrg = split_USE(def,b,n,inpidx,maxlrg,false,false, splits,slidx);
if (!maxlrg) {
return 0;
}
insidx++; // Reset iterator to skip USE side split
}
else { // DOWN, mem->mem copy
uint def_ideal = def->ideal_reg();
const RegMask* tmp_rm = Matcher::idealreg2regmask[def_ideal];
Node *spill = new (C) MachSpillCopyNode(def, dmask, *tmp_rm);
insert_proj( b, insidx, spill, maxlrg );
maxlrg = split_USE(spill,b,n,inpidx,maxlrg,false,false, splits,slidx);
if (!maxlrg) {
return 0;
}
insidx += 2; // Reset iterator to skip USE side splits
}
} // End else no overlap
} // End if dup == uup
else {
if( dup ) { // If UP, Split-DOWN and check Debug Info
if( n->is_SpillCopy() ) {
RegMask tmp_rm(umask);
tmp_rm.SUBTRACT(Matcher::STACK_ONLY_mask);
if( dmask.overlap(tmp_rm) ) {
if( def != n->in(inpidx) ) {
n->set_req(inpidx, def);
}
continue;
}
}
maxlrg = split_USE(def,b,n,inpidx,maxlrg,false,false, splits,slidx);
if (!maxlrg) {
return 0;
}
insidx++; // Reset iterator to skip USE side split
if (jvms && jvms->debug_start() <= inpidx && inpidx < oopoff)
debug_defs[slidx] = n->in(inpidx);
}
else { // DOWN, Split-UP and check register pressure
if( is_high_pressure( b, &lrgs(useidx), insidx ) ) {
maxlrg = split_USE(def,b,n,inpidx,maxlrg,true,true, splits,slidx);
if (!maxlrg) {
return 0;
}
insidx++; // Reset iterator to skip USE side split
} else { // LRP
maxlrg = split_USE(def,b,n,inpidx,maxlrg,true,false, splits,slidx);
if (!maxlrg) {
return 0;
}
set_was_spilled(n->in(inpidx));
Reachblock[slidx] = n->in(inpidx);
UPblock[slidx] = true;
insidx++; // Reset iterator to skip USE side split
}
} // End else DOWN
} // End dup != uup
} // End if Spill USE
} // End For All Inputs
} // End If not nullcheck
if( deflrg.reg() >= LRG::SPILL_REG ) { // Spilled?
uint slidx = lrg2reach[defidx];
defs->push(n);
if( !deflrg._direct_conflict )
set_was_spilled(n);
assert(!n->is_Phi(),"Cannot insert Phi into DEFS list");
const RegMask &dmask = n->out_RegMask();
bool defup = dmask.is_UP();
uint ireg = n->ideal_reg();
bool is_vect = RegMask::is_vector(ireg);
if( !n->rematerialize() &&
(((dmask.is_bound(ireg) || !is_vect && dmask.is_misaligned_pair()) &&
(deflrg._direct_conflict || deflrg._must_spill)) ||
(defup && is_high_pressure(b,&deflrg,insidx) && !n->is_SpillCopy())) ) {
assert( !n->rematerialize(), "" );
maxlrg = split_DEF( n, b, insidx, maxlrg, Reachblock, debug_defs, splits, slidx );
if (!maxlrg) {
return 0;
}
UPblock[slidx] = 0;
#ifndef PRODUCT
if( trace_spilling() ) {
tty->print("\nNew Split DOWN DEF of Spill Idx ");
tty->print("%d, UP %d:\n",slidx,false);
n->dump();
}
#endif
}
else { // Neither bound nor HRP, must be LRP
Reachblock[slidx] = n;
UPblock[slidx] = defup;
debug_defs[slidx] = defup ? NULL : n;
#ifndef PRODUCT
if( trace_spilling() ) {
tty->print("\nNew DEF of Spill Idx ");
tty->print("%d, UP %d:\n",slidx,defup);
n->dump();
}
#endif
} // End else LRP
} // End if spill def
if (copyidx) {
Node *use = n->in(copyidx);
uint useidx = _lrg_map.find_id(use);
if (useidx < _lrg_map.max_lrg_id() && // This is not a new split
OptoReg::is_stack(deflrg.reg()) &&
deflrg.reg() < LRG::SPILL_REG ) { // And DEF is from stack
LRG &uselrg = lrgs(useidx);
if( OptoReg::is_stack(uselrg.reg()) &&
uselrg.reg() < LRG::SPILL_REG && // USE is from stack
deflrg.reg() != uselrg.reg() ) { // Not trivially removed
uint def_ideal_reg = n->bottom_type()->ideal_reg();
const RegMask &def_rm = *Matcher::idealreg2regmask[def_ideal_reg];
const RegMask &use_rm = n->in_RegMask(copyidx);
if( def_rm.overlap(use_rm) && n->is_SpillCopy() ) { // Bug 4707800, 'n' may be a storeSSL
if (C->check_node_count(NodeLimitFudgeFactor, out_of_nodes)) { // Check when generating nodes
return 0;
}
Node *spill = new (C) MachSpillCopyNode(use,use_rm,def_rm);
n->set_req(copyidx,spill);
n->as_MachSpillCopy()->set_in_RegMask(def_rm);
insert_proj( b, insidx++, spill, maxlrg++ );
}
}
}
}
} // End For All Instructions in Block - Non-PHI Pass
for( slidx = 0; slidx < spill_cnt; slidx++ ) {
uint defidx = lidxs.at(slidx);
IndexSet *liveout = _live->live(b);
if( !liveout->member(defidx) ) {
#ifdef ASSERT
uint member;
IndexSetIterator isi(liveout);
while ((member = isi.next()) != 0) {
assert(defidx != _lrg_map.find_const(member), "Live out member has not been compressed");
}
#endif
Reachblock[slidx] = NULL;
} else {
assert(Reachblock[slidx] != NULL,"No reaching definition for liveout value");
}
}
#ifndef PRODUCT
if( trace_spilling() )
b->dump();
#endif
} // End For All Blocks
for( insidx = 0; insidx < defs->size(); insidx++ ) {
n1 = defs->at(insidx);
new_lrg(n1, maxlrg++);
}
uint lrgs_before_phi_split = maxlrg;
for( insidx = 0; insidx < phis->size(); insidx++ ) {
Node *phi = phis->at(insidx);
assert(phi->is_Phi(),"This list must only contain Phi Nodes");
Block *b = _cfg.get_block_for_node(phi);
uint lidx = _lrg_map.find_id(phi);
uint slidx = lrg2reach[lidx];
new_lrg(phi, maxlrg++);
int phi_up = !!UP_entry[slidx]->test(b->_pre_order);
if( lrgs(lidx)._was_spilled1 )
phi_up = false;
for( uint i = 1; i < b->num_preds(); i++ ) {
Block *pred = _cfg.get_block_for_node(b->pred(i));
pidx = pred->_pre_order;
Node *def = Reaches[pidx][slidx];
Node** Reachblock = Reaches[pidx];
assert( def, "must have reaching def" );
if (def->rematerialize()) {
int insert = pred->end_idx();
while (insert >= 1 &&
pred->get_node(insert - 1)->is_SpillCopy() &&
_lrg_map.find(pred->get_node(insert - 1)) >= lrgs_before_phi_split) {
insert--;
}
def = split_Rematerialize(def, pred, insert, maxlrg, splits, slidx, lrg2reach, Reachblock, false);
if (!def) {
return 0; // Bail out
}
}
phi->set_req(i,def);
u1 = UP[pidx][slidx];
if( u1 != (phi_up != 0)) {
maxlrg = split_USE(def, b, phi, i, maxlrg, !u1, false, splits,slidx);
if (!maxlrg) {
return 0;
}
}
} // End for all inputs to the Phi
} // End for all Phi Nodes
_lrg_map.set_max_lrg_id(maxlrg);
for( insidx = 0; insidx < phis->size(); insidx++ ) {
Node *phi = phis->at(insidx);
assert(phi->is_Phi(),"This list must only contain Phi Nodes");
for( uint i = 1; i < phi->req(); i++ ) {
Node *n = phi->in(i);
assert(n, "node should exist");
uint lidx = _lrg_map.find(n);
uint pidx = _lrg_map.find(phi);
if (lidx < pidx) {
Union(n, phi);
}
else if(lidx > pidx) {
Union(phi, n);
}
} // End for all inputs to the Phi Node
} // End for all Phi Nodes
for (insidx = 0; insidx < defs->size(); insidx++) {
n1 = defs->at(insidx);
if (n1->is_Mach() && ((twoidx = n1->as_Mach()->two_adr()) != 0)) {
assert(_lrg_map.find(n1->in(twoidx)) < maxlrg,"Assigning bad live range index");
uint lr1 = _lrg_map.find(n1);
uint lr2 = _lrg_map.find(n1->in(twoidx));
if (lr1 < lr2) {
Union(n1, n1->in(twoidx));
}
else if (lr1 > lr2) {
Union(n1->in(twoidx), n1);
}
} // End if two address
} // End for all defs
#ifdef ASSERT
for (bidx = 0; bidx < _cfg.number_of_blocks(); bidx++) {
b = _cfg.get_block(bidx);
for (insidx = 0; insidx <= b->end_idx(); insidx++) {
Node *n = b->get_node(insidx);
uint defidx = _lrg_map.find(n);
assert(defidx < _lrg_map.max_lrg_id(), "Bad live range index in Split");
assert(defidx < maxlrg,"Bad live range index in Split");
}
}
int noprogress = 0;
for (slidx = 0; slidx < spill_cnt; slidx++) {
if (PrintOpto && WizardMode && splits.at(slidx) == 0) {
tty->print_cr("Failed to split live range %d", lidxs.at(slidx));
}
else {
noprogress++;
}
}
if(!noprogress) {
tty->print_cr("Failed to make progress in Split");
}
#endif
return maxlrg;
}
C:\hotspot-69087d08d473\src\share\vm/opto/replacednodes.cpp
#include "precompiled.hpp"
#include "opto/cfgnode.hpp"
#include "opto/phaseX.hpp"
#include "opto/replacednodes.hpp"
void ReplacedNodes::allocate_if_necessary() {
if (_replaced_nodes == NULL) {
_replaced_nodes = new GrowableArray<ReplacedNode>();
}
}
bool ReplacedNodes::is_empty() const {
return _replaced_nodes == NULL || _replaced_nodes->length() == 0;
}
bool ReplacedNodes::has_node(const ReplacedNode& r) const {
return _replaced_nodes->find(r) != -1;
}
bool ReplacedNodes::has_target_node(Node* n) const {
for (int i = 0; i < _replaced_nodes->length(); i++) {
if (_replaced_nodes->at(i).improved() == n) {
return true;
}
}
return false;
}
void ReplacedNodes::record(Node* initial, Node* improved) {
allocate_if_necessary();
ReplacedNode r(initial, improved);
if (!has_node(r)) {
_replaced_nodes->push(r);
}
}
void ReplacedNodes::transfer_from(const ReplacedNodes& other, uint idx) {
if (other.is_empty()) {
return;
}
allocate_if_necessary();
for (int i = 0; i < other._replaced_nodes->length(); i++) {
ReplacedNode replaced = other._replaced_nodes->at(i);
if (!has_node(replaced) && (replaced.initial()->_idx < idx || has_target_node(replaced.initial()))) {
_replaced_nodes->push(replaced);
}
}
}
void ReplacedNodes::clone() {
if (_replaced_nodes != NULL) {
GrowableArray<ReplacedNode>* replaced_nodes_clone = new GrowableArray<ReplacedNode>();
replaced_nodes_clone->appendAll(_replaced_nodes);
_replaced_nodes = replaced_nodes_clone;
}
}
void ReplacedNodes::reset() {
if (_replaced_nodes != NULL) {
_replaced_nodes->clear();
}
}
void ReplacedNodes::apply(Node* n, uint idx) {
if (is_empty()) {
return;
}
for (int i = 0; i < _replaced_nodes->length(); i++) {
ReplacedNode replaced = _replaced_nodes->at(i);
if (replaced.improved()->_idx >= idx) {
n->replace_edge(replaced.initial(), replaced.improved());
}
}
}
static void enqueue_use(Node* n, Node* use, Unique_Node_List& work) {
if (use->is_Phi()) {
Node* r = use->in(0);
assert(r->is_Region(), "Phi should have Region");
for (uint i = 1; i < use->req(); i++) {
if (use->in(i) == n) {
work.push(r->in(i));
}
}
} else {
work.push(use);
}
}
void ReplacedNodes::apply(Compile* C, Node* ctl) {
if (is_empty()) {
return;
}
for (int i = 0; i < _replaced_nodes->length(); i++) {
ReplacedNode replaced = _replaced_nodes->at(i);
Node* initial = replaced.initial();
Node* improved = replaced.improved();
assert (ctl != NULL && !ctl->is_top(), "replaced node should have actual control");
ResourceMark rm;
Unique_Node_List work;
for (DUIterator j = initial->outs(); initial->has_out(j); j++) {
Node* use = initial->out(j);
if (use == improved || use->outcnt() == 0) {
continue;
}
work.clear();
enqueue_use(initial, use, work);
bool replace = true;
while (work.size() != 0 && replace) {
Node* n = work.pop();
if (use->outcnt() == 0) {
continue;
}
if (n->is_CFG() || (n->in(0) != NULL && !n->in(0)->is_top())) {
int depth = 0;
Node *m = n;
if (!n->is_CFG()) {
n = n->in(0);
}
assert(n->is_CFG(), "should be CFG now");
while(n != ctl) {
n = IfNode::up_one_dom(n);
depth++;
if (depth >= 100 || n == NULL) {
replace = false;
break;
}
}
} else {
for (DUIterator k = n->outs(); n->has_out(k); k++) {
enqueue_use(n, n->out(k), work);
}
}
}
if (replace) {
bool is_in_table = C->initial_gvn()->hash_delete(use);
int replaced = use->replace_edge(initial, improved);
if (is_in_table) {
C->initial_gvn()->hash_find_insert(use);
}
C->record_for_igvn(use);
assert(replaced > 0, "inconsistent");
--j;
}
}
}
}
void ReplacedNodes::dump(outputStream *st) const {
if (!is_empty()) {
st->print("replaced nodes: ");
for (int i = 0; i < _replaced_nodes->length(); i++) {
st->print("%d->%d", _replaced_nodes->at(i).initial()->_idx, _replaced_nodes->at(i).improved()->_idx);
if (i < _replaced_nodes->length()-1) {
st->print(",");
}
}
}
}
void ReplacedNodes::merge_with(const ReplacedNodes& other) {
if (is_empty()) {
return;
}
if (other.is_empty()) {
reset();
return;
}
int shift = 0;
int len = _replaced_nodes->length();
for (int i = 0; i < len; i++) {
if (!other.has_node(_replaced_nodes->at(i))) {
shift++;
} else if (shift > 0) {
_replaced_nodes->at_put(i-shift, _replaced_nodes->at(i));
}
}
if (shift > 0) {
_replaced_nodes->trunc_to(len - shift);
}
}
C:\hotspot-69087d08d473\src\share\vm/opto/replacednodes.hpp
#ifndef SHARE_VM_OPTO_REPLACEDNODES_HPP
#define SHARE_VM_OPTO_REPLACEDNODES_HPP
#include "opto/connode.hpp"
class ReplacedNodes VALUE_OBJ_CLASS_SPEC {
private:
class ReplacedNode VALUE_OBJ_CLASS_SPEC {
private:
Node* _initial;
Node* _improved;
public:
ReplacedNode() : _initial(NULL), _improved(NULL) {}
ReplacedNode(Node* initial, Node* improved) : _initial(initial), _improved(improved) {}
Node* initial() const { return _initial; }
Node* improved() const { return _improved; }
bool operator==(const ReplacedNode& other) {
return _initial == other._initial && _improved == other._improved;
}
};
GrowableArray<ReplacedNode>* _replaced_nodes;
void allocate_if_necessary();
bool has_node(const ReplacedNode& r) const;
bool has_target_node(Node* n) const;
public:
ReplacedNodes()
: _replaced_nodes(NULL) {}
void clone();
void record(Node* initial, Node* improved);
void transfer_from(const ReplacedNodes& other, uint idx);
void reset();
void apply(Node* n, uint idx);
void merge_with(const ReplacedNodes& other);
bool is_empty() const;
void dump(outputStream *st) const;
void apply(Compile* C, Node* ctl);
};
#endif // SHARE_VM_OPTO_REPLACEDNODES_HPP
C:\hotspot-69087d08d473\src\share\vm/opto/rootnode.cpp
#include "precompiled.hpp"
#include "memory/allocation.inline.hpp"
#include "opto/callnode.hpp"
#include "opto/cfgnode.hpp"
#include "opto/phaseX.hpp"
#include "opto/regmask.hpp"
#include "opto/rootnode.hpp"
#include "opto/subnode.hpp"
#include "opto/type.hpp"
Node *RootNode::Ideal(PhaseGVN *phase, bool can_reshape) {
for( uint i = 1; i < req(); i++ ) { // For all inputs
if( phase->type(in(i)) == Type::TOP ) {
del_req(i--); // Delete TOP inputs
}
}
return NULL; // No further opportunities exposed
}
HaltNode::HaltNode( Node *ctrl, Node *frameptr ) : Node(TypeFunc::Parms) {
Node* top = Compile::current()->top();
init_req(TypeFunc::Control, ctrl );
init_req(TypeFunc::I_O, top);
init_req(TypeFunc::Memory, top);
init_req(TypeFunc::FramePtr, frameptr );
init_req(TypeFunc::ReturnAdr,top);
}
const Type *HaltNode::bottom_type() const { return Type::BOTTOM; }
Node *HaltNode::Ideal(PhaseGVN *phase, bool can_reshape) {
return remove_dead_region(phase, can_reshape) ? this : NULL;
}
const Type *HaltNode::Value( PhaseTransform *phase ) const {
return ( phase->type(in(TypeFunc::Control)) == Type::TOP)
? Type::TOP
: Type::BOTTOM;
}
const RegMask &HaltNode::out_RegMask() const {
return RegMask::Empty;
}
C:\hotspot-69087d08d473\src\share\vm/opto/rootnode.hpp
#ifndef SHARE_VM_OPTO_ROOTNODE_HPP
#define SHARE_VM_OPTO_ROOTNODE_HPP
#include "opto/loopnode.hpp"
class RootNode : public LoopNode {
public:
RootNode( ) : LoopNode(0,0) {
init_class_id(Class_Root);
del_req(2);
del_req(1);
}
virtual int Opcode() const;
virtual const Node *is_block_proj() const { return this; }
virtual const Type *bottom_type() const { return Type::BOTTOM; }
virtual Node *Identity( PhaseTransform *phase ) { return this; }
virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
virtual const Type *Value( PhaseTransform *phase ) const { return Type::BOTTOM; }
};
class HaltNode : public Node {
public:
HaltNode( Node *ctrl, Node *frameptr );
virtual int Opcode() const;
virtual bool pinned() const { return true; };
virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
virtual const Type *Value( PhaseTransform *phase ) const;
virtual const Type *bottom_type() const;
virtual bool is_CFG() const { return true; }
virtual uint hash() const { return NO_HASH; } // CFG nodes do not hash
virtual bool depends_only_on_test() const { return false; }
virtual const Node *is_block_proj() const { return this; }
virtual const RegMask &out_RegMask() const;
virtual uint ideal_reg() const { return NotAMachineReg; }
virtual uint match_edge(uint idx) const { return 0; }
};
#endif // SHARE_VM_OPTO_ROOTNODE_HPP
C:\hotspot-69087d08d473\src\share\vm/opto/runtime.cpp
#include "precompiled.hpp"
#include "classfile/systemDictionary.hpp"
#include "classfile/vmSymbols.hpp"
#include "code/compiledIC.hpp"
#include "code/icBuffer.hpp"
#include "code/nmethod.hpp"
#include "code/pcDesc.hpp"
#include "code/scopeDesc.hpp"
#include "code/vtableStubs.hpp"
#include "compiler/compileBroker.hpp"
#include "compiler/compilerOracle.hpp"
#include "compiler/oopMap.hpp"
#include "gc_implementation/g1/g1SATBCardTableModRefBS.hpp"
#include "gc_implementation/g1/heapRegion.hpp"
#include "gc_interface/collectedHeap.hpp"
#include "interpreter/bytecode.hpp"
#include "interpreter/interpreter.hpp"
#include "interpreter/linkResolver.hpp"
#include "memory/barrierSet.hpp"
#include "memory/gcLocker.inline.hpp"
#include "memory/oopFactory.hpp"
#include "oops/objArrayKlass.hpp"
#include "oops/oop.inline.hpp"
#include "opto/addnode.hpp"
#include "opto/callnode.hpp"
#include "opto/cfgnode.hpp"
#include "opto/connode.hpp"
#include "opto/graphKit.hpp"
#include "opto/machnode.hpp"
#include "opto/matcher.hpp"
#include "opto/memnode.hpp"
#include "opto/mulnode.hpp"
#include "opto/runtime.hpp"
#include "opto/subnode.hpp"
#include "runtime/fprofiler.hpp"
#include "runtime/handles.inline.hpp"
#include "runtime/interfaceSupport.hpp"
#include "runtime/javaCalls.hpp"
#include "runtime/sharedRuntime.hpp"
#include "runtime/signature.hpp"
#include "runtime/threadCritical.hpp"
#include "runtime/vframe.hpp"
#include "runtime/vframeArray.hpp"
#include "runtime/vframe_hp.hpp"
#include "utilities/copy.hpp"
#include "utilities/preserveException.hpp"
#if defined AD_MD_HPP
# include AD_MD_HPP
#elif defined TARGET_ARCH_MODEL_x86_32
# include "adfiles/ad_x86_32.hpp"
#elif defined TARGET_ARCH_MODEL_x86_64
# include "adfiles/ad_x86_64.hpp"
#elif defined TARGET_ARCH_MODEL_aarch64
# include "adfiles/ad_aarch64.hpp"
#elif defined TARGET_ARCH_MODEL_sparc
# include "adfiles/ad_sparc.hpp"
#elif defined TARGET_ARCH_MODEL_zero
# include "adfiles/ad_zero.hpp"
#elif defined TARGET_ARCH_MODEL_ppc_64
# include "adfiles/ad_ppc_64.hpp"
#endif
const TypeFunc* OptoRuntime::ghash_processBlocks_Type() {
int argcnt = 4;
const Type** fields = TypeTuple::fields(argcnt);
int argp = TypeFunc::Parms;
fields[argp++] = TypePtr::NOTNULL; // state
fields[argp++] = TypePtr::NOTNULL; // subkeyH
fields[argp++] = TypePtr::NOTNULL; // data
fields[argp++] = TypeInt::INT; // blocks
assert(argp == TypeFunc::Parms+argcnt, "correct decoding");
const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms+argcnt, fields);
fields = TypeTuple::fields(1);
fields[TypeFunc::Parms+0] = NULL; // void
const TypeTuple* range = TypeTuple::make(TypeFunc::Parms, fields);
return TypeFunc::make(domain, range);
}
address OptoRuntime::_new_instance_Java = NULL;
address OptoRuntime::_new_array_Java = NULL;
address OptoRuntime::_new_array_nozero_Java = NULL;
address OptoRuntime::_multianewarray2_Java = NULL;
address OptoRuntime::_multianewarray3_Java = NULL;
address OptoRuntime::_multianewarray4_Java = NULL;
address OptoRuntime::_multianewarray5_Java = NULL;
address OptoRuntime::_multianewarrayN_Java = NULL;
address OptoRuntime::_g1_wb_pre_Java = NULL;
address OptoRuntime::_g1_wb_post_Java = NULL;
address OptoRuntime::_vtable_must_compile_Java = NULL;
address OptoRuntime::_complete_monitor_locking_Java = NULL;
address OptoRuntime::_rethrow_Java = NULL;
address OptoRuntime::_slow_arraycopy_Java = NULL;
address OptoRuntime::_register_finalizer_Java = NULL;
# ifdef ENABLE_ZAP_DEAD_LOCALS
address OptoRuntime::_zap_dead_Java_locals_Java = NULL;
address OptoRuntime::_zap_dead_native_locals_Java = NULL;
# endif
ExceptionBlob* OptoRuntime::_exception_blob;
#ifdef ASSERT
static bool check_compiled_frame(JavaThread* thread) {
assert(thread->last_frame().is_runtime_frame(), "cannot call runtime directly from compiled code");
RegisterMap map(thread, false);
frame caller = thread->last_frame().sender(&map);
assert(caller.is_compiled_frame(), "not being called from compiled like code");
return true;
}
#endif // ASSERT
#define gen(env, var, type_func_gen, c_func, fancy_jump, pass_tls, save_arg_regs, return_pc) \
var = generate_stub(env, type_func_gen, CAST_FROM_FN_PTR(address, c_func), #var, fancy_jump, pass_tls, save_arg_regs, return_pc); \
if (var == NULL) { return false; }
bool OptoRuntime::generate(ciEnv* env) {
generate_exception_blob();
gen(env, _new_instance_Java , new_instance_Type , new_instance_C , 0 , true , false, false);
gen(env, _new_array_Java , new_array_Type , new_array_C , 0 , true , false, false);
gen(env, _new_array_nozero_Java , new_array_Type , new_array_nozero_C , 0 , true , false, false);
gen(env, _multianewarray2_Java , multianewarray2_Type , multianewarray2_C , 0 , true , false, false);
gen(env, _multianewarray3_Java , multianewarray3_Type , multianewarray3_C , 0 , true , false, false);
gen(env, _multianewarray4_Java , multianewarray4_Type , multianewarray4_C , 0 , true , false, false);
gen(env, _multianewarray5_Java , multianewarray5_Type , multianewarray5_C , 0 , true , false, false);
gen(env, _multianewarrayN_Java , multianewarrayN_Type , multianewarrayN_C , 0 , true , false, false);
gen(env, _g1_wb_pre_Java , g1_wb_pre_Type , SharedRuntime::g1_wb_pre , 0 , false, false, false);
gen(env, _g1_wb_post_Java , g1_wb_post_Type , SharedRuntime::g1_wb_post , 0 , false, false, false);
gen(env, _complete_monitor_locking_Java , complete_monitor_enter_Type , SharedRuntime::complete_monitor_locking_C, 0, false, false, false);
gen(env, _rethrow_Java , rethrow_Type , rethrow_C , 2 , true , false, true );
gen(env, _slow_arraycopy_Java , slow_arraycopy_Type , SharedRuntime::slow_arraycopy_C , 0 , false, false, false);
gen(env, _register_finalizer_Java , register_finalizer_Type , register_finalizer , 0 , false, false, false);
# ifdef ENABLE_ZAP_DEAD_LOCALS
gen(env, _zap_dead_Java_locals_Java , zap_dead_locals_Type , zap_dead_Java_locals_C , 0 , false, true , false );
gen(env, _zap_dead_native_locals_Java , zap_dead_locals_Type , zap_dead_native_locals_C , 0 , false, true , false );
# endif
return true;
}
#undef gen
address OptoRuntime::generate_stub( ciEnv* env,
TypeFunc_generator gen, address C_function,
const char *name, int is_fancy_jump,
bool pass_tls,
bool save_argument_registers,
bool return_pc ) {
ResourceMark rm;
Compile C( env, gen, C_function, name, is_fancy_jump, pass_tls, save_argument_registers, return_pc );
return C.stub_entry_point();
}
const char* OptoRuntime::stub_name(address entry) {
#ifndef PRODUCT
CodeBlob* cb = CodeCache::find_blob(entry);
RuntimeStub* rs =(RuntimeStub *)cb;
assert(rs != NULL && rs->is_runtime_stub(), "not a runtime stub");
return rs->name();
#else
return "runtime stub";
#endif
}
void OptoRuntime::new_store_pre_barrier(JavaThread* thread) {
oop new_obj = thread->vm_result();
if (new_obj == NULL) return;
assert(Universe::heap()->can_elide_tlab_store_barriers(),
"compiler must check this first");
new_obj = Universe::heap()->new_store_pre_barrier(thread, new_obj);
thread->set_vm_result(new_obj);
}
JRT_BLOCK_ENTRY(void, OptoRuntime::new_instance_C(Klass* klass, JavaThread* thread))
JRT_BLOCK;
#ifndef PRODUCT
SharedRuntime::_new_instance_ctr++; // new instance requires GC
#endif
assert(check_compiled_frame(thread), "incorrect caller");
int lh = klass->layout_helper();
if (Klass::layout_helper_needs_slow_path(lh) || !InstanceKlass::cast(klass)->is_initialized()) {
Handle holder(THREAD, klass->klass_holder()); // keep the klass alive
klass->check_valid_for_instantiation(false, THREAD);
if (!HAS_PENDING_EXCEPTION) {
InstanceKlass::cast(klass)->initialize(THREAD);
}
}
if (!HAS_PENDING_EXCEPTION) {
Handle holder(THREAD, klass->klass_holder()); // keep the klass alive
oop result = InstanceKlass::cast(klass)->allocate_instance(THREAD);
thread->set_vm_result(result);
}
deoptimize_caller_frame(thread, HAS_PENDING_EXCEPTION);
JRT_BLOCK_END;
if (GraphKit::use_ReduceInitialCardMarks()) {
new_store_pre_barrier(thread);
}
JRT_END
JRT_BLOCK_ENTRY(void, OptoRuntime::new_array_C(Klass* array_type, int len, JavaThread *thread))
JRT_BLOCK;
#ifndef PRODUCT
SharedRuntime::_new_array_ctr++; // new array requires GC
#endif
assert(check_compiled_frame(thread), "incorrect caller");
oop result;
if (array_type->oop_is_typeArray()) {
BasicType elem_type = TypeArrayKlass::cast(array_type)->element_type();
result = oopFactory::new_typeArray(elem_type, len, THREAD);
} else {
Handle holder(THREAD, array_type->klass_holder()); // keep the array klass alive
Klass* elem_type = ObjArrayKlass::cast(array_type)->element_klass();
result = oopFactory::new_objArray(elem_type, len, THREAD);
}
deoptimize_caller_frame(thread, HAS_PENDING_EXCEPTION);
thread->set_vm_result(result);
JRT_BLOCK_END;
if (GraphKit::use_ReduceInitialCardMarks()) {
new_store_pre_barrier(thread);
}
JRT_END
JRT_BLOCK_ENTRY(void, OptoRuntime::new_array_nozero_C(Klass* array_type, int len, JavaThread *thread))
JRT_BLOCK;
#ifndef PRODUCT
SharedRuntime::_new_array_ctr++; // new array requires GC
#endif
assert(check_compiled_frame(thread), "incorrect caller");
oop result;
assert(array_type->oop_is_typeArray(), "should be called only for type array");
BasicType elem_type = TypeArrayKlass::cast(array_type)->element_type();
result = oopFactory::new_typeArray_nozero(elem_type, len, THREAD);
deoptimize_caller_frame(thread, HAS_PENDING_EXCEPTION);
thread->set_vm_result(result);
JRT_BLOCK_END;
if (GraphKit::use_ReduceInitialCardMarks()) {
new_store_pre_barrier(thread);
}
oop result = thread->vm_result();
if ((len > 0) && (result != NULL) &&
is_deoptimized_caller_frame(thread)) {
int size = ((typeArrayOop)result)->object_size();
BasicType elem_type = TypeArrayKlass::cast(array_type)->element_type();
const size_t hs = arrayOopDesc::header_size(elem_type);
const size_t aligned_hs = align_object_offset(hs);
HeapWord* obj = (HeapWord*)result;
if (aligned_hs > hs) {
Copy::zero_to_words(obj+hs, aligned_hs-hs);
}
Copy::fill_to_aligned_words(obj+aligned_hs, size-aligned_hs);
}
JRT_END
JRT_ENTRY(void, OptoRuntime::multianewarray2_C(Klass* elem_type, int len1, int len2, JavaThread *thread))
#ifndef PRODUCT
SharedRuntime::_multi2_ctr++; // multianewarray for 1 dimension
#endif
assert(check_compiled_frame(thread), "incorrect caller");
assert(elem_type->is_klass(), "not a class");
jint dims[2];
dims[0] = len1;
dims[1] = len2;
Handle holder(THREAD, elem_type->klass_holder()); // keep the klass alive
oop obj = ArrayKlass::cast(elem_type)->multi_allocate(2, dims, THREAD);
deoptimize_caller_frame(thread, HAS_PENDING_EXCEPTION);
thread->set_vm_result(obj);
JRT_END
JRT_ENTRY(void, OptoRuntime::multianewarray3_C(Klass* elem_type, int len1, int len2, int len3, JavaThread *thread))
#ifndef PRODUCT
SharedRuntime::_multi3_ctr++; // multianewarray for 1 dimension
#endif
assert(check_compiled_frame(thread), "incorrect caller");
assert(elem_type->is_klass(), "not a class");
jint dims[3];
dims[0] = len1;
dims[1] = len2;
dims[2] = len3;
Handle holder(THREAD, elem_type->klass_holder()); // keep the klass alive
oop obj = ArrayKlass::cast(elem_type)->multi_allocate(3, dims, THREAD);
deoptimize_caller_frame(thread, HAS_PENDING_EXCEPTION);
thread->set_vm_result(obj);
JRT_END
JRT_ENTRY(void, OptoRuntime::multianewarray4_C(Klass* elem_type, int len1, int len2, int len3, int len4, JavaThread *thread))
#ifndef PRODUCT
SharedRuntime::_multi4_ctr++; // multianewarray for 1 dimension
#endif
assert(check_compiled_frame(thread), "incorrect caller");
assert(elem_type->is_klass(), "not a class");
jint dims[4];
dims[0] = len1;
dims[1] = len2;
dims[2] = len3;
dims[3] = len4;
Handle holder(THREAD, elem_type->klass_holder()); // keep the klass alive
oop obj = ArrayKlass::cast(elem_type)->multi_allocate(4, dims, THREAD);
deoptimize_caller_frame(thread, HAS_PENDING_EXCEPTION);
thread->set_vm_result(obj);
JRT_END
JRT_ENTRY(void, OptoRuntime::multianewarray5_C(Klass* elem_type, int len1, int len2, int len3, int len4, int len5, JavaThread *thread))
#ifndef PRODUCT
SharedRuntime::_multi5_ctr++; // multianewarray for 1 dimension
#endif
assert(check_compiled_frame(thread), "incorrect caller");
assert(elem_type->is_klass(), "not a class");
jint dims[5];
dims[0] = len1;
dims[1] = len2;
dims[2] = len3;
dims[3] = len4;
dims[4] = len5;
Handle holder(THREAD, elem_type->klass_holder()); // keep the klass alive
oop obj = ArrayKlass::cast(elem_type)->multi_allocate(5, dims, THREAD);
deoptimize_caller_frame(thread, HAS_PENDING_EXCEPTION);
thread->set_vm_result(obj);
JRT_END
JRT_ENTRY(void, OptoRuntime::multianewarrayN_C(Klass* elem_type, arrayOopDesc* dims, JavaThread *thread))
assert(check_compiled_frame(thread), "incorrect caller");
assert(elem_type->is_klass(), "not a class");
assert(oop(dims)->is_typeArray(), "not an array");
ResourceMark rm;
jint len = dims->length();
assert(len > 0, "Dimensions array should contain data");
jint *j_dims = typeArrayOop(dims)->int_at_addr(0);
jint *c_dims = NEW_RESOURCE_ARRAY(jint, len);
Copy::conjoint_jints_atomic(j_dims, c_dims, len);
Handle holder(THREAD, elem_type->klass_holder()); // keep the klass alive
oop obj = ArrayKlass::cast(elem_type)->multi_allocate(len, c_dims, THREAD);
deoptimize_caller_frame(thread, HAS_PENDING_EXCEPTION);
thread->set_vm_result(obj);
JRT_END
const TypeFunc *OptoRuntime::new_instance_Type() {
const Type **fields = TypeTuple::fields(1);
fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL; // Klass to be allocated
const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+1, fields);
fields = TypeTuple::fields(1);
fields[TypeFunc::Parms+0] = TypeRawPtr::NOTNULL; // Returned oop
const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+1, fields);
return TypeFunc::make(domain, range);
}
const TypeFunc *OptoRuntime::athrow_Type() {
const Type **fields = TypeTuple::fields(1);
fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL; // Klass to be allocated
const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+1, fields);
fields = TypeTuple::fields(0);
const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+0, fields);
return TypeFunc::make(domain, range);
}
const TypeFunc *OptoRuntime::new_array_Type() {
const Type **fields = TypeTuple::fields(2);
fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL; // element klass
fields[TypeFunc::Parms+1] = TypeInt::INT; // array size
const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+2, fields);
fields = TypeTuple::fields(1);
fields[TypeFunc::Parms+0] = TypeRawPtr::NOTNULL; // Returned oop
const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+1, fields);
return TypeFunc::make(domain, range);
}
const TypeFunc *OptoRuntime::multianewarray_Type(int ndim) {
const int nargs = ndim + 1;
const Type **fields = TypeTuple::fields(nargs);
fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL; // element klass
for( int i = 1; i < nargs; i++ )
fields[TypeFunc::Parms + i] = TypeInt::INT; // array size
const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+nargs, fields);
fields = TypeTuple::fields(1);
fields[TypeFunc::Parms+0] = TypeRawPtr::NOTNULL; // Returned oop
const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+1, fields);
return TypeFunc::make(domain, range);
}
const TypeFunc *OptoRuntime::multianewarray2_Type() {
return multianewarray_Type(2);
}
const TypeFunc *OptoRuntime::multianewarray3_Type() {
return multianewarray_Type(3);
}
const TypeFunc *OptoRuntime::multianewarray4_Type() {
return multianewarray_Type(4);
}
const TypeFunc *OptoRuntime::multianewarray5_Type() {
return multianewarray_Type(5);
}
const TypeFunc *OptoRuntime::multianewarrayN_Type() {
const Type **fields = TypeTuple::fields(2);
fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL; // element klass
fields[TypeFunc::Parms+1] = TypeInstPtr::NOTNULL; // array of dim sizes
const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+2, fields);
fields = TypeTuple::fields(1);
fields[TypeFunc::Parms+0] = TypeRawPtr::NOTNULL; // Returned oop
const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+1, fields);
return TypeFunc::make(domain, range);
}
const TypeFunc *OptoRuntime::g1_wb_pre_Type() {
const Type **fields = TypeTuple::fields(2);
fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL; // original field value
fields[TypeFunc::Parms+1] = TypeRawPtr::NOTNULL; // thread
const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+2, fields);
fields = TypeTuple::fields(0);
const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+0, fields);
return TypeFunc::make(domain, range);
}
const TypeFunc *OptoRuntime::g1_wb_post_Type() {
const Type **fields = TypeTuple::fields(2);
fields[TypeFunc::Parms+0] = TypeRawPtr::NOTNULL; // Card addr
fields[TypeFunc::Parms+1] = TypeRawPtr::NOTNULL; // thread
const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+2, fields);
fields = TypeTuple::fields(0);
const TypeTuple *range = TypeTuple::make(TypeFunc::Parms, fields);
return TypeFunc::make(domain, range);
}
const TypeFunc *OptoRuntime::uncommon_trap_Type() {
const Type **fields = TypeTuple::fields(1);
fields[TypeFunc::Parms+0] = TypeInt::INT;
const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+1, fields);
fields = TypeTuple::fields(0);
const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+0, fields);
return TypeFunc::make(domain, range);
}
# ifdef ENABLE_ZAP_DEAD_LOCALS
const TypeFunc *OptoRuntime::zap_dead_locals_Type() {
const Type **fields = TypeTuple::fields(0);
const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms,fields);
fields = TypeTuple::fields(0);
const TypeTuple *range = TypeTuple::make(TypeFunc::Parms,fields);
return TypeFunc::make(domain,range);
}
# endif
const TypeFunc *OptoRuntime::complete_monitor_enter_Type() {
const Type **fields = TypeTuple::fields(2);
fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL; // Object to be Locked
fields[TypeFunc::Parms+1] = TypeRawPtr::BOTTOM; // Address of stack location for lock
const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+2,fields);
fields = TypeTuple::fields(0);
const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+0,fields);
return TypeFunc::make(domain,range);
}
const TypeFunc *OptoRuntime::complete_monitor_exit_Type() {
const Type **fields = TypeTuple::fields(2);
fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL; // Object to be Locked
fields[TypeFunc::Parms+1] = TypeRawPtr::BOTTOM; // Address of stack location for lock
const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+2,fields);
fields = TypeTuple::fields(0);
const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+0,fields);
return TypeFunc::make(domain,range);
}
const TypeFunc* OptoRuntime::flush_windows_Type() {
const Type** fields = TypeTuple::fields(1);
fields[TypeFunc::Parms+0] = NULL; // void
const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms, fields);
fields = TypeTuple::fields(1);
fields[TypeFunc::Parms+0] = NULL; // void
const TypeTuple *range = TypeTuple::make(TypeFunc::Parms, fields);
return TypeFunc::make(domain, range);
}
const TypeFunc* OptoRuntime::l2f_Type() {
const Type **fields = TypeTuple::fields(2);
fields[TypeFunc::Parms+0] = TypeLong::LONG;
fields[TypeFunc::Parms+1] = Type::HALF;
const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+2, fields);
fields = TypeTuple::fields(1);
fields[TypeFunc::Parms+0] = Type::FLOAT;
const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+1, fields);
return TypeFunc::make(domain, range);
}
const TypeFunc* OptoRuntime::modf_Type() {
const Type **fields = TypeTuple::fields(2);
fields[TypeFunc::Parms+0] = Type::FLOAT;
fields[TypeFunc::Parms+1] = Type::FLOAT;
const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+2, fields);
fields = TypeTuple::fields(1);
fields[TypeFunc::Parms+0] = Type::FLOAT;
const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+1, fields);
return TypeFunc::make(domain, range);
}
const TypeFunc *OptoRuntime::Math_D_D_Type() {
const Type **fields = TypeTuple::fields(2);
fields[TypeFunc::Parms+0] = Type::DOUBLE;
fields[TypeFunc::Parms+1] = Type::HALF;
const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+2, fields);
fields = TypeTuple::fields(2);
fields[TypeFunc::Parms+0] = Type::DOUBLE;
fields[TypeFunc::Parms+1] = Type::HALF;
const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+2, fields);
return TypeFunc::make(domain, range);
}
const TypeFunc* OptoRuntime::Math_DD_D_Type() {
const Type **fields = TypeTuple::fields(4);
fields[TypeFunc::Parms+0] = Type::DOUBLE;
fields[TypeFunc::Parms+1] = Type::HALF;
fields[TypeFunc::Parms+2] = Type::DOUBLE;
fields[TypeFunc::Parms+3] = Type::HALF;
const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+4, fields);
fields = TypeTuple::fields(2);
fields[TypeFunc::Parms+0] = Type::DOUBLE;
fields[TypeFunc::Parms+1] = Type::HALF;
const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+2, fields);
return TypeFunc::make(domain, range);
}
const TypeFunc* OptoRuntime::void_long_Type() {
const Type **fields = TypeTuple::fields(0);
const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+0, fields);
fields = TypeTuple::fields(2);
fields[TypeFunc::Parms+0] = TypeLong::LONG;
fields[TypeFunc::Parms+1] = Type::HALF;
const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+2, fields);
return TypeFunc::make(domain, range);
}
enum ArrayCopyType {
ac_fast, // void(ptr, ptr, size_t)
ac_checkcast, // int(ptr, ptr, size_t, size_t, ptr)
ac_slow, // void(ptr, int, ptr, int, int)
ac_generic // int(ptr, int, ptr, int, int)
};
static const TypeFunc* make_arraycopy_Type(ArrayCopyType act) {
int num_args = (act == ac_fast ? 3 : 5);
int num_size_args = (act == ac_fast ? 1 : act == ac_checkcast ? 2 : 0);
int argcnt = num_args;
LP64_ONLY(argcnt += num_size_args); // halfwords for lengths
const Type** fields = TypeTuple::fields(argcnt);
int argp = TypeFunc::Parms;
fields[argp++] = TypePtr::NOTNULL; // src
if (num_size_args == 0) {
fields[argp++] = TypeInt::INT; // src_pos
}
fields[argp++] = TypePtr::NOTNULL; // dest
if (num_size_args == 0) {
fields[argp++] = TypeInt::INT; // dest_pos
fields[argp++] = TypeInt::INT; // length
}
while (num_size_args-- > 0) {
fields[argp++] = TypeX_X; // size in whatevers (size_t)
LP64_ONLY(fields[argp++] = Type::HALF); // other half of long length
}
if (act == ac_checkcast) {
fields[argp++] = TypePtr::NOTNULL; // super_klass
}
assert(argp == TypeFunc::Parms+argcnt, "correct decoding of act");
const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms+argcnt, fields);
int retcnt = (act == ac_checkcast || act == ac_generic ? 1 : 0);
fields = TypeTuple::fields(1);
if (retcnt == 0)
fields[TypeFunc::Parms+0] = NULL; // void
else
fields[TypeFunc::Parms+0] = TypeInt::INT; // status result, if needed
const TypeTuple* range = TypeTuple::make(TypeFunc::Parms+retcnt, fields);
return TypeFunc::make(domain, range);
}
const TypeFunc* OptoRuntime::fast_arraycopy_Type() {
return make_arraycopy_Type(ac_fast);
}
const TypeFunc* OptoRuntime::checkcast_arraycopy_Type() {
return make_arraycopy_Type(ac_checkcast);
}
const TypeFunc* OptoRuntime::slow_arraycopy_Type() {
return make_arraycopy_Type(ac_slow);
}
const TypeFunc* OptoRuntime::generic_arraycopy_Type() {
return make_arraycopy_Type(ac_generic);
}
const TypeFunc* OptoRuntime::array_fill_Type() {
const Type** fields;
int argp = TypeFunc::Parms;
if (CCallingConventionRequiresIntsAsLongs) {
fields = TypeTuple::fields(3 LP64_ONLY( + 2));
fields[argp++] = TypePtr::NOTNULL;
fields[argp++] = TypeLong::LONG;
fields[argp++] = Type::HALF;
} else {
fields = TypeTuple::fields(3 LP64_ONLY( + 1));
fields[argp++] = TypePtr::NOTNULL;
fields[argp++] = TypeInt::INT;
}
fields[argp++] = TypeX_X; // size in whatevers (size_t)
LP64_ONLY(fields[argp++] = Type::HALF); // other half of long length
const TypeTuple *domain = TypeTuple::make(argp, fields);
fields = TypeTuple::fields(1);
fields[TypeFunc::Parms+0] = NULL; // void
const TypeTuple *range = TypeTuple::make(TypeFunc::Parms, fields);
return TypeFunc::make(domain, range);
}
const TypeFunc* OptoRuntime::aescrypt_block_Type() {
int num_args = 3;
if (Matcher::pass_original_key_for_aes()) {
num_args = 4;
}
int argcnt = num_args;
const Type** fields = TypeTuple::fields(argcnt);
int argp = TypeFunc::Parms;
fields[argp++] = TypePtr::NOTNULL; // src
fields[argp++] = TypePtr::NOTNULL; // dest
fields[argp++] = TypePtr::NOTNULL; // k array
if (Matcher::pass_original_key_for_aes()) {
fields[argp++] = TypePtr::NOTNULL; // original k array
}
assert(argp == TypeFunc::Parms+argcnt, "correct decoding");
const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms+argcnt, fields);
fields = TypeTuple::fields(1);
fields[TypeFunc::Parms+0] = NULL; // void
const TypeTuple* range = TypeTuple::make(TypeFunc::Parms, fields);
return TypeFunc::make(domain, range);
}
const TypeFunc* OptoRuntime::updateBytesCRC32_Type() {
int num_args = 3;
int argcnt = num_args;
if (CCallingConventionRequiresIntsAsLongs) {
argcnt += 2;
}
const Type** fields = TypeTuple::fields(argcnt);
int argp = TypeFunc::Parms;
if (CCallingConventionRequiresIntsAsLongs) {
fields[argp++] = TypeLong::LONG; // crc
fields[argp++] = Type::HALF;
fields[argp++] = TypePtr::NOTNULL; // src
fields[argp++] = TypeLong::LONG; // len
fields[argp++] = Type::HALF;
} else {
fields[argp++] = TypeInt::INT; // crc
fields[argp++] = TypePtr::NOTNULL; // src
fields[argp++] = TypeInt::INT; // len
}
assert(argp == TypeFunc::Parms+argcnt, "correct decoding");
const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms+argcnt, fields);
fields = TypeTuple::fields(1);
fields[TypeFunc::Parms+0] = TypeInt::INT; // crc result
const TypeTuple* range = TypeTuple::make(TypeFunc::Parms+1, fields);
return TypeFunc::make(domain, range);
}
const TypeFunc* OptoRuntime::cipherBlockChaining_aescrypt_Type() {
int num_args = 5;
if (Matcher::pass_original_key_for_aes()) {
num_args = 6;
}
int argcnt = num_args;
const Type** fields = TypeTuple::fields(argcnt);
int argp = TypeFunc::Parms;
fields[argp++] = TypePtr::NOTNULL; // src
fields[argp++] = TypePtr::NOTNULL; // dest
fields[argp++] = TypePtr::NOTNULL; // k array
fields[argp++] = TypePtr::NOTNULL; // r array
fields[argp++] = TypeInt::INT; // src len
if (Matcher::pass_original_key_for_aes()) {
fields[argp++] = TypePtr::NOTNULL; // original k array
}
assert(argp == TypeFunc::Parms+argcnt, "correct decoding");
const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms+argcnt, fields);
fields = TypeTuple::fields(1);
fields[TypeFunc::Parms+0] = TypeInt::INT;
const TypeTuple* range = TypeTuple::make(TypeFunc::Parms+1, fields);
return TypeFunc::make(domain, range);
}
const TypeFunc* OptoRuntime::sha_implCompress_Type() {
int num_args = 2;
int argcnt = num_args;
const Type** fields = TypeTuple::fields(argcnt);
int argp = TypeFunc::Parms;
fields[argp++] = TypePtr::NOTNULL; // buf
fields[argp++] = TypePtr::NOTNULL; // state
assert(argp == TypeFunc::Parms+argcnt, "correct decoding");
const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms+argcnt, fields);
fields = TypeTuple::fields(1);
fields[TypeFunc::Parms+0] = NULL; // void
const TypeTuple* range = TypeTuple::make(TypeFunc::Parms, fields);
return TypeFunc::make(domain, range);
}
const TypeFunc* OptoRuntime::digestBase_implCompressMB_Type() {
int num_args = 4;
int argcnt = num_args;
if(CCallingConventionRequiresIntsAsLongs) {
argcnt += 2;
}
const Type** fields = TypeTuple::fields(argcnt);
int argp = TypeFunc::Parms;
if(CCallingConventionRequiresIntsAsLongs) {
fields[argp++] = TypePtr::NOTNULL; // buf
fields[argp++] = TypePtr::NOTNULL; // state
fields[argp++] = TypeLong::LONG; // ofs
fields[argp++] = Type::HALF;
fields[argp++] = TypeLong::LONG; // limit
fields[argp++] = Type::HALF;
} else {
fields[argp++] = TypePtr::NOTNULL; // buf
fields[argp++] = TypePtr::NOTNULL; // state
fields[argp++] = TypeInt::INT; // ofs
fields[argp++] = TypeInt::INT; // limit
}
assert(argp == TypeFunc::Parms+argcnt, "correct decoding");
const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms+argcnt, fields);
fields = TypeTuple::fields(1);
fields[TypeFunc::Parms+0] = TypeInt::INT; // ofs
const TypeTuple* range = TypeTuple::make(TypeFunc::Parms+1, fields);
return TypeFunc::make(domain, range);
}
const TypeFunc* OptoRuntime::multiplyToLen_Type() {
int num_args = 6;
int argcnt = num_args;
const Type** fields = TypeTuple::fields(argcnt);
int argp = TypeFunc::Parms;
fields[argp++] = TypePtr::NOTNULL; // x
fields[argp++] = TypeInt::INT; // xlen
fields[argp++] = TypePtr::NOTNULL; // y
fields[argp++] = TypeInt::INT; // ylen
fields[argp++] = TypePtr::NOTNULL; // z
fields[argp++] = TypeInt::INT; // zlen
assert(argp == TypeFunc::Parms+argcnt, "correct decoding");
const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms+argcnt, fields);
fields = TypeTuple::fields(1);
fields[TypeFunc::Parms+0] = NULL;
const TypeTuple* range = TypeTuple::make(TypeFunc::Parms, fields);
return TypeFunc::make(domain, range);
}
const TypeFunc* OptoRuntime::squareToLen_Type() {
int num_args = 4;
int argcnt = num_args;
const Type** fields = TypeTuple::fields(argcnt);
int argp = TypeFunc::Parms;
fields[argp++] = TypePtr::NOTNULL; // x
fields[argp++] = TypeInt::INT; // len
fields[argp++] = TypePtr::NOTNULL; // z
fields[argp++] = TypeInt::INT; // zlen
assert(argp == TypeFunc::Parms+argcnt, "correct decoding");
const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms+argcnt, fields);
fields = TypeTuple::fields(1);
fields[TypeFunc::Parms+0] = NULL;
const TypeTuple* range = TypeTuple::make(TypeFunc::Parms, fields);
return TypeFunc::make(domain, range);
}
const TypeFunc* OptoRuntime::mulAdd_Type() {
int num_args = 5;
int argcnt = num_args;
const Type** fields = TypeTuple::fields(argcnt);
int argp = TypeFunc::Parms;
fields[argp++] = TypePtr::NOTNULL; // out
fields[argp++] = TypePtr::NOTNULL; // in
fields[argp++] = TypeInt::INT; // offset
fields[argp++] = TypeInt::INT; // len
fields[argp++] = TypeInt::INT; // k
assert(argp == TypeFunc::Parms+argcnt, "correct decoding");
const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms+argcnt, fields);
fields = TypeTuple::fields(1);
fields[TypeFunc::Parms+0] = TypeInt::INT;
const TypeTuple* range = TypeTuple::make(TypeFunc::Parms+1, fields);
return TypeFunc::make(domain, range);
}
const TypeFunc* OptoRuntime::montgomeryMultiply_Type() {
int num_args = 7;
int argcnt = num_args;
if (CCallingConventionRequiresIntsAsLongs) {
argcnt++; // additional placeholder
}
const Type** fields = TypeTuple::fields(argcnt);
int argp = TypeFunc::Parms;
fields[argp++] = TypePtr::NOTNULL; // a
fields[argp++] = TypePtr::NOTNULL; // b
fields[argp++] = TypePtr::NOTNULL; // n
if (CCallingConventionRequiresIntsAsLongs) {
fields[argp++] = TypeLong::LONG; // len
fields[argp++] = TypeLong::HALF; // placeholder
} else {
fields[argp++] = TypeInt::INT; // len
}
fields[argp++] = TypeLong::LONG; // inv
fields[argp++] = Type::HALF;
fields[argp++] = TypePtr::NOTNULL; // result
assert(argp == TypeFunc::Parms+argcnt, "correct decoding");
const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms+argcnt, fields);
fields = TypeTuple::fields(1);
fields[TypeFunc::Parms+0] = TypePtr::NOTNULL;
const TypeTuple* range = TypeTuple::make(TypeFunc::Parms, fields);
return TypeFunc::make(domain, range);
}
const TypeFunc* OptoRuntime::montgomerySquare_Type() {
int num_args = 6;
int argcnt = num_args;
if (CCallingConventionRequiresIntsAsLongs) {
argcnt++; // additional placeholder
}
const Type** fields = TypeTuple::fields(argcnt);
int argp = TypeFunc::Parms;
fields[argp++] = TypePtr::NOTNULL; // a
fields[argp++] = TypePtr::NOTNULL; // n
if (CCallingConventionRequiresIntsAsLongs) {
fields[argp++] = TypeLong::LONG; // len
fields[argp++] = TypeLong::HALF; // placeholder
} else {
fields[argp++] = TypeInt::INT; // len
}
fields[argp++] = TypeLong::LONG; // inv
fields[argp++] = Type::HALF;
fields[argp++] = TypePtr::NOTNULL; // result
assert(argp == TypeFunc::Parms+argcnt, "correct decoding");
const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms+argcnt, fields);
fields = TypeTuple::fields(1);
fields[TypeFunc::Parms+0] = TypePtr::NOTNULL;
const TypeTuple* range = TypeTuple::make(TypeFunc::Parms, fields);
return TypeFunc::make(domain, range);
}
const TypeFunc* OptoRuntime::osr_end_Type() {
const Type **fields = TypeTuple::fields(1);
fields[TypeFunc::Parms+0] = TypeRawPtr::BOTTOM; // OSR temp buf
const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+1, fields);
fields = TypeTuple::fields(1);
fields[TypeFunc::Parms+0] = NULL; // void
const TypeTuple *range = TypeTuple::make(TypeFunc::Parms, fields);
return TypeFunc::make(domain, range);
}
const TypeFunc* OptoRuntime::profile_receiver_type_Type() {
const Type **fields = TypeTuple::fields(2);
fields[TypeFunc::Parms+0] = TypeAryPtr::NOTNULL; // methodData pointer
fields[TypeFunc::Parms+1] = TypeInstPtr::BOTTOM; // receiver oop
const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+2, fields);
fields = TypeTuple::fields(1);
fields[TypeFunc::Parms+0] = NULL; // void
const TypeTuple *range = TypeTuple::make(TypeFunc::Parms, fields);
return TypeFunc::make(domain,range);
}
JRT_LEAF(void, OptoRuntime::profile_receiver_type_C(DataLayout* data, oopDesc* receiver))
if (receiver == NULL) return;
Klass* receiver_klass = receiver->klass();
intptr_t* mdp = ((intptr_t*)(data)) + DataLayout::header_size_in_cells();
int empty_row = -1; // free row, if any is encountered
for (uint row = 0; row < ReceiverTypeData::row_limit(); row++) {
int receiver_off = ReceiverTypeData::receiver_cell_index(row);
intptr_t row_recv = *(mdp + receiver_off);
if (row_recv == (intptr_t) receiver_klass) {
int count_off = ReceiverTypeData::receiver_count_cell_index(row);
return;
} else if (row_recv == 0) {
empty_row = (int) row;
}
}
if (empty_row != -1) {
int receiver_off = ReceiverTypeData::receiver_cell_index(empty_row);
int count_off = ReceiverTypeData::receiver_count_cell_index(empty_row);
} else {
intptr_t* count_p = (intptr_t*)(((byte*)(data)) + in_bytes(CounterData::count_offset()));
}
JRT_END
bool OptoRuntime::is_callee_saved_register(MachRegisterNumbers reg) {
assert(reg >= 0 && reg < _last_Mach_Reg, "must be a machine register");
switch (register_save_policy[reg]) {
case 'C': return false; //SOC
case 'E': return true ; //SOE
case 'N': return false; //NS
case 'A': return false; //AS
}
ShouldNotReachHere();
return false;
}
static void trace_exception(oop exception_oop, address exception_pc, const char* msg) PRODUCT_RETURN;
JRT_ENTRY_NO_ASYNC(address, OptoRuntime::handle_exception_C_helper(JavaThread* thread, nmethod* &nm))
assert(thread->exception_oop() != NULL, "exception oop is found");
address handler_address = NULL;
Handle exception(thread, thread->exception_oop());
address pc = thread->exception_pc();
thread->clear_exception_oop_and_pc();
if (TraceExceptions) {
trace_exception(exception(), pc, "");
}
NOT_PRODUCT(Exceptions::debug_check_abort(exception));
#ifdef ASSERT
if (!(exception->is_a(SystemDictionary::Throwable_klass()))) {
ShouldNotReachHere();
}
#endif
nm = CodeCache::find_nmethod(pc);
assert(nm != NULL, "No NMethod found");
if (nm->is_native_method()) {
fatal("Native method should not have path to exception handling");
} else {
if (JvmtiExport::can_post_on_exceptions()) {
deoptimize_caller_frame(thread);
}
bool force_unwind = !thread->reguard_stack();
bool deopting = false;
if (nm->is_deopt_pc(pc)) {
deopting = true;
RegisterMap map(thread, false);
frame deoptee = thread->last_frame().sender(&map);
assert(deoptee.is_deoptimized_frame(), "must be deopted");
pc = deoptee.pc();
}
if (deopting && !force_unwind) {
handler_address = SharedRuntime::deopt_blob()->unpack_with_exception();
} else {
handler_address =
force_unwind ? NULL : nm->handler_for_exception_and_pc(exception, pc);
if (handler_address == NULL) {
bool recursive_exception = false;
handler_address = SharedRuntime::compute_compiled_exc_handler(nm, pc, exception, force_unwind, true, recursive_exception);
assert (handler_address != NULL, "must have compiled handler");
if (!force_unwind && !recursive_exception) {
nm->add_handler_for_exception_and_pc(exception,pc,handler_address);
}
} else {
#ifdef ASSERT
bool recursive_exception = false;
address computed_address = SharedRuntime::compute_compiled_exc_handler(nm, pc, exception, force_unwind, true, recursive_exception);
assert(recursive_exception || (handler_address == computed_address), err_msg("Handler address inconsistency: " PTR_FORMAT " != " PTR_FORMAT,
p2i(handler_address), p2i(computed_address)));
#endif
}
}
thread->set_exception_pc(pc);
thread->set_exception_handler_pc(handler_address);
thread->set_is_method_handle_return(nm->is_method_handle_return(pc));
}
thread->set_exception_oop(exception());
return handler_address;
JRT_END
address OptoRuntime::handle_exception_C(JavaThread* thread) {
#ifndef PRODUCT
SharedRuntime::_find_handler_ctr++; // find exception handler
#endif
debug_only(NoHandleMark __hm;)
nmethod* nm = NULL;
address handler_address = NULL;
{
ResetNoHandleMark rnhm;
handler_address = handle_exception_C_helper(thread, nm);
}
if (nm != NULL) {
RegisterMap map(thread, false);
frame caller = thread->last_frame().sender(&map);
#ifdef ASSERT
assert(caller.is_compiled_frame(), "must be");
#endif // ASSERT
if (caller.is_deoptimized_frame()) {
handler_address = SharedRuntime::deopt_blob()->unpack_with_exception();
}
}
return handler_address;
}
address OptoRuntime::rethrow_C(oopDesc* exception, JavaThread* thread, address ret_pc) {
#ifndef PRODUCT
SharedRuntime::_rethrow_ctr++; // count rethrows
#endif
assert (exception != NULL, "should have thrown a NULLPointerException");
#ifdef ASSERT
if (!(exception->is_a(SystemDictionary::Throwable_klass()))) {
ShouldNotReachHere();
}
#endif
thread->set_vm_result(exception);
return SharedRuntime::raw_exception_handler_for_return_address(thread, ret_pc);
}
const TypeFunc *OptoRuntime::rethrow_Type() {
const Type **fields = TypeTuple::fields(1);
fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL; // Exception oop
const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+1,fields);
fields = TypeTuple::fields(1);
fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL; // Exception oop
const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+1, fields);
return TypeFunc::make(domain, range);
}
void OptoRuntime::deoptimize_caller_frame(JavaThread *thread, bool doit) {
if (!StressCompiledExceptionHandlers && doit) {
deoptimize_caller_frame(thread);
}
}
void OptoRuntime::deoptimize_caller_frame(JavaThread *thread) {
RegisterMap reg_map(thread);
frame stub_frame = thread->last_frame();
assert(stub_frame.is_runtime_frame() || exception_blob()->contains(stub_frame.pc()), "sanity check");
frame caller_frame = stub_frame.sender(®_map);
Deoptimization::deoptimize_frame(thread, caller_frame.id());
}
bool OptoRuntime::is_deoptimized_caller_frame(JavaThread *thread) {
RegisterMap reg_map(thread);
frame stub_frame = thread->last_frame();
assert(stub_frame.is_runtime_frame() || exception_blob()->contains(stub_frame.pc()), "sanity check");
frame caller_frame = stub_frame.sender(®_map);
return caller_frame.is_deoptimized_frame();
}
const TypeFunc *OptoRuntime::register_finalizer_Type() {
const Type **fields = TypeTuple::fields(1);
fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL; // oop; Receiver
const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+1,fields);
fields = TypeTuple::fields(0);
const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+0,fields);
return TypeFunc::make(domain,range);
}
const TypeFunc *OptoRuntime::dtrace_method_entry_exit_Type() {
const Type **fields = TypeTuple::fields(2);
fields[TypeFunc::Parms+0] = TypeRawPtr::BOTTOM; // Thread-local storage
fields[TypeFunc::Parms+1] = TypeMetadataPtr::BOTTOM; // Method*; Method we are entering
const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+2,fields);
fields = TypeTuple::fields(0);
const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+0,fields);
return TypeFunc::make(domain,range);
}
const TypeFunc *OptoRuntime::dtrace_object_alloc_Type() {
const Type **fields = TypeTuple::fields(2);
fields[TypeFunc::Parms+0] = TypeRawPtr::BOTTOM; // Thread-local storage
fields[TypeFunc::Parms+1] = TypeInstPtr::NOTNULL; // oop; newly allocated object
const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+2,fields);
fields = TypeTuple::fields(0);
const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+0,fields);
return TypeFunc::make(domain,range);
}
JRT_ENTRY_NO_ASYNC(void, OptoRuntime::register_finalizer(oopDesc* obj, JavaThread* thread))
assert(obj->is_oop(), "must be a valid oop");
assert(obj->klass()->has_finalizer(), "shouldn't be here otherwise");
InstanceKlass::register_finalizer(instanceOop(obj), CHECK);
JRT_END
NamedCounter * volatile OptoRuntime::_named_counters = NULL;
void OptoRuntime::print_named_counters() {
int total_lock_count = 0;
int eliminated_lock_count = 0;
NamedCounter* c = _named_counters;
while (c) {
if (c->tag() == NamedCounter::LockCounter || c->tag() == NamedCounter::EliminatedLockCounter) {
int count = c->count();
if (count > 0) {
bool eliminated = c->tag() == NamedCounter::EliminatedLockCounter;
if (Verbose) {
tty->print_cr("%d %s%s", count, c->name(), eliminated ? " (eliminated)" : "");
}
total_lock_count += count;
if (eliminated) {
eliminated_lock_count += count;
}
}
} else if (c->tag() == NamedCounter::BiasedLockingCounter) {
BiasedLockingCounters* blc = ((BiasedLockingNamedCounter*)c)->counters();
if (blc->nonzero()) {
tty->print_cr("%s", c->name());
blc->print_on(tty);
}
#if INCLUDE_RTM_OPT
} else if (c->tag() == NamedCounter::RTMLockingCounter) {
RTMLockingCounters* rlc = ((RTMLockingNamedCounter*)c)->counters();
if (rlc->nonzero()) {
tty->print_cr("%s", c->name());
rlc->print_on(tty);
}
#endif
}
c = c->next();
}
if (total_lock_count > 0) {
tty->print_cr("dynamic locks: %d", total_lock_count);
if (eliminated_lock_count) {
tty->print_cr("eliminated locks: %d (%d%%)", eliminated_lock_count,
(int)(eliminated_lock_count * 100.0 / total_lock_count));
}
}
}
NamedCounter* OptoRuntime::new_named_counter(JVMState* youngest_jvms, NamedCounter::CounterTag tag) {
int max_depth = youngest_jvms->depth();
bool first = true;
stringStream st;
for (int depth = max_depth; depth >= 1; depth--) {
JVMState* jvms = youngest_jvms->of_depth(depth);
ciMethod* m = jvms->has_method() ? jvms->method() : NULL;
if (!first) {
st.print(" ");
} else {
first = false;
}
int bci = jvms->bci();
if (bci < 0) bci = 0;
st.print("%s.%s@%d", m->holder()->name()->as_utf8(), m->name()->as_utf8(), bci);
}
NamedCounter* c;
if (tag == NamedCounter::BiasedLockingCounter) {
c = new BiasedLockingNamedCounter(strdup(st.as_string()));
} else if (tag == NamedCounter::RTMLockingCounter) {
c = new RTMLockingNamedCounter(strdup(st.as_string()));
} else {
c = new NamedCounter(strdup(st.as_string()), tag);
}
NamedCounter* head;
do {
c->set_next(NULL);
head = _named_counters;
c->set_next(head);
} while (Atomic::cmpxchg_ptr(c, &_named_counters, head) != head);
return c;
}
#ifndef PRODUCT
int trace_exception_counter = 0;
static void trace_exception(oop exception_oop, address exception_pc, const char* msg) {
ttyLocker ttyl;
trace_exception_counter++;
tty->print("%d [Exception (%s): ", trace_exception_counter, msg);
exception_oop->print_value();
tty->print(" in ");
CodeBlob* blob = CodeCache::find_blob(exception_pc);
if (blob->is_nmethod()) {
nmethod* nm = blob->as_nmethod_or_null();
nm->method()->print_value();
} else if (blob->is_runtime_stub()) {
tty->print("<runtime-stub>");
} else {
tty->print("<unknown>");
}
tty->print(" at " INTPTR_FORMAT, p2i(exception_pc));
tty->print_cr("]");
}
#endif // PRODUCT
# ifdef ENABLE_ZAP_DEAD_LOCALS
int OptoRuntime::ZapDeadCompiledLocals_count = 0;
static bool is_java_frame( frame* f) { return f->is_java_frame(); }
static bool is_native_frame(frame* f) { return f->is_native_frame(); }
void OptoRuntime::zap_dead_java_or_native_locals(JavaThread* thread,
bool (*is_this_the_right_frame_to_zap)(frame*)) {
assert(JavaThread::current() == thread, "is this needed?");
if ( !ZapDeadCompiledLocals ) return;
bool skip = false;
if ( ZapDeadCompiledLocalsFirst == 0 ) ; // nothing special
else if ( ZapDeadCompiledLocalsFirst > ZapDeadCompiledLocals_count ) skip = true;
else if ( ZapDeadCompiledLocalsFirst == ZapDeadCompiledLocals_count )
warning("starting zapping after skipping");
if ( ZapDeadCompiledLocalsLast == -1 ) ; // nothing special
else if ( ZapDeadCompiledLocalsLast < ZapDeadCompiledLocals_count ) skip = true;
else if ( ZapDeadCompiledLocalsLast == ZapDeadCompiledLocals_count )
warning("about to zap last zap");
++ZapDeadCompiledLocals_count; // counts skipped zaps, too
if ( skip ) return;
for (StackFrameStream sfs(thread); !sfs.is_done(); sfs.next()) {
if (is_this_the_right_frame_to_zap(sfs.current()) ) {
sfs.current()->zap_dead_locals(thread, sfs.register_map());
return;
}
}
warning("no frame found to zap in zap_dead_Java_locals_C");
}
JRT_LEAF(void, OptoRuntime::zap_dead_Java_locals_C(JavaThread* thread))
zap_dead_java_or_native_locals(thread, is_java_frame);
JRT_END
JRT_LEAF(void, OptoRuntime::zap_dead_native_locals_C(JavaThread* thread))
zap_dead_java_or_native_locals(thread, is_native_frame);
JRT_END
# endif
C:\hotspot-69087d08d473\src\share\vm/opto/runtime.hpp
#ifndef SHARE_VM_OPTO_RUNTIME_HPP
#define SHARE_VM_OPTO_RUNTIME_HPP
#include "code/codeBlob.hpp"
#include "opto/machnode.hpp"
#include "opto/type.hpp"
#include "runtime/biasedLocking.hpp"
#include "runtime/rtmLocking.hpp"
#include "runtime/deoptimization.hpp"
#include "runtime/vframe.hpp"
class CallInfo;
class NamedCounter : public CHeapObj<mtCompiler> {
public:
enum CounterTag {
NoTag,
LockCounter,
EliminatedLockCounter,
BiasedLockingCounter,
RTMLockingCounter
};
private:
const char * _name;
int _count;
CounterTag _tag;
NamedCounter* _next;
public:
NamedCounter(const char *n, CounterTag tag = NoTag):
_name(n),
_count(0),
_next(NULL),
_tag(tag) {}
const char * name() const { return _name; }
int count() const { return _count; }
address addr() { return (address)&_count; }
CounterTag tag() const { return _tag; }
void set_tag(CounterTag tag) { _tag = tag; }
NamedCounter* next() const { return _next; }
void set_next(NamedCounter* next) {
assert(_next == NULL || next == NULL, "already set");
_next = next;
}
};
class BiasedLockingNamedCounter : public NamedCounter {
private:
BiasedLockingCounters _counters;
public:
BiasedLockingNamedCounter(const char *n) :
NamedCounter(n, BiasedLockingCounter), _counters() {}
BiasedLockingCounters* counters() { return &_counters; }
};
class RTMLockingNamedCounter : public NamedCounter {
private:
RTMLockingCounters _counters;
public:
RTMLockingNamedCounter(const char *n) :
NamedCounter(n, RTMLockingCounter), _counters() {}
RTMLockingCounters* counters() { return &_counters; }
};
typedef const TypeFunc*(*TypeFunc_generator)();
class OptoRuntime : public AllStatic {
friend class Matcher; // allow access to stub names
private:
static address generate_stub(ciEnv* ci_env, TypeFunc_generator gen, address C_function, const char *name, int is_fancy_jump, bool pass_tls, bool save_arguments, bool return_pc);
static address _new_instance_Java;
static address _new_array_Java;
static address _new_array_nozero_Java;
static address _multianewarray2_Java;
static address _multianewarray3_Java;
static address _multianewarray4_Java;
static address _multianewarray5_Java;
static address _multianewarrayN_Java;
static address _g1_wb_pre_Java;
static address _g1_wb_post_Java;
static address _vtable_must_compile_Java;
static address _complete_monitor_locking_Java;
static address _rethrow_Java;
static address _slow_arraycopy_Java;
static address _register_finalizer_Java;
# ifdef ENABLE_ZAP_DEAD_LOCALS
static address _zap_dead_Java_locals_Java;
static address _zap_dead_native_locals_Java;
# endif
static void new_instance_C(Klass* instance_klass, JavaThread *thread);
static void new_array_C(Klass* array_klass, int len, JavaThread *thread);
static void new_array_nozero_C(Klass* array_klass, int len, JavaThread *thread);
static void new_store_pre_barrier(JavaThread* thread);
static void multianewarray2_C(Klass* klass, int len1, int len2, JavaThread *thread);
static void multianewarray3_C(Klass* klass, int len1, int len2, int len3, JavaThread *thread);
static void multianewarray4_C(Klass* klass, int len1, int len2, int len3, int len4, JavaThread *thread);
static void multianewarray5_C(Klass* klass, int len1, int len2, int len3, int len4, int len5, JavaThread *thread);
static void multianewarrayN_C(Klass* klass, arrayOopDesc* dims, JavaThread *thread);
static void g1_wb_pre_C(oopDesc* orig, JavaThread* thread);
static void g1_wb_post_C(void* card_addr, JavaThread* thread);
public:
static void complete_monitor_locking_C(oopDesc* obj, BasicLock* lock, JavaThread* thread);
static void complete_monitor_unlocking_C(oopDesc* obj, BasicLock* lock);
private:
static void throw_null_exception_C(JavaThread* thread);
static address handle_exception_C (JavaThread* thread);
static address handle_exception_C_helper(JavaThread* thread, nmethod*& nm);
static address rethrow_C (oopDesc* exception, JavaThread *thread, address return_pc );
static void deoptimize_caller_frame (JavaThread *thread);
static void deoptimize_caller_frame (JavaThread *thread, bool doit);
static bool is_deoptimized_caller_frame (JavaThread *thread);
static ExceptionBlob* _exception_blob;
static void generate_exception_blob();
static void register_finalizer(oopDesc* obj, JavaThread* thread);
# ifdef ENABLE_ZAP_DEAD_LOCALS
static void zap_dead_Java_locals_C( JavaThread* thread);
static void zap_dead_native_locals_C( JavaThread* thread);
static void zap_dead_java_or_native_locals( JavaThread*, bool (*)(frame*));
public:
static int ZapDeadCompiledLocals_count;
# endif
public:
static bool is_callee_saved_register(MachRegisterNumbers reg);
static bool generate(ciEnv* env);
static const char* stub_name(address entry);
static address new_instance_Java() { return _new_instance_Java; }
static address new_array_Java() { return _new_array_Java; }
static address new_array_nozero_Java() { return _new_array_nozero_Java; }
static address multianewarray2_Java() { return _multianewarray2_Java; }
static address multianewarray3_Java() { return _multianewarray3_Java; }
static address multianewarray4_Java() { return _multianewarray4_Java; }
static address multianewarray5_Java() { return _multianewarray5_Java; }
static address multianewarrayN_Java() { return _multianewarrayN_Java; }
static address g1_wb_pre_Java() { return _g1_wb_pre_Java; }
static address g1_wb_post_Java() { return _g1_wb_post_Java; }
static address vtable_must_compile_stub() { return _vtable_must_compile_Java; }
static address complete_monitor_locking_Java() { return _complete_monitor_locking_Java; }
static address slow_arraycopy_Java() { return _slow_arraycopy_Java; }
static address register_finalizer_Java() { return _register_finalizer_Java; }
# ifdef ENABLE_ZAP_DEAD_LOCALS
static address zap_dead_locals_stub(bool is_native) { return is_native
? _zap_dead_native_locals_Java
: _zap_dead_Java_locals_Java; }
static MachNode* node_to_call_zap_dead_locals(Node* n, int block_num, bool is_native);
# endif
static ExceptionBlob* exception_blob() { return _exception_blob; }
static void profile_receiver_type_C(DataLayout* data, oopDesc* receiver);
static void throw_div0_exception_C (JavaThread* thread);
static void throw_stack_overflow_error_C(JavaThread* thread);
static address rethrow_stub() { return _rethrow_Java; }
static const TypeFunc* new_instance_Type(); // object allocation (slow case)
static const TypeFunc* new_array_Type (); // [a]newarray (slow case)
static const TypeFunc* multianewarray_Type(int ndim); // multianewarray
static const TypeFunc* multianewarray2_Type(); // multianewarray
static const TypeFunc* multianewarray3_Type(); // multianewarray
static const TypeFunc* multianewarray4_Type(); // multianewarray
static const TypeFunc* multianewarray5_Type(); // multianewarray
static const TypeFunc* multianewarrayN_Type(); // multianewarray
static const TypeFunc* g1_wb_pre_Type();
static const TypeFunc* g1_wb_post_Type();
static const TypeFunc* complete_monitor_enter_Type();
static const TypeFunc* complete_monitor_exit_Type();
static const TypeFunc* uncommon_trap_Type();
static const TypeFunc* athrow_Type();
static const TypeFunc* rethrow_Type();
static const TypeFunc* Math_D_D_Type(); // sin,cos & friends
static const TypeFunc* Math_DD_D_Type(); // mod,pow & friends
static const TypeFunc* modf_Type();
static const TypeFunc* l2f_Type();
static const TypeFunc* void_long_Type();
static const TypeFunc* flush_windows_Type();
static const TypeFunc* fast_arraycopy_Type(); // bit-blasters
static const TypeFunc* checkcast_arraycopy_Type();
static const TypeFunc* generic_arraycopy_Type();
static const TypeFunc* slow_arraycopy_Type(); // the full routine
static const TypeFunc* array_fill_Type();
static const TypeFunc* aescrypt_block_Type();
static const TypeFunc* cipherBlockChaining_aescrypt_Type();
static const TypeFunc* sha_implCompress_Type();
static const TypeFunc* digestBase_implCompressMB_Type();
static const TypeFunc* multiplyToLen_Type();
static const TypeFunc* squareToLen_Type();
static const TypeFunc* mulAdd_Type();
static const TypeFunc* montgomeryMultiply_Type();
static const TypeFunc* montgomerySquare_Type();
static const TypeFunc* ghash_processBlocks_Type();
static const TypeFunc* updateBytesCRC32_Type();
static const TypeFunc* osr_end_Type();
static const TypeFunc* profile_receiver_type_Type();
static const TypeFunc* fetch_int_Type();
static const TypeFunc* fetch_long_Type();
static const TypeFunc* fetch_float_Type();
static const TypeFunc* fetch_double_Type();
static const TypeFunc* fetch_oop_Type();
static const TypeFunc* fetch_monitor_Type();
static const TypeFunc* register_finalizer_Type();
static const TypeFunc* dtrace_method_entry_exit_Type();
static const TypeFunc* dtrace_object_alloc_Type();
# ifdef ENABLE_ZAP_DEAD_LOCALS
static const TypeFunc* zap_dead_locals_Type();
# endif
private:
static NamedCounter * volatile _named_counters;
public:
static NamedCounter* new_named_counter(JVMState* jvms, NamedCounter::CounterTag tag);
static void print_named_counters();
};
#endif // SHARE_VM_OPTO_RUNTIME_HPP
C:\hotspot-69087d08d473\src\share\vm/opto/split_if.cpp
#include "precompiled.hpp"
#include "memory/allocation.inline.hpp"
#include "opto/callnode.hpp"
#include "opto/connode.hpp"
#include "opto/loopnode.hpp"
Node *PhaseIdealLoop::split_thru_region( Node *n, Node *region ) {
uint wins = 0;
assert( n->is_CFG(), "" );
assert( region->is_Region(), "" );
Node *r = new (C) RegionNode( region->req() );
IdealLoopTree *loop = get_loop( n );
for( uint i = 1; i < region->req(); i++ ) {
Node *x = n->clone();
Node *in0 = n->in(0);
if( in0->in(0) == region ) x->set_req( 0, in0->in(i) );
for( uint j = 1; j < n->req(); j++ ) {
Node *in = n->in(j);
if( get_ctrl(in) == region )
x->set_req( j, in->in(i) );
}
_igvn.register_new_node_with_optimizer(x);
set_loop(x, loop);
set_idom(x, x->in(0), dom_depth(x->in(0))+1);
r->init_req(i, x);
}
r->set_req(0,region); // Not a TRUE RegionNode
_igvn.register_new_node_with_optimizer(r);
set_loop(r, loop);
if( !loop->_child )
loop->_body.push(r);
return r;
}
bool PhaseIdealLoop::split_up( Node *n, Node *blk1, Node *blk2 ) {
if( n->is_CFG() ) {
assert( n->in(0) != blk1, "Lousy candidate for split-if" );
return false;
}
if( get_ctrl(n) != blk1 && get_ctrl(n) != blk2 )
return false; // Not block local
if( n->is_Phi() ) return false; // Local PHIs are expected
for (uint i = 1; i < n->req(); i++) {
if( split_up( n->in(i), blk1, blk2 ) ) {
if (n->outcnt() == 0)
_igvn.remove_dead_node(n);
return true;
}
}
if( n->is_Cmp() ) {
assert(get_ctrl(n) == blk2 || get_ctrl(n) == blk1, "must be in block with IF");
Node *bol, *cmov;
if( !(n->outcnt() == 1 && n->unique_out()->is_Bool() &&
(bol = n->unique_out()->as_Bool()) &&
(get_ctrl(bol) == blk1 ||
get_ctrl(bol) == blk2) &&
bol->outcnt() == 1 &&
bol->unique_out()->is_CMove() &&
(cmov = bol->unique_out()->as_CMove()) &&
(get_ctrl(cmov) == blk1 ||
get_ctrl(cmov) == blk2) ) ) {
#ifndef PRODUCT
if( PrintOpto && VerifyLoopOptimizations ) {
tty->print("Cloning down: ");
n->dump();
}
#endif
for (DUIterator i = n->outs(); n->has_out(i); i++) {
Node* bol = n->out(i);
assert( bol->is_Bool(), "" );
if (bol->outcnt() == 1) {
Node* use = bol->unique_out();
Node *use_c = use->is_If() ? use->in(0) : get_ctrl(use);
if (use_c == blk1 || use_c == blk2) {
continue;
}
}
if (get_ctrl(bol) == blk1 || get_ctrl(bol) == blk2) {
#ifndef PRODUCT
if( PrintOpto && VerifyLoopOptimizations ) {
tty->print("Cloning down: ");
bol->dump();
}
#endif
for (DUIterator_Last jmin, j = bol->last_outs(jmin); j >= jmin; --j) {
Node* iff = bol->last_out(j);
assert( iff->in(1) == bol, "" );
Node *iff_ctrl = iff->is_If() ? iff->in(0) : get_ctrl(iff);
Node *x = bol->clone();
register_new_node(x, iff_ctrl);
_igvn.replace_input_of(iff, 1, x);
}
_igvn.remove_dead_node( bol );
--i;
}
}
for (DUIterator_Last jmin, j = n->last_outs(jmin); j >= jmin; --j) {
Node* bol = n->last_out(j);
assert( bol->in(1) == n, "" );
Node *x = n->clone();
register_new_node(x, get_ctrl(bol));
_igvn.replace_input_of(bol, 1, x);
}
_igvn.remove_dead_node( n );
return true;
}
}
if( n->is_Store() && n->in(MemNode::Memory)->in(0) == n->in(0) ) {
int alias_idx = C->get_alias_index(_igvn.type(n->in(MemNode::Address))->is_ptr());
Node *memphi = n->in(MemNode::Memory);
assert( memphi->is_Phi(), "" );
for (DUIterator_Fast imax,i = memphi->fast_outs(imax); i < imax; i++) {
Node *load = memphi->fast_out(i);
if( load->is_Load() && alias_idx == C->get_alias_index(_igvn.type(load->in(MemNode::Address))->is_ptr()) )
set_ctrl(load,blk1);
}
}
#ifndef PRODUCT
if( PrintOpto && VerifyLoopOptimizations ) {
tty->print("Cloning up: ");
n->dump();
}
#endif
const Type* rtype = NULL;
if (n->Opcode() == Op_ConvI2L && n->bottom_type() != TypeLong::INT) {
rtype = TypeLong::INT;
}
Node *phi = PhiNode::make_blank(blk1, n);
for( uint j = 1; j < blk1->req(); j++ ) {
Node *x = n->clone();
if (rtype != NULL) x->as_Type()->set_type(rtype);
if( n->in(0) && n->in(0) == blk1 )
x->set_req( 0, blk1->in(j) );
for( uint i = 1; i < n->req(); i++ ) {
Node *m = n->in(i);
if( get_ctrl(m) == blk1 ) {
assert( m->in(0) == blk1, "" );
x->set_req( i, m->in(j) );
}
}
register_new_node( x, blk1->in(j) );
phi->init_req( j, x );
}
register_new_node(phi, blk1);
_igvn.replace_node( n, phi );
return true;
}
void PhaseIdealLoop::register_new_node( Node *n, Node *blk ) {
assert(!n->is_CFG(), "must be data node");
_igvn.register_new_node_with_optimizer(n);
set_ctrl(n, blk);
IdealLoopTree *loop = get_loop(blk);
if( !loop->_child )
loop->_body.push(n);
}
struct small_cache : public Dict {
small_cache() : Dict( cmpkey, hashptr ) {}
Node *probe( Node *use_blk ) { return (Node*)((*this)[use_blk]); }
void lru_insert( Node *use_blk, Node *new_def ) { Insert(use_blk,new_def); }
};
Node *PhaseIdealLoop::spinup( Node *iff_dom, Node *new_false, Node *new_true, Node *use_blk, Node *def, small_cache *cache ) {
if (use_blk->is_top()) // Handle dead uses
return use_blk;
Node *prior_n = (Node*)((intptr_t)0xdeadbeef);
Node *n = use_blk; // Get path input
assert( use_blk != iff_dom, "" );
while( n != iff_dom ) { // Found post-dominating point?
prior_n = n;
n = idom(n); // Search higher
Node *s = cache->probe( prior_n ); // Check cache
if( s ) return s; // Cache hit!
}
Node *phi_post;
if( prior_n == new_false || prior_n == new_true ) {
phi_post = def->clone();
phi_post->set_req(0, prior_n );
register_new_node(phi_post, prior_n);
} else {
if( def->is_CFG() ) {
phi_post = prior_n; // If looking for CFG, return prior
} else {
assert( def->is_Phi(), "" );
assert( prior_n->is_Region(), "must be a post-dominating merge point" );
phi_post = PhiNode::make_blank(prior_n, def);
for( uint i = 1; i < phi_post->req(); i++ ) // For all paths
phi_post->init_req( i, spinup( iff_dom, new_false, new_true, prior_n->in(i), def, cache ) );
Node *t = _igvn.hash_find_insert(phi_post);
if( t ) { // See if we already have this one
_igvn.remove_dead_node(phi_post);
phi_post->destruct();
phi_post = t;
} else {
register_new_node( phi_post, prior_n );
}
}
}
prior_n = (Node*)((intptr_t)0xdeadbeef); // Reset IDOM walk
n = use_blk; // Get path input
while( n != iff_dom ) { // Found post-dominating point?
prior_n = n;
n = idom(n); // Search higher
cache->lru_insert( prior_n, phi_post ); // Fill cache
} // End of while not gone high enough
return phi_post;
}
Node *PhaseIdealLoop::find_use_block( Node *use, Node *def, Node *old_false, Node *new_false, Node *old_true, Node *new_true ) {
if( use->is_CFG() )
return use;
if( use->is_Phi() ) { // Phi uses in prior block
uint j;
for( j = 1; j < use->req(); j++ )
if( use->in(j) == def )
break;
assert( j < use->req(), "def should be among use's inputs" );
return use->in(0)->in(j);
}
Node *use_blk = get_ctrl(use);
if( use_blk == old_false ) {
use_blk = new_false;
set_ctrl(use, new_false);
}
if( use_blk == old_true ) {
use_blk = new_true;
set_ctrl(use, new_true);
}
if (use_blk == NULL) { // He's dead, Jim
_igvn.replace_node(use, C->top());
}
return use_blk;
}
void PhaseIdealLoop::handle_use( Node *use, Node *def, small_cache *cache, Node *region_dom, Node *new_false, Node *new_true, Node *old_false, Node *old_true ) {
Node *use_blk = find_use_block(use,def,old_false,new_false,old_true,new_true);
if( !use_blk ) return; // He's dead, Jim
Node *new_def = spinup( region_dom, new_false, new_true, use_blk, def, cache );
uint i;
for( i = 0; i < use->req(); i++ )
if( use->in(i) == def )
break;
assert( i < use->req(), "def should be among use's inputs" );
_igvn.replace_input_of(use, i, new_def);
}
void PhaseIdealLoop::do_split_if( Node *iff ) {
#ifndef PRODUCT
if( PrintOpto && VerifyLoopOptimizations )
tty->print_cr("Split-if");
if (TraceLoopOpts) {
tty->print_cr("SplitIf");
}
#endif
C->set_major_progress();
Node *region = iff->in(0);
Node *region_dom = idom(region);
DUIterator i, j;
bool progress = true;
while (progress) {
progress = false;
for (i = region->outs(); region->has_out(i); i++) {
Node* n = region->out(i);
if( n == region ) continue;
if( n == iff ) continue;
if( !n->is_Phi() ) { // Found pinned memory op or such
if (split_up(n, region, iff)) {
i = region->refresh_out_pos(i);
progress = true;
}
continue;
}
assert( n->in(0) == region, "" );
for (j = n->outs(); n->has_out(j); j++) {
Node* m = n->out(j);
if (_nodes[m->_idx] == NULL) {
_igvn.remove_dead_node(m);
}
else if (m != iff && split_up(m, region, iff)) {
} else {
continue;
}
i = region->refresh_out_pos(i);
j = region->refresh_out_pos(j);
progress = true;
}
}
}
Node *new_iff = split_thru_region( iff, region );
Node *old_false = NULL, *old_true = NULL;
Node *new_false = NULL, *new_true = NULL;
for (DUIterator_Last j2min, j2 = iff->last_outs(j2min); j2 >= j2min; --j2) {
Node *ifp = iff->last_out(j2);
assert( ifp->Opcode() == Op_IfFalse || ifp->Opcode() == Op_IfTrue, "" );
ifp->set_req(0, new_iff);
Node *ifpx = split_thru_region( ifp, region );
ifpx->set_req(0, ifpx); // A TRUE RegionNode
set_idom(ifpx, region_dom, dom_depth(region_dom) + 1);
if( get_loop(iff)->tail() == ifp )
get_loop(iff)->_tail = ifpx;
new_iff->set_req(0, new_iff); // hook self so it does not go dead
lazy_replace(ifp, ifpx);
new_iff->set_req(0, region);
if( ifp->Opcode() == Op_IfFalse ) {
old_false = ifp;
new_false = ifpx;
} else {
old_true = ifp;
new_true = ifpx;
}
}
_igvn.remove_dead_node(new_iff);
lazy_replace( iff, region_dom );
small_cache region_cache;
region_cache.lru_insert( new_false, new_false );
region_cache.lru_insert( new_true , new_true );
for (DUIterator k = region->outs(); region->has_out(k); k++) {
Node* phi = region->out(k);
if (!phi->in(0)) { // Dead phi? Remove it
_igvn.remove_dead_node(phi);
} else if (phi == region) { // Found the self-reference
continue; // No roll-back of DUIterator
} else if (phi->is_Phi()) { // Expected common case: Phi hanging off of Region
assert(phi->in(0) == region, "Inconsistent graph");
small_cache phi_cache;
for (DUIterator_Last lmin, l = phi->last_outs(lmin); l >= lmin; --l) {
Node* use = phi->last_out(l);
handle_use(use, phi, &phi_cache, region_dom, new_false, new_true, old_false, old_true);
} // End of while phi has uses
_igvn.remove_dead_node( phi );
} else {
assert(phi->in(0) == region, "Inconsistent graph");
handle_use(phi, region, ®ion_cache, region_dom, new_false, new_true, old_false, old_true);
}
--k;
} // End of while merge point has phis
assert(region->outcnt() == 1, "Only self reference should remain"); // Just Self on the Region
region->set_req(0, NULL); // Break the self-cycle
lazy_replace( region, region_dom );
#ifndef PRODUCT
if( VerifyLoopOptimizations ) verify();
#endif
}
C:\hotspot-69087d08d473\src\share\vm/opto/stringopts.cpp
#include "precompiled.hpp"
#include "compiler/compileLog.hpp"
#include "opto/addnode.hpp"
#include "opto/callGenerator.hpp"
#include "opto/callnode.hpp"
#include "opto/divnode.hpp"
#include "opto/graphKit.hpp"
#include "opto/idealKit.hpp"
#include "opto/rootnode.hpp"
#include "opto/runtime.hpp"
#include "opto/stringopts.hpp"
#include "opto/subnode.hpp"
#define __ kit.
class StringConcat : public ResourceObj {
private:
PhaseStringOpts* _stringopts;
Node* _string_alloc;
AllocateNode* _begin; // The allocation the begins the pattern
CallStaticJavaNode* _end; // The final call of the pattern. Will either be
bool _multiple; // indicates this is a fusion of two or more
Node* _arguments; // The list of arguments to be concatenated
GrowableArray<int> _mode; // into a String along with a mode flag
Node_List _constructors; // List of constructors (many in case of stacked concat)
Node_List _control; // List of control nodes that will be deleted
Node_List _uncommon_traps; // Uncommon traps that needs to be rewritten
public:
enum {
StringMode,
IntMode,
CharMode,
StringNullCheckMode
};
StringConcat(PhaseStringOpts* stringopts, CallStaticJavaNode* end):
_end(end),
_begin(NULL),
_multiple(false),
_string_alloc(NULL),
_stringopts(stringopts) {
_arguments = new (_stringopts->C) Node(1);
_arguments->del_req(0);
}
bool validate_mem_flow();
bool validate_control_flow();
void merge_add() {
#if 0
CallProjections endprojs;
sc->end()->extract_projections(&endprojs, false);
if (endprojs.resproj != NULL) {
for (SimpleDUIterator i(endprojs.resproj); i.has_next(); i.next()) {
CallStaticJavaNode *use = i.get()->isa_CallStaticJava();
if (use != NULL && use->method() != NULL &&
use->method()->intrinsic_id() == vmIntrinsics::_String_String &&
use->in(TypeFunc::Parms + 1) == endprojs.resproj) {
sc->set_string_alloc(use->in(TypeFunc::Parms));
sc->set_end(use);
}
}
}
#endif
}
StringConcat* merge(StringConcat* other, Node* arg);
void set_allocation(AllocateNode* alloc) {
_begin = alloc;
}
void append(Node* value, int mode) {
_arguments->add_req(value);
_mode.append(mode);
}
void push(Node* value, int mode) {
_arguments->ins_req(0, value);
_mode.insert_before(0, mode);
}
void push_string(Node* value) {
push(value, StringMode);
}
void push_string_null_check(Node* value) {
push(value, StringNullCheckMode);
}
void push_int(Node* value) {
push(value, IntMode);
}
void push_char(Node* value) {
push(value, CharMode);
}
static bool is_SB_toString(Node* call) {
if (call->is_CallStaticJava()) {
CallStaticJavaNode* csj = call->as_CallStaticJava();
ciMethod* m = csj->method();
if (m != NULL &&
(m->intrinsic_id() == vmIntrinsics::_StringBuilder_toString ||
m->intrinsic_id() == vmIntrinsics::_StringBuffer_toString)) {
return true;
}
}
return false;
}
static Node* skip_string_null_check(Node* value) {
if (value->is_Phi()) {
int true_path = value->as_Phi()->is_diamond_phi();
if (true_path != 0) {
BoolNode* b = value->in(0)->in(1)->in(0)->in(1)->as_Bool();
Node* cmp = b->in(1);
Node* v1 = cmp->in(1);
Node* v2 = cmp->in(2);
if (b->_test._test == BoolTest::ne &&
v2->bottom_type() == TypePtr::NULL_PTR &&
value->in(true_path)->Opcode() == Op_CastPP &&
value->in(true_path)->in(1) == v1 &&
v1->is_Proj() && is_SB_toString(v1->in(0))) {
return v1;
}
}
}
return value;
}
Node* argument(int i) {
return _arguments->in(i);
}
Node* argument_uncast(int i) {
Node* arg = argument(i);
int amode = mode(i);
if (amode == StringConcat::StringMode ||
amode == StringConcat::StringNullCheckMode) {
arg = skip_string_null_check(arg);
}
return arg;
}
void set_argument(int i, Node* value) {
_arguments->set_req(i, value);
}
int num_arguments() {
return _mode.length();
}
int mode(int i) {
return _mode.at(i);
}
void add_control(Node* ctrl) {
assert(!_control.contains(ctrl), "only push once");
_control.push(ctrl);
}
void add_constructor(Node* init) {
assert(!_constructors.contains(init), "only push once");
_constructors.push(init);
}
CallStaticJavaNode* end() { return _end; }
AllocateNode* begin() { return _begin; }
Node* string_alloc() { return _string_alloc; }
void eliminate_unneeded_control();
void eliminate_initialize(InitializeNode* init);
void eliminate_call(CallNode* call);
void maybe_log_transform() {
CompileLog* log = _stringopts->C->log();
if (log != NULL) {
log->head("replace_string_concat arguments='%d' string_alloc='%d' multiple='%d'",
num_arguments(),
_string_alloc != NULL,
_multiple);
JVMState* p = _begin->jvms();
while (p != NULL) {
log->elem("jvms bci='%d' method='%d'", p->bci(), log->identify(p->method()));
p = p->caller();
}
log->tail("replace_string_concat");
}
}
void convert_uncommon_traps(GraphKit& kit, const JVMState* jvms) {
for (uint u = 0; u < _uncommon_traps.size(); u++) {
Node* uct = _uncommon_traps.at(u);
address call_addr = SharedRuntime::uncommon_trap_blob()->entry_point();
const TypeFunc* call_type = OptoRuntime::uncommon_trap_Type();
const TypePtr* no_memory_effects = NULL;
Compile* C = _stringopts->C;
CallStaticJavaNode* call = new (C) CallStaticJavaNode(call_type, call_addr, "uncommon_trap",
jvms->bci(), no_memory_effects);
for (int e = 0; e < TypeFunc::Parms; e++) {
call->init_req(e, uct->in(e));
}
int trap_request = Deoptimization::make_trap_request(Deoptimization::Reason_intrinsic,
Deoptimization::Action_make_not_entrant);
call->init_req(TypeFunc::Parms, __ intcon(trap_request));
kit.add_safepoint_edges(call);
_stringopts->gvn()->transform(call);
C->gvn_replace_by(uct, call);
uct->disconnect_inputs(NULL, C);
}
}
void cleanup() {
_arguments->disconnect_inputs(NULL, _stringopts->C);
}
};
void StringConcat::eliminate_unneeded_control() {
for (uint i = 0; i < _control.size(); i++) {
Node* n = _control.at(i);
if (n->is_Allocate()) {
eliminate_initialize(n->as_Allocate()->initialization());
}
if (n->is_Call()) {
if (n != _end) {
eliminate_call(n->as_Call());
}
} else if (n->is_IfTrue()) {
Compile* C = _stringopts->C;
C->gvn_replace_by(n, n->in(0)->in(0));
C->gvn_replace_by(n->in(0)->as_If()->proj_out(false), C->top());
}
}
}
StringConcat* StringConcat::merge(StringConcat* other, Node* arg) {
StringConcat* result = new StringConcat(_stringopts, _end);
for (uint x = 0; x < _control.size(); x++) {
Node* n = _control.at(x);
if (n->is_Call()) {
result->_control.push(n);
}
}
for (uint x = 0; x < other->_control.size(); x++) {
Node* n = other->_control.at(x);
if (n->is_Call()) {
result->_control.push(n);
}
}
assert(result->_control.contains(other->_end), "what?");
assert(result->_control.contains(_begin), "what?");
for (int x = 0; x < num_arguments(); x++) {
Node* argx = argument_uncast(x);
if (argx == arg) {
for (int y = 0; y < other->num_arguments(); y++) {
result->append(other->argument(y), other->mode(y));
}
} else {
result->append(argx, mode(x));
}
}
result->set_allocation(other->_begin);
for (uint i = 0; i < _constructors.size(); i++) {
result->add_constructor(_constructors.at(i));
}
for (uint i = 0; i < other->_constructors.size(); i++) {
result->add_constructor(other->_constructors.at(i));
}
result->_multiple = true;
return result;
}
void StringConcat::eliminate_call(CallNode* call) {
Compile* C = _stringopts->C;
CallProjections projs;
call->extract_projections(&projs, false);
if (projs.fallthrough_catchproj != NULL) {
C->gvn_replace_by(projs.fallthrough_catchproj, call->in(TypeFunc::Control));
}
if (projs.fallthrough_memproj != NULL) {
C->gvn_replace_by(projs.fallthrough_memproj, call->in(TypeFunc::Memory));
}
if (projs.catchall_memproj != NULL) {
C->gvn_replace_by(projs.catchall_memproj, C->top());
}
if (projs.fallthrough_ioproj != NULL) {
C->gvn_replace_by(projs.fallthrough_ioproj, call->in(TypeFunc::I_O));
}
if (projs.catchall_ioproj != NULL) {
C->gvn_replace_by(projs.catchall_ioproj, C->top());
}
if (projs.catchall_catchproj != NULL) {
for (SimpleDUIterator i(projs.catchall_catchproj); i.has_next(); i.next()) {
Node *use = i.get();
int opc = use->Opcode();
if (opc == Op_CreateEx || opc == Op_Region) {
_stringopts->record_dead_node(use);
}
}
C->gvn_replace_by(projs.catchall_catchproj, C->top());
}
if (projs.resproj != NULL) {
C->gvn_replace_by(projs.resproj, C->top());
}
C->gvn_replace_by(call, C->top());
}
void StringConcat::eliminate_initialize(InitializeNode* init) {
Compile* C = _stringopts->C;
assert(init->outcnt() <= 2, "only a control and memory projection expected");
assert(init->req() <= InitializeNode::RawStores, "no pending inits");
Node *ctrl_proj = init->proj_out(TypeFunc::Control);
if (ctrl_proj != NULL) {
C->gvn_replace_by(ctrl_proj, init->in(TypeFunc::Control));
}
Node *mem_proj = init->proj_out(TypeFunc::Memory);
if (mem_proj != NULL) {
Node *mem = init->in(TypeFunc::Memory);
C->gvn_replace_by(mem_proj, mem);
}
C->gvn_replace_by(init, C->top());
init->disconnect_inputs(NULL, C);
}
Node_List PhaseStringOpts::collect_toString_calls() {
Node_List string_calls;
Node_List worklist;
_visited.Clear();
for (uint i = 1; i < C->root()->len(); i++) {
Node* n = C->root()->in(i);
if (n != NULL && !_visited.test_set(n->_idx)) {
worklist.push(n);
}
}
while (worklist.size() > 0) {
Node* ctrl = worklist.pop();
if (StringConcat::is_SB_toString(ctrl)) {
CallStaticJavaNode* csj = ctrl->as_CallStaticJava();
string_calls.push(csj);
}
if (ctrl->in(0) != NULL && !_visited.test_set(ctrl->in(0)->_idx)) {
worklist.push(ctrl->in(0));
}
if (ctrl->is_Region()) {
for (uint i = 1; i < ctrl->len(); i++) {
if (ctrl->in(i) != NULL && !_visited.test_set(ctrl->in(i)->_idx)) {
worklist.push(ctrl->in(i));
}
}
}
}
return string_calls;
}
StringConcat* PhaseStringOpts::build_candidate(CallStaticJavaNode* call) {
ciMethod* m = call->method();
ciSymbol* string_sig;
ciSymbol* int_sig;
ciSymbol* char_sig;
if (m->holder() == C->env()->StringBuilder_klass()) {
string_sig = ciSymbol::String_StringBuilder_signature();
int_sig = ciSymbol::int_StringBuilder_signature();
char_sig = ciSymbol::char_StringBuilder_signature();
} else if (m->holder() == C->env()->StringBuffer_klass()) {
string_sig = ciSymbol::String_StringBuffer_signature();
int_sig = ciSymbol::int_StringBuffer_signature();
char_sig = ciSymbol::char_StringBuffer_signature();
} else {
return NULL;
}
#ifndef PRODUCT
if (PrintOptimizeStringConcat) {
tty->print("considering toString call in ");
call->jvms()->dump_spec(tty); tty->cr();
}
#endif
StringConcat* sc = new StringConcat(this, call);
AllocateNode* alloc = NULL;
InitializeNode* init = NULL;
CallStaticJavaNode* cnode = call;
while (cnode) {
Node* recv = cnode->in(TypeFunc::Parms)->uncast();
if (recv->is_Proj()) {
recv = recv->in(0);
}
cnode = recv->isa_CallStaticJava();
if (cnode == NULL) {
alloc = recv->isa_Allocate();
if (alloc == NULL) {
break;
}
Node* result = alloc->result_cast();
if (result == NULL || !result->is_CheckCastPP() || alloc->in(TypeFunc::Memory)->is_top()) {
#ifndef PRODUCT
if (PrintOptimizeStringConcat) {
tty->print("giving up because allocation looks strange ");
alloc->jvms()->dump_spec(tty); tty->cr();
}
#endif
break;
}
Node* constructor = NULL;
for (SimpleDUIterator i(result); i.has_next(); i.next()) {
CallStaticJavaNode *use = i.get()->isa_CallStaticJava();
if (use != NULL &&
use->method() != NULL &&
!use->method()->is_static() &&
use->method()->name() == ciSymbol::object_initializer_name() &&
use->method()->holder() == m->holder()) {
ciSymbol* sig = use->method()->signature()->as_symbol();
if (sig == ciSymbol::void_method_signature() ||
sig == ciSymbol::int_void_signature() ||
sig == ciSymbol::string_void_signature()) {
if (sig == ciSymbol::string_void_signature()) {
assert(use->in(TypeFunc::Parms + 1) != NULL, "what?");
const Type* type = _gvn->type(use->in(TypeFunc::Parms + 1));
if (type == TypePtr::NULL_PTR) {
#ifndef PRODUCT
if (PrintOptimizeStringConcat) {
tty->print("giving up because StringBuilder(null) throws exception");
alloc->jvms()->dump_spec(tty); tty->cr();
}
#endif
return NULL;
}
sc->push_string_null_check(use->in(TypeFunc::Parms + 1));
}
constructor = use;
} else {
#ifndef PRODUCT
if (PrintOptimizeStringConcat) {
tty->print("unexpected constructor signature: %s", sig->as_utf8());
}
#endif
}
break;
}
}
if (constructor == NULL) {
#ifndef PRODUCT
if (PrintOptimizeStringConcat) {
tty->print("giving up because couldn't find constructor ");
alloc->jvms()->dump_spec(tty); tty->cr();
}
#endif
break;
}
sc->add_control(call);
sc->add_control(constructor);
sc->add_control(alloc);
sc->set_allocation(alloc);
sc->add_constructor(constructor);
if (sc->validate_control_flow() && sc->validate_mem_flow()) {
return sc;
} else {
return NULL;
}
} else if (cnode->method() == NULL) {
break;
} else if (!cnode->method()->is_static() &&
cnode->method()->holder() == m->holder() &&
cnode->method()->name() == ciSymbol::append_name() &&
(cnode->method()->signature()->as_symbol() == string_sig ||
cnode->method()->signature()->as_symbol() == char_sig ||
cnode->method()->signature()->as_symbol() == int_sig)) {
sc->add_control(cnode);
Node* arg = cnode->in(TypeFunc::Parms + 1);
if (cnode->method()->signature()->as_symbol() == int_sig) {
sc->push_int(arg);
} else if (cnode->method()->signature()->as_symbol() == char_sig) {
sc->push_char(arg);
} else {
if (arg->is_Proj() && arg->in(0)->is_CallStaticJava()) {
CallStaticJavaNode* csj = arg->in(0)->as_CallStaticJava();
if (csj->method() != NULL &&
csj->method()->intrinsic_id() == vmIntrinsics::_Integer_toString &&
arg->outcnt() == 1) {
assert(arg->unique_out() == cnode, "sanity");
sc->add_control(csj);
sc->push_int(csj->in(TypeFunc::Parms));
continue;
}
}
sc->push_string(arg);
}
continue;
} else {
#ifndef PRODUCT
if (PrintOptimizeStringConcat) {
tty->print("giving up because encountered unexpected signature ");
cnode->tf()->dump(); tty->cr();
cnode->in(TypeFunc::Parms + 1)->dump();
}
#endif
break;
}
}
return NULL;
}
PhaseStringOpts::PhaseStringOpts(PhaseGVN* gvn, Unique_Node_List*):
Phase(StringOpts),
_gvn(gvn),
_visited(Thread::current()->resource_area()) {
assert(OptimizeStringConcat, "shouldn't be here");
size_table_field = C->env()->Integer_klass()->get_field_by_name(ciSymbol::make("sizeTable"),
ciSymbol::make("[I"), true);
if (size_table_field == NULL) {
assert(false, "why can't we find Integer.sizeTable?");
return;
}
char_adr_idx = C->get_alias_index(TypeAryPtr::CHARS);
GrowableArray<StringConcat*> concats;
Node_List toStrings = collect_toString_calls();
while (toStrings.size() > 0) {
StringConcat* sc = build_candidate(toStrings.pop()->as_CallStaticJava());
if (sc != NULL) {
concats.push(sc);
}
}
restart:
for (int c = 0; c < concats.length(); c++) {
StringConcat* sc = concats.at(c);
for (int i = 0; i < sc->num_arguments(); i++) {
Node* arg = sc->argument_uncast(i);
if (arg->is_Proj() && StringConcat::is_SB_toString(arg->in(0))) {
CallStaticJavaNode* csj = arg->in(0)->as_CallStaticJava();
for (int o = 0; o < concats.length(); o++) {
if (c == o) continue;
StringConcat* other = concats.at(o);
if (other->end() == csj) {
#ifndef PRODUCT
if (PrintOptimizeStringConcat) {
tty->print_cr("considering stacked concats");
}
#endif
StringConcat* merged = sc->merge(other, arg);
if (merged->validate_control_flow() && merged->validate_mem_flow()) {
#ifndef PRODUCT
if (PrintOptimizeStringConcat) {
tty->print_cr("stacking would succeed");
}
#endif
if (c < o) {
concats.remove_at(o);
concats.at_put(c, merged);
} else {
concats.remove_at(c);
concats.at_put(o, merged);
}
goto restart;
} else {
#ifndef PRODUCT
if (PrintOptimizeStringConcat) {
tty->print_cr("stacking would fail");
}
#endif
}
}
}
}
}
}
for (int c = 0; c < concats.length(); c++) {
StringConcat* sc = concats.at(c);
replace_string_concat(sc);
}
remove_dead_nodes();
}
void PhaseStringOpts::record_dead_node(Node* dead) {
dead_worklist.push(dead);
}
void PhaseStringOpts::remove_dead_nodes() {
while (dead_worklist.size() > 0) {
Node* use = dead_worklist.pop();
int opc = use->Opcode();
switch (opc) {
case Op_Region: {
uint i = 1;
for (i = 1; i < use->req(); i++) {
if (use->in(i) != C->top()) {
break;
}
}
if (i >= use->req()) {
for (SimpleDUIterator i(use); i.has_next(); i.next()) {
Node* m = i.get();
if (m->is_Phi()) {
dead_worklist.push(m);
}
}
C->gvn_replace_by(use, C->top());
}
break;
}
case Op_AddP:
case Op_CreateEx: {
for (SimpleDUIterator i(use); i.has_next(); i.next()) {
Node* m = i.get();
if (m->is_AddP()) {
dead_worklist.push(m);
}
}
C->gvn_replace_by(use, C->top());
break;
}
case Op_Phi:
if (use->in(0) == C->top()) {
C->gvn_replace_by(use, C->top());
}
break;
}
}
}
bool StringConcat::validate_mem_flow() {
Compile* C = _stringopts->C;
for (uint i = 0; i < _control.size(); i++) {
#ifndef PRODUCT
Node_List path;
#endif
Node* curr = _control.at(i);
if (curr->is_Call() && curr != _begin) { // For all calls except the first allocation
if (!_constructors.contains(curr)) {
NOT_PRODUCT(path.push(curr);)
Node* mem = curr->in(TypeFunc::Memory);
assert(mem != NULL, "calls should have memory edge");
assert(!mem->is_Phi(), "should be handled by control flow validation");
NOT_PRODUCT(path.push(mem);)
while (mem->is_MergeMem()) {
for (uint i = 1; i < mem->req(); i++) {
if (i != Compile::AliasIdxBot && mem->in(i) != C->top()) {
#ifndef PRODUCT
if (PrintOptimizeStringConcat) {
tty->print("fusion has incorrect memory flow (side effects) for ");
_begin->jvms()->dump_spec(tty); tty->cr();
path.dump();
}
#endif
return false;
}
}
mem = mem->in(Compile::AliasIdxBot);
NOT_PRODUCT(path.push(mem);)
}
if (mem->is_Proj()) {
Node *prev = mem->in(0);
NOT_PRODUCT(path.push(prev);)
if (!prev->is_Call() || !_control.contains(prev)) {
#ifndef PRODUCT
if (PrintOptimizeStringConcat) {
tty->print("fusion has incorrect memory flow (unknown call) for ");
_begin->jvms()->dump_spec(tty); tty->cr();
path.dump();
}
#endif
return false;
}
} else {
assert(mem->is_Store() || mem->is_LoadStore(), err_msg_res("unexpected node type: %s", mem->Name()));
#ifndef PRODUCT
if (PrintOptimizeStringConcat) {
tty->print("fusion has incorrect memory flow (unexpected source) for ");
_begin->jvms()->dump_spec(tty); tty->cr();
path.dump();
}
#endif
return false;
}
} else {
#ifdef ASSERT
assert(curr->is_Call(), "constructor should be a call");
Node* ctrl = curr->in(0);
IfNode* iff = NULL;
RegionNode* copy = NULL;
while (true) {
if (ctrl->is_Region()) {
if (ctrl->as_Region()->is_copy()) {
copy = ctrl->as_Region();
ctrl = copy->is_copy();
} else { // a cast
assert(ctrl->req() == 3 &&
ctrl->in(1) != NULL && ctrl->in(1)->is_Proj() &&
ctrl->in(2) != NULL && ctrl->in(2)->is_Proj() &&
ctrl->in(1)->in(0) == ctrl->in(2)->in(0) &&
ctrl->in(1)->in(0) != NULL && ctrl->in(1)->in(0)->is_If(),
"must be a simple diamond");
Node* true_proj = ctrl->in(1)->is_IfTrue() ? ctrl->in(1) : ctrl->in(2);
for (SimpleDUIterator i(true_proj); i.has_next(); i.next()) {
Node* use = i.get();
assert(use == ctrl || use->is_ConstraintCast(),
err_msg_res("unexpected user: %s", use->Name()));
}
iff = ctrl->in(1)->in(0)->as_If();
ctrl = iff->in(0);
}
} else if (ctrl->is_IfTrue()) { // null checks, class checks
iff = ctrl->in(0)->as_If();
assert(iff->is_If(), "must be if");
Node* otherproj = iff->proj_out(1 - ctrl->as_Proj()->_con);
CallStaticJavaNode* call = otherproj->unique_out()->isa_CallStaticJava();
assert(strcmp(call->_name, "uncommon_trap") == 0, "must be uncommond trap");
ctrl = iff->in(0);
} else {
break;
}
}
assert(ctrl->is_Proj(), "must be a projection");
assert(ctrl->in(0)->is_Initialize(), "should be initialize");
for (SimpleDUIterator i(ctrl); i.has_next(); i.next()) {
Node* use = i.get();
assert(use == copy || use == iff || use == curr || use->is_CheckCastPP() || use->is_Load(),
err_msg_res("unexpected user: %s", use->Name()));
}
#endif // ASSERT
}
}
}
#ifndef PRODUCT
if (PrintOptimizeStringConcat) {
tty->print("fusion has correct memory flow for ");
_begin->jvms()->dump_spec(tty); tty->cr();
tty->cr();
}
#endif
return true;
}
bool StringConcat::validate_control_flow() {
if (Compile::current()->too_many_traps(_begin->jvms()->method(), _begin->jvms()->bci(),
Deoptimization::Reason_intrinsic)) {
return false;
}
int null_check_count = 0;
Unique_Node_List ctrl_path;
assert(_control.contains(_begin), "missing");
assert(_control.contains(_end), "missing");
for (uint i = 0; i < _control.size(); i++) {
Node* n = _control.at(i);
if (n->is_Allocate()) {
AllocateNode* an = n->as_Allocate();
InitializeNode* init = an->initialization();
ctrl_path.push(init);
ctrl_path.push(init->as_Multi()->proj_out(0));
}
if (n->is_Call()) {
CallNode* cn = n->as_Call();
ctrl_path.push(cn);
ctrl_path.push(cn->proj_out(0));
ctrl_path.push(cn->proj_out(0)->unique_out());
Node* catchproj = cn->proj_out(0)->unique_out()->as_Catch()->proj_out(0);
if (catchproj != NULL) {
ctrl_path.push(catchproj);
}
} else {
ShouldNotReachHere();
}
}
Node* ptr = _end;
bool fail = false;
while (ptr != _begin) {
if (ptr->is_Call() && ctrl_path.member(ptr)) {
ptr = ptr->in(0);
} else if (ptr->is_CatchProj() && ctrl_path.member(ptr)) {
ptr = ptr->in(0)->in(0)->in(0);
assert(ctrl_path.member(ptr), "should be a known piece of control");
} else if (ptr->is_IfTrue()) {
IfNode* iff = ptr->in(0)->as_If();
BoolNode* b = iff->in(1)->isa_Bool();
if (b == NULL) {
fail = true;
break;
}
Node* cmp = b->in(1);
Node* v1 = cmp->in(1);
Node* v2 = cmp->in(2);
Node* otherproj = iff->proj_out(1 - ptr->as_Proj()->_con);
if (b->_test._test == BoolTest::ne &&
v2->bottom_type() == TypePtr::NULL_PTR &&
v1->is_Proj() && ctrl_path.member(v1->in(0))) {
null_check_count++;
if (otherproj->outcnt() == 1) {
CallStaticJavaNode* call = otherproj->unique_out()->isa_CallStaticJava();
if (call != NULL && call->_name != NULL && strcmp(call->_name, "uncommon_trap") == 0) {
ctrl_path.push(call);
}
}
_control.push(ptr);
ptr = ptr->in(0)->in(0);
continue;
}
if (otherproj->outcnt() == 1) {
CallStaticJavaNode* call = otherproj->unique_out()->isa_CallStaticJava();
if (call != NULL && call->_name != NULL && strcmp(call->_name, "uncommon_trap") == 0) {
_uncommon_traps.push(call);
ctrl_path.push(call);
ptr = ptr->in(0)->in(0);
continue;
}
}
#ifndef PRODUCT
if (PrintOptimizeStringConcat) {
tty->print_cr("failing with unknown test");
b->dump();
cmp->dump();
v1->dump();
v2->dump();
tty->cr();
}
#endif
fail = true;
break;
} else if (ptr->is_Proj() && ptr->in(0)->is_Initialize()) {
ptr = ptr->in(0)->in(0);
} else if (ptr->is_Region()) {
Node* copy = ptr->as_Region()->is_copy();
if (copy != NULL) {
ptr = copy;
continue;
}
if (ptr->req() == 3 &&
ptr->in(1) != NULL && ptr->in(1)->is_Proj() &&
ptr->in(2) != NULL && ptr->in(2)->is_Proj() &&
ptr->in(1)->in(0) == ptr->in(2)->in(0) &&
ptr->in(1)->in(0) != NULL && ptr->in(1)->in(0)->is_If()) {
Compile::current()->record_for_igvn(ptr);
ptr = ptr->in(1)->in(0)->in(0);
continue;
}
#ifndef PRODUCT
if (PrintOptimizeStringConcat) {
tty->print_cr("fusion would fail for region");
_begin->dump();
ptr->dump(2);
}
#endif
fail = true;
break;
} else {
if (!fail) {
#ifndef PRODUCT
if (PrintOptimizeStringConcat) {
tty->print_cr("fusion would fail for");
_begin->dump();
}
#endif
fail = true;
}
#ifndef PRODUCT
if (PrintOptimizeStringConcat) {
ptr->dump();
}
#endif
ptr = ptr->in(0);
}
}
#ifndef PRODUCT
if (PrintOptimizeStringConcat && fail) {
tty->cr();
}
#endif
if (fail) return !fail;
_stringopts->_visited.Clear();
Node_List worklist;
Node* final_result = _end->proj_out(TypeFunc::Parms);
for (uint i = 0; i < _control.size(); i++) {
CallNode* cnode = _control.at(i)->isa_Call();
if (cnode != NULL) {
_stringopts->_visited.test_set(cnode->_idx);
}
Node* result = cnode != NULL ? cnode->proj_out(TypeFunc::Parms) : NULL;
if (result != NULL && result != final_result) {
worklist.push(result);
}
}
Node* last_result = NULL;
while (worklist.size() > 0) {
Node* result = worklist.pop();
if (_stringopts->_visited.test_set(result->_idx))
continue;
for (SimpleDUIterator i(result); i.has_next(); i.next()) {
Node *use = i.get();
if (ctrl_path.member(use)) {
continue;
}
int opc = use->Opcode();
if (opc == Op_CmpP || opc == Op_Node) {
ctrl_path.push(use);
continue;
}
if (opc == Op_CastPP || opc == Op_CheckCastPP) {
for (SimpleDUIterator j(use); j.has_next(); j.next()) {
worklist.push(j.get());
}
worklist.push(use->in(1));
ctrl_path.push(use);
continue;
}
#ifndef PRODUCT
if (PrintOptimizeStringConcat) {
if (result != last_result) {
last_result = result;
tty->print_cr("extra uses for result:");
last_result->dump();
}
use->dump();
}
#endif
fail = true;
break;
}
}
#ifndef PRODUCT
if (PrintOptimizeStringConcat && !fail) {
ttyLocker ttyl;
tty->cr();
tty->print("fusion has correct control flow (%d %d) for ", null_check_count, _uncommon_traps.size());
_begin->jvms()->dump_spec(tty); tty->cr();
for (int i = 0; i < num_arguments(); i++) {
argument(i)->dump();
}
_control.dump();
tty->cr();
}
#endif
return !fail;
}
Node* PhaseStringOpts::fetch_static_field(GraphKit& kit, ciField* field) {
const TypeInstPtr* mirror_type = TypeInstPtr::make(field->holder()->java_mirror());
Node* klass_node = __ makecon(mirror_type);
BasicType bt = field->layout_type();
ciType* field_klass = field->type();
const Type *type;
if( bt == T_OBJECT ) {
if (!field->type()->is_loaded()) {
type = TypeInstPtr::BOTTOM;
} else if (field->is_constant()) {
ciObject* con = field->constant_value().as_object();
type = TypeOopPtr::make_from_constant(con, true)->isa_oopptr();
assert(type != NULL, "field singleton type must be consistent");
return __ makecon(type);
} else {
type = TypeOopPtr::make_from_klass(field_klass->as_klass());
}
} else {
type = Type::get_const_basic_type(bt);
}
return kit.make_load(NULL, kit.basic_plus_adr(klass_node, field->offset_in_bytes()),
type, T_OBJECT,
C->get_alias_index(mirror_type->add_offset(field->offset_in_bytes())),
MemNode::unordered);
}
Node* PhaseStringOpts::int_stringSize(GraphKit& kit, Node* arg) {
RegionNode *final_merge = new (C) RegionNode(3);
kit.gvn().set_type(final_merge, Type::CONTROL);
Node* final_size = new (C) PhiNode(final_merge, TypeInt::INT);
kit.gvn().set_type(final_size, TypeInt::INT);
IfNode* iff = kit.create_and_map_if(kit.control(),
__ Bool(__ CmpI(arg, __ intcon(0x80000000)), BoolTest::ne),
PROB_FAIR, COUNT_UNKNOWN);
Node* is_min = __ IfFalse(iff);
final_merge->init_req(1, is_min);
final_size->init_req(1, __ intcon(11));
kit.set_control(__ IfTrue(iff));
if (kit.stopped()) {
final_merge->init_req(2, C->top());
final_size->init_req(2, C->top());
} else {
RegionNode *r = new (C) RegionNode(3);
kit.gvn().set_type(r, Type::CONTROL);
Node *phi = new (C) PhiNode(r, TypeInt::INT);
kit.gvn().set_type(phi, TypeInt::INT);
Node *size = new (C) PhiNode(r, TypeInt::INT);
kit.gvn().set_type(size, TypeInt::INT);
Node* chk = __ CmpI(arg, __ intcon(0));
Node* p = __ Bool(chk, BoolTest::lt);
IfNode* iff = kit.create_and_map_if(kit.control(), p, PROB_FAIR, COUNT_UNKNOWN);
Node* lessthan = __ IfTrue(iff);
Node* greaterequal = __ IfFalse(iff);
r->init_req(1, lessthan);
phi->init_req(1, __ SubI(__ intcon(0), arg));
size->init_req(1, __ intcon(1));
r->init_req(2, greaterequal);
phi->init_req(2, arg);
size->init_req(2, __ intcon(0));
kit.set_control(r);
C->record_for_igvn(r);
C->record_for_igvn(phi);
C->record_for_igvn(size);
kit.add_predicate();
RegionNode *loop = new (C) RegionNode(3);
loop->init_req(1, kit.control());
kit.gvn().set_type(loop, Type::CONTROL);
Node *index = new (C) PhiNode(loop, TypeInt::INT);
index->init_req(1, __ intcon(0));
kit.gvn().set_type(index, TypeInt::INT);
kit.set_control(loop);
Node* sizeTable = fetch_static_field(kit, size_table_field);
Node* value = kit.load_array_element(NULL, sizeTable, index, TypeAryPtr::INTS);
C->record_for_igvn(value);
Node* limit = __ CmpI(phi, value);
Node* limitb = __ Bool(limit, BoolTest::le);
IfNode* iff2 = kit.create_and_map_if(kit.control(), limitb, PROB_MIN, COUNT_UNKNOWN);
Node* lessEqual = __ IfTrue(iff2);
Node* greater = __ IfFalse(iff2);
loop->init_req(2, greater);
index->init_req(2, __ AddI(index, __ intcon(1)));
kit.set_control(lessEqual);
C->record_for_igvn(loop);
C->record_for_igvn(index);
final_merge->init_req(2, kit.control());
final_size->init_req(2, __ AddI(__ AddI(index, size), __ intcon(1)));
}
kit.set_control(final_merge);
C->record_for_igvn(final_merge);
C->record_for_igvn(final_size);
return final_size;
}
void PhaseStringOpts::int_getChars(GraphKit& kit, Node* arg, Node* char_array, Node* start, Node* end) {
RegionNode *final_merge = new (C) RegionNode(4);
kit.gvn().set_type(final_merge, Type::CONTROL);
Node *final_mem = PhiNode::make(final_merge, kit.memory(char_adr_idx), Type::MEMORY, TypeAryPtr::CHARS);
kit.gvn().set_type(final_mem, Type::MEMORY);
{
IfNode* iff = kit.create_and_map_if(kit.control(),
__ Bool(__ CmpI(arg, __ intcon(0x80000000)), BoolTest::ne),
PROB_FAIR, COUNT_UNKNOWN);
Node* old_mem = kit.memory(char_adr_idx);
kit.set_control(__ IfFalse(iff));
if (kit.stopped()) {
final_merge->init_req(3, kit.control());
} else {
copy_string(kit, __ makecon(TypeInstPtr::make(C->env()->the_min_jint_string())),
char_array, start);
final_merge->init_req(3, kit.control());
final_mem->init_req(3, kit.memory(char_adr_idx));
}
kit.set_control(__ IfTrue(iff));
kit.set_memory(old_mem, char_adr_idx);
}
Node* charPos = end;
Node* i = arg;
Node* sign = __ intcon(0);
{
IfNode* iff = kit.create_and_map_if(kit.control(),
__ Bool(__ CmpI(arg, __ intcon(0)), BoolTest::lt),
PROB_FAIR, COUNT_UNKNOWN);
RegionNode *merge = new (C) RegionNode(3);
kit.gvn().set_type(merge, Type::CONTROL);
i = new (C) PhiNode(merge, TypeInt::INT);
kit.gvn().set_type(i, TypeInt::INT);
sign = new (C) PhiNode(merge, TypeInt::INT);
kit.gvn().set_type(sign, TypeInt::INT);
merge->init_req(1, __ IfTrue(iff));
i->init_req(1, __ SubI(__ intcon(0), arg));
sign->init_req(1, __ intcon('-'));
merge->init_req(2, __ IfFalse(iff));
i->init_req(2, arg);
sign->init_req(2, __ intcon(0));
kit.set_control(merge);
C->record_for_igvn(merge);
C->record_for_igvn(i);
C->record_for_igvn(sign);
}
{
kit.add_predicate();
RegionNode *head = new (C) RegionNode(3);
head->init_req(1, kit.control());
kit.gvn().set_type(head, Type::CONTROL);
Node *i_phi = new (C) PhiNode(head, TypeInt::INT);
i_phi->init_req(1, i);
kit.gvn().set_type(i_phi, TypeInt::INT);
charPos = PhiNode::make(head, charPos);
kit.gvn().set_type(charPos, TypeInt::INT);
Node *mem = PhiNode::make(head, kit.memory(char_adr_idx), Type::MEMORY, TypeAryPtr::CHARS);
kit.gvn().set_type(mem, Type::MEMORY);
kit.set_control(head);
kit.set_memory(mem, char_adr_idx);
Node* q = __ DivI(NULL, i_phi, __ intcon(10));
Node* r = __ SubI(i_phi, __ AddI(__ LShiftI(q, __ intcon(3)),
__ LShiftI(q, __ intcon(1))));
Node* m1 = __ SubI(charPos, __ intcon(1));
Node* ch = __ AddI(r, __ intcon('0'));
Node* st = __ store_to_memory(kit.control(), kit.array_element_address(char_array, m1, T_CHAR),
ch, T_CHAR, char_adr_idx, MemNode::unordered);
IfNode* iff = kit.create_and_map_if(head, __ Bool(__ CmpI(q, __ intcon(0)), BoolTest::ne),
PROB_FAIR, COUNT_UNKNOWN);
Node* ne = __ IfTrue(iff);
Node* eq = __ IfFalse(iff);
head->init_req(2, ne);
mem->init_req(2, st);
i_phi->init_req(2, q);
charPos->init_req(2, m1);
charPos = m1;
kit.set_control(eq);
kit.set_memory(st, char_adr_idx);
C->record_for_igvn(head);
C->record_for_igvn(mem);
C->record_for_igvn(i_phi);
C->record_for_igvn(charPos);
}
{
IfNode* iff = kit.create_and_map_if(kit.control(),
__ Bool(__ CmpI(sign, __ intcon(0)), BoolTest::ne),
PROB_FAIR, COUNT_UNKNOWN);
final_merge->init_req(2, __ IfFalse(iff));
final_mem->init_req(2, kit.memory(char_adr_idx));
kit.set_control(__ IfTrue(iff));
if (kit.stopped()) {
final_merge->init_req(1, C->top());
final_mem->init_req(1, C->top());
} else {
Node* m1 = __ SubI(charPos, __ intcon(1));
Node* st = __ store_to_memory(kit.control(), kit.array_element_address(char_array, m1, T_CHAR),
sign, T_CHAR, char_adr_idx, MemNode::unordered);
final_merge->init_req(1, kit.control());
final_mem->init_req(1, st);
}
kit.set_control(final_merge);
kit.set_memory(final_mem, char_adr_idx);
C->record_for_igvn(final_merge);
C->record_for_igvn(final_mem);
}
}
Node* PhaseStringOpts::copy_string(GraphKit& kit, Node* str, Node* char_array, Node* start) {
Node* string = str;
Node* offset = kit.load_String_offset(kit.control(), string);
Node* count = kit.load_String_length(kit.control(), string);
Node* value = kit.load_String_value (kit.control(), string);
if (offset->is_Con() && count->is_Con() && value->is_Con() && count->get_int() < unroll_string_copy_length) {
int c = count->get_int();
int o = offset->get_int();
const TypeOopPtr* t = kit.gvn().type(value)->isa_oopptr();
ciTypeArray* value_array = t->const_oop()->as_type_array();
for (int e = 0; e < c; e++) {
__ store_to_memory(kit.control(), kit.array_element_address(char_array, start, T_CHAR),
__ intcon(value_array->char_at(o + e)), T_CHAR, char_adr_idx,
MemNode::unordered);
start = __ AddI(start, __ intcon(1));
}
} else {
Node* src_ptr = kit.array_element_address(value, offset, T_CHAR);
Node* dst_ptr = kit.array_element_address(char_array, start, T_CHAR);
Node* c = count;
Node* extra = NULL;
#ifdef _LP64
c = __ ConvI2L(c);
extra = C->top();
#endif
Node* call = kit.make_runtime_call(GraphKit::RC_LEAF|GraphKit::RC_NO_FP,
OptoRuntime::fast_arraycopy_Type(),
CAST_FROM_FN_PTR(address, StubRoutines::jshort_disjoint_arraycopy()),
"jshort_disjoint_arraycopy", TypeAryPtr::CHARS,
src_ptr, dst_ptr, c, extra);
start = __ AddI(start, count);
}
return start;
}
void PhaseStringOpts::replace_string_concat(StringConcat* sc) {
sc->maybe_log_transform();
JVMState* jvms = sc->begin()->jvms()->clone_shallow(C);
uint size = sc->begin()->req();
SafePointNode* map = new (C) SafePointNode(size, jvms);
for (uint i1 = 0; i1 < TypeFunc::Parms; i1++) {
map->init_req(i1, sc->end()->in(i1));
}
for (uint i1 = TypeFunc::Parms; i1 < jvms->debug_start(); i1++) {
map->init_req(i1, C->top());
}
for (uint i1 = jvms->debug_start(); i1 < sc->begin()->req(); i1++) {
map->init_req(i1, sc->begin()->in(i1));
}
if (!map->in(TypeFunc::Memory)->is_MergeMem()) {
map->set_req(TypeFunc::Memory, MergeMemNode::make(C, map->in(TypeFunc::Memory)));
}
jvms->set_map(map);
map->ensure_stack(jvms, jvms->method()->max_stack());
sc->eliminate_unneeded_control();
GraphKit kit(jvms);
sc->convert_uncommon_traps(kit, jvms);
Node* null_string = __ makecon(TypeInstPtr::make(C->env()->the_null_string()));
int args = MAX2(sc->num_arguments(), 1);
RegionNode* overflow = new (C) RegionNode(args);
kit.gvn().set_type(overflow, Type::CONTROL);
Node* string_sizes = new (C) Node(args);
Node* length = __ intcon(0);
for (int argi = 0; argi < sc->num_arguments(); argi++) {
Node* arg = sc->argument(argi);
switch (sc->mode(argi)) {
case StringConcat::IntMode: {
Node* string_size = int_stringSize(kit, arg);
length = __ AddI(length, string_size);
string_sizes->init_req(argi, string_size);
break;
}
case StringConcat::StringNullCheckMode: {
const Type* type = kit.gvn().type(arg);
assert(type != TypePtr::NULL_PTR, "missing check");
if (!type->higher_equal(TypeInstPtr::NOTNULL)) {
Node* p = __ Bool(__ CmpP(arg, kit.null()), BoolTest::ne);
IfNode* iff = kit.create_and_map_if(kit.control(), p, PROB_MIN, COUNT_UNKNOWN);
overflow->add_req(__ IfFalse(iff));
Node* notnull = __ IfTrue(iff);
kit.set_control(notnull); // set control for the cast_not_null
arg = kit.cast_not_null(arg, false);
sc->set_argument(argi, arg);
}
assert(kit.gvn().type(arg)->higher_equal(TypeInstPtr::NOTNULL), "sanity");
}
case StringConcat::StringMode: {
const Type* type = kit.gvn().type(arg);
Node* count = NULL;
if (type == TypePtr::NULL_PTR) {
arg = null_string;
sc->set_argument(argi, arg);
count = kit.load_String_length(kit.control(), arg);
} else if (!type->higher_equal(TypeInstPtr::NOTNULL)) {
RegionNode *r = new (C) RegionNode(3);
kit.gvn().set_type(r, Type::CONTROL);
Node *phi = new (C) PhiNode(r, type);
kit.gvn().set_type(phi, phi->bottom_type());
Node* p = __ Bool(__ CmpP(arg, kit.null()), BoolTest::ne);
IfNode* iff = kit.create_and_map_if(kit.control(), p, PROB_MIN, COUNT_UNKNOWN);
Node* notnull = __ IfTrue(iff);
Node* isnull = __ IfFalse(iff);
kit.set_control(notnull); // set control for the cast_not_null
r->init_req(1, notnull);
phi->init_req(1, kit.cast_not_null(arg, false));
r->init_req(2, isnull);
phi->init_req(2, null_string);
kit.set_control(r);
C->record_for_igvn(r);
C->record_for_igvn(phi);
arg = phi;
sc->set_argument(argi, arg);
count = kit.load_String_length(kit.control(), arg);
} else {
count = kit.load_String_length(NULL, arg);
}
length = __ AddI(length, count);
string_sizes->init_req(argi, NULL);
break;
}
case StringConcat::CharMode: {
length = __ AddI(length, __ intcon(1));
break;
}
default:
ShouldNotReachHere();
}
if (argi > 0) {
IfNode* iff = kit.create_and_map_if(kit.control(),
__ Bool(__ CmpI(length, __ intcon(0)), BoolTest::lt),
PROB_MIN, COUNT_UNKNOWN);
kit.set_control(__ IfFalse(iff));
overflow->set_req(argi, __ IfTrue(iff));
}
}
{
PreserveJVMState pjvms(&kit);
kit.set_control(overflow);
C->record_for_igvn(overflow);
kit.uncommon_trap(Deoptimization::Reason_intrinsic,
Deoptimization::Action_make_not_entrant);
}
Node* result;
if (!kit.stopped()) {
Node* char_array = NULL;
{
PreserveReexecuteState preexecs(&kit);
kit.jvms()->set_should_reexecute(true);
char_array = kit.new_array(__ makecon(TypeKlassPtr::make(ciTypeArrayKlass::make(T_CHAR))),
length, 1);
}
AllocateArrayNode* char_alloc = AllocateArrayNode::Ideal_array_allocation(char_array, _gvn);
char_alloc->maybe_set_complete(_gvn);
Node* start = __ intcon(0);
for (int argi = 0; argi < sc->num_arguments(); argi++) {
Node* arg = sc->argument(argi);
switch (sc->mode(argi)) {
case StringConcat::IntMode: {
Node* end = __ AddI(start, string_sizes->in(argi));
int_getChars(kit, arg, char_array, start, end);
start = end;
break;
}
case StringConcat::StringNullCheckMode:
case StringConcat::StringMode: {
start = copy_string(kit, arg, char_array, start);
break;
}
case StringConcat::CharMode: {
__ store_to_memory(kit.control(), kit.array_element_address(char_array, start, T_CHAR),
arg, T_CHAR, char_adr_idx, MemNode::unordered);
start = __ AddI(start, __ intcon(1));
break;
}
default:
ShouldNotReachHere();
}
}
result = sc->string_alloc();
if (result == NULL) {
PreserveReexecuteState preexecs(&kit);
kit.jvms()->set_should_reexecute(true);
result = kit.new_instance(__ makecon(TypeKlassPtr::make(C->env()->String_klass())));
}
if (java_lang_String::has_offset_field()) {
kit.store_String_offset(kit.control(), result, __ intcon(0));
kit.store_String_length(kit.control(), result, length);
}
kit.store_String_value(kit.control(), result, char_array);
assert(AllocateNode::Ideal_allocation(result, _gvn) != NULL, "should be newly allocated");
kit.insert_mem_bar(Op_MemBarRelease, result);
} else {
result = C->top();
}
kit.replace_call(sc->end(), result);
string_sizes->disconnect_inputs(NULL, C);
sc->cleanup();
}
C:\hotspot-69087d08d473\src\share\vm/opto/stringopts.hpp
#ifndef SHARE_VM_OPTO_STRINGOPTS_HPP
#define SHARE_VM_OPTO_STRINGOPTS_HPP
#include "opto/node.hpp"
#include "opto/phaseX.hpp"
class StringConcat;
class PhaseStringOpts : public Phase {
friend class StringConcat;
private:
PhaseGVN* _gvn;
Unique_Node_List dead_worklist;
int char_adr_idx;
ciField* size_table_field;
VectorSet _visited;
Node_List collect_toString_calls();
StringConcat* build_candidate(CallStaticJavaNode* call);
void replace_string_concat(StringConcat* concat);
Node* fetch_static_field(GraphKit& kit, ciField* field);
Node* int_stringSize(GraphKit& kit, Node* value);
void int_getChars(GraphKit& kit, Node* value, Node* char_array, Node* start, Node* end);
Node* copy_string(GraphKit& kit, Node* str, Node* char_array, Node* start);
void record_dead_node(Node* node);
void remove_dead_nodes();
PhaseGVN* gvn() { return _gvn; }
enum {
unroll_string_copy_length = 6
};
public:
PhaseStringOpts(PhaseGVN* gvn, Unique_Node_List* worklist);
};
#endif // SHARE_VM_OPTO_STRINGOPTS_HPP
C:\hotspot-69087d08d473\src\share\vm/opto/subnode.cpp
#include "precompiled.hpp"
#include "compiler/compileLog.hpp"
#include "memory/allocation.inline.hpp"
#include "opto/addnode.hpp"
#include "opto/callnode.hpp"
#include "opto/cfgnode.hpp"
#include "opto/connode.hpp"
#include "opto/loopnode.hpp"
#include "opto/matcher.hpp"
#include "opto/mulnode.hpp"
#include "opto/opcodes.hpp"
#include "opto/phaseX.hpp"
#include "opto/subnode.hpp"
#include "runtime/sharedRuntime.hpp"
#include "math.h"
Node *SubNode::Identity( PhaseTransform *phase ) {
assert(in(1) != this, "Must already have called Value");
assert(in(2) != this, "Must already have called Value");
const Type *zero = add_id();
if( phase->type( in(1) )->higher_equal( zero ) &&
in(2)->Opcode() == Opcode() &&
phase->type( in(2)->in(1) )->higher_equal( zero ) ) {
return in(2)->in(2);
}
if( in(1)->Opcode() == Op_AddI ) {
if( phase->eqv(in(1)->in(2),in(2)) )
return in(1)->in(1);
if (phase->eqv(in(1)->in(1),in(2)))
return in(1)->in(2);
if( in(1)->in(2)->Opcode() == Op_Opaque2 &&
phase->eqv(in(1)->in(2)->in(1),in(2)) )
return in(1)->in(1);
}
return ( phase->type( in(2) )->higher_equal( zero ) ) ? in(1) : this;
}
const Type* SubNode::Value_common(PhaseTransform *phase) const {
const Node* in1 = in(1);
const Node* in2 = in(2);
const Type* t1 = (in1 == this) ? Type::TOP : phase->type(in1);
if( t1 == Type::TOP ) return Type::TOP;
const Type* t2 = (in2 == this) ? Type::TOP : phase->type(in2);
if( t2 == Type::TOP ) return Type::TOP;
if (in1->eqv_uncast(in2)) return add_id();
if( t1 == Type::BOTTOM || t2 == Type::BOTTOM )
return bottom_type();
return NULL;
}
const Type* SubNode::Value(PhaseTransform *phase) const {
const Type* t = Value_common(phase);
if (t != NULL) {
return t;
}
const Type* t1 = phase->type(in(1));
const Type* t2 = phase->type(in(2));
return sub(t1,t2); // Local flavor of type subtraction
}
static bool ok_to_convert(Node* inc, Node* iv) {
const PhiNode *phi;
if( ( !inc->in(1)->is_Phi() ||
!(phi=inc->in(1)->as_Phi()) ||
phi->is_copy() ||
!phi->region()->is_CountedLoop() ||
inc != phi->region()->as_CountedLoop()->incr() )
&&
( !iv->is_loop_iv() )
) {
return true;
} else {
return false;
}
}
Node *SubINode::Ideal(PhaseGVN *phase, bool can_reshape){
Node *in1 = in(1);
Node *in2 = in(2);
uint op1 = in1->Opcode();
uint op2 = in2->Opcode();
#ifdef ASSERT
if( phase->eqv( in1, this ) || phase->eqv( in2, this ) ||
( op1 == Op_AddI || op1 == Op_SubI ) &&
( phase->eqv( in1->in(1), this ) || phase->eqv( in1->in(2), this ) ||
phase->eqv( in1->in(1), in1 ) || phase->eqv( in1->in(2), in1 ) ) )
assert(false, "dead loop in SubINode::Ideal");
#endif
const Type *t2 = phase->type( in2 );
if( t2 == Type::TOP ) return NULL;
if( t2->base() == Type::Int ){ // Might be bottom or top...
const TypeInt *i = t2->is_int();
if( i->is_con() )
return new (phase->C) AddINode(in1, phase->intcon(-i->get_con()));
}
if( op1 == Op_AddI && ok_to_convert(in1, in2) ) {
const Type *tadd = phase->type( in1->in(2) );
if( tadd->singleton() && tadd != Type::TOP ) {
Node *sub2 = phase->transform( new (phase->C) SubINode( in1->in(1), in2 ));
return new (phase->C) AddINode( sub2, in1->in(2) );
}
}
if (op2 == Op_AddI && ok_to_convert(in2, in1)) {
Node* in21 = in2->in(1);
Node* in22 = in2->in(2);
const TypeInt* tcon = phase->type(in22)->isa_int();
if (tcon != NULL && tcon->is_con()) {
Node* sub2 = phase->transform( new (phase->C) SubINode(in1, in21) );
Node* neg_c0 = phase->intcon(- tcon->get_con());
return new (phase->C) AddINode(sub2, neg_c0);
}
}
const Type *t1 = phase->type( in1 );
if( t1 == Type::TOP ) return NULL;
#ifdef ASSERT
if( ( op2 == Op_AddI || op2 == Op_SubI ) &&
( phase->eqv( in2->in(1), this ) || phase->eqv( in2->in(2), this ) ||
phase->eqv( in2->in(1), in2 ) || phase->eqv( in2->in(2), in2 ) ) )
assert(false, "dead loop in SubINode::Ideal");
#endif
if( op2 == Op_AddI &&
phase->eqv( in1, in2->in(1) ) )
return new (phase->C) SubINode( phase->intcon(0),in2->in(2));
if( op1 == Op_SubI &&
phase->eqv( in1->in(1), in2 ) )
return new (phase->C) SubINode( phase->intcon(0),in1->in(2));
if( op2 == Op_AddI &&
phase->eqv( in1, in2->in(2) ) )
return new (phase->C) SubINode( phase->intcon(0),in2->in(1));
if( t1 == TypeInt::ZERO && op2 == Op_SubI )
return new (phase->C) SubINode( in2->in(2), in2->in(1) );
jint con;
if( t1 == TypeInt::ZERO && op2 == Op_AddI &&
(con = in2->in(2)->find_int_con(0)) != 0 )
return new (phase->C) SubINode( phase->intcon(-con), in2->in(1) );
if( op1 == Op_AddI && op2 == Op_AddI && in1->in(1) == in2->in(1) )
return new (phase->C) SubINode( in1->in(2), in2->in(2) );
if( op1 == Op_AddI && op2 == Op_AddI && in1->in(2) == in2->in(2) )
return new (phase->C) SubINode( in1->in(1), in2->in(1) );
if( op1 == Op_AddI && op2 == Op_AddI && in1->in(2) == in2->in(1) )
return new (phase->C) SubINode( in1->in(1), in2->in(2) );
if( op1 == Op_AddI && op2 == Op_AddI && in1->in(1) == in2->in(2) )
return new (phase->C) SubINode( in1->in(2), in2->in(1) );
if( op2 == Op_SubI && in2->outcnt() == 1) {
Node *add1 = phase->transform( new (phase->C) AddINode( in1, in2->in(2) ) );
return new (phase->C) SubINode( add1, in2->in(1) );
}
return NULL;
}
const Type *SubINode::sub( const Type *t1, const Type *t2 ) const {
const TypeInt *r0 = t1->is_int(); // Handy access
const TypeInt *r1 = t2->is_int();
int32 lo = java_subtract(r0->_lo, r1->_hi);
int32 hi = java_subtract(r0->_hi, r1->_lo);
if( (((r0->_lo ^ r1->_hi) >= 0) || // lo ends have same signs OR
((r0->_lo ^ lo) >= 0)) && // lo results have same signs AND
(((r0->_hi ^ r1->_lo) >= 0) || // hi ends have same signs OR
((r0->_hi ^ hi) >= 0)) ) // hi results have same signs
return TypeInt::make(lo,hi,MAX2(r0->_widen,r1->_widen));
else // Overflow; assume all integers
return TypeInt::INT;
}
Node *SubLNode::Ideal(PhaseGVN *phase, bool can_reshape) {
Node *in1 = in(1);
Node *in2 = in(2);
uint op1 = in1->Opcode();
uint op2 = in2->Opcode();
#ifdef ASSERT
if( phase->eqv( in1, this ) || phase->eqv( in2, this ) ||
( op1 == Op_AddL || op1 == Op_SubL ) &&
( phase->eqv( in1->in(1), this ) || phase->eqv( in1->in(2), this ) ||
phase->eqv( in1->in(1), in1 ) || phase->eqv( in1->in(2), in1 ) ) )
assert(false, "dead loop in SubLNode::Ideal");
#endif
if( phase->type( in2 ) == Type::TOP ) return NULL;
const TypeLong *i = phase->type( in2 )->isa_long();
if( i && // Might be bottom or top...
i->is_con() )
return new (phase->C) AddLNode(in1, phase->longcon(-i->get_con()));
if( op1 == Op_AddL && ok_to_convert(in1, in2) ) {
Node *in11 = in1->in(1);
const Type *tadd = phase->type( in1->in(2) );
if( tadd->singleton() && tadd != Type::TOP ) {
Node *sub2 = phase->transform( new (phase->C) SubLNode( in11, in2 ));
return new (phase->C) AddLNode( sub2, in1->in(2) );
}
}
if (op2 == Op_AddL && ok_to_convert(in2, in1)) {
Node* in21 = in2->in(1);
Node* in22 = in2->in(2);
const TypeLong* tcon = phase->type(in22)->isa_long();
if (tcon != NULL && tcon->is_con()) {
Node* sub2 = phase->transform( new (phase->C) SubLNode(in1, in21) );
Node* neg_c0 = phase->longcon(- tcon->get_con());
return new (phase->C) AddLNode(sub2, neg_c0);
}
}
const Type *t1 = phase->type( in1 );
if( t1 == Type::TOP ) return NULL;
#ifdef ASSERT
if( ( op2 == Op_AddL || op2 == Op_SubL ) &&
( phase->eqv( in2->in(1), this ) || phase->eqv( in2->in(2), this ) ||
phase->eqv( in2->in(1), in2 ) || phase->eqv( in2->in(2), in2 ) ) )
assert(false, "dead loop in SubLNode::Ideal");
#endif
if( op2 == Op_AddL &&
phase->eqv( in1, in2->in(1) ) )
return new (phase->C) SubLNode( phase->makecon(TypeLong::ZERO), in2->in(2));
if( op2 == Op_AddL &&
phase->eqv( in1, in2->in(2) ) )
return new (phase->C) SubLNode( phase->makecon(TypeLong::ZERO),in2->in(1));
if( phase->type( in1 ) == TypeLong::ZERO && op2 == Op_SubL )
return new (phase->C) SubLNode( in2->in(2), in2->in(1) );
if( op1 == Op_AddL && op2 == Op_AddL && in1->in(1) == in2->in(1) )
return new (phase->C) SubLNode( in1->in(2), in2->in(2) );
if( op1 == Op_AddL && op2 == Op_AddL && in1->in(2) == in2->in(2) )
return new (phase->C) SubLNode( in1->in(1), in2->in(1) );
if( op2 == Op_SubL && in2->outcnt() == 1) {
Node *add1 = phase->transform( new (phase->C) AddLNode( in1, in2->in(2) ) );
return new (phase->C) SubLNode( add1, in2->in(1) );
}
return NULL;
}
const Type *SubLNode::sub( const Type *t1, const Type *t2 ) const {
const TypeLong *r0 = t1->is_long(); // Handy access
const TypeLong *r1 = t2->is_long();
jlong lo = java_subtract(r0->_lo, r1->_hi);
jlong hi = java_subtract(r0->_hi, r1->_lo);
if( (((r0->_lo ^ r1->_hi) >= 0) || // lo ends have same signs OR
((r0->_lo ^ lo) >= 0)) && // lo results have same signs AND
(((r0->_hi ^ r1->_lo) >= 0) || // hi ends have same signs OR
((r0->_hi ^ hi) >= 0)) ) // hi results have same signs
return TypeLong::make(lo,hi,MAX2(r0->_widen,r1->_widen));
else // Overflow; assume all integers
return TypeLong::LONG;
}
const Type *SubFPNode::Value( PhaseTransform *phase ) const {
const Node* in1 = in(1);
const Node* in2 = in(2);
const Type* t1 = (in1 == this) ? Type::TOP : phase->type(in1);
if( t1 == Type::TOP ) return Type::TOP;
const Type* t2 = (in2 == this) ? Type::TOP : phase->type(in2);
if( t2 == Type::TOP ) return Type::TOP;
if( (t1->is_finite() && t2->is_finite()) ) {
if( phase->eqv(in1, in2) ) return add_id();
}
const Type *bot = bottom_type();
if( (t1 == bot) || (t2 == bot) ||
(t1 == Type::BOTTOM) || (t2 == Type::BOTTOM) )
return bot;
return sub(t1,t2); // Local flavor of type subtraction
}
Node *SubFNode::Ideal(PhaseGVN *phase, bool can_reshape) {
const Type *t2 = phase->type( in(2) );
if( t2->base() == Type::FloatCon ) { // Might be bottom or top...
}
if( IdealizedNumerics && !phase->C->method()->is_strict() ) {
if( in(2)->is_Add() &&
phase->eqv(in(1),in(2)->in(1) ) )
return new (phase->C) SubFNode( phase->makecon(TypeF::ZERO),in(2)->in(2));
}
return NULL;
}
const Type *SubFNode::sub( const Type *t1, const Type *t2 ) const {
if( g_isfinite(t1->getf()) && g_isfinite(t2->getf()) ) {
return TypeF::make( t1->getf() - t2->getf() );
}
else if( g_isnan(t1->getf()) ) {
return t1;
}
else if( g_isnan(t2->getf()) ) {
return t2;
}
else {
return Type::FLOAT;
}
}
Node *SubDNode::Ideal(PhaseGVN *phase, bool can_reshape){
const Type *t2 = phase->type( in(2) );
if( t2->base() == Type::DoubleCon ) { // Might be bottom or top...
}
if( IdealizedNumerics && !phase->C->method()->is_strict() ) {
if( in(2)->is_Add() &&
phase->eqv(in(1),in(2)->in(1) ) )
return new (phase->C) SubDNode( phase->makecon(TypeD::ZERO),in(2)->in(2));
}
return NULL;
}
const Type *SubDNode::sub( const Type *t1, const Type *t2 ) const {
if( g_isfinite(t1->getd()) && g_isfinite(t2->getd()) ) {
return TypeD::make( t1->getd() - t2->getd() );
}
else if( g_isnan(t1->getd()) ) {
return t1;
}
else if( g_isnan(t2->getd()) ) {
return t2;
}
else {
return Type::DOUBLE;
}
}
Node *CmpNode::Identity( PhaseTransform *phase ) {
return this;
}
const Type *CmpINode::sub( const Type *t1, const Type *t2 ) const {
const TypeInt *r0 = t1->is_int(); // Handy access
const TypeInt *r1 = t2->is_int();
if( r0->_hi < r1->_lo ) // Range is always low?
return TypeInt::CC_LT;
else if( r0->_lo > r1->_hi ) // Range is always high?
return TypeInt::CC_GT;
else if( r0->is_con() && r1->is_con() ) { // comparing constants?
assert(r0->get_con() == r1->get_con(), "must be equal");
return TypeInt::CC_EQ; // Equal results.
} else if( r0->_hi == r1->_lo ) // Range is never high?
return TypeInt::CC_LE;
else if( r0->_lo == r1->_hi ) // Range is never low?
return TypeInt::CC_GE;
return TypeInt::CC; // else use worst case results
}
const Type *CmpUNode::sub( const Type *t1, const Type *t2 ) const {
assert(!t1->isa_ptr(), "obsolete usage of CmpU");
const TypeInt *r0 = t1->is_int(); // Handy access
const TypeInt *r1 = t2->is_int();
juint lo0 = r0->_lo;
juint hi0 = r0->_hi;
juint lo1 = r1->_lo;
juint hi1 = r1->_hi;
bool bot0 = ((jint)(lo0 ^ hi0) < 0);
bool bot1 = ((jint)(lo1 ^ hi1) < 0);
if (bot0 || bot1) {
if (lo0 == 0 && hi0 == 0) {
return TypeInt::CC_LE; // 0 <= bot
} else if ((jint)lo0 == -1 && (jint)hi0 == -1) {
return TypeInt::CC_GE; // -1 >= bot
} else if (lo1 == 0 && hi1 == 0) {
return TypeInt::CC_GE; // bot >= 0
} else if ((jint)lo1 == -1 && (jint)hi1 == -1) {
return TypeInt::CC_LE; // bot <= -1
}
} else {
assert(lo0 <= hi0 && lo1 <= hi1, "unsigned ranges are valid");
if (hi0 < lo1) {
return TypeInt::CC_LT; // smaller
} else if (lo0 > hi1) {
return TypeInt::CC_GT; // greater
} else if (hi0 == lo1 && lo0 == hi1) {
return TypeInt::CC_EQ; // Equal results
} else if (lo0 >= hi1) {
return TypeInt::CC_GE;
} else if (hi0 <= lo1) {
if ((jint)lo0 >= 0 && (jint)lo1 >= 0 && is_index_range_check())
return TypeInt::CC_LT;
return TypeInt::CC_LE;
}
}
if ((jint)lo0 >= 0 && (jint)lo1 >= 0 && is_index_range_check())
return TypeInt::CC_LT;
return TypeInt::CC; // else use worst case results
}
const Type* CmpUNode::Value(PhaseTransform *phase) const {
const Type* t = SubNode::Value_common(phase);
if (t != NULL) {
return t;
}
const Node* in1 = in(1);
const Node* in2 = in(2);
const Type* t1 = phase->type(in1);
const Type* t2 = phase->type(in2);
assert(t1->isa_int(), "CmpU has only Int type inputs");
if (t2 == TypeInt::INT) { // Compare to bottom?
return bottom_type();
}
uint in1_op = in1->Opcode();
if (in1_op == Op_AddI || in1_op == Op_SubI) {
const Node* in11 = in1->in(1);
const Node* in12 = in1->in(2);
const Type* t11 = (in11 == in1) ? Type::TOP : phase->type(in11);
const Type* t12 = (in12 == in1) ? Type::TOP : phase->type(in12);
if ((t11 != Type::TOP) && (t11 != TypeInt::INT) &&
(t12 != Type::TOP) && (t12 != TypeInt::INT)) {
const TypeInt *r0 = t11->is_int();
const TypeInt *r1 = t12->is_int();
jlong lo_r0 = r0->_lo;
jlong hi_r0 = r0->_hi;
jlong lo_r1 = r1->_lo;
jlong hi_r1 = r1->_hi;
if (in1_op == Op_SubI) {
jlong tmp = hi_r1;
hi_r1 = -lo_r1;
lo_r1 = -tmp;
}
jlong lo_long = lo_r0 + lo_r1;
jlong hi_long = hi_r0 + hi_r1;
int lo_tr1 = min_jint;
int hi_tr1 = (int)hi_long;
int lo_tr2 = (int)lo_long;
int hi_tr2 = max_jint;
bool underflow = lo_long != (jlong)lo_tr2;
bool overflow = hi_long != (jlong)hi_tr1;
if ((underflow != overflow) && (hi_tr1 < lo_tr2)) {
int w = MAX2(r0->_widen, r1->_widen); // _widen does not matter here
const TypeInt* tr1 = TypeInt::make(lo_tr1, hi_tr1, w);
const TypeInt* tr2 = TypeInt::make(lo_tr2, hi_tr2, w);
const Type* cmp1 = sub(tr1, t2);
const Type* cmp2 = sub(tr2, t2);
if (cmp1 == cmp2) {
return cmp1; // Hit!
}
}
}
}
return sub(t1, t2); // Local flavor of type subtraction
}
bool CmpUNode::is_index_range_check() const {
return (in(1)->Opcode() == Op_ModI &&
in(1)->in(2)->eqv_uncast(in(2)));
}
Node *CmpINode::Ideal( PhaseGVN *phase, bool can_reshape ) {
if (phase->type(in(2))->higher_equal(TypeInt::ZERO)) {
switch (in(1)->Opcode()) {
case Op_CmpL3: // Collapse a CmpL3/CmpI into a CmpL
return new (phase->C) CmpLNode(in(1)->in(1),in(1)->in(2));
case Op_CmpF3: // Collapse a CmpF3/CmpI into a CmpF
return new (phase->C) CmpFNode(in(1)->in(1),in(1)->in(2));
case Op_CmpD3: // Collapse a CmpD3/CmpI into a CmpD
return new (phase->C) CmpDNode(in(1)->in(1),in(1)->in(2));
}
}
return NULL; // No change
}
const Type *CmpLNode::sub( const Type *t1, const Type *t2 ) const {
const TypeLong *r0 = t1->is_long(); // Handy access
const TypeLong *r1 = t2->is_long();
if( r0->_hi < r1->_lo ) // Range is always low?
return TypeInt::CC_LT;
else if( r0->_lo > r1->_hi ) // Range is always high?
return TypeInt::CC_GT;
else if( r0->is_con() && r1->is_con() ) { // comparing constants?
assert(r0->get_con() == r1->get_con(), "must be equal");
return TypeInt::CC_EQ; // Equal results.
} else if( r0->_hi == r1->_lo ) // Range is never high?
return TypeInt::CC_LE;
else if( r0->_lo == r1->_hi ) // Range is never low?
return TypeInt::CC_GE;
return TypeInt::CC; // else use worst case results
}
const Type* CmpULNode::sub(const Type* t1, const Type* t2) const {
assert(!t1->isa_ptr(), "obsolete usage of CmpUL");
const TypeLong* r0 = t1->is_long(); // Handy access
const TypeLong* r1 = t2->is_long();
julong lo0 = r0->_lo;
julong hi0 = r0->_hi;
julong lo1 = r1->_lo;
julong hi1 = r1->_hi;
bool bot0 = ((jlong)(lo0 ^ hi0) < 0);
bool bot1 = ((jlong)(lo1 ^ hi1) < 0);
if (bot0 || bot1) {
if (lo0 == 0 && hi0 == 0) {
return TypeInt::CC_LE; // 0 <= bot
} else if ((jlong)lo0 == -1 && (jlong)hi0 == -1) {
return TypeInt::CC_GE; // -1 >= bot
} else if (lo1 == 0 && hi1 == 0) {
return TypeInt::CC_GE; // bot >= 0
} else if ((jlong)lo1 == -1 && (jlong)hi1 == -1) {
return TypeInt::CC_LE; // bot <= -1
}
} else {
assert(lo0 <= hi0 && lo1 <= hi1, "unsigned ranges are valid");
if (hi0 < lo1) {
return TypeInt::CC_LT; // smaller
} else if (lo0 > hi1) {
return TypeInt::CC_GT; // greater
} else if (hi0 == lo1 && lo0 == hi1) {
return TypeInt::CC_EQ; // Equal results
} else if (lo0 >= hi1) {
return TypeInt::CC_GE;
} else if (hi0 <= lo1) {
return TypeInt::CC_LE;
}
}
return TypeInt::CC; // else use worst case results
}
const Type *CmpPNode::sub( const Type *t1, const Type *t2 ) const {
const TypePtr *r0 = t1->is_ptr(); // Handy access
const TypePtr *r1 = t2->is_ptr();
if( TypePtr::above_centerline(r0->_ptr) ||
TypePtr::above_centerline(r1->_ptr) )
return Type::TOP;
if (r0 == r1 && r0->singleton()) {
return TypeInt::CC_EQ;
}
const TypeOopPtr* p0 = r0->isa_oopptr();
const TypeOopPtr* p1 = r1->isa_oopptr();
if (p0 && p1) {
Node* in1 = in(1)->uncast();
Node* in2 = in(2)->uncast();
AllocateNode* alloc1 = AllocateNode::Ideal_allocation(in1, NULL);
AllocateNode* alloc2 = AllocateNode::Ideal_allocation(in2, NULL);
if (MemNode::detect_ptr_independence(in1, alloc1, in2, alloc2, NULL)) {
return TypeInt::CC_GT; // different pointers
}
ciKlass* klass0 = p0->klass();
bool xklass0 = p0->klass_is_exact();
ciKlass* klass1 = p1->klass();
bool xklass1 = p1->klass_is_exact();
int kps = (p0->isa_klassptr()?1:0) + (p1->isa_klassptr()?1:0);
if (klass0 && klass1 &&
kps != 1 && // both or neither are klass pointers
klass0->is_loaded() && !klass0->is_interface() && // do not trust interfaces
klass1->is_loaded() && !klass1->is_interface() &&
(!klass0->is_obj_array_klass() ||
!klass0->as_obj_array_klass()->base_element_klass()->is_interface()) &&
(!klass1->is_obj_array_klass() ||
!klass1->as_obj_array_klass()->base_element_klass()->is_interface())) {
bool unrelated_classes = false;
if (klass0->equals(klass1)) { // if types are unequal but klasses are equal
} else if (klass0->is_subtype_of(klass1)) {
unrelated_classes = xklass1;
} else if (klass1->is_subtype_of(klass0)) {
unrelated_classes = xklass0;
} else { // Neither subtypes the other
unrelated_classes = true;
}
if (unrelated_classes) {
TypePtr::PTR jp = r0->join_ptr(r1->_ptr);
if (jp != TypePtr::Null && jp != TypePtr::BotPTR) {
return TypeInt::CC_GT;
}
}
}
}
if( r0->singleton() ) {
intptr_t bits0 = r0->get_con();
if( r1->singleton() )
return bits0 == r1->get_con() ? TypeInt::CC_EQ : TypeInt::CC_GT;
return ( r1->_ptr == TypePtr::NotNull && bits0==0 ) ? TypeInt::CC_GT : TypeInt::CC;
} else if( r1->singleton() ) {
intptr_t bits1 = r1->get_con();
return ( r0->_ptr == TypePtr::NotNull && bits1==0 ) ? TypeInt::CC_GT : TypeInt::CC;
} else
return TypeInt::CC;
}
static inline Node* isa_java_mirror_load(PhaseGVN* phase, Node* n) {
if (n->Opcode() != Op_LoadP) return NULL;
const TypeInstPtr* tp = phase->type(n)->isa_instptr();
if (!tp || tp->klass() != phase->C->env()->Class_klass()) return NULL;
Node* adr = n->in(MemNode::Address);
intptr_t off = 0;
Node* k = AddPNode::Ideal_base_and_offset(adr, phase, off);
if (k == NULL) return NULL;
const TypeKlassPtr* tkp = phase->type(k)->isa_klassptr();
if (!tkp || off != in_bytes(Klass::java_mirror_offset())) return NULL;
return k;
}
static inline Node* isa_const_java_mirror(PhaseGVN* phase, Node* n) {
if (!n->is_Con()) return NULL;
const TypeInstPtr* tp = phase->type(n)->isa_instptr();
if (!tp) return NULL;
ciType* mirror_type = tp->java_mirror_type();
if (!mirror_type) return NULL;
if (mirror_type->is_classless()) {
return phase->makecon(TypePtr::NULL_PTR);
}
assert(mirror_type->is_klass(), "mirror_type should represent a Klass*");
return phase->makecon(TypeKlassPtr::make(mirror_type->as_klass()));
}
Node *CmpPNode::Ideal( PhaseGVN *phase, bool can_reshape ) {
{
Node* k1 = isa_java_mirror_load(phase, in(1));
Node* k2 = isa_java_mirror_load(phase, in(2));
Node* conk2 = isa_const_java_mirror(phase, in(2));
if (k1 && (k2 || conk2)) {
Node* lhs = k1;
Node* rhs = (k2 != NULL) ? k2 : conk2;
this->set_req(1, lhs);
this->set_req(2, rhs);
return this;
}
}
const TypeKlassPtr* t2 = phase->type(in(2))->isa_klassptr();
if (t2 == NULL || !t2->klass_is_exact())
return NULL;
ciKlass* superklass = t2->klass();
Node* ldk1 = in(1);
if (ldk1->is_DecodeNKlass()) {
ldk1 = ldk1->in(1);
if (ldk1->Opcode() != Op_LoadNKlass )
return NULL;
} else if (ldk1->Opcode() != Op_LoadKlass )
return NULL;
Node* adr1 = ldk1->in(MemNode::Address);
intptr_t con2 = 0;
Node* ldk2 = AddPNode::Ideal_base_and_offset(adr1, phase, con2);
if (ldk2 == NULL)
return NULL;
if (con2 == oopDesc::klass_offset_in_bytes()) {
if (superklass->is_interface() ||
superklass->is_abstract()) {
this->set_req(2, phase->makecon(TypePtr::NULL_PTR));
return this;
}
}
if (ldk2->is_DecodeNKlass()) {
if (ldk2->in(1)->Opcode() != Op_LoadNKlass )
return NULL;
} else if (ldk2->Opcode() != Op_LoadKlass)
return NULL;
if (con2 != (intptr_t) superklass->super_check_offset())
return NULL; // Might be element-klass loading from array klass
while (superklass->is_obj_array_klass()) {
ciType* elem = superklass->as_obj_array_klass()->element_type();
superklass = elem->as_klass();
}
if (superklass->is_instance_klass()) {
ciInstanceKlass* ik = superklass->as_instance_klass();
if (ik->has_subklass() || ik->is_interface()) return NULL;
if (!ik->is_final()) {
phase->C->dependencies()->assert_leaf_type(ik);
}
}
this->set_req(1,ldk2);
return this;
}
const Type *CmpNNode::sub( const Type *t1, const Type *t2 ) const {
const TypePtr *r0 = t1->make_ptr(); // Handy access
const TypePtr *r1 = t2->make_ptr();
if ((r0 == NULL) || (r1 == NULL) ||
TypePtr::above_centerline(r0->_ptr) ||
TypePtr::above_centerline(r1->_ptr)) {
return Type::TOP;
}
if (r0 == r1 && r0->singleton()) {
return TypeInt::CC_EQ;
}
const TypeOopPtr* p0 = r0->isa_oopptr();
const TypeOopPtr* p1 = r1->isa_oopptr();
if (p0 && p1) {
ciKlass* klass0 = p0->klass();
bool xklass0 = p0->klass_is_exact();
ciKlass* klass1 = p1->klass();
bool xklass1 = p1->klass_is_exact();
int kps = (p0->isa_klassptr()?1:0) + (p1->isa_klassptr()?1:0);
if (klass0 && klass1 &&
kps != 1 && // both or neither are klass pointers
!klass0->is_interface() && // do not trust interfaces
!klass1->is_interface()) {
bool unrelated_classes = false;
if (klass0->equals(klass1)) { // if types are unequal but klasses are equal
} else if (klass0->is_subtype_of(klass1)) {
unrelated_classes = xklass1;
} else if (klass1->is_subtype_of(klass0)) {
unrelated_classes = xklass0;
} else { // Neither subtypes the other
unrelated_classes = true;
}
if (unrelated_classes) {
TypePtr::PTR jp = r0->join_ptr(r1->_ptr);
if (jp != TypePtr::Null && jp != TypePtr::BotPTR) {
return TypeInt::CC_GT;
}
}
}
}
if( r0->singleton() ) {
intptr_t bits0 = r0->get_con();
if( r1->singleton() )
return bits0 == r1->get_con() ? TypeInt::CC_EQ : TypeInt::CC_GT;
return ( r1->_ptr == TypePtr::NotNull && bits0==0 ) ? TypeInt::CC_GT : TypeInt::CC;
} else if( r1->singleton() ) {
intptr_t bits1 = r1->get_con();
return ( r0->_ptr == TypePtr::NotNull && bits1==0 ) ? TypeInt::CC_GT : TypeInt::CC;
} else
return TypeInt::CC;
}
Node *CmpNNode::Ideal( PhaseGVN *phase, bool can_reshape ) {
return NULL;
}
const Type *CmpFNode::Value( PhaseTransform *phase ) const {
const Node* in1 = in(1);
const Node* in2 = in(2);
const Type* t1 = (in1 == this) ? Type::TOP : phase->type(in1);
if( t1 == Type::TOP ) return Type::TOP;
const Type* t2 = (in2 == this) ? Type::TOP : phase->type(in2);
if( t2 == Type::TOP ) return Type::TOP;
const TypeF *tf1 = t1->isa_float_constant();
const TypeF *tf2 = t2->isa_float_constant();
if( !tf1 || !tf2 ) return TypeInt::CC;
if( tf1->is_nan() || tf2->is_nan() )
return TypeInt::CC_LT;
if( tf1->_f < tf2->_f ) return TypeInt::CC_LT;
if( tf1->_f > tf2->_f ) return TypeInt::CC_GT;
assert( tf1->_f == tf2->_f, "do not understand FP behavior" );
return TypeInt::CC_EQ;
}
const Type *CmpDNode::Value( PhaseTransform *phase ) const {
const Node* in1 = in(1);
const Node* in2 = in(2);
const Type* t1 = (in1 == this) ? Type::TOP : phase->type(in1);
if( t1 == Type::TOP ) return Type::TOP;
const Type* t2 = (in2 == this) ? Type::TOP : phase->type(in2);
if( t2 == Type::TOP ) return Type::TOP;
const TypeD *td1 = t1->isa_double_constant();
const TypeD *td2 = t2->isa_double_constant();
if( !td1 || !td2 ) return TypeInt::CC;
if( td1->is_nan() || td2->is_nan() )
return TypeInt::CC_LT;
if( td1->_d < td2->_d ) return TypeInt::CC_LT;
if( td1->_d > td2->_d ) return TypeInt::CC_GT;
assert( td1->_d == td2->_d, "do not understand FP behavior" );
return TypeInt::CC_EQ;
}
Node *CmpDNode::Ideal(PhaseGVN *phase, bool can_reshape){
int idx_f2d = 1; // ConvF2D on left side?
if( in(idx_f2d)->Opcode() != Op_ConvF2D )
idx_f2d = 2; // No, swap to check for reversed args
int idx_con = 3-idx_f2d; // Check for the constant on other input
if( ConvertCmpD2CmpF &&
in(idx_f2d)->Opcode() == Op_ConvF2D &&
in(idx_con)->Opcode() == Op_ConD ) {
const TypeD *t2 = in(idx_con)->bottom_type()->is_double_constant();
double t2_value_as_double = t2->_d;
float t2_value_as_float = (float)t2_value_as_double;
if( t2_value_as_double == (double)t2_value_as_float ) {
Node *new_in1 = in(idx_f2d)->in(1);
Node *new_in2 = phase->makecon( TypeF::make(t2_value_as_float) );
if( idx_f2d != 1 ) { // Must flip args to match original order
Node *tmp = new_in1;
new_in1 = new_in2;
new_in2 = tmp;
}
CmpFNode *new_cmp = (Opcode() == Op_CmpD3)
? new (phase->C) CmpF3Node( new_in1, new_in2 )
: new (phase->C) CmpFNode ( new_in1, new_in2 ) ;
return new_cmp; // Changed to CmpFNode
}
}
return NULL; // No change
}
const Type *BoolTest::cc2logical( const Type *CC ) const {
if( CC == Type::TOP ) return Type::TOP;
if( CC->base() != Type::Int ) return TypeInt::BOOL; // Bottom or worse
const TypeInt *ti = CC->is_int();
if( ti->is_con() ) { // Only 1 kind of condition codes set?
int tmp = ((ti->get_con()&3) == (_test&3)) ? 1 : 0;
if( _test & 4 ) tmp = 1-tmp; // Optionally complement result
return TypeInt::make(tmp); // Boolean result
}
if( CC == TypeInt::CC_GE ) {
if( _test == ge ) return TypeInt::ONE;
if( _test == lt ) return TypeInt::ZERO;
}
if( CC == TypeInt::CC_LE ) {
if( _test == le ) return TypeInt::ONE;
if( _test == gt ) return TypeInt::ZERO;
}
return TypeInt::BOOL;
}
void BoolTest::dump_on(outputStream *st) const {
const char *msg[] = {"eq","gt","of","lt","ne","le","nof","ge"};
st->print("%s", msg[_test]);
}
uint BoolNode::hash() const { return (Node::hash() << 3)|(_test._test+1); }
uint BoolNode::size_of() const { return sizeof(BoolNode); }
uint BoolNode::cmp( const Node &n ) const {
const BoolNode *b = (const BoolNode *)&n; // Cast up
return (_test._test == b->_test._test);
}
Node* BoolNode::make_predicate(Node* test_value, PhaseGVN* phase) {
if (test_value->is_Con()) return test_value;
if (test_value->is_Bool()) return test_value;
Compile* C = phase->C;
if (test_value->is_CMove() &&
test_value->in(CMoveNode::Condition)->is_Bool()) {
BoolNode* bol = test_value->in(CMoveNode::Condition)->as_Bool();
const Type* ftype = phase->type(test_value->in(CMoveNode::IfFalse));
const Type* ttype = phase->type(test_value->in(CMoveNode::IfTrue));
if (ftype == TypeInt::ZERO && !TypeInt::ZERO->higher_equal(ttype)) {
return bol;
} else if (ttype == TypeInt::ZERO && !TypeInt::ZERO->higher_equal(ftype)) {
return phase->transform( bol->negate(phase) );
}
}
Node* cmp = new (C) CmpINode(test_value, phase->intcon(0));
cmp = phase->transform(cmp);
Node* bol = new (C) BoolNode(cmp, BoolTest::ne);
return phase->transform(bol);
}
Node* BoolNode::as_int_value(PhaseGVN* phase) {
Node* cmov = CMoveNode::make(phase->C, NULL, this,
phase->intcon(0), phase->intcon(1),
TypeInt::BOOL);
return phase->transform(cmov);
}
BoolNode* BoolNode::negate(PhaseGVN* phase) {
Compile* C = phase->C;
return new (C) BoolNode(in(1), _test.negate());
}
Node *BoolNode::Ideal(PhaseGVN *phase, bool can_reshape) {
Node *cmp = in(1);
if( !cmp->is_Sub() ) return NULL;
int cop = cmp->Opcode();
if( cop == Op_FastLock || cop == Op_FastUnlock) return NULL;
Node *cmp1 = cmp->in(1);
Node *cmp2 = cmp->in(2);
if( !cmp1 ) return NULL;
if (_test._test == BoolTest::overflow || _test._test == BoolTest::no_overflow) {
return NULL;
}
Node *con = cmp1;
uint op2 = cmp2->Opcode();
if( con->is_Con() && !cmp2->is_Con() && op2 != Op_Opaque1 &&
cop != Op_CmpD && cop != Op_CmpF &&
!is_counted_loop_exit_test() ) {
cmp = cmp->clone();
cmp->swap_edges(1, 2);
cmp = phase->transform( cmp );
return new (phase->C) BoolNode( cmp, _test.commute() );
}
int cmp1_op = cmp1->Opcode();
const TypeInt* cmp2_type = phase->type(cmp2)->isa_int();
if (cmp2_type == NULL) return NULL;
Node* j_xor = cmp1;
if( cmp2_type == TypeInt::ZERO &&
cmp1_op == Op_XorI &&
j_xor->in(1) != j_xor && // An xor of itself is dead
phase->type( j_xor->in(1) ) == TypeInt::BOOL &&
phase->type( j_xor->in(2) ) == TypeInt::ONE &&
(_test._test == BoolTest::eq ||
_test._test == BoolTest::ne) ) {
Node *ncmp = phase->transform(new (phase->C) CmpINode(j_xor->in(1),cmp2));
return new (phase->C) BoolNode( ncmp, _test.negate() );
}
Node *c2b = cmp1;
if( cmp2_type == TypeInt::ZERO &&
cmp1_op == Op_Conv2B &&
(_test._test == BoolTest::eq ||
_test._test == BoolTest::ne) ) {
Node *ncmp = phase->transform(phase->type(c2b->in(1))->isa_int()
? (Node*)new (phase->C) CmpINode(c2b->in(1),cmp2)
: (Node*)new (phase->C) CmpPNode(c2b->in(1),phase->makecon(TypePtr::NULL_PTR))
);
return new (phase->C) BoolNode( ncmp, _test._test );
}
if ((_test._test == BoolTest::eq || _test._test == BoolTest::ne) &&
(cop == Op_CmpI) &&
(cmp1->Opcode() == Op_SubI) &&
( cmp2_type == TypeInt::ZERO ) ) {
Node *ncmp = phase->transform( new (phase->C) CmpINode(cmp1->in(1),cmp1->in(2)));
return new (phase->C) BoolNode( ncmp, _test._test );
}
if( cop == Op_CmpI &&
cmp1->Opcode() == Op_SubI &&
cmp2_type == TypeInt::ZERO &&
phase->type( cmp1->in(1) ) == TypeInt::ZERO &&
phase->type( cmp1->in(2) )->higher_equal(TypeInt::SYMINT) ) {
Node *ncmp = phase->transform( new (phase->C) CmpINode(cmp1->in(2),cmp2));
return new (phase->C) BoolNode( ncmp, _test.commute() );
}
return NULL;
}
const Type *BoolNode::Value( PhaseTransform *phase ) const {
return _test.cc2logical( phase->type( in(1) ) );
}
#ifndef PRODUCT
void BoolNode::dump_spec(outputStream *st) const {
st->print("[");
_test.dump_on(st);
st->print("]");
}
#endif
bool BoolNode::is_counted_loop_exit_test() {
for( DUIterator_Fast imax, i = fast_outs(imax); i < imax; i++ ) {
Node* use = fast_out(i);
if (use->is_CountedLoopEnd()) {
return true;
}
}
return false;
}
const Type *SqrtDNode::Value( PhaseTransform *phase ) const {
const Type *t1 = phase->type( in(1) );
if( t1 == Type::TOP ) return Type::TOP;
if( t1->base() != Type::DoubleCon ) return Type::DOUBLE;
double d = t1->getd();
if( d < 0.0 ) return Type::DOUBLE;
return TypeD::make( sqrt( d ) );
}
const Type *CosDNode::Value( PhaseTransform *phase ) const {
const Type *t1 = phase->type( in(1) );
if( t1 == Type::TOP ) return Type::TOP;
if( t1->base() != Type::DoubleCon ) return Type::DOUBLE;
double d = t1->getd();
return TypeD::make( StubRoutines::intrinsic_cos( d ) );
}
const Type *SinDNode::Value( PhaseTransform *phase ) const {
const Type *t1 = phase->type( in(1) );
if( t1 == Type::TOP ) return Type::TOP;
if( t1->base() != Type::DoubleCon ) return Type::DOUBLE;
double d = t1->getd();
return TypeD::make( StubRoutines::intrinsic_sin( d ) );
}
const Type *TanDNode::Value( PhaseTransform *phase ) const {
const Type *t1 = phase->type( in(1) );
if( t1 == Type::TOP ) return Type::TOP;
if( t1->base() != Type::DoubleCon ) return Type::DOUBLE;
double d = t1->getd();
return TypeD::make( StubRoutines::intrinsic_tan( d ) );
}
const Type *LogDNode::Value( PhaseTransform *phase ) const {
const Type *t1 = phase->type( in(1) );
if( t1 == Type::TOP ) return Type::TOP;
if( t1->base() != Type::DoubleCon ) return Type::DOUBLE;
double d = t1->getd();
return TypeD::make( StubRoutines::intrinsic_log( d ) );
}
const Type *Log10DNode::Value( PhaseTransform *phase ) const {
const Type *t1 = phase->type( in(1) );
if( t1 == Type::TOP ) return Type::TOP;
if( t1->base() != Type::DoubleCon ) return Type::DOUBLE;
double d = t1->getd();
return TypeD::make( StubRoutines::intrinsic_log10( d ) );
}
const Type *ExpDNode::Value( PhaseTransform *phase ) const {
const Type *t1 = phase->type( in(1) );
if( t1 == Type::TOP ) return Type::TOP;
if( t1->base() != Type::DoubleCon ) return Type::DOUBLE;
double d = t1->getd();
return TypeD::make( StubRoutines::intrinsic_exp( d ) );
}
const Type *PowDNode::Value( PhaseTransform *phase ) const {
const Type *t1 = phase->type( in(1) );
if( t1 == Type::TOP ) return Type::TOP;
if( t1->base() != Type::DoubleCon ) return Type::DOUBLE;
const Type *t2 = phase->type( in(2) );
if( t2 == Type::TOP ) return Type::TOP;
if( t2->base() != Type::DoubleCon ) return Type::DOUBLE;
double d1 = t1->getd();
double d2 = t2->getd();
return TypeD::make( StubRoutines::intrinsic_pow( d1, d2 ) );
}
C:\hotspot-69087d08d473\src\share\vm/opto/subnode.hpp
#ifndef SHARE_VM_OPTO_SUBNODE_HPP
#define SHARE_VM_OPTO_SUBNODE_HPP
#include "opto/node.hpp"
#include "opto/opcodes.hpp"
#include "opto/type.hpp"
class SubNode : public Node {
public:
SubNode( Node *in1, Node *in2 ) : Node(0,in1,in2) {
init_class_id(Class_Sub);
}
virtual Node *Identity( PhaseTransform *phase );
virtual const Type *Value( PhaseTransform *phase ) const;
const Type* Value_common( PhaseTransform *phase ) const;
virtual const Type *sub( const Type *, const Type * ) const = 0;
virtual const Type *add_id() const = 0;
};
class SubINode : public SubNode {
public:
SubINode( Node *in1, Node *in2 ) : SubNode(in1,in2) {}
virtual int Opcode() const;
virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
virtual const Type *sub( const Type *, const Type * ) const;
const Type *add_id() const { return TypeInt::ZERO; }
const Type *bottom_type() const { return TypeInt::INT; }
virtual uint ideal_reg() const { return Op_RegI; }
};
class SubLNode : public SubNode {
public:
SubLNode( Node *in1, Node *in2 ) : SubNode(in1,in2) {}
virtual int Opcode() const;
virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
virtual const Type *sub( const Type *, const Type * ) const;
const Type *add_id() const { return TypeLong::ZERO; }
const Type *bottom_type() const { return TypeLong::LONG; }
virtual uint ideal_reg() const { return Op_RegL; }
};
class SubFPNode : public SubNode {
protected:
SubFPNode( Node *in1, Node *in2 ) : SubNode(in1,in2) {}
public:
const Type *Value( PhaseTransform *phase ) const;
};
class SubFNode : public SubFPNode {
public:
SubFNode( Node *in1, Node *in2 ) : SubFPNode(in1,in2) {}
virtual int Opcode() const;
virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
virtual const Type *sub( const Type *, const Type * ) const;
const Type *add_id() const { return TypeF::ZERO; }
const Type *bottom_type() const { return Type::FLOAT; }
virtual uint ideal_reg() const { return Op_RegF; }
};
class SubDNode : public SubFPNode {
public:
SubDNode( Node *in1, Node *in2 ) : SubFPNode(in1,in2) {}
virtual int Opcode() const;
virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
virtual const Type *sub( const Type *, const Type * ) const;
const Type *add_id() const { return TypeD::ZERO; }
const Type *bottom_type() const { return Type::DOUBLE; }
virtual uint ideal_reg() const { return Op_RegD; }
};
class CmpNode : public SubNode {
public:
CmpNode( Node *in1, Node *in2 ) : SubNode(in1,in2) {
init_class_id(Class_Cmp);
}
virtual Node *Identity( PhaseTransform *phase );
const Type *add_id() const { return TypeInt::ZERO; }
const Type *bottom_type() const { return TypeInt::CC; }
virtual uint ideal_reg() const { return Op_RegFlags; }
};
class CmpINode : public CmpNode {
public:
CmpINode( Node *in1, Node *in2 ) : CmpNode(in1,in2) {}
virtual int Opcode() const;
virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
virtual const Type *sub( const Type *, const Type * ) const;
};
class CmpUNode : public CmpNode {
public:
CmpUNode( Node *in1, Node *in2 ) : CmpNode(in1,in2) {}
virtual int Opcode() const;
virtual const Type *sub( const Type *, const Type * ) const;
const Type *Value( PhaseTransform *phase ) const;
bool is_index_range_check() const;
};
class CmpPNode : public CmpNode {
public:
CmpPNode( Node *in1, Node *in2 ) : CmpNode(in1,in2) {}
virtual int Opcode() const;
virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
virtual const Type *sub( const Type *, const Type * ) const;
};
class CmpNNode : public CmpNode {
public:
CmpNNode( Node *in1, Node *in2 ) : CmpNode(in1,in2) {}
virtual int Opcode() const;
virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
virtual const Type *sub( const Type *, const Type * ) const;
};
class CmpLNode : public CmpNode {
public:
CmpLNode( Node *in1, Node *in2 ) : CmpNode(in1,in2) {}
virtual int Opcode() const;
virtual const Type *sub( const Type *, const Type * ) const;
};
class CmpULNode : public CmpNode {
public:
CmpULNode(Node* in1, Node* in2) : CmpNode(in1, in2) { }
virtual int Opcode() const;
virtual const Type* sub(const Type*, const Type*) const;
};
class CmpL3Node : public CmpLNode {
public:
CmpL3Node( Node *in1, Node *in2 ) : CmpLNode(in1,in2) {
init_class_id(Class_Sub);
}
virtual int Opcode() const;
virtual uint ideal_reg() const { return Op_RegI; }
};
class CmpFNode : public CmpNode {
public:
CmpFNode( Node *in1, Node *in2 ) : CmpNode(in1,in2) {}
virtual int Opcode() const;
virtual const Type *sub( const Type *, const Type * ) const { ShouldNotReachHere(); return NULL; }
const Type *Value( PhaseTransform *phase ) const;
};
class CmpF3Node : public CmpFNode {
public:
CmpF3Node( Node *in1, Node *in2 ) : CmpFNode(in1,in2) {
init_class_id(Class_Sub);
}
virtual int Opcode() const;
virtual uint ideal_reg() const { return Op_RegI; }
};
class CmpDNode : public CmpNode {
public:
CmpDNode( Node *in1, Node *in2 ) : CmpNode(in1,in2) {}
virtual int Opcode() const;
virtual const Type *sub( const Type *, const Type * ) const { ShouldNotReachHere(); return NULL; }
const Type *Value( PhaseTransform *phase ) const;
virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
};
class CmpD3Node : public CmpDNode {
public:
CmpD3Node( Node *in1, Node *in2 ) : CmpDNode(in1,in2) {
init_class_id(Class_Sub);
}
virtual int Opcode() const;
virtual uint ideal_reg() const { return Op_RegI; }
};
struct BoolTest VALUE_OBJ_CLASS_SPEC {
enum mask { eq = 0, ne = 4, le = 5, ge = 7, lt = 3, gt = 1, overflow = 2, no_overflow = 6, illegal = 8 };
mask _test;
BoolTest( mask btm ) : _test(btm) {}
const Type *cc2logical( const Type *CC ) const;
mask commute( ) const { return mask("032147658"[_test]-'0'); }
mask negate( ) const { return mask(_test^4); }
bool is_canonical( ) const { return (_test == BoolTest::ne || _test == BoolTest::lt || _test == BoolTest::le || _test == BoolTest::overflow); }
void dump_on(outputStream *st) const;
};
class BoolNode : public Node {
virtual uint hash() const;
virtual uint cmp( const Node &n ) const;
virtual uint size_of() const;
public:
const BoolTest _test;
BoolNode( Node *cc, BoolTest::mask t): _test(t), Node(0,cc) {
init_class_id(Class_Bool);
}
static Node* make_predicate(Node* test_value, PhaseGVN* phase);
Node* as_int_value(PhaseGVN* phase);
BoolNode* negate(PhaseGVN* phase);
virtual int Opcode() const;
virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
virtual const Type *Value( PhaseTransform *phase ) const;
virtual const Type *bottom_type() const { return TypeInt::BOOL; }
uint match_edge(uint idx) const { return 0; }
virtual uint ideal_reg() const { return Op_RegI; }
bool is_counted_loop_exit_test();
#ifndef PRODUCT
virtual void dump_spec(outputStream *st) const;
#endif
};
class AbsNode : public Node {
public:
AbsNode( Node *value ) : Node(0,value) {}
};
class AbsINode : public AbsNode {
public:
AbsINode( Node *in1 ) : AbsNode(in1) {}
virtual int Opcode() const;
const Type *bottom_type() const { return TypeInt::INT; }
virtual uint ideal_reg() const { return Op_RegI; }
};
class AbsFNode : public AbsNode {
public:
AbsFNode( Node *in1 ) : AbsNode(in1) {}
virtual int Opcode() const;
const Type *bottom_type() const { return Type::FLOAT; }
virtual uint ideal_reg() const { return Op_RegF; }
};
class AbsDNode : public AbsNode {
public:
AbsDNode( Node *in1 ) : AbsNode(in1) {}
virtual int Opcode() const;
const Type *bottom_type() const { return Type::DOUBLE; }
virtual uint ideal_reg() const { return Op_RegD; }
};
class CmpLTMaskNode : public Node {
public:
CmpLTMaskNode( Node *p, Node *q ) : Node(0, p, q) {}
virtual int Opcode() const;
const Type *bottom_type() const { return TypeInt::INT; }
virtual uint ideal_reg() const { return Op_RegI; }
};
class NegNode : public Node {
public:
NegNode( Node *in1 ) : Node(0,in1) {}
};
class NegFNode : public NegNode {
public:
NegFNode( Node *in1 ) : NegNode(in1) {}
virtual int Opcode() const;
const Type *bottom_type() const { return Type::FLOAT; }
virtual uint ideal_reg() const { return Op_RegF; }
};
class NegDNode : public NegNode {
public:
NegDNode( Node *in1 ) : NegNode(in1) {}
virtual int Opcode() const;
const Type *bottom_type() const { return Type::DOUBLE; }
virtual uint ideal_reg() const { return Op_RegD; }
};
class CosDNode : public Node {
public:
CosDNode(Compile* C, Node *c, Node *in1) : Node(c, in1) {
init_flags(Flag_is_expensive);
C->add_expensive_node(this);
}
virtual int Opcode() const;
const Type *bottom_type() const { return Type::DOUBLE; }
virtual uint ideal_reg() const { return Op_RegD; }
virtual const Type *Value( PhaseTransform *phase ) const;
};
class SinDNode : public Node {
public:
SinDNode(Compile* C, Node *c, Node *in1) : Node(c, in1) {
init_flags(Flag_is_expensive);
C->add_expensive_node(this);
}
virtual int Opcode() const;
const Type *bottom_type() const { return Type::DOUBLE; }
virtual uint ideal_reg() const { return Op_RegD; }
virtual const Type *Value( PhaseTransform *phase ) const;
};
class TanDNode : public Node {
public:
TanDNode(Compile* C, Node *c,Node *in1) : Node(c, in1) {
init_flags(Flag_is_expensive);
C->add_expensive_node(this);
}
virtual int Opcode() const;
const Type *bottom_type() const { return Type::DOUBLE; }
virtual uint ideal_reg() const { return Op_RegD; }
virtual const Type *Value( PhaseTransform *phase ) const;
};
class AtanDNode : public Node {
public:
AtanDNode(Node *c, Node *in1, Node *in2 ) : Node(c, in1, in2) {}
virtual int Opcode() const;
const Type *bottom_type() const { return Type::DOUBLE; }
virtual uint ideal_reg() const { return Op_RegD; }
};
class SqrtDNode : public Node {
public:
SqrtDNode(Compile* C, Node *c, Node *in1) : Node(c, in1) {
init_flags(Flag_is_expensive);
C->add_expensive_node(this);
}
virtual int Opcode() const;
const Type *bottom_type() const { return Type::DOUBLE; }
virtual uint ideal_reg() const { return Op_RegD; }
virtual const Type *Value( PhaseTransform *phase ) const;
};
class ExpDNode : public Node {
public:
ExpDNode(Compile* C, Node *c, Node *in1) : Node(c, in1) {
init_flags(Flag_is_expensive);
C->add_expensive_node(this);
}
virtual int Opcode() const;
const Type *bottom_type() const { return Type::DOUBLE; }
virtual uint ideal_reg() const { return Op_RegD; }
virtual const Type *Value( PhaseTransform *phase ) const;
};
class LogDNode : public Node {
public:
LogDNode(Compile* C, Node *c, Node *in1) : Node(c, in1) {
init_flags(Flag_is_expensive);
C->add_expensive_node(this);
}
virtual int Opcode() const;
const Type *bottom_type() const { return Type::DOUBLE; }
virtual uint ideal_reg() const { return Op_RegD; }
virtual const Type *Value( PhaseTransform *phase ) const;
};
class Log10DNode : public Node {
public:
Log10DNode(Compile* C, Node *c, Node *in1) : Node(c, in1) {
init_flags(Flag_is_expensive);
C->add_expensive_node(this);
}
virtual int Opcode() const;
const Type *bottom_type() const { return Type::DOUBLE; }
virtual uint ideal_reg() const { return Op_RegD; }
virtual const Type *Value( PhaseTransform *phase ) const;
};
class PowDNode : public Node {
public:
PowDNode(Compile* C, Node *c, Node *in1, Node *in2 ) : Node(c, in1, in2) {
init_flags(Flag_is_expensive);
C->add_expensive_node(this);
}
virtual int Opcode() const;
const Type *bottom_type() const { return Type::DOUBLE; }
virtual uint ideal_reg() const { return Op_RegD; }
virtual const Type *Value( PhaseTransform *phase ) const;
};
class ReverseBytesINode : public Node {
public:
ReverseBytesINode(Node *c, Node *in1) : Node(c, in1) {}
virtual int Opcode() const;
const Type *bottom_type() const { return TypeInt::INT; }
virtual uint ideal_reg() const { return Op_RegI; }
};
class ReverseBytesLNode : public Node {
public:
ReverseBytesLNode(Node *c, Node *in1) : Node(c, in1) {}
virtual int Opcode() const;
const Type *bottom_type() const { return TypeLong::LONG; }
virtual uint ideal_reg() const { return Op_RegL; }
};
class ReverseBytesUSNode : public Node {
public:
ReverseBytesUSNode(Node *c, Node *in1) : Node(c, in1) {}
virtual int Opcode() const;
const Type *bottom_type() const { return TypeInt::CHAR; }
virtual uint ideal_reg() const { return Op_RegI; }
};
class ReverseBytesSNode : public Node {
public:
ReverseBytesSNode(Node *c, Node *in1) : Node(c, in1) {}
virtual int Opcode() const;
const Type *bottom_type() const { return TypeInt::SHORT; }
virtual uint ideal_reg() const { return Op_RegI; }
};
#endif // SHARE_VM_OPTO_SUBNODE_HPP
C:\hotspot-69087d08d473\src\share\vm/opto/superword.cpp
#include "precompiled.hpp"
#include "compiler/compileLog.hpp"
#include "libadt/vectset.hpp"
#include "memory/allocation.inline.hpp"
#include "opto/addnode.hpp"
#include "opto/callnode.hpp"
#include "opto/divnode.hpp"
#include "opto/matcher.hpp"
#include "opto/memnode.hpp"
#include "opto/mulnode.hpp"
#include "opto/opcodes.hpp"
#include "opto/superword.hpp"
#include "opto/vectornode.hpp"
SuperWord::SuperWord(PhaseIdealLoop* phase) :
_phase(phase),
_igvn(phase->_igvn),
_arena(phase->C->comp_arena()),
_packset(arena(), 8, 0, NULL), // packs for the current block
_bb_idx(arena(), (int)(1.10 * phase->C->unique()), 0, 0), // node idx to index in bb
_block(arena(), 8, 0, NULL), // nodes in current block
_data_entry(arena(), 8, 0, NULL), // nodes with all inputs from outside
_mem_slice_head(arena(), 8, 0, NULL), // memory slice heads
_mem_slice_tail(arena(), 8, 0, NULL), // memory slice tails
_node_info(arena(), 8, 0, SWNodeInfo::initial), // info needed per node
_align_to_ref(NULL), // memory reference to align vectors to
_disjoint_ptrs(arena(), 8, 0, OrderedPair::initial), // runtime disambiguated pointer pairs
_dg(_arena), // dependence graph
_visited(arena()), // visited node set
_post_visited(arena()), // post visited node set
_n_idx_list(arena(), 8), // scratch list of (node,index) pairs
_stk(arena(), 8, 0, NULL), // scratch stack of nodes
_nlist(arena(), 8, 0, NULL), // scratch list of nodes
_lpt(NULL), // loop tree node
_lp(NULL), // LoopNode
_bb(NULL), // basic block
_iv(NULL) // induction var
{}
void SuperWord::transform_loop(IdealLoopTree* lpt) {
assert(UseSuperWord, "should be");
if (Matcher::vector_width_in_bytes(T_BYTE) < 2) return;
assert(lpt->_head->is_CountedLoop(), "must be");
CountedLoopNode *cl = lpt->_head->as_CountedLoop();
if (!cl->is_valid_counted_loop()) return; // skip malformed counted loop
if (!cl->is_main_loop() ) return; // skip normal, pre, and post loops
Node *cl_exit = cl->loopexit();
if (cl_exit->in(0) != lpt->_head) return;
if (cl->back_control()->outcnt() != 1) {
return;
}
CountedLoopEndNode* pre_end = get_pre_loop_end(cl);
if (pre_end == NULL) return;
Node *pre_opaq1 = pre_end->limit();
if (pre_opaq1->Opcode() != Op_Opaque1) return;
init(); // initialize data structures
set_lpt(lpt);
set_lp(cl);
set_bb(cl);
assert(_packset.length() == 0, "packset must be empty");
SLP_extract();
}
void SuperWord::SLP_extract() {
if (!construct_bb())
return; // Exit if no interesting nodes or complex graph.
dependence_graph();
compute_max_depth();
compute_vector_element_type();
find_adjacent_refs();
extend_packlist();
combine_packs();
construct_my_pack_map();
filter_packs();
schedule();
output();
}
void SuperWord::find_adjacent_refs() {
Node_List memops;
for (int i = 0; i < _block.length(); i++) {
Node* n = _block.at(i);
if (n->is_Mem() && !n->is_LoadStore() && in_bb(n) &&
is_java_primitive(n->as_Mem()->memory_type())) {
int align = memory_alignment(n->as_Mem(), 0);
if (align != bottom_align) {
memops.push(n);
}
}
}
Node_List align_to_refs;
int best_iv_adjustment = 0;
MemNode* best_align_to_mem_ref = NULL;
while (memops.size() != 0) {
MemNode* mem_ref = find_align_to_ref(memops);
if (mem_ref == NULL) break;
align_to_refs.push(mem_ref);
int iv_adjustment = get_iv_adjustment(mem_ref);
if (best_align_to_mem_ref == NULL) {
best_align_to_mem_ref = mem_ref;
best_iv_adjustment = iv_adjustment;
}
SWPointer align_to_ref_p(mem_ref, this);
for (int i = memops.size() - 1; i >= 0; i--) {
MemNode* s = memops.at(i)->as_Mem();
if (isomorphic(s, mem_ref)) {
SWPointer p2(s, this);
if (p2.comparable(align_to_ref_p)) {
int align = memory_alignment(s, iv_adjustment);
set_alignment(s, align);
}
}
}
bool create_pack = true;
if (memory_alignment(mem_ref, best_iv_adjustment) == 0) {
if (!Matcher::misaligned_vectors_ok()) {
int vw = vector_width(mem_ref);
int vw_best = vector_width(best_align_to_mem_ref);
if (vw > vw_best) {
create_pack = false;
} else {
SWPointer p2(best_align_to_mem_ref, this);
if (align_to_ref_p.invar() != p2.invar()) {
create_pack = false;
}
}
}
} else {
if (same_velt_type(mem_ref, best_align_to_mem_ref)) {
create_pack = false;
} else {
if (!Matcher::misaligned_vectors_ok()) {
create_pack = false;
} else {
for (uint i = 0; i < align_to_refs.size(); i++) {
MemNode* mr = align_to_refs.at(i)->as_Mem();
if (same_velt_type(mr, mem_ref) &&
memory_alignment(mr, iv_adjustment) != 0)
create_pack = false;
}
}
}
}
if (create_pack) {
for (uint i = 0; i < memops.size(); i++) {
Node* s1 = memops.at(i);
int align = alignment(s1);
if (align == top_align) continue;
for (uint j = 0; j < memops.size(); j++) {
Node* s2 = memops.at(j);
if (alignment(s2) == top_align) continue;
if (s1 != s2 && are_adjacent_refs(s1, s2)) {
if (stmts_can_pack(s1, s2, align)) {
Node_List* pair = new Node_List();
pair->push(s1);
pair->push(s2);
_packset.append(pair);
}
}
}
}
} else { // Don't create unaligned pack
for (int i = memops.size() - 1; i >= 0; i--) {
MemNode* s = memops.at(i)->as_Mem();
if (same_velt_type(s, mem_ref)) {
memops.remove(i);
}
}
for (int i = _packset.length() - 1; i >= 0; i--) {
Node_List* p = _packset.at(i);
MemNode* s = p->at(0)->as_Mem();
if (same_velt_type(s, mem_ref)) {
remove_pack_at(i);
}
}
if (same_velt_type(mem_ref, best_align_to_mem_ref)) {
uint orig_msize = memops.size();
for (int i = 0; i < _packset.length(); i++) {
Node_List* p = _packset.at(i);
MemNode* s = p->at(0)->as_Mem();
assert(!same_velt_type(s, mem_ref), "sanity");
memops.push(s);
}
MemNode* best_align_to_mem_ref = find_align_to_ref(memops);
if (best_align_to_mem_ref == NULL) break;
best_iv_adjustment = get_iv_adjustment(best_align_to_mem_ref);
while (memops.size() > orig_msize)
(void)memops.pop();
}
} // unaligned memory accesses
for (int i = memops.size() - 1; i >= 0; i--) {
MemNode* m = memops.at(i)->as_Mem();
if (alignment(m) != top_align) {
memops.remove(i);
}
}
} // while (memops.size() != 0
set_align_to_ref(best_align_to_mem_ref);
#ifndef PRODUCT
if (TraceSuperWord) {
tty->print_cr("\nAfter find_adjacent_refs");
print_packset();
}
#endif
}
MemNode* SuperWord::find_align_to_ref(Node_List &memops) {
GrowableArray<int> cmp_ct(arena(), memops.size(), memops.size(), 0);
for (uint i = 0; i < memops.size(); i++) {
MemNode* s1 = memops.at(i)->as_Mem();
SWPointer p1(s1, this);
if (!ref_is_alignable(p1)) {
continue;
}
for (uint j = i+1; j < memops.size(); j++) {
MemNode* s2 = memops.at(j)->as_Mem();
if (isomorphic(s1, s2)) {
SWPointer p2(s2, this);
if (p1.comparable(p2)) {
(*cmp_ct.adr_at(i))++;
(*cmp_ct.adr_at(j))++;
}
}
}
}
int max_ct = 0;
int max_vw = 0;
int max_idx = -1;
int min_size = max_jint;
int min_iv_offset = max_jint;
for (uint j = 0; j < memops.size(); j++) {
MemNode* s = memops.at(j)->as_Mem();
if (s->is_Store()) {
int vw = vector_width_in_bytes(s);
assert(vw > 1, "sanity");
SWPointer p(s, this);
if (cmp_ct.at(j) > max_ct ||
cmp_ct.at(j) == max_ct &&
(vw > max_vw ||
vw == max_vw &&
(data_size(s) < min_size ||
data_size(s) == min_size &&
(p.offset_in_bytes() < min_iv_offset)))) {
max_ct = cmp_ct.at(j);
max_vw = vw;
max_idx = j;
min_size = data_size(s);
min_iv_offset = p.offset_in_bytes();
}
}
}
if (max_ct == 0) {
for (uint j = 0; j < memops.size(); j++) {
MemNode* s = memops.at(j)->as_Mem();
if (s->is_Load()) {
int vw = vector_width_in_bytes(s);
assert(vw > 1, "sanity");
SWPointer p(s, this);
if (cmp_ct.at(j) > max_ct ||
cmp_ct.at(j) == max_ct &&
(vw > max_vw ||
vw == max_vw &&
(data_size(s) < min_size ||
data_size(s) == min_size &&
(p.offset_in_bytes() < min_iv_offset)))) {
max_ct = cmp_ct.at(j);
max_vw = vw;
max_idx = j;
min_size = data_size(s);
min_iv_offset = p.offset_in_bytes();
}
}
}
}
#ifdef ASSERT
if (TraceSuperWord && Verbose) {
tty->print_cr("\nVector memops after find_align_to_refs");
for (uint i = 0; i < memops.size(); i++) {
MemNode* s = memops.at(i)->as_Mem();
s->dump();
}
}
#endif
if (max_ct > 0) {
#ifdef ASSERT
if (TraceSuperWord) {
tty->print("\nVector align to node: ");
memops.at(max_idx)->as_Mem()->dump();
}
#endif
return memops.at(max_idx)->as_Mem();
}
return NULL;
}
bool SuperWord::ref_is_alignable(SWPointer& p) {
if (!p.has_iv()) {
return true; // no induction variable
}
CountedLoopEndNode* pre_end = get_pre_loop_end(lp()->as_CountedLoop());
assert(pre_end != NULL, "we must have a correct pre-loop");
assert(pre_end->stride_is_con(), "pre loop stride is constant");
int preloop_stride = pre_end->stride_con();
int span = preloop_stride * p.scale_in_bytes();
int mem_size = p.memory_size();
int offset = p.offset_in_bytes();
if (ABS(span) == mem_size && (ABS(offset) % mem_size) == 0) {
return true;
}
int vw = vector_width_in_bytes(p.mem());
assert(vw > 1, "sanity");
Node* init_nd = pre_end->init_trip();
if (init_nd->is_Con() && p.invar() == NULL) {
int init = init_nd->bottom_type()->is_int()->get_con();
int init_offset = init * p.scale_in_bytes() + offset;
if (init_offset < 0) { // negative offset from object start?
return false; // may happen in dead loop
}
if (vw % span == 0) {
if (span > 0) {
return (vw - (init_offset % vw)) % span == 0;
} else {
assert(span < 0, "nonzero stride * scale");
return (init_offset % vw) % -span == 0;
}
} else if (span % vw == 0) {
return (init_offset % vw) == 0;
}
}
return false;
}
int SuperWord::get_iv_adjustment(MemNode* mem_ref) {
SWPointer align_to_ref_p(mem_ref, this);
int offset = align_to_ref_p.offset_in_bytes();
int scale = align_to_ref_p.scale_in_bytes();
int elt_size = align_to_ref_p.memory_size();
int vw = vector_width_in_bytes(mem_ref);
assert(vw > 1, "sanity");
int iv_adjustment;
if (scale != 0) {
int stride_sign = (scale * iv_stride()) > 0 ? 1 : -1;
int iv_adjustment_in_bytes = (stride_sign * vw - (offset % vw));
assert(((ABS(iv_adjustment_in_bytes) % elt_size) == 0),
err_msg_res("(%d) should be divisible by (%d)", iv_adjustment_in_bytes, elt_size));
iv_adjustment = iv_adjustment_in_bytes/elt_size;
} else {
iv_adjustment = 0;
}
#ifndef PRODUCT
if (TraceSuperWord)
tty->print_cr("\noffset = %d iv_adjust = %d elt_size = %d scale = %d iv_stride = %d vect_size %d",
offset, iv_adjustment, elt_size, scale, iv_stride(), vw);
#endif
return iv_adjustment;
}
void SuperWord::dependence_graph() {
for (int i = 0; i < _block.length(); i++ ) {
Node *n = _block.at(i);
if (n->is_Mem() || n->is_Phi() && n->bottom_type() == Type::MEMORY) {
_dg.make_node(n);
}
}
for (int i = 0; i < _mem_slice_head.length(); i++) {
Node* n = _mem_slice_head.at(i);
Node* n_tail = _mem_slice_tail.at(i);
mem_slice_preds(n_tail, n, _nlist);
DepMem* slice = _dg.dep(n);
_dg.make_edge(_dg.root(), slice);
DepMem* slice_sink = _dg.make_node(NULL);
_dg.make_edge(slice_sink, _dg.tail());
for (int j = _nlist.length() - 1; j >= 0 ; j--) {
Node* s1 = _nlist.at(j);
if (_dg.dep(s1)->in_cnt() == 0) {
_dg.make_edge(slice, s1);
}
SWPointer p1(s1->as_Mem(), this);
bool sink_dependent = true;
for (int k = j - 1; k >= 0; k--) {
Node* s2 = _nlist.at(k);
if (s1->is_Load() && s2->is_Load())
continue;
SWPointer p2(s2->as_Mem(), this);
int cmp = p1.cmp(p2);
if (SuperWordRTDepCheck &&
p1.base() != p2.base() && p1.valid() && p2.valid()) {
OrderedPair pp(p1.base(), p2.base());
_disjoint_ptrs.append_if_missing(pp);
} else if (!SWPointer::not_equal(cmp)) {
_dg.make_edge(s1, s2);
sink_dependent = false;
}
}
if (sink_dependent) {
_dg.make_edge(s1, slice_sink);
}
}
#ifndef PRODUCT
if (TraceSuperWord) {
tty->print_cr("\nDependence graph for slice: %d", n->_idx);
for (int q = 0; q < _nlist.length(); q++) {
_dg.print(_nlist.at(q));
}
tty->cr();
}
#endif
_nlist.clear();
}
#ifndef PRODUCT
if (TraceSuperWord) {
tty->print_cr("\ndisjoint_ptrs: %s", _disjoint_ptrs.length() > 0 ? "" : "NONE");
for (int r = 0; r < _disjoint_ptrs.length(); r++) {
_disjoint_ptrs.at(r).print();
tty->cr();
}
tty->cr();
}
#endif
}
void SuperWord::mem_slice_preds(Node* start, Node* stop, GrowableArray<Node*> &preds) {
assert(preds.length() == 0, "start empty");
Node* n = start;
Node* prev = NULL;
while (true) {
assert(in_bb(n), "must be in block");
for (DUIterator_Fast imax, i = n->fast_outs(imax); i < imax; i++) {
Node* out = n->fast_out(i);
if (out->is_Load()) {
if (in_bb(out)) {
preds.push(out);
}
} else {
if (out->is_MergeMem() && !in_bb(out)) {
} else if (out->is_Phi() && out->bottom_type() == Type::MEMORY && !in_bb(out)) {
} else if (out->Opcode() == Op_StoreCM && out->in(MemNode::OopStore) == n) {
} else {
assert(out == prev || prev == NULL, "no branches off of store slice");
}
}
}
if (n == stop) break;
preds.push(n);
prev = n;
assert(n->is_Mem(), err_msg_res("unexpected node %s", n->Name()));
n = n->in(MemNode::Memory);
}
}
bool SuperWord::stmts_can_pack(Node* s1, Node* s2, int align) {
BasicType bt1 = velt_basic_type(s1);
BasicType bt2 = velt_basic_type(s2);
if(!is_java_primitive(bt1) || !is_java_primitive(bt2))
return false;
if (Matcher::max_vector_size(bt1) < 2) {
return false; // No vectors for this type
}
if (isomorphic(s1, s2)) {
if (independent(s1, s2)) {
if (!exists_at(s1, 0) && !exists_at(s2, 1)) {
if (!s1->is_Mem() || are_adjacent_refs(s1, s2)) {
int s1_align = alignment(s1);
int s2_align = alignment(s2);
if (s1_align == top_align || s1_align == align) {
if (s2_align == top_align || s2_align == align + data_size(s1)) {
return true;
}
}
}
}
}
}
return false;
}
bool SuperWord::exists_at(Node* s, uint pos) {
for (int i = 0; i < _packset.length(); i++) {
Node_List* p = _packset.at(i);
if (p->at(pos) == s) {
return true;
}
}
return false;
}
bool SuperWord::are_adjacent_refs(Node* s1, Node* s2) {
if (!s1->is_Mem() || !s2->is_Mem()) return false;
if (!in_bb(s1) || !in_bb(s2)) return false;
if (!is_java_primitive(s1->as_Mem()->memory_type()) ||
!is_java_primitive(s2->as_Mem()->memory_type())) {
return false;
}
if (_phase->C->get_alias_index(s1->as_Mem()->adr_type()) !=
_phase->C->get_alias_index(s2->as_Mem()->adr_type()))
return false;
SWPointer p1(s1->as_Mem(), this);
SWPointer p2(s2->as_Mem(), this);
if (p1.base() != p2.base() || !p1.comparable(p2)) return false;
int diff = p2.offset_in_bytes() - p1.offset_in_bytes();
return diff == data_size(s1);
}
bool SuperWord::isomorphic(Node* s1, Node* s2) {
if (s1->Opcode() != s2->Opcode()) return false;
if (s1->req() != s2->req()) return false;
if (s1->in(0) != s2->in(0)) return false;
if (!same_velt_type(s1, s2)) return false;
return true;
}
bool SuperWord::independent(Node* s1, Node* s2) {
int d1 = depth(s1);
int d2 = depth(s2);
if (d1 == d2) return s1 != s2;
Node* deep = d1 > d2 ? s1 : s2;
Node* shallow = d1 > d2 ? s2 : s1;
visited_clear();
return independent_path(shallow, deep);
}
bool SuperWord::independent_path(Node* shallow, Node* deep, uint dp) {
if (dp >= 1000) return false; // stop deep recursion
visited_set(deep);
int shal_depth = depth(shallow);
assert(shal_depth <= depth(deep), "must be");
for (DepPreds preds(deep, _dg); !preds.done(); preds.next()) {
Node* pred = preds.current();
if (in_bb(pred) && !visited_test(pred)) {
if (shallow == pred) {
return false;
}
if (shal_depth < depth(pred) && !independent_path(shallow, pred, dp+1)) {
return false;
}
}
}
return true;
}
void SuperWord::set_alignment(Node* s1, Node* s2, int align) {
set_alignment(s1, align);
if (align == top_align || align == bottom_align) {
set_alignment(s2, align);
} else {
set_alignment(s2, align + data_size(s1));
}
}
int SuperWord::data_size(Node* s) {
int bsize = type2aelembytes(velt_basic_type(s));
assert(bsize != 0, "valid size");
return bsize;
}
void SuperWord::extend_packlist() {
bool changed;
do {
changed = false;
for (int i = 0; i < _packset.length(); i++) {
Node_List* p = _packset.at(i);
changed |= follow_use_defs(p);
changed |= follow_def_uses(p);
}
} while (changed);
#ifndef PRODUCT
if (TraceSuperWord) {
tty->print_cr("\nAfter extend_packlist");
print_packset();
}
#endif
}
bool SuperWord::follow_use_defs(Node_List* p) {
assert(p->size() == 2, "just checking");
Node* s1 = p->at(0);
Node* s2 = p->at(1);
assert(s1->req() == s2->req(), "just checking");
assert(alignment(s1) + data_size(s1) == alignment(s2), "just checking");
if (s1->is_Load()) return false;
int align = alignment(s1);
bool changed = false;
int start = s1->is_Store() ? MemNode::ValueIn : 1;
int end = s1->is_Store() ? MemNode::ValueIn+1 : s1->req();
for (int j = start; j < end; j++) {
Node* t1 = s1->in(j);
Node* t2 = s2->in(j);
if (!in_bb(t1) || !in_bb(t2))
continue;
if (stmts_can_pack(t1, t2, align)) {
if (est_savings(t1, t2) >= 0) {
Node_List* pair = new Node_List();
pair->push(t1);
pair->push(t2);
_packset.append(pair);
set_alignment(t1, t2, align);
changed = true;
}
}
}
return changed;
}
bool SuperWord::follow_def_uses(Node_List* p) {
bool changed = false;
Node* s1 = p->at(0);
Node* s2 = p->at(1);
assert(p->size() == 2, "just checking");
assert(s1->req() == s2->req(), "just checking");
assert(alignment(s1) + data_size(s1) == alignment(s2), "just checking");
if (s1->is_Store()) return false;
int align = alignment(s1);
int savings = -1;
Node* u1 = NULL;
Node* u2 = NULL;
for (DUIterator_Fast imax, i = s1->fast_outs(imax); i < imax; i++) {
Node* t1 = s1->fast_out(i);
if (!in_bb(t1)) continue;
for (DUIterator_Fast jmax, j = s2->fast_outs(jmax); j < jmax; j++) {
Node* t2 = s2->fast_out(j);
if (!in_bb(t2)) continue;
if (!opnd_positions_match(s1, t1, s2, t2))
continue;
if (stmts_can_pack(t1, t2, align)) {
int my_savings = est_savings(t1, t2);
if (my_savings > savings) {
savings = my_savings;
u1 = t1;
u2 = t2;
}
}
}
}
if (savings >= 0) {
Node_List* pair = new Node_List();
pair->push(u1);
pair->push(u2);
_packset.append(pair);
set_alignment(u1, u2, align);
changed = true;
}
return changed;
}
bool SuperWord::opnd_positions_match(Node* d1, Node* u1, Node* d2, Node* u2) {
uint ct = u1->req();
if (ct != u2->req()) return false;
uint i1 = 0;
uint i2 = 0;
do {
for (i1++; i1 < ct; i1++) if (u1->in(i1) == d1) break;
for (i2++; i2 < ct; i2++) if (u2->in(i2) == d2) break;
if (i1 != i2) {
if ((i1 == (3-i2)) && (u2->is_Add() || u2->is_Mul())) {
u2->swap_edges(i1, i2);
} else {
return false;
}
}
} while (i1 < ct);
return true;
}
int SuperWord::est_savings(Node* s1, Node* s2) {
int save_in = 2 - 1; // 2 operations per instruction in packed form
for (uint i = 1; i < s1->req(); i++) {
Node* x1 = s1->in(i);
Node* x2 = s2->in(i);
if (x1 != x2) {
if (are_adjacent_refs(x1, x2)) {
save_in += adjacent_profit(x1, x2);
} else if (!in_packset(x1, x2)) {
save_in -= pack_cost(2);
} else {
save_in += unpack_cost(2);
}
}
}
uint ct = 0;
int save_use = 0;
for (DUIterator_Fast imax, i = s1->fast_outs(imax); i < imax; i++) {
Node* s1_use = s1->fast_out(i);
for (int j = 0; j < _packset.length(); j++) {
Node_List* p = _packset.at(j);
if (p->at(0) == s1_use) {
for (DUIterator_Fast kmax, k = s2->fast_outs(kmax); k < kmax; k++) {
Node* s2_use = s2->fast_out(k);
if (p->at(p->size()-1) == s2_use) {
ct++;
if (are_adjacent_refs(s1_use, s2_use)) {
save_use += adjacent_profit(s1_use, s2_use);
}
}
}
}
}
}
if (ct < s1->outcnt()) save_use += unpack_cost(1);
if (ct < s2->outcnt()) save_use += unpack_cost(1);
return MAX2(save_in, save_use);
}
int SuperWord::adjacent_profit(Node* s1, Node* s2) { return 2; }
int SuperWord::pack_cost(int ct) { return ct; }
int SuperWord::unpack_cost(int ct) { return ct; }
void SuperWord::combine_packs() {
bool changed = true;
while (changed) {
changed = false;
for (int i = 0; i < _packset.length(); i++) {
Node_List* p1 = _packset.at(i);
if (p1 == NULL) continue;
for (int j = 0; j < _packset.length(); j++) {
Node_List* p2 = _packset.at(j);
if (p2 == NULL) continue;
if (i == j) continue;
if (p1->at(p1->size()-1) == p2->at(0)) {
for (uint k = 1; k < p2->size(); k++) {
p1->push(p2->at(k));
}
_packset.at_put(j, NULL);
changed = true;
}
}
}
}
for (int i = 0; i < _packset.length(); i++) {
Node_List* p1 = _packset.at(i);
if (p1 != NULL) {
BasicType bt = velt_basic_type(p1->at(0));
uint max_vlen = Matcher::max_vector_size(bt); // Max elements in vector
assert(is_power_of_2(max_vlen), "sanity");
uint psize = p1->size();
if (!is_power_of_2(psize)) {
_packset.at_put(i, NULL);
continue;
}
if (psize > max_vlen) {
Node_List* pack = new Node_List();
for (uint j = 0; j < psize; j++) {
pack->push(p1->at(j));
if (pack->size() >= max_vlen) {
assert(is_power_of_2(pack->size()), "sanity");
_packset.append(pack);
pack = new Node_List();
}
}
_packset.at_put(i, NULL);
}
}
}
for (int i = _packset.length() - 1; i >= 0; i--) {
Node_List* p1 = _packset.at(i);
if (p1 == NULL) {
_packset.remove_at(i);
}
}
#ifndef PRODUCT
if (TraceSuperWord) {
tty->print_cr("\nAfter combine_packs");
print_packset();
}
#endif
}
void SuperWord::construct_my_pack_map() {
Node_List* rslt = NULL;
for (int i = 0; i < _packset.length(); i++) {
Node_List* p = _packset.at(i);
for (uint j = 0; j < p->size(); j++) {
Node* s = p->at(j);
assert(my_pack(s) == NULL, "only in one pack");
set_my_pack(s, p);
}
}
}
void SuperWord::filter_packs() {
for (int i = _packset.length() - 1; i >= 0; i--) {
Node_List* pk = _packset.at(i);
bool impl = implemented(pk);
if (!impl) {
#ifndef PRODUCT
if (TraceSuperWord && Verbose) {
tty->print_cr("Unimplemented");
pk->at(0)->dump();
}
#endif
remove_pack_at(i);
}
}
bool changed;
do {
changed = false;
for (int i = _packset.length() - 1; i >= 0; i--) {
Node_List* pk = _packset.at(i);
bool prof = profitable(pk);
if (!prof) {
#ifndef PRODUCT
if (TraceSuperWord && Verbose) {
tty->print_cr("Unprofitable");
pk->at(0)->dump();
}
#endif
remove_pack_at(i);
changed = true;
}
}
} while (changed);
#ifndef PRODUCT
if (TraceSuperWord) {
tty->print_cr("\nAfter filter_packs");
print_packset();
tty->cr();
}
#endif
}
bool SuperWord::implemented(Node_List* p) {
Node* p0 = p->at(0);
return VectorNode::implemented(p0->Opcode(), p->size(), velt_basic_type(p0));
}
static bool same_inputs(Node_List* p, int idx) {
Node* p0 = p->at(0);
uint vlen = p->size();
Node* p0_def = p0->in(idx);
for (uint i = 1; i < vlen; i++) {
Node* pi = p->at(i);
Node* pi_def = pi->in(idx);
if (p0_def != pi_def)
return false;
}
return true;
}
bool SuperWord::profitable(Node_List* p) {
Node* p0 = p->at(0);
uint start, end;
VectorNode::vector_operands(p0, &start, &end);
for (uint i = start; i < end; i++) {
if (!is_vector_use(p0, i))
return false;
}
if (VectorNode::is_shift(p0)) {
Node* cnt = p0->in(2);
Node_List* cnt_pk = my_pack(cnt);
if (cnt_pk != NULL)
return false;
if (!same_inputs(p, 2))
return false;
}
if (!p0->is_Store()) {
for (uint i = 0; i < p->size(); i++) {
Node* def = p->at(i);
for (DUIterator_Fast jmax, j = def->fast_outs(jmax); j < jmax; j++) {
Node* use = def->fast_out(j);
for (uint k = 0; k < use->req(); k++) {
Node* n = use->in(k);
if (def == n) {
if (!is_vector_use(use, k)) {
return false;
}
}
}
}
}
}
return true;
}
void SuperWord::schedule() {
for (int i = 0; i < _packset.length(); i++) {
co_locate_pack(_packset.at(i));
}
}
void SuperWord::remove_and_insert(MemNode *current, MemNode *prev, MemNode *lip,
Node *uip, Unique_Node_List &sched_before) {
Node* my_mem = current->in(MemNode::Memory);
bool sched_up = sched_before.member(current);
for (DUIterator i = current->outs(); current->has_out(i); i++) {
Node* use = current->out(i);
if (use->is_Mem()) {
assert(use->in(MemNode::Memory) == current, "must be");
if (use == prev) { // connect prev to my_mem
_igvn.replace_input_of(use, MemNode::Memory, my_mem);
--i; //deleted this edge; rescan position
} else if (sched_before.member(use)) {
if (!sched_up) { // Will be moved together with current
_igvn.replace_input_of(use, MemNode::Memory, uip);
--i; //deleted this edge; rescan position
}
} else {
if (sched_up) { // Will be moved together with current
_igvn.replace_input_of(use, MemNode::Memory, lip);
--i; //deleted this edge; rescan position
}
}
}
}
Node *insert_pt = sched_up ? uip : lip;
for (DUIterator i = insert_pt->outs(); insert_pt->has_out(i); i++) {
Node* use = insert_pt->out(i);
if (use->is_Mem()) {
assert(use->in(MemNode::Memory) == insert_pt, "must be");
_igvn.replace_input_of(use, MemNode::Memory, current);
--i; //deleted this edge; rescan position
} else if (!sched_up && use->is_Phi() && use->bottom_type() == Type::MEMORY) {
uint pos; //lip (lower insert point) must be the last one in the memory slice
for (pos=1; pos < use->req(); pos++) {
if (use->in(pos) == insert_pt) break;
}
_igvn.replace_input_of(use, pos, current);
--i;
}
}
_igvn.replace_input_of(current, MemNode::Memory, insert_pt);
}
void SuperWord::co_locate_pack(Node_List* pk) {
if (pk->at(0)->is_Store()) {
MemNode* first = executed_first(pk)->as_Mem();
MemNode* last = executed_last(pk)->as_Mem();
Unique_Node_List schedule_before_pack;
Unique_Node_List memops;
MemNode* current = last->in(MemNode::Memory)->as_Mem();
MemNode* previous = last;
while (true) {
assert(in_bb(current), "stay in block");
memops.push(previous);
for (DUIterator i = current->outs(); current->has_out(i); i++) {
Node* use = current->out(i);
if (use->is_Mem() && use != previous)
memops.push(use);
}
if (current == first) break;
previous = current;
current = current->in(MemNode::Memory)->as_Mem();
}
for (uint i = 1; i < memops.size(); i++) {
Node *s1 = memops.at(i);
if (!in_pack(s1, pk) && !schedule_before_pack.member(s1)) {
for (uint j = 0; j< i; j++) {
Node *s2 = memops.at(j);
if (!independent(s1, s2)) {
if (in_pack(s2, pk) || schedule_before_pack.member(s2)) {
schedule_before_pack.push(s1); // s1 must be scheduled before
Node_List* mem_pk = my_pack(s1);
if (mem_pk != NULL) {
for (uint ii = 0; ii < mem_pk->size(); ii++) {
Node* s = mem_pk->at(ii); // follow partner
if (memops.member(s) && !schedule_before_pack.member(s))
schedule_before_pack.push(s);
}
}
break;
}
}
}
}
}
Node* upper_insert_pt = first->in(MemNode::Memory);
memops.clear();
for (DUIterator i = upper_insert_pt->outs(); upper_insert_pt->has_out(i); i++) {
Node* use = upper_insert_pt->out(i);
if (use->is_Mem() && !use->is_Store()) {
memops.push(use);
}
}
MemNode* lower_insert_pt = last;
previous = last; //previous store in pk
current = last->in(MemNode::Memory)->as_Mem();
while (true) {
assert(in_bb(current), "stay in block");
assert(in_pack(previous, pk), "previous stays in pack");
Node* my_mem = current->in(MemNode::Memory);
if (in_pack(current, pk)) {
for (DUIterator i = current->outs(); current->has_out(i); i++) {
Node* use = current->out(i);
if (use->is_Mem() && use != previous) {
assert(use->in(MemNode::Memory) == current, "must be");
if (schedule_before_pack.member(use)) {
_igvn.replace_input_of(use, MemNode::Memory, upper_insert_pt);
} else {
_igvn.replace_input_of(use, MemNode::Memory, lower_insert_pt);
}
--i; // deleted this edge; rescan position
}
}
previous = current;
} else { // !in_pack(current, pk) ==> a sandwiched store
remove_and_insert(current, previous, lower_insert_pt, upper_insert_pt, schedule_before_pack);
}
if (current == first) break;
current = my_mem->as_Mem();
} // end while
for (uint i = 0; i < memops.size(); i++) {
Node *ld = memops.at(i);
if (ld->in(MemNode::Memory) != upper_insert_pt) {
_igvn.replace_input_of(ld, MemNode::Memory, upper_insert_pt);
}
}
} else if (pk->at(0)->is_Load()) { //load
Node* last_mem = executed_last(pk)->in(MemNode::Memory);
Node* first_mem = executed_first(pk)->in(MemNode::Memory);
bool schedule_last = true;
for (uint i = 0; i < pk->size(); i++) {
Node* ld = pk->at(i);
for (Node* current = last_mem; current != ld->in(MemNode::Memory);
current=current->in(MemNode::Memory)) {
assert(current != first_mem, "corrupted memory graph");
if(current->is_Mem() && !independent(current, ld)){
schedule_last = false; // a later store depends on this load
break;
}
}
}
Node* mem_input = schedule_last ? last_mem : first_mem;
_igvn.hash_delete(mem_input);
for (uint i = 0; i < pk->size(); i++) {
LoadNode* ld = pk->at(i)->as_Load();
_igvn.replace_input_of(ld, MemNode::Memory, mem_input);
}
}
}
void SuperWord::output() {
if (_packset.length() == 0) return;
#ifndef PRODUCT
if (TraceLoopOpts) {
tty->print("SuperWord ");
lpt()->dump_head();
}
#endif
align_initial_loop_index(align_to_ref());
for (int i = 0; i < _packset.length(); i++) {
insert_extracts(_packset.at(i));
}
Compile* C = _phase->C;
uint max_vlen_in_bytes = 0;
for (int i = 0; i < _block.length(); i++) {
Node* n = _block.at(i);
Node_List* p = my_pack(n);
if (p && n == executed_last(p)) {
uint vlen = p->size();
uint vlen_in_bytes = 0;
Node* vn = NULL;
Node* low_adr = p->at(0);
Node* first = executed_first(p);
int opc = n->Opcode();
if (n->is_Load()) {
Node* ctl = n->in(MemNode::Control);
Node* mem = first->in(MemNode::Memory);
SWPointer p1(n->as_Mem(), this);
while (mem->is_StoreVector()) {
SWPointer p2(mem->as_Mem(), this);
int cmp = p1.cmp(p2);
if (SWPointer::not_equal(cmp) || !SWPointer::comparable(cmp)) {
mem = mem->in(MemNode::Memory);
} else {
break; // dependent memory
}
}
Node* adr = low_adr->in(MemNode::Address);
const TypePtr* atyp = n->adr_type();
vn = LoadVectorNode::make(C, opc, ctl, mem, adr, atyp, vlen, velt_basic_type(n), control_dependency(p));
vlen_in_bytes = vn->as_LoadVector()->memory_size();
} else if (n->is_Store()) {
Node* val = vector_opd(p, MemNode::ValueIn);
Node* ctl = n->in(MemNode::Control);
Node* mem = first->in(MemNode::Memory);
Node* adr = low_adr->in(MemNode::Address);
const TypePtr* atyp = n->adr_type();
vn = StoreVectorNode::make(C, opc, ctl, mem, adr, atyp, val, vlen);
vlen_in_bytes = vn->as_StoreVector()->memory_size();
} else if (n->req() == 3) {
Node* in1 = vector_opd(p, 1);
Node* in2 = vector_opd(p, 2);
if (VectorNode::is_invariant_vector(in1) && (n->is_Add() || n->is_Mul())) {
Node* tmp = in1;
in1 = in2;
in2 = tmp;
}
vn = VectorNode::make(C, opc, in1, in2, vlen, velt_basic_type(n));
vlen_in_bytes = vn->as_Vector()->length_in_bytes();
} else {
ShouldNotReachHere();
}
assert(vn != NULL, "sanity");
_igvn.register_new_node_with_optimizer(vn);
_phase->set_ctrl(vn, _phase->get_ctrl(p->at(0)));
for (uint j = 0; j < p->size(); j++) {
Node* pm = p->at(j);
_igvn.replace_node(pm, vn);
}
_igvn._worklist.push(vn);
if (vlen_in_bytes > max_vlen_in_bytes) {
max_vlen_in_bytes = vlen_in_bytes;
}
#ifdef ASSERT
if (TraceNewVectors) {
tty->print("new Vector node: ");
vn->dump();
}
#endif
}
}
C->set_max_vector_size(max_vlen_in_bytes);
}
ssssssss60
最新推荐文章于 2024-09-08 12:41:07 发布