6953576: bottom_type for matched AddPNodes doesn't always agree with ideal

Tue, 18 May 2010 23:58:32 -0700

author
never
date
Tue, 18 May 2010 23:58:32 -0700
changeset 1896
b5fdf39b9749
parent 1895
99791ad65936
child 1898
1a1603f975b5

6953576: bottom_type for matched AddPNodes doesn't always agree with ideal
Reviewed-by: kvn

src/share/vm/adlc/formssel.cpp file | annotate | diff | comparison | revisions
src/share/vm/adlc/formssel.hpp file | annotate | diff | comparison | revisions
src/share/vm/adlc/output_c.cpp file | annotate | diff | comparison | revisions
src/share/vm/adlc/output_h.cpp file | annotate | diff | comparison | revisions
src/share/vm/opto/addnode.cpp file | annotate | diff | comparison | revisions
src/share/vm/opto/addnode.hpp file | annotate | diff | comparison | revisions
     1.1 --- a/src/share/vm/adlc/formssel.cpp	Tue May 18 13:45:03 2010 -0700
     1.2 +++ b/src/share/vm/adlc/formssel.cpp	Tue May 18 23:58:32 2010 -0700
     1.3 @@ -735,7 +735,7 @@
     1.4  
     1.5  // This instruction captures the machine-independent bottom_type
     1.6  // Expected use is for pointer vs oop determination for LoadP
     1.7 -bool InstructForm::captures_bottom_type() const {
     1.8 +bool InstructForm::captures_bottom_type(FormDict &globals) const {
     1.9    if( _matrule && _matrule->_rChild &&
    1.10         (!strcmp(_matrule->_rChild->_opType,"CastPP")     ||  // new result type
    1.11          !strcmp(_matrule->_rChild->_opType,"CastX2P")    ||  // new result type
    1.12 @@ -748,6 +748,8 @@
    1.13    else if ( is_ideal_load() == Form::idealP )                return true;
    1.14    else if ( is_ideal_store() != Form::none  )                return true;
    1.15  
    1.16 +  if (needs_base_oop_edge(globals)) return true;
    1.17 +
    1.18    return  false;
    1.19  }
    1.20  
    1.21 @@ -1061,7 +1063,7 @@
    1.22  
    1.23  
    1.24  // Base class for this instruction, MachNode except for calls
    1.25 -const char *InstructForm::mach_base_class()  const {
    1.26 +const char *InstructForm::mach_base_class(FormDict &globals)  const {
    1.27    if( is_ideal_call() == Form::JAVA_STATIC ) {
    1.28      return "MachCallStaticJavaNode";
    1.29    }
    1.30 @@ -1092,7 +1094,7 @@
    1.31    else if (is_ideal_nop()) {
    1.32      return "MachNopNode";
    1.33    }
    1.34 -  else if (captures_bottom_type()) {
    1.35 +  else if (captures_bottom_type(globals)) {
    1.36      return "MachTypeNode";
    1.37    } else {
    1.38      return "MachNode";
     2.1 --- a/src/share/vm/adlc/formssel.hpp	Tue May 18 13:45:03 2010 -0700
     2.2 +++ b/src/share/vm/adlc/formssel.hpp	Tue May 18 23:58:32 2010 -0700
     2.3 @@ -188,7 +188,7 @@
     2.4  
     2.5    // This instruction captures the machine-independent bottom_type
     2.6    // Expected use is for pointer vs oop determination for LoadP
     2.7 -  virtual bool        captures_bottom_type() const;
     2.8 +  virtual bool        captures_bottom_type(FormDict& globals) const;
     2.9  
    2.10    virtual const char *cost();      // Access ins_cost attribute
    2.11    virtual uint        num_opnds(); // Count of num_opnds for MachNode class
    2.12 @@ -229,7 +229,7 @@
    2.13    const char         *reduce_left(FormDict &globals)   const;
    2.14  
    2.15    // Base class for this instruction, MachNode except for calls
    2.16 -  virtual const char *mach_base_class()  const;
    2.17 +  virtual const char *mach_base_class(FormDict &globals)  const;
    2.18  
    2.19    // Check if this instruction can cisc-spill to 'alternate'
    2.20    bool                cisc_spills_to(ArchDesc &AD, InstructForm *alternate);
    2.21 @@ -252,7 +252,7 @@
    2.22    bool                has_short_branch_form() { return _short_branch_form != NULL; }
    2.23    // Output short branch prototypes and method bodies
    2.24    void                declare_short_branch_methods(FILE *fp_cpp);
    2.25 -  bool                define_short_branch_methods(FILE *fp_cpp);
    2.26 +  bool                define_short_branch_methods(ArchDesc &AD, FILE *fp_cpp);
    2.27  
    2.28    uint                alignment() { return _alignment; }
    2.29    void                set_alignment(uint val) { _alignment = val; }
     3.1 --- a/src/share/vm/adlc/output_c.cpp	Tue May 18 13:45:03 2010 -0700
     3.2 +++ b/src/share/vm/adlc/output_c.cpp	Tue May 18 23:58:32 2010 -0700
     3.3 @@ -1382,7 +1382,7 @@
     3.4                                            inst_num, unmatched_edge);
     3.5          }
     3.6          // If new instruction captures bottom type
     3.7 -        if( root_form->captures_bottom_type() ) {
     3.8 +        if( root_form->captures_bottom_type(globals) ) {
     3.9            // Get bottom type from instruction whose result we are replacing
    3.10            fprintf(fp, "        root->_bottom_type = inst%d->bottom_type();\n", inst_num);
    3.11          }
    3.12 @@ -2963,7 +2963,7 @@
    3.13      used |= instr->define_cisc_version(*this, fp);
    3.14  
    3.15      // Output code to convert to the short branch version, if applicable
    3.16 -    used |= instr->define_short_branch_methods(fp);
    3.17 +    used |= instr->define_short_branch_methods(*this, fp);
    3.18    }
    3.19  
    3.20    // Construct the method called by cisc_version() to copy inputs and operands.
    3.21 @@ -3708,7 +3708,7 @@
    3.22    }
    3.23  
    3.24    // Fill in the bottom_type where requested
    3.25 -  if ( inst->captures_bottom_type() ) {
    3.26 +  if ( inst->captures_bottom_type(_globalNames) ) {
    3.27      fprintf(fp_cpp, "%s node->_bottom_type = _leaf->bottom_type();\n", indent);
    3.28    }
    3.29    if( inst->is_ideal_if() ) {
    3.30 @@ -3762,7 +3762,7 @@
    3.31      // Create the MachNode object
    3.32      fprintf(fp_cpp, "  %sNode *node = new (C) %sNode();\n", name, name);
    3.33      // Fill in the bottom_type where requested
    3.34 -    if ( this->captures_bottom_type() ) {
    3.35 +    if ( this->captures_bottom_type(AD.globalNames()) ) {
    3.36        fprintf(fp_cpp, "  node->_bottom_type = bottom_type();\n");
    3.37      }
    3.38  
    3.39 @@ -3798,7 +3798,7 @@
    3.40  
    3.41  //---------------------------define_short_branch_methods-----------------------
    3.42  // Build definitions for short branch methods
    3.43 -bool InstructForm::define_short_branch_methods(FILE *fp_cpp) {
    3.44 +bool InstructForm::define_short_branch_methods(ArchDesc &AD, FILE *fp_cpp) {
    3.45    if (has_short_branch_form()) {
    3.46      InstructForm *short_branch = short_branch_form();
    3.47      const char   *name         = short_branch->_ident;
    3.48 @@ -3813,7 +3813,7 @@
    3.49        fprintf(fp_cpp, "  node->_fcnt = _fcnt;\n");
    3.50      }
    3.51      // Fill in the bottom_type where requested
    3.52 -    if ( this->captures_bottom_type() ) {
    3.53 +    if ( this->captures_bottom_type(AD.globalNames()) ) {
    3.54        fprintf(fp_cpp, "  node->_bottom_type = bottom_type();\n");
    3.55      }
    3.56  
     4.1 --- a/src/share/vm/adlc/output_h.cpp	Tue May 18 13:45:03 2010 -0700
     4.2 +++ b/src/share/vm/adlc/output_h.cpp	Tue May 18 23:58:32 2010 -0700
     4.3 @@ -1493,7 +1493,7 @@
     4.4      // Build class definition for this instruction
     4.5      fprintf(fp,"\n");
     4.6      fprintf(fp,"class %sNode : public %s { \n",
     4.7 -            instr->_ident, instr->mach_base_class() );
     4.8 +            instr->_ident, instr->mach_base_class(_globalNames) );
     4.9      fprintf(fp,"private:\n");
    4.10      fprintf(fp,"  MachOper *_opnd_array[%d];\n", instr->num_opnds() );
    4.11      if ( instr->is_ideal_jump() ) {
    4.12 @@ -1566,7 +1566,7 @@
    4.13      // Use MachNode::ideal_Opcode() for nodes based on MachNode class
    4.14      // if the ideal_Opcode == Op_Node.
    4.15      if ( strcmp("Node", instr->ideal_Opcode(_globalNames)) != 0 ||
    4.16 -         strcmp("MachNode", instr->mach_base_class()) != 0 ) {
    4.17 +         strcmp("MachNode", instr->mach_base_class(_globalNames)) != 0 ) {
    4.18        fprintf(fp,"  virtual int            ideal_Opcode() const { return Op_%s; }\n",
    4.19              instr->ideal_Opcode(_globalNames) );
    4.20      }
    4.21 @@ -1631,7 +1631,7 @@
    4.22      // Use MachNode::oper_input_base() for nodes based on MachNode class
    4.23      // if the base == 1.
    4.24      if ( instr->oper_input_base(_globalNames) != 1 ||
    4.25 -         strcmp("MachNode", instr->mach_base_class()) != 0 ) {
    4.26 +         strcmp("MachNode", instr->mach_base_class(_globalNames)) != 0 ) {
    4.27        fprintf(fp,"  virtual uint           oper_input_base() const { return %d; }\n",
    4.28              instr->oper_input_base(_globalNames));
    4.29      }
    4.30 @@ -1906,11 +1906,6 @@
    4.31        fprintf(fp,"  const Type            *bottom_type() const { const Type *t = in(oper_input_base()+%d)->bottom_type(); return (req() <= oper_input_base()+%d) ? t : t->meet(in(oper_input_base()+%d)->bottom_type()); } // CMoveN\n",
    4.32          offset, offset+1, offset+1);
    4.33      }
    4.34 -    else if( instr->needs_base_oop_edge(_globalNames) ) {
    4.35 -      // Special hack for ideal AddP.  Bottom type is an oop IFF it has a
    4.36 -      // legal base-pointer input.  Otherwise it is NOT an oop.
    4.37 -      fprintf(fp,"  const Type *bottom_type() const { return AddPNode::mach_bottom_type(this); } // AddP\n");
    4.38 -    }
    4.39      else if (instr->is_tls_instruction()) {
    4.40        // Special hack for tlsLoadP
    4.41        fprintf(fp,"  const Type            *bottom_type() const { return TypeRawPtr::BOTTOM; } // tlsLoadP\n");
     5.1 --- a/src/share/vm/opto/addnode.cpp	Tue May 18 13:45:03 2010 -0700
     5.2 +++ b/src/share/vm/opto/addnode.cpp	Tue May 18 23:58:32 2010 -0700
     5.3 @@ -714,71 +714,6 @@
     5.4    return idx > Base;
     5.5  }
     5.6  
     5.7 -//---------------------------mach_bottom_type----------------------------------
     5.8 -// Utility function for use by ADLC.  Implements bottom_type for matched AddP.
     5.9 -const Type *AddPNode::mach_bottom_type( const MachNode* n) {
    5.10 -  Node* base = n->in(Base);
    5.11 -  const Type *t = base->bottom_type();
    5.12 -  if ( t == Type::TOP ) {
    5.13 -    // an untyped pointer
    5.14 -    return TypeRawPtr::BOTTOM;
    5.15 -  }
    5.16 -  const TypePtr* tp = t->isa_oopptr();
    5.17 -  if ( tp == NULL )  return t;
    5.18 -  if ( tp->_offset == TypePtr::OffsetBot )  return tp;
    5.19 -
    5.20 -  // We must carefully add up the various offsets...
    5.21 -  intptr_t offset = 0;
    5.22 -  const TypePtr* tptr = NULL;
    5.23 -
    5.24 -  uint numopnds = n->num_opnds();
    5.25 -  uint index = n->oper_input_base();
    5.26 -  for ( uint i = 1; i < numopnds; i++ ) {
    5.27 -    MachOper *opnd = n->_opnds[i];
    5.28 -    // Check for any interesting operand info.
    5.29 -    // In particular, check for both memory and non-memory operands.
    5.30 -    // %%%%% Clean this up: use xadd_offset
    5.31 -    intptr_t con = opnd->constant();
    5.32 -    if ( con == TypePtr::OffsetBot )  goto bottom_out;
    5.33 -    offset += con;
    5.34 -    con = opnd->constant_disp();
    5.35 -    if ( con == TypePtr::OffsetBot )  goto bottom_out;
    5.36 -    offset += con;
    5.37 -    if( opnd->scale() != 0 ) goto bottom_out;
    5.38 -
    5.39 -    // Check each operand input edge.  Find the 1 allowed pointer
    5.40 -    // edge.  Other edges must be index edges; track exact constant
    5.41 -    // inputs and otherwise assume the worst.
    5.42 -    for ( uint j = opnd->num_edges(); j > 0; j-- ) {
    5.43 -      Node* edge = n->in(index++);
    5.44 -      const Type*    et  = edge->bottom_type();
    5.45 -      const TypeX*   eti = et->isa_intptr_t();
    5.46 -      if ( eti == NULL ) {
    5.47 -        // there must be one pointer among the operands
    5.48 -        guarantee(tptr == NULL, "must be only one pointer operand");
    5.49 -        if (UseCompressedOops && Universe::narrow_oop_shift() == 0) {
    5.50 -          // 32-bits narrow oop can be the base of address expressions
    5.51 -          tptr = et->make_ptr()->isa_oopptr();
    5.52 -        } else {
    5.53 -          // only regular oops are expected here
    5.54 -          tptr = et->isa_oopptr();
    5.55 -        }
    5.56 -        guarantee(tptr != NULL, "non-int operand must be pointer");
    5.57 -        if (tptr->higher_equal(tp->add_offset(tptr->offset())))
    5.58 -          tp = tptr; // Set more precise type for bailout
    5.59 -        continue;
    5.60 -      }
    5.61 -      if ( eti->_hi != eti->_lo )  goto bottom_out;
    5.62 -      offset += eti->_lo;
    5.63 -    }
    5.64 -  }
    5.65 -  guarantee(tptr != NULL, "must be exactly one pointer operand");
    5.66 -  return tptr->add_offset(offset);
    5.67 -
    5.68 - bottom_out:
    5.69 -  return tp->add_offset(TypePtr::OffsetBot);
    5.70 -}
    5.71 -
    5.72  //=============================================================================
    5.73  //------------------------------Identity---------------------------------------
    5.74  Node *OrINode::Identity( PhaseTransform *phase ) {
     6.1 --- a/src/share/vm/opto/addnode.hpp	Tue May 18 13:45:03 2010 -0700
     6.2 +++ b/src/share/vm/opto/addnode.hpp	Tue May 18 23:58:32 2010 -0700
     6.3 @@ -151,7 +151,6 @@
     6.4  
     6.5    // Do not match base-ptr edge
     6.6    virtual uint match_edge(uint idx) const;
     6.7 -  static const Type *mach_bottom_type(const MachNode* n);  // used by ad_<arch>.hpp
     6.8  };
     6.9  
    6.10  //------------------------------OrINode----------------------------------------

mercurial