< prev index next >

src/hotspot/share/opto/valuetypenode.cpp

Print this page
   1 /*
   2  * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   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  *


 516     } else {
 517       value = gvn.zerocon(field_type->basic_type());
 518     }
 519     vt->set_field_value(i, value);
 520   }
 521   vt = gvn.transform(vt)->as_ValueType();
 522   assert(vt->is_default(gvn), "must be the default value type");
 523   return vt;
 524 }
 525 
 526 
 527 bool ValueTypeNode::is_default(PhaseGVN& gvn) const {
 528   for (uint i = 0; i < field_count(); ++i) {
 529     Node* value = field_value(i);
 530     if (!gvn.type(value)->is_zero_type() &&
 531         !(value->is_ValueType() && value->as_ValueType()->is_default(gvn))) {
 532       return false;
 533     }
 534   }
 535   return true;










 536 }
 537 
 538 ValueTypeNode* ValueTypeNode::make_from_oop(GraphKit* kit, Node* oop, ciValueKlass* vk, bool buffer_check, bool null2default, int trap_bci) {
 539   PhaseGVN& gvn = kit->gvn();
 540   const TypePtr* oop_type = gvn.type(oop)->is_ptr();
 541   bool null_check = oop_type->maybe_null();
 542 
 543   // Create and initialize a ValueTypeNode by loading all field
 544   // values from a heap-allocated version and also save the oop.
 545   ValueTypeNode* vt = new ValueTypeNode(TypeValueType::make(vk), oop);
 546 
 547   if (null_check) {
 548     // Add a null check because the oop may be null
 549     Node* null_ctl = kit->top();
 550     Node* not_null_oop = kit->null_check_oop(oop, &null_ctl);
 551     if (kit->stopped()) {
 552       // Constant null
 553       if (null2default) {
 554         kit->set_control(null_ctl);
 555         return make_default(gvn, vk);


   1 /*
   2  * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   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  *


 516     } else {
 517       value = gvn.zerocon(field_type->basic_type());
 518     }
 519     vt->set_field_value(i, value);
 520   }
 521   vt = gvn.transform(vt)->as_ValueType();
 522   assert(vt->is_default(gvn), "must be the default value type");
 523   return vt;
 524 }
 525 
 526 
 527 bool ValueTypeNode::is_default(PhaseGVN& gvn) const {
 528   for (uint i = 0; i < field_count(); ++i) {
 529     Node* value = field_value(i);
 530     if (!gvn.type(value)->is_zero_type() &&
 531         !(value->is_ValueType() && value->as_ValueType()->is_default(gvn))) {
 532       return false;
 533     }
 534   }
 535   return true;
 536 }
 537 
 538 ValueTypeNode* ValueTypeNode::make_from_returned_oop(GraphKit* kit, Node* oop, ciValueKlass* vk) {
 539 #ifdef ASSERT  
 540   PhaseGVN& gvn = kit->gvn();
 541   const TypePtr* oop_type = gvn.type(oop)->is_ptr();
 542   assert(!oop_type->maybe_null(), "a ValueType returned to compiled code must never be NULL");
 543 #endif
 544 
 545   return make_from_oop(kit, oop, vk, /* buffer_check */ false, /* null2default */ false, /* trap_bci */ -1);
 546 }
 547 
 548 ValueTypeNode* ValueTypeNode::make_from_oop(GraphKit* kit, Node* oop, ciValueKlass* vk, bool buffer_check, bool null2default, int trap_bci) {
 549   PhaseGVN& gvn = kit->gvn();
 550   const TypePtr* oop_type = gvn.type(oop)->is_ptr();
 551   bool null_check = oop_type->maybe_null();
 552 
 553   // Create and initialize a ValueTypeNode by loading all field
 554   // values from a heap-allocated version and also save the oop.
 555   ValueTypeNode* vt = new ValueTypeNode(TypeValueType::make(vk), oop);
 556 
 557   if (null_check) {
 558     // Add a null check because the oop may be null
 559     Node* null_ctl = kit->top();
 560     Node* not_null_oop = kit->null_check_oop(oop, &null_ctl);
 561     if (kit->stopped()) {
 562       // Constant null
 563       if (null2default) {
 564         kit->set_control(null_ctl);
 565         return make_default(gvn, vk);


< prev index next >