comparison src/share/vm/opto/memnode.cpp @ 23055:c1c199dde5c9

8077504: Unsafe load can loose control dependency and cause crash Summary: Node::depends_only_on_test() should return false for Unsafe loads Reviewed-by: kvn, adinn
author roland
date Wed, 03 Jun 2015 14:22:57 +0200
parents 55d07ec5bde4
children dd9cc155639c 32b682649973
comparison
equal deleted inserted replaced
23054:55d07ec5bde4 23055:c1c199dde5c9
876 MemNode::dump_spec(st); 876 MemNode::dump_spec(st);
877 if( !Verbose && !WizardMode ) { 877 if( !Verbose && !WizardMode ) {
878 // standard dump does this in Verbose and WizardMode 878 // standard dump does this in Verbose and WizardMode
879 st->print(" #"); _type->dump_on(st); 879 st->print(" #"); _type->dump_on(st);
880 } 880 }
881 if (!_depends_only_on_test) {
882 st->print(" (does not depend only on test)");
883 }
881 } 884 }
882 #endif 885 #endif
883 886
884 #ifdef ASSERT 887 #ifdef ASSERT
885 //----------------------------is_immutable_value------------------------------- 888 //----------------------------is_immutable_value-------------------------------
892 } 895 }
893 #endif 896 #endif
894 897
895 //----------------------------LoadNode::make----------------------------------- 898 //----------------------------LoadNode::make-----------------------------------
896 // Polymorphic factory method: 899 // Polymorphic factory method:
897 Node *LoadNode::make(PhaseGVN& gvn, Node *ctl, Node *mem, Node *adr, const TypePtr* adr_type, const Type *rt, BasicType bt, MemOrd mo) { 900 Node *LoadNode::make(PhaseGVN& gvn, Node *ctl, Node *mem, Node *adr, const TypePtr* adr_type, const Type *rt, BasicType bt, MemOrd mo, ControlDependency control_dependency) {
898 Compile* C = gvn.C; 901 Compile* C = gvn.C;
899 902
900 // sanity check the alias category against the created node type 903 // sanity check the alias category against the created node type
901 assert(!(adr_type->isa_oopptr() && 904 assert(!(adr_type->isa_oopptr() &&
902 adr_type->offset() == oopDesc::klass_offset_in_bytes()), 905 adr_type->offset() == oopDesc::klass_offset_in_bytes()),
908 assert( ctl != NULL || C->get_alias_index(adr_type) != Compile::AliasIdxRaw || 911 assert( ctl != NULL || C->get_alias_index(adr_type) != Compile::AliasIdxRaw ||
909 // oop will be recorded in oop map if load crosses safepoint 912 // oop will be recorded in oop map if load crosses safepoint
910 rt->isa_oopptr() || is_immutable_value(adr), 913 rt->isa_oopptr() || is_immutable_value(adr),
911 "raw memory operations should have control edge"); 914 "raw memory operations should have control edge");
912 switch (bt) { 915 switch (bt) {
913 case T_BOOLEAN: return new (C) LoadUBNode(ctl, mem, adr, adr_type, rt->is_int(), mo); 916 case T_BOOLEAN: return new (C) LoadUBNode(ctl, mem, adr, adr_type, rt->is_int(), mo, control_dependency);
914 case T_BYTE: return new (C) LoadBNode (ctl, mem, adr, adr_type, rt->is_int(), mo); 917 case T_BYTE: return new (C) LoadBNode (ctl, mem, adr, adr_type, rt->is_int(), mo, control_dependency);
915 case T_INT: return new (C) LoadINode (ctl, mem, adr, adr_type, rt->is_int(), mo); 918 case T_INT: return new (C) LoadINode (ctl, mem, adr, adr_type, rt->is_int(), mo, control_dependency);
916 case T_CHAR: return new (C) LoadUSNode(ctl, mem, adr, adr_type, rt->is_int(), mo); 919 case T_CHAR: return new (C) LoadUSNode(ctl, mem, adr, adr_type, rt->is_int(), mo, control_dependency);
917 case T_SHORT: return new (C) LoadSNode (ctl, mem, adr, adr_type, rt->is_int(), mo); 920 case T_SHORT: return new (C) LoadSNode (ctl, mem, adr, adr_type, rt->is_int(), mo, control_dependency);
918 case T_LONG: return new (C) LoadLNode (ctl, mem, adr, adr_type, rt->is_long(), mo); 921 case T_LONG: return new (C) LoadLNode (ctl, mem, adr, adr_type, rt->is_long(), mo, control_dependency);
919 case T_FLOAT: return new (C) LoadFNode (ctl, mem, adr, adr_type, rt, mo); 922 case T_FLOAT: return new (C) LoadFNode (ctl, mem, adr, adr_type, rt, mo, control_dependency);
920 case T_DOUBLE: return new (C) LoadDNode (ctl, mem, adr, adr_type, rt, mo); 923 case T_DOUBLE: return new (C) LoadDNode (ctl, mem, adr, adr_type, rt, mo, control_dependency);
921 case T_ADDRESS: return new (C) LoadPNode (ctl, mem, adr, adr_type, rt->is_ptr(), mo); 924 case T_ADDRESS: return new (C) LoadPNode (ctl, mem, adr, adr_type, rt->is_ptr(), mo, control_dependency);
922 case T_OBJECT: 925 case T_OBJECT:
923 #ifdef _LP64 926 #ifdef _LP64
924 if (adr->bottom_type()->is_ptr_to_narrowoop()) { 927 if (adr->bottom_type()->is_ptr_to_narrowoop()) {
925 Node* load = gvn.transform(new (C) LoadNNode(ctl, mem, adr, adr_type, rt->make_narrowoop(), mo)); 928 Node* load = gvn.transform(new (C) LoadNNode(ctl, mem, adr, adr_type, rt->make_narrowoop(), mo, control_dependency));
926 return new (C) DecodeNNode(load, load->bottom_type()->make_ptr()); 929 return new (C) DecodeNNode(load, load->bottom_type()->make_ptr());
927 } else 930 } else
928 #endif 931 #endif
929 { 932 {
930 assert(!adr->bottom_type()->is_ptr_to_narrowoop() && !adr->bottom_type()->is_ptr_to_narrowklass(), "should have got back a narrow oop"); 933 assert(!adr->bottom_type()->is_ptr_to_narrowoop() && !adr->bottom_type()->is_ptr_to_narrowklass(), "should have got back a narrow oop");
931 return new (C) LoadPNode(ctl, mem, adr, adr_type, rt->is_oopptr(), mo); 934 return new (C) LoadPNode(ctl, mem, adr, adr_type, rt->is_oopptr(), mo, control_dependency);
932 } 935 }
933 } 936 }
934 ShouldNotReachHere(); 937 ShouldNotReachHere();
935 return (LoadNode*)NULL; 938 return (LoadNode*)NULL;
936 } 939 }
937 940
938 LoadLNode* LoadLNode::make_atomic(Compile *C, Node* ctl, Node* mem, Node* adr, const TypePtr* adr_type, const Type* rt, MemOrd mo) { 941 LoadLNode* LoadLNode::make_atomic(Compile *C, Node* ctl, Node* mem, Node* adr, const TypePtr* adr_type, const Type* rt, MemOrd mo, ControlDependency control_dependency) {
939 bool require_atomic = true; 942 bool require_atomic = true;
940 return new (C) LoadLNode(ctl, mem, adr, adr_type, rt->is_long(), mo, require_atomic); 943 return new (C) LoadLNode(ctl, mem, adr, adr_type, rt->is_long(), mo, control_dependency, require_atomic);
941 } 944 }
942 945
943 LoadDNode* LoadDNode::make_atomic(Compile *C, Node* ctl, Node* mem, Node* adr, const TypePtr* adr_type, const Type* rt, MemOrd mo) { 946 LoadDNode* LoadDNode::make_atomic(Compile *C, Node* ctl, Node* mem, Node* adr, const TypePtr* adr_type, const Type* rt, MemOrd mo, ControlDependency control_dependency) {
944 bool require_atomic = true; 947 bool require_atomic = true;
945 return new (C) LoadDNode(ctl, mem, adr, adr_type, rt, mo, require_atomic); 948 return new (C) LoadDNode(ctl, mem, adr, adr_type, rt, mo, control_dependency, require_atomic);
946 } 949 }
947 950
948 951
949 952
950 //------------------------------hash------------------------------------------- 953 //------------------------------hash-------------------------------------------