< prev index next >

src/hotspot/share/opto/parseHelper.cpp

Print this page




   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"

  26 #include "classfile/systemDictionary.hpp"
  27 #include "compiler/compileLog.hpp"
  28 #include "oops/objArrayKlass.hpp"

  29 #include "opto/addnode.hpp"

  30 #include "opto/memnode.hpp"
  31 #include "opto/mulnode.hpp"
  32 #include "opto/parse.hpp"
  33 #include "opto/rootnode.hpp"
  34 #include "opto/runtime.hpp"

  35 #include "runtime/sharedRuntime.hpp"
  36 
  37 //------------------------------make_dtrace_method_entry_exit ----------------
  38 // Dtrace -- record entry or exit of a method if compiled with dtrace support
  39 void GraphKit::make_dtrace_method_entry_exit(ciMethod* method, bool is_entry) {
  40   const TypeFunc *call_type    = OptoRuntime::dtrace_method_entry_exit_Type();
  41   address         call_address = is_entry ? CAST_FROM_FN_PTR(address, SharedRuntime::dtrace_method_entry) :
  42                                             CAST_FROM_FN_PTR(address, SharedRuntime::dtrace_method_exit);
  43   const char     *call_name    = is_entry ? "dtrace_method_entry" : "dtrace_method_exit";
  44 
  45   // Get base of thread-local storage area
  46   Node* thread = _gvn.transform( new ThreadLocalNode() );
  47 
  48   // Get method
  49   const TypePtr* method_type = TypeMetadataPtr::make(method);
  50   Node *method_node = _gvn.transform(ConNode::make(method_type));
  51 
  52   kill_dead_locals();
  53 
  54   // For some reason, this call reads only raw memory.
  55   const TypePtr* raw_adr_type = TypeRawPtr::BOTTOM;
  56   make_runtime_call(RC_LEAF | RC_NARROW_MEM,
  57                     call_type, call_address,
  58                     call_name, raw_adr_type,
  59                     thread, method_node);
  60 }
  61 
  62 
  63 //=============================================================================
  64 //------------------------------do_checkcast-----------------------------------
  65 void Parse::do_checkcast() {
  66   bool will_link;
  67   ciKlass* klass = iter().get_klass(will_link);

  68 
  69   Node *obj = peek();
  70 
  71   // Throw uncommon trap if class is not loaded or the value we are casting
  72   // _from_ is not loaded, and value is not null.  If the value _is_ NULL,
  73   // then the checkcast does nothing.
  74   const TypeOopPtr *tp = _gvn.type(obj)->isa_oopptr();
  75   if (!will_link || (tp && tp->klass() && !tp->klass()->is_loaded())) {

  76     if (C->log() != NULL) {
  77       if (!will_link) {
  78         C->log()->elem("assert_null reason='checkcast' klass='%d'",
  79                        C->log()->identify(klass));
  80       }
  81       if (tp && tp->klass() && !tp->klass()->is_loaded()) {
  82         // %%% Cannot happen?
  83         C->log()->elem("assert_null reason='checkcast source' klass='%d'",
  84                        C->log()->identify(tp->klass()));
  85       }
  86     }
  87     null_assert(obj);
  88     assert( stopped() || _gvn.type(peek())->higher_equal(TypePtr::NULL_PTR), "what's left behind is null" );
  89     if (!stopped()) {
  90       profile_null_checkcast();
  91     }
  92     return;
  93   }
  94 
  95   Node *res = gen_checkcast(obj, makecon(TypeKlassPtr::make(klass)) );



  96 
  97   // Pop from stack AFTER gen_checkcast because it can uncommon trap and
  98   // the debug info has to be correct.
  99   pop();
 100   push(res);
 101 }
 102 
 103 
 104 //------------------------------do_instanceof----------------------------------
 105 void Parse::do_instanceof() {
 106   if (stopped())  return;
 107   // We would like to return false if class is not loaded, emitting a
 108   // dependency, but Java requires instanceof to load its operand.
 109 
 110   // Throw uncommon trap if class is not loaded
 111   bool will_link;
 112   ciKlass* klass = iter().get_klass(will_link);
 113 
 114   if (!will_link) {
 115     if (C->log() != NULL) {


 120     assert( stopped() || _gvn.type(peek())->higher_equal(TypePtr::NULL_PTR), "what's left behind is null" );
 121     if (!stopped()) {
 122       // The object is now known to be null.
 123       // Shortcut the effect of gen_instanceof and return "false" directly.
 124       pop();                   // pop the null
 125       push(_gvn.intcon(0));    // push false answer
 126     }
 127     return;
 128   }
 129 
 130   // Push the bool result back on stack
 131   Node* res = gen_instanceof(peek(), makecon(TypeKlassPtr::make(klass)), true);
 132 
 133   // Pop from stack AFTER gen_instanceof because it can uncommon trap.
 134   pop();
 135   push(res);
 136 }
 137 
 138 //------------------------------array_store_check------------------------------
 139 // pull array from stack and check that the store is valid
 140 void Parse::array_store_check() {
 141 
 142   // Shorthand access to array store elements without popping them.
 143   Node *obj = peek(0);
 144   Node *idx = peek(1);
 145   Node *ary = peek(2);
 146 
 147   if (_gvn.type(obj) == TypePtr::NULL_PTR) {
 148     // There's never a type check on null values.
 149     // This cutout lets us avoid the uncommon_trap(Reason_array_check)
 150     // below, which turns into a performance liability if the
 151     // gen_checkcast folds up completely.
 152     return;
 153   }
 154 
 155   // Extract the array klass type
 156   int klass_offset = oopDesc::klass_offset_in_bytes();
 157   Node* p = basic_plus_adr( ary, ary, klass_offset );
 158   // p's type is array-of-OOPS plus klass_offset
 159   Node* array_klass = _gvn.transform(LoadKlassNode::make(_gvn, NULL, immutable_memory(), p, TypeInstPtr::KLASS));
 160   // Get the array klass
 161   const TypeKlassPtr *tak = _gvn.type(array_klass)->is_klassptr();
 162 
 163   // The type of array_klass is usually INexact array-of-oop.  Heroically
 164   // cast array_klass to EXACT array and uncommon-trap if the cast fails.
 165   // Make constant out of the inexact array klass, but use it only if the cast
 166   // succeeds.
 167   bool always_see_exact_class = false;
 168   if (MonomorphicArrayCheck
 169       && !too_many_traps(Deoptimization::Reason_array_check)
 170       && !tak->klass_is_exact()
 171       && tak != TypeKlassPtr::OBJECT) {
 172       // Regarding the fourth condition in the if-statement from above:
 173       //
 174       // If the compiler has determined that the type of array 'ary' (represented
 175       // by 'array_klass') is java/lang/Object, the compiler must not assume that
 176       // the array 'ary' is monomorphic.
 177       //
 178       // If 'ary' were of type java/lang/Object, this arraystore would have to fail,
 179       // because it is not possible to perform a arraystore into an object that is not


 192 
 193     always_see_exact_class = true;
 194     // (If no MDO at all, hope for the best, until a trap actually occurs.)
 195 
 196     // Make a constant out of the inexact array klass
 197     const TypeKlassPtr *extak = tak->cast_to_exactness(true)->is_klassptr();
 198     Node* con = makecon(extak);
 199     Node* cmp = _gvn.transform(new CmpPNode( array_klass, con ));
 200     Node* bol = _gvn.transform(new BoolNode( cmp, BoolTest::eq ));
 201     Node* ctrl= control();
 202     { BuildCutout unless(this, bol, PROB_MAX);
 203       uncommon_trap(Deoptimization::Reason_array_check,
 204                     Deoptimization::Action_maybe_recompile,
 205                     tak->klass());
 206     }
 207     if (stopped()) {          // MUST uncommon-trap?
 208       set_control(ctrl);      // Then Don't Do It, just fall into the normal checking
 209     } else {                  // Cast array klass to exactness:
 210       // Use the exact constant value we know it is.
 211       replace_in_map(array_klass,con);



 212       CompileLog* log = C->log();
 213       if (log != NULL) {
 214         log->elem("cast_up reason='monomorphic_array' from='%d' to='(exact)'",
 215                   log->identify(tak->klass()));
 216       }
 217       array_klass = con;      // Use cast value moving forward
 218     }
 219   }
 220 
 221   // Come here for polymorphic array klasses
 222 
 223   // Extract the array element class
 224   int element_klass_offset = in_bytes(ObjArrayKlass::element_klass_offset());

 225   Node *p2 = basic_plus_adr(array_klass, array_klass, element_klass_offset);
 226   // We are allowed to use the constant type only if cast succeeded. If always_see_exact_class is true,
 227   // we must set a control edge from the IfTrue node created by the uncommon_trap above to the
 228   // LoadKlassNode.
 229   Node* a_e_klass = _gvn.transform(LoadKlassNode::make(_gvn, always_see_exact_class ? control() : NULL,
 230                                                        immutable_memory(), p2, tak));
 231 







 232   // Check (the hard way) and throw if not a subklass.
 233   // Result is ignored, we just need the CFG effects.
 234   gen_checkcast(obj, a_e_klass);
 235 }
 236 
 237 
 238 //------------------------------do_new-----------------------------------------
 239 void Parse::do_new() {
 240   kill_dead_locals();
 241 
 242   bool will_link;
 243   ciInstanceKlass* klass = iter().get_klass(will_link)->as_instance_klass();
 244   assert(will_link, "_new: typeflow responsibility");
 245 
 246   // Should throw an InstantiationError?
 247   if (klass->is_abstract() || klass->is_interface() ||
 248       klass->name() == ciSymbol::java_lang_Class() ||
 249       iter().is_unresolved_klass()) {
 250     uncommon_trap(Deoptimization::Reason_unhandled,
 251                   Deoptimization::Action_none,
 252                   klass);
 253     return;
 254   }


 258     if (stopped())  return;
 259   }
 260 
 261   Node* kls = makecon(TypeKlassPtr::make(klass));
 262   Node* obj = new_instance(kls);
 263 
 264   // Push resultant oop onto stack
 265   push(obj);
 266 
 267   // Keep track of whether opportunities exist for StringBuilder
 268   // optimizations.
 269   if (OptimizeStringConcat &&
 270       (klass == C->env()->StringBuilder_klass() ||
 271        klass == C->env()->StringBuffer_klass())) {
 272     C->set_has_stringbuilder(true);
 273   }
 274 
 275   // Keep track of boxed values for EliminateAutoBox optimizations.
 276   if (C->eliminate_boxing() && klass->is_box_klass()) {
 277     C->set_has_boxed_value(true);






































































 278   }
 279 }
 280 
 281 #ifndef PRODUCT
 282 //------------------------------dump_map_adr_mem-------------------------------
 283 // Debug dump of the mapping from address types to MergeMemNode indices.
 284 void Parse::dump_map_adr_mem() const {
 285   tty->print_cr("--- Mapping from address types to memory Nodes ---");
 286   MergeMemNode *mem = map() == NULL ? NULL : (map()->memory()->is_MergeMem() ?
 287                                       map()->memory()->as_MergeMem() : NULL);
 288   for (uint i = 0; i < (uint)C->num_alias_types(); i++) {
 289     C->alias_type(i)->print_on(tty);
 290     tty->print("\t");
 291     // Node mapping, if any
 292     if (mem && i < mem->req() && mem->in(i) && mem->in(i) != mem->empty_memory()) {
 293       mem->in(i)->dump();
 294     } else {
 295       tty->cr();
 296     }
 297   }




   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "ci/ciValueKlass.hpp"
  27 #include "classfile/systemDictionary.hpp"
  28 #include "compiler/compileLog.hpp"
  29 #include "oops/objArrayKlass.hpp"
  30 #include "oops/valueArrayKlass.hpp"
  31 #include "opto/addnode.hpp"
  32 #include "opto/castnode.hpp"
  33 #include "opto/memnode.hpp"
  34 #include "opto/mulnode.hpp"
  35 #include "opto/parse.hpp"
  36 #include "opto/rootnode.hpp"
  37 #include "opto/runtime.hpp"
  38 #include "opto/valuetypenode.hpp"
  39 #include "runtime/sharedRuntime.hpp"
  40 
  41 //------------------------------make_dtrace_method_entry_exit ----------------
  42 // Dtrace -- record entry or exit of a method if compiled with dtrace support
  43 void GraphKit::make_dtrace_method_entry_exit(ciMethod* method, bool is_entry) {
  44   const TypeFunc *call_type    = OptoRuntime::dtrace_method_entry_exit_Type();
  45   address         call_address = is_entry ? CAST_FROM_FN_PTR(address, SharedRuntime::dtrace_method_entry) :
  46                                             CAST_FROM_FN_PTR(address, SharedRuntime::dtrace_method_exit);
  47   const char     *call_name    = is_entry ? "dtrace_method_entry" : "dtrace_method_exit";
  48 
  49   // Get base of thread-local storage area
  50   Node* thread = _gvn.transform( new ThreadLocalNode() );
  51 
  52   // Get method
  53   const TypePtr* method_type = TypeMetadataPtr::make(method);
  54   Node *method_node = _gvn.transform(ConNode::make(method_type));
  55 
  56   kill_dead_locals();
  57 
  58   // For some reason, this call reads only raw memory.
  59   const TypePtr* raw_adr_type = TypeRawPtr::BOTTOM;
  60   make_runtime_call(RC_LEAF | RC_NARROW_MEM,
  61                     call_type, call_address,
  62                     call_name, raw_adr_type,
  63                     thread, method_node);
  64 }
  65 
  66 
  67 //=============================================================================
  68 //------------------------------do_checkcast-----------------------------------
  69 void Parse::do_checkcast() {
  70   bool will_link;
  71   ciKlass* klass = iter().get_klass(will_link);
  72   bool never_null = iter().is_klass_never_null();
  73 
  74   Node *obj = peek();
  75 
  76   // Throw uncommon trap if class is not loaded or the value we are casting
  77   // _from_ is not loaded, and value is not null.  If the value _is_ NULL,
  78   // then the checkcast does nothing.
  79   const TypeOopPtr *tp = _gvn.type(obj)->isa_oopptr();
  80   if (!will_link || (tp && tp->klass() && !tp->klass()->is_loaded())) {
  81     assert(!never_null, "Null-free value type should be loaded");
  82     if (C->log() != NULL) {
  83       if (!will_link) {
  84         C->log()->elem("assert_null reason='checkcast' klass='%d'",
  85                        C->log()->identify(klass));
  86       }
  87       if (tp && tp->klass() && !tp->klass()->is_loaded()) {
  88         // %%% Cannot happen?
  89         C->log()->elem("assert_null reason='checkcast source' klass='%d'",
  90                        C->log()->identify(tp->klass()));
  91       }
  92     }
  93     null_assert(obj);
  94     assert( stopped() || _gvn.type(peek())->higher_equal(TypePtr::NULL_PTR), "what's left behind is null" );
  95     if (!stopped()) {
  96       profile_null_checkcast();
  97     }
  98     return;
  99   }
 100 
 101   Node* res = gen_checkcast(obj, makecon(TypeKlassPtr::make(klass)), NULL, never_null);
 102   if (stopped()) {
 103     return;
 104   }
 105 
 106   // Pop from stack AFTER gen_checkcast because it can uncommon trap and
 107   // the debug info has to be correct.
 108   pop();
 109   push(res);
 110 }
 111 
 112 
 113 //------------------------------do_instanceof----------------------------------
 114 void Parse::do_instanceof() {
 115   if (stopped())  return;
 116   // We would like to return false if class is not loaded, emitting a
 117   // dependency, but Java requires instanceof to load its operand.
 118 
 119   // Throw uncommon trap if class is not loaded
 120   bool will_link;
 121   ciKlass* klass = iter().get_klass(will_link);
 122 
 123   if (!will_link) {
 124     if (C->log() != NULL) {


 129     assert( stopped() || _gvn.type(peek())->higher_equal(TypePtr::NULL_PTR), "what's left behind is null" );
 130     if (!stopped()) {
 131       // The object is now known to be null.
 132       // Shortcut the effect of gen_instanceof and return "false" directly.
 133       pop();                   // pop the null
 134       push(_gvn.intcon(0));    // push false answer
 135     }
 136     return;
 137   }
 138 
 139   // Push the bool result back on stack
 140   Node* res = gen_instanceof(peek(), makecon(TypeKlassPtr::make(klass)), true);
 141 
 142   // Pop from stack AFTER gen_instanceof because it can uncommon trap.
 143   pop();
 144   push(res);
 145 }
 146 
 147 //------------------------------array_store_check------------------------------
 148 // pull array from stack and check that the store is valid
 149 Node* Parse::array_store_check() {

 150   // Shorthand access to array store elements without popping them.
 151   Node *obj = peek(0);
 152   Node *idx = peek(1);
 153   Node *ary = peek(2);
 154 
 155   if (_gvn.type(obj) == TypePtr::NULL_PTR) {
 156     // There's never a type check on null values.
 157     // This cutout lets us avoid the uncommon_trap(Reason_array_check)
 158     // below, which turns into a performance liability if the
 159     // gen_checkcast folds up completely.
 160     return obj;
 161   }
 162 
 163   // Extract the array klass type
 164   Node* array_klass = load_object_klass(ary);



 165   // Get the array klass
 166   const TypeKlassPtr *tak = _gvn.type(array_klass)->is_klassptr();
 167 
 168   // The type of array_klass is usually INexact array-of-oop.  Heroically
 169   // cast array_klass to EXACT array and uncommon-trap if the cast fails.
 170   // Make constant out of the inexact array klass, but use it only if the cast
 171   // succeeds.
 172   bool always_see_exact_class = false;
 173   if (MonomorphicArrayCheck
 174       && !too_many_traps(Deoptimization::Reason_array_check)
 175       && !tak->klass_is_exact()
 176       && tak != TypeKlassPtr::OBJECT) {
 177       // Regarding the fourth condition in the if-statement from above:
 178       //
 179       // If the compiler has determined that the type of array 'ary' (represented
 180       // by 'array_klass') is java/lang/Object, the compiler must not assume that
 181       // the array 'ary' is monomorphic.
 182       //
 183       // If 'ary' were of type java/lang/Object, this arraystore would have to fail,
 184       // because it is not possible to perform a arraystore into an object that is not


 197 
 198     always_see_exact_class = true;
 199     // (If no MDO at all, hope for the best, until a trap actually occurs.)
 200 
 201     // Make a constant out of the inexact array klass
 202     const TypeKlassPtr *extak = tak->cast_to_exactness(true)->is_klassptr();
 203     Node* con = makecon(extak);
 204     Node* cmp = _gvn.transform(new CmpPNode( array_klass, con ));
 205     Node* bol = _gvn.transform(new BoolNode( cmp, BoolTest::eq ));
 206     Node* ctrl= control();
 207     { BuildCutout unless(this, bol, PROB_MAX);
 208       uncommon_trap(Deoptimization::Reason_array_check,
 209                     Deoptimization::Action_maybe_recompile,
 210                     tak->klass());
 211     }
 212     if (stopped()) {          // MUST uncommon-trap?
 213       set_control(ctrl);      // Then Don't Do It, just fall into the normal checking
 214     } else {                  // Cast array klass to exactness:
 215       // Use the exact constant value we know it is.
 216       replace_in_map(array_klass,con);
 217       Node* cast = _gvn.transform(new CheckCastPPNode(control(), ary, extak->as_instance_type()));
 218       replace_in_map(ary, cast);
 219 
 220       CompileLog* log = C->log();
 221       if (log != NULL) {
 222         log->elem("cast_up reason='monomorphic_array' from='%d' to='(exact)'",
 223                   log->identify(tak->klass()));
 224       }
 225       array_klass = con;      // Use cast value moving forward
 226     }
 227   }
 228 
 229   // Come here for polymorphic array klasses
 230 
 231   // Extract the array element class
 232   int element_klass_offset = in_bytes(ArrayKlass::element_klass_offset());
 233 
 234   Node *p2 = basic_plus_adr(array_klass, array_klass, element_klass_offset);
 235   // We are allowed to use the constant type only if cast succeeded. If always_see_exact_class is true,
 236   // we must set a control edge from the IfTrue node created by the uncommon_trap above to the
 237   // LoadKlassNode.
 238   Node* a_e_klass = _gvn.transform(LoadKlassNode::make(_gvn, always_see_exact_class ? control() : NULL,
 239                                                        immutable_memory(), p2, tak));
 240 
 241   // Handle value type arrays
 242   const Type* elemtype = _gvn.type(ary)->is_aryptr()->elem();
 243   if (elemtype->isa_valuetype() != NULL || elemtype->is_valuetypeptr()) {
 244     // We statically know that this is a value type array, use precise klass ptr
 245     a_e_klass = makecon(TypeKlassPtr::make(elemtype->value_klass()));
 246   }
 247 
 248   // Check (the hard way) and throw if not a subklass.
 249   return gen_checkcast(obj, a_e_klass);

 250 }
 251 
 252 
 253 //------------------------------do_new-----------------------------------------
 254 void Parse::do_new() {
 255   kill_dead_locals();
 256 
 257   bool will_link;
 258   ciInstanceKlass* klass = iter().get_klass(will_link)->as_instance_klass();
 259   assert(will_link, "_new: typeflow responsibility");
 260 
 261   // Should throw an InstantiationError?
 262   if (klass->is_abstract() || klass->is_interface() ||
 263       klass->name() == ciSymbol::java_lang_Class() ||
 264       iter().is_unresolved_klass()) {
 265     uncommon_trap(Deoptimization::Reason_unhandled,
 266                   Deoptimization::Action_none,
 267                   klass);
 268     return;
 269   }


 273     if (stopped())  return;
 274   }
 275 
 276   Node* kls = makecon(TypeKlassPtr::make(klass));
 277   Node* obj = new_instance(kls);
 278 
 279   // Push resultant oop onto stack
 280   push(obj);
 281 
 282   // Keep track of whether opportunities exist for StringBuilder
 283   // optimizations.
 284   if (OptimizeStringConcat &&
 285       (klass == C->env()->StringBuilder_klass() ||
 286        klass == C->env()->StringBuffer_klass())) {
 287     C->set_has_stringbuilder(true);
 288   }
 289 
 290   // Keep track of boxed values for EliminateAutoBox optimizations.
 291   if (C->eliminate_boxing() && klass->is_box_klass()) {
 292     C->set_has_boxed_value(true);
 293   }
 294 }
 295 
 296 //------------------------------do_defaultvalue---------------------------------
 297 void Parse::do_defaultvalue() {
 298   bool will_link;
 299   ciValueKlass* vk = iter().get_klass(will_link)->as_value_klass();
 300   assert(will_link, "defaultvalue: typeflow responsibility");
 301 
 302   // Should throw an InstantiationError?
 303   if (iter().is_unresolved_klass()) {
 304     uncommon_trap(Deoptimization::Reason_unhandled,
 305                   Deoptimization::Action_none,
 306                   vk);
 307     return;
 308   }
 309 
 310   if (C->needs_clinit_barrier(vk, method())) {
 311     clinit_barrier(vk, method());
 312     if (stopped())  return;
 313   }
 314 
 315   ValueTypeNode* vt = ValueTypeNode::make_default(_gvn, vk);
 316   if (vk->is_scalarizable()) {
 317     push(vt);
 318   } else {
 319     push(vt->get_oop());
 320   }
 321 }
 322 
 323 //------------------------------do_withfield------------------------------------
 324 void Parse::do_withfield() {
 325   bool will_link;
 326   ciField* field = iter().get_field(will_link);
 327   assert(will_link, "withfield: typeflow responsibility");
 328   BasicType bt = field->layout_type();
 329   Node* val = type2size[bt] == 1 ? pop() : pop_pair();
 330   ciValueKlass* holder_klass = field->holder()->as_value_klass();
 331   Node* holder = pop();
 332 
 333   if (!holder->is_ValueType()) {
 334     // Null check and scalarize value type holder
 335     inc_sp(2);
 336     holder = null_check(holder);
 337     dec_sp(2);
 338     if (stopped()) return;
 339     holder = ValueTypeNode::make_from_oop(this, holder, holder_klass);
 340   }
 341   if (!val->is_ValueType() && field->is_flattenable()) {
 342     // Null check and scalarize value type field value
 343     inc_sp(2);
 344     val = null_check(val);
 345     dec_sp(2);
 346     if (stopped()) return;
 347     val = ValueTypeNode::make_from_oop(this, val, gvn().type(val)->value_klass());
 348   } else if (val->is_ValueType() && !field->is_flattenable()) {
 349     // Non-flattenable field should not be scalarized
 350     val = ValueTypePtrNode::make_from_value_type(this, val->as_ValueType());
 351   }
 352 
 353   // Clone the value type node and set the new field value
 354   ValueTypeNode* new_vt = holder->clone()->as_ValueType();
 355   new_vt->set_oop(_gvn.zerocon(T_VALUETYPE));
 356   gvn().set_type(new_vt, new_vt->bottom_type());
 357   new_vt->set_field_value_by_offset(field->offset(), val);
 358 
 359   if (holder_klass->is_scalarizable()) {
 360     push(_gvn.transform(new_vt));
 361   } else {
 362     push(new_vt->allocate(this)->get_oop());
 363   }
 364 }
 365 
 366 #ifndef PRODUCT
 367 //------------------------------dump_map_adr_mem-------------------------------
 368 // Debug dump of the mapping from address types to MergeMemNode indices.
 369 void Parse::dump_map_adr_mem() const {
 370   tty->print_cr("--- Mapping from address types to memory Nodes ---");
 371   MergeMemNode *mem = map() == NULL ? NULL : (map()->memory()->is_MergeMem() ?
 372                                       map()->memory()->as_MergeMem() : NULL);
 373   for (uint i = 0; i < (uint)C->num_alias_types(); i++) {
 374     C->alias_type(i)->print_on(tty);
 375     tty->print("\t");
 376     // Node mapping, if any
 377     if (mem && i < mem->req() && mem->in(i) && mem->in(i) != mem->empty_memory()) {
 378       mem->in(i)->dump();
 379     } else {
 380       tty->cr();
 381     }
 382   }


< prev index next >