src/share/vm/opto/escape.cpp

changeset 1219
b2934faac289
parent 1040
98cb887364d3
child 1279
bd02caa94611
child 1286
fc4be448891f
equal deleted inserted replaced
1218:a9e116455022 1219:b2934faac289
903 PointsToNode::EscapeState es = escape_state(alloc, igvn); 903 PointsToNode::EscapeState es = escape_state(alloc, igvn);
904 // We have an allocation or call which returns a Java object, 904 // We have an allocation or call which returns a Java object,
905 // see if it is unescaped. 905 // see if it is unescaped.
906 if (es != PointsToNode::NoEscape || !ptn->_scalar_replaceable) 906 if (es != PointsToNode::NoEscape || !ptn->_scalar_replaceable)
907 continue; 907 continue;
908 if (alloc->is_Allocate()) { 908
909 // Set the scalar_replaceable flag before the next check. 909 // Find CheckCastPP for the allocate or for the return value of a call
910 alloc->as_Allocate()->_is_scalar_replaceable = true;
911 }
912 // find CheckCastPP of call return value
913 n = alloc->result_cast(); 910 n = alloc->result_cast();
914 if (n == NULL || // No uses accept Initialize or 911 if (n == NULL) { // No uses except Initialize node
915 !n->is_CheckCastPP()) // not unique CheckCastPP. 912 if (alloc->is_Allocate()) {
913 // Set the scalar_replaceable flag for allocation
914 // so it could be eliminated if it has no uses.
915 alloc->as_Allocate()->_is_scalar_replaceable = true;
916 }
916 continue; 917 continue;
918 }
919 if (!n->is_CheckCastPP()) { // not unique CheckCastPP.
920 assert(!alloc->is_Allocate(), "allocation should have unique type");
921 continue;
922 }
923
917 // The inline code for Object.clone() casts the allocation result to 924 // The inline code for Object.clone() casts the allocation result to
918 // java.lang.Object and then to the actual type of the allocated 925 // java.lang.Object and then to the actual type of the allocated
919 // object. Detect this case and use the second cast. 926 // object. Detect this case and use the second cast.
920 // Also detect j.l.reflect.Array.newInstance(jobject, jint) case when 927 // Also detect j.l.reflect.Array.newInstance(jobject, jint) case when
921 // the allocation result is cast to java.lang.Object and then 928 // the allocation result is cast to java.lang.Object and then
932 } 939 }
933 } 940 }
934 if (cast2 != NULL) { 941 if (cast2 != NULL) {
935 n = cast2; 942 n = cast2;
936 } else { 943 } else {
944 // Non-scalar replaceable if the allocation type is unknown statically
945 // (reflection allocation), the object can't be restored during
946 // deoptimization without precise type.
937 continue; 947 continue;
938 } 948 }
949 }
950 if (alloc->is_Allocate()) {
951 // Set the scalar_replaceable flag for allocation
952 // so it could be eliminated.
953 alloc->as_Allocate()->_is_scalar_replaceable = true;
939 } 954 }
940 set_escape_state(n->_idx, es); 955 set_escape_state(n->_idx, es);
941 // in order for an object to be scalar-replaceable, it must be: 956 // in order for an object to be scalar-replaceable, it must be:
942 // - a direct allocation (not a call returning an object) 957 // - a direct allocation (not a call returning an object)
943 // - non-escaping 958 // - non-escaping

mercurial