< prev index next >

src/hotspot/share/c1/c1_Optimizer.cpp

Print this page


   1 /*
   2  * Copyright (c) 1999, 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  *


 851     }
 852   }
 853 }
 854 
 855 
 856 void NullCheckEliminator::iterate(BlockBegin* block) {
 857   work_list()->push(block);
 858   iterate_all();
 859 }
 860 
 861 void NullCheckEliminator::handle_AccessField(AccessField* x) {
 862   if (x->is_static()) {
 863     if (x->as_LoadField() != NULL) {
 864       // If the field is a non-null static final object field (as is
 865       // often the case for sun.misc.Unsafe), put this LoadField into
 866       // the non-null map
 867       ciField* field = x->field();
 868       if (field->is_constant()) {
 869         ciConstant field_val = field->constant_value();
 870         BasicType field_type = field_val.basic_type();
 871         if (field_type == T_OBJECT || field_type == T_ARRAY) {
 872           ciObject* obj_val = field_val.as_object();
 873           if (!obj_val->is_null_object()) {
 874             if (PrintNullCheckElimination) {
 875               tty->print_cr("AccessField %d proven non-null by static final non-null oop check",
 876                             x->id());
 877             }
 878             set_put(x);
 879           }
 880         }
 881       }
 882     }
 883     // Be conservative
 884     clear_last_explicit_null_check();
 885     return;
 886   }
 887 
 888   Value obj = x->obj();
 889   if (set_contains(obj)) {
 890     // Value is non-null => update AccessField
 891     if (last_explicit_null_check_obj() == obj && !x->needs_patching()) {


   1 /*
   2  * Copyright (c) 1999, 2019, 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  *


 851     }
 852   }
 853 }
 854 
 855 
 856 void NullCheckEliminator::iterate(BlockBegin* block) {
 857   work_list()->push(block);
 858   iterate_all();
 859 }
 860 
 861 void NullCheckEliminator::handle_AccessField(AccessField* x) {
 862   if (x->is_static()) {
 863     if (x->as_LoadField() != NULL) {
 864       // If the field is a non-null static final object field (as is
 865       // often the case for sun.misc.Unsafe), put this LoadField into
 866       // the non-null map
 867       ciField* field = x->field();
 868       if (field->is_constant()) {
 869         ciConstant field_val = field->constant_value();
 870         BasicType field_type = field_val.basic_type();
 871         if (is_reference_type(field_type)) {
 872           ciObject* obj_val = field_val.as_object();
 873           if (!obj_val->is_null_object()) {
 874             if (PrintNullCheckElimination) {
 875               tty->print_cr("AccessField %d proven non-null by static final non-null oop check",
 876                             x->id());
 877             }
 878             set_put(x);
 879           }
 880         }
 881       }
 882     }
 883     // Be conservative
 884     clear_last_explicit_null_check();
 885     return;
 886   }
 887 
 888   Value obj = x->obj();
 889   if (set_contains(obj)) {
 890     // Value is non-null => update AccessField
 891     if (last_explicit_null_check_obj() == obj && !x->needs_patching()) {


< prev index next >