28 #include "classfile/vmSymbols.hpp" |
28 #include "classfile/vmSymbols.hpp" |
29 #include "compiler/compileBroker.hpp" |
29 #include "compiler/compileBroker.hpp" |
30 #include "compiler/compileLog.hpp" |
30 #include "compiler/compileLog.hpp" |
31 #include "oops/objArrayKlass.hpp" |
31 #include "oops/objArrayKlass.hpp" |
32 #include "opto/addnode.hpp" |
32 #include "opto/addnode.hpp" |
|
33 #include "opto/arraycopynode.hpp" |
33 #include "opto/callGenerator.hpp" |
34 #include "opto/callGenerator.hpp" |
34 #include "opto/castnode.hpp" |
35 #include "opto/castnode.hpp" |
35 #include "opto/cfgnode.hpp" |
36 #include "opto/cfgnode.hpp" |
36 #include "opto/convertnode.hpp" |
37 #include "opto/convertnode.hpp" |
37 #include "opto/countbitsnode.hpp" |
38 #include "opto/countbitsnode.hpp" |
3874 // We know the copy is disjoint but we might not know if the |
3875 // We know the copy is disjoint but we might not know if the |
3875 // oop stores need checking. |
3876 // oop stores need checking. |
3876 // Extreme case: Arrays.copyOf((Integer[])x, 10, String[].class). |
3877 // Extreme case: Arrays.copyOf((Integer[])x, 10, String[].class). |
3877 // This will fail a store-check if x contains any non-nulls. |
3878 // This will fail a store-check if x contains any non-nulls. |
3878 |
3879 |
3879 Node* alloc = tightly_coupled_allocation(newcopy, NULL); |
3880 // ArrayCopyNode:Ideal may transform the ArrayCopyNode to |
3880 |
3881 // loads/stores but it is legal only if we're sure the |
3881 ArrayCopyNode* ac = ArrayCopyNode::make(this, true, original, start, newcopy, intcon(0), moved, alloc != NULL, |
3882 // Arrays.copyOf would succeed. So we need all input arguments |
|
3883 // to the copyOf to be validated, including that the copy to the |
|
3884 // new array won't trigger an ArrayStoreException. That subtype |
|
3885 // check can be optimized if we know something on the type of |
|
3886 // the input array from type speculation. |
|
3887 if (_gvn.type(klass_node)->singleton()) { |
|
3888 ciKlass* subk = _gvn.type(load_object_klass(original))->is_klassptr()->klass(); |
|
3889 ciKlass* superk = _gvn.type(klass_node)->is_klassptr()->klass(); |
|
3890 |
|
3891 int test = C->static_subtype_check(superk, subk); |
|
3892 if (test != Compile::SSC_always_true && test != Compile::SSC_always_false) { |
|
3893 const TypeOopPtr* t_original = _gvn.type(original)->is_oopptr(); |
|
3894 if (t_original->speculative_type() != NULL) { |
|
3895 original = maybe_cast_profiled_obj(original, t_original->speculative_type(), true); |
|
3896 } |
|
3897 } |
|
3898 } |
|
3899 |
|
3900 bool validated = false; |
|
3901 // Reason_class_check rather than Reason_intrinsic because we |
|
3902 // want to intrinsify even if this traps. |
|
3903 if (!too_many_traps(Deoptimization::Reason_class_check)) { |
|
3904 Node* not_subtype_ctrl = gen_subtype_check(load_object_klass(original), |
|
3905 klass_node); |
|
3906 |
|
3907 if (not_subtype_ctrl != top()) { |
|
3908 PreserveJVMState pjvms(this); |
|
3909 set_control(not_subtype_ctrl); |
|
3910 uncommon_trap(Deoptimization::Reason_class_check, |
|
3911 Deoptimization::Action_make_not_entrant); |
|
3912 assert(stopped(), "Should be stopped"); |
|
3913 } |
|
3914 validated = true; |
|
3915 } |
|
3916 |
|
3917 ArrayCopyNode* ac = ArrayCopyNode::make(this, true, original, start, newcopy, intcon(0), moved, true, |
3882 load_object_klass(original), klass_node); |
3918 load_object_klass(original), klass_node); |
3883 if (!is_copyOfRange) { |
3919 if (!is_copyOfRange) { |
3884 ac->set_copyof(); |
3920 ac->set_copyof(validated); |
3885 } else { |
3921 } else { |
3886 ac->set_copyofrange(); |
3922 ac->set_copyofrange(validated); |
3887 } |
3923 } |
3888 Node* n = _gvn.transform(ac); |
3924 Node* n = _gvn.transform(ac); |
3889 assert(n == ac, "cannot disappear"); |
3925 if (n == ac) { |
3890 ac->connect_outputs(this); |
3926 ac->connect_outputs(this); |
|
3927 } else { |
|
3928 assert(validated, "shouldn't transform if all arguments not validated"); |
|
3929 set_all_memory(n); |
|
3930 } |
3891 } |
3931 } |
3892 } // original reexecute is set back here |
3932 } // original reexecute is set back here |
3893 |
3933 |
3894 C->set_has_split_ifs(true); // Has chance for split-if optimization |
3934 C->set_has_split_ifs(true); // Has chance for split-if optimization |
3895 if (!stopped()) { |
3935 if (!stopped()) { |