< prev index next >

src/hotspot/share/opto/graphKit.cpp

Print this page




  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "compiler/compileLog.hpp"
  27 #include "gc/g1/g1SATBCardTableModRefBS.hpp"
  28 #include "gc/g1/heapRegion.hpp"
  29 #include "gc/shared/barrierSet.hpp"
  30 #include "gc/shared/cardTableModRefBS.hpp"
  31 #include "gc/shared/collectedHeap.hpp"
  32 #include "memory/resourceArea.hpp"
  33 #include "opto/addnode.hpp"
  34 #include "opto/castnode.hpp"
  35 #include "opto/convertnode.hpp"
  36 #include "opto/graphKit.hpp"
  37 #include "opto/idealKit.hpp"
  38 #include "opto/intrinsicnode.hpp"
  39 #include "opto/locknode.hpp"
  40 #include "opto/machnode.hpp"

  41 #include "opto/opaquenode.hpp"
  42 #include "opto/parse.hpp"
  43 #include "opto/rootnode.hpp"
  44 #include "opto/runtime.hpp"
  45 #include "runtime/deoptimization.hpp"
  46 #include "runtime/sharedRuntime.hpp"
  47 
  48 //----------------------------GraphKit-----------------------------------------
  49 // Main utility constructor.
  50 GraphKit::GraphKit(JVMState* jvms)
  51   : Phase(Phase::Parser),
  52     _env(C->env()),
  53     _gvn(*C->initial_gvn())
  54 {
  55   _exceptions = jvms->map()->next_exception();
  56   if (_exceptions != NULL)  jvms->map()->set_next_exception(NULL);
  57   set_jvms(jvms);
  58 }
  59 
  60 // Private constructor for parser.


4516   }
4517   ciInstance* holder = NULL;
4518   if (!field->is_static()) {
4519     ciObject* const_oop = obj->bottom_type()->is_oopptr()->const_oop();
4520     if (const_oop != NULL && const_oop->is_instance()) {
4521       holder = const_oop->as_instance();
4522     }
4523   }
4524   const Type* con_type = Type::make_constant_from_field(field, holder, field->layout_type(),
4525                                                         /*is_unsigned_load=*/false);
4526   if (con_type != NULL) {
4527     return makecon(con_type);
4528   }
4529   return NULL;
4530 }
4531 
4532 Node* GraphKit::cast_array_to_stable(Node* ary, const TypeAryPtr* ary_type) {
4533   // Reify the property as a CastPP node in Ideal graph to comply with monotonicity
4534   // assumption of CCP analysis.
4535   return _gvn.transform(new CastPPNode(ary, ary_type->cast_to_stable(true)));


















































4536 }


  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "compiler/compileLog.hpp"
  27 #include "gc/g1/g1SATBCardTableModRefBS.hpp"
  28 #include "gc/g1/heapRegion.hpp"
  29 #include "gc/shared/barrierSet.hpp"
  30 #include "gc/shared/cardTableModRefBS.hpp"
  31 #include "gc/shared/collectedHeap.hpp"
  32 #include "memory/resourceArea.hpp"
  33 #include "opto/addnode.hpp"
  34 #include "opto/castnode.hpp"
  35 #include "opto/convertnode.hpp"
  36 #include "opto/graphKit.hpp"
  37 #include "opto/idealKit.hpp"
  38 #include "opto/intrinsicnode.hpp"
  39 #include "opto/locknode.hpp"
  40 #include "opto/machnode.hpp"
  41 #include "opto/narrowptrnode.hpp"
  42 #include "opto/opaquenode.hpp"
  43 #include "opto/parse.hpp"
  44 #include "opto/rootnode.hpp"
  45 #include "opto/runtime.hpp"
  46 #include "runtime/deoptimization.hpp"
  47 #include "runtime/sharedRuntime.hpp"
  48 
  49 //----------------------------GraphKit-----------------------------------------
  50 // Main utility constructor.
  51 GraphKit::GraphKit(JVMState* jvms)
  52   : Phase(Phase::Parser),
  53     _env(C->env()),
  54     _gvn(*C->initial_gvn())
  55 {
  56   _exceptions = jvms->map()->next_exception();
  57   if (_exceptions != NULL)  jvms->map()->set_next_exception(NULL);
  58   set_jvms(jvms);
  59 }
  60 
  61 // Private constructor for parser.


4517   }
4518   ciInstance* holder = NULL;
4519   if (!field->is_static()) {
4520     ciObject* const_oop = obj->bottom_type()->is_oopptr()->const_oop();
4521     if (const_oop != NULL && const_oop->is_instance()) {
4522       holder = const_oop->as_instance();
4523     }
4524   }
4525   const Type* con_type = Type::make_constant_from_field(field, holder, field->layout_type(),
4526                                                         /*is_unsigned_load=*/false);
4527   if (con_type != NULL) {
4528     return makecon(con_type);
4529   }
4530   return NULL;
4531 }
4532 
4533 Node* GraphKit::cast_array_to_stable(Node* ary, const TypeAryPtr* ary_type) {
4534   // Reify the property as a CastPP node in Ideal graph to comply with monotonicity
4535   // assumption of CCP analysis.
4536   return _gvn.transform(new CastPPNode(ary, ary_type->cast_to_stable(true)));
4537 }
4538 
4539 Node* GraphKit::acmp(Node* a, Node* b) {
4540   // In the case were both operands might be value types, we need to
4541   // use the new acmp implementation. Otherwise, i.e. if one operand
4542   // is not a value type, we can use the old acmp implementation.
4543   Node* cmp = C->optimize_acmp(&_gvn, a, b);
4544   if (cmp != NULL) {
4545     return cmp; // Use optimized/old acmp
4546   }
4547 
4548   Node* region = new RegionNode(2);
4549   Node* is_value = new PhiNode(region, TypeX_X);
4550 
4551   // Null check operand before loading the is_value bit
4552   bool speculate = false;
4553   if (!TypePtr::NULL_PTR->higher_equal(_gvn.type(b))) {
4554     // Operand 'b' is never null, swap operands to avoid null check
4555     swap(a, b);
4556   } else if (!too_many_traps(Deoptimization::Reason_speculate_null_check)) {
4557     // Speculate on non-nullness of one operand
4558     if (!_gvn.type(a)->speculative_maybe_null()) {
4559       speculate = true;
4560     } else if (!_gvn.type(b)->speculative_maybe_null()) {
4561       speculate = true;
4562       swap(a, b);
4563     }
4564   }
4565 
4566   inc_sp(2);
4567   Node* null_ctl = top();
4568   Node* not_null_a = null_check_oop(a, &null_ctl, speculate, speculate, speculate);
4569   assert(!stopped(), "operand is always null");
4570   dec_sp(2);
4571   if (null_ctl != top()) {
4572     assert(!speculate, "should never be null");
4573     region->add_req(null_ctl);
4574     is_value->add_req(_gvn.MakeConX(0));
4575   }
4576 
4577   Node* value_bit = C->load_is_value_bit(&_gvn, not_null_a);
4578   region->init_req(1, control());
4579   is_value->set_req(1, value_bit);
4580 
4581   set_control(_gvn.transform(region));
4582   is_value = _gvn.transform(is_value);
4583 
4584   // Perturbe oop if operand is a value type to make comparison fail
4585   Node* pert = _gvn.transform(new AddPNode(a, a, is_value));
4586   return new CmpPNode(pert, b);
4587 }
< prev index next >