src/share/vm/opto/parse1.cpp

changeset 8415
d109bda16490
parent 8316
626f594dffa6
parent 8368
32b682649973
child 8424
2094cac55c59
equal deleted inserted replaced
8332:b5b3db42efca 8415:d109bda16490
1 /* 1 /*
2 * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. 2 * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 * 4 *
5 * This code is free software; you can redistribute it and/or modify it 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 6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
715 } 715 }
716 } 716 }
717 #endif 717 #endif
718 } 718 }
719 719
720 static Node* mask_int_value(Node* v, BasicType bt, PhaseGVN* gvn) {
721 Compile* C = gvn->C;
722 switch (bt) {
723 case T_BYTE:
724 v = gvn->transform(new (C) LShiftINode(v, gvn->intcon(24)));
725 v = gvn->transform(new (C) RShiftINode(v, gvn->intcon(24)));
726 break;
727 case T_SHORT:
728 v = gvn->transform(new (C) LShiftINode(v, gvn->intcon(16)));
729 v = gvn->transform(new (C) RShiftINode(v, gvn->intcon(16)));
730 break;
731 case T_CHAR:
732 v = gvn->transform(new (C) AndINode(v, gvn->intcon(0xFFFF)));
733 break;
734 case T_BOOLEAN:
735 v = gvn->transform(new (C) AndINode(v, gvn->intcon(0x1)));
736 break;
737 }
738 return v;
739 }
740
720 //-------------------------------build_exits---------------------------------- 741 //-------------------------------build_exits----------------------------------
721 // Build normal and exceptional exit merge points. 742 // Build normal and exceptional exit merge points.
722 void Parse::build_exits() { 743 void Parse::build_exits() {
723 // make a clone of caller to prevent sharing of side-effects 744 // make a clone of caller to prevent sharing of side-effects
724 _exits.set_map(_exits.clone_map()); 745 _exits.set_map(_exits.clone_map());
739 _exits.set_all_memory(memphi); 760 _exits.set_all_memory(memphi);
740 761
741 // Add a return value to the exit state. (Do not push it yet.) 762 // Add a return value to the exit state. (Do not push it yet.)
742 if (tf()->range()->cnt() > TypeFunc::Parms) { 763 if (tf()->range()->cnt() > TypeFunc::Parms) {
743 const Type* ret_type = tf()->range()->field_at(TypeFunc::Parms); 764 const Type* ret_type = tf()->range()->field_at(TypeFunc::Parms);
765 if (ret_type->isa_int()) {
766 BasicType ret_bt = method()->return_type()->basic_type();
767 if (ret_bt == T_BOOLEAN ||
768 ret_bt == T_CHAR ||
769 ret_bt == T_BYTE ||
770 ret_bt == T_SHORT) {
771 ret_type = TypeInt::INT;
772 }
773 }
774
744 // Don't "bind" an unloaded return klass to the ret_phi. If the klass 775 // Don't "bind" an unloaded return klass to the ret_phi. If the klass
745 // becomes loaded during the subsequent parsing, the loaded and unloaded 776 // becomes loaded during the subsequent parsing, the loaded and unloaded
746 // types will not join when we transform and push in do_exits(). 777 // types will not join when we transform and push in do_exits().
747 const TypeOopPtr* ret_oop_type = ret_type->isa_oopptr(); 778 const TypeOopPtr* ret_oop_type = ret_type->isa_oopptr();
748 if (ret_oop_type && !ret_oop_type->klass()->is_loaded()) { 779 if (ret_oop_type && !ret_oop_type->klass()->is_loaded()) {
956 987
957 if (tf()->range()->cnt() > TypeFunc::Parms) { 988 if (tf()->range()->cnt() > TypeFunc::Parms) {
958 const Type* ret_type = tf()->range()->field_at(TypeFunc::Parms); 989 const Type* ret_type = tf()->range()->field_at(TypeFunc::Parms);
959 Node* ret_phi = _gvn.transform( _exits.argument(0) ); 990 Node* ret_phi = _gvn.transform( _exits.argument(0) );
960 assert(_exits.control()->is_top() || !_gvn.type(ret_phi)->empty(), "return value must be well defined"); 991 assert(_exits.control()->is_top() || !_gvn.type(ret_phi)->empty(), "return value must be well defined");
992 if (ret_type->isa_int()) {
993 BasicType ret_bt = method()->return_type()->basic_type();
994 ret_phi = mask_int_value(ret_phi, ret_bt, &_gvn);
995 }
961 _exits.push_node(ret_type->basic_type(), ret_phi); 996 _exits.push_node(ret_type->basic_type(), ret_phi);
962 } 997 }
963 998
964 // Note: Logic for creating and optimizing the ReturnNode is in Compile. 999 // Note: Logic for creating and optimizing the ReturnNode is in Compile.
965 1000

mercurial