26 #include "ci/ciUtilities.hpp"
27 #include "compiler/compileLog.hpp"
28 #include "gc/shared/barrierSet.hpp"
29 #include "gc/shared/c2/barrierSetC2.hpp"
30 #include "interpreter/interpreter.hpp"
31 #include "memory/resourceArea.hpp"
32 #include "opto/addnode.hpp"
33 #include "opto/castnode.hpp"
34 #include "opto/convertnode.hpp"
35 #include "opto/graphKit.hpp"
36 #include "opto/idealKit.hpp"
37 #include "opto/intrinsicnode.hpp"
38 #include "opto/locknode.hpp"
39 #include "opto/machnode.hpp"
40 #include "opto/opaquenode.hpp"
41 #include "opto/parse.hpp"
42 #include "opto/rootnode.hpp"
43 #include "opto/runtime.hpp"
44 #include "runtime/deoptimization.hpp"
45 #include "runtime/sharedRuntime.hpp"
46
47 //----------------------------GraphKit-----------------------------------------
48 // Main utility constructor.
49 GraphKit::GraphKit(JVMState* jvms)
50 : Phase(Phase::Parser),
51 _env(C->env()),
52 _gvn(*C->initial_gvn()),
53 _barrier_set(BarrierSet::barrier_set()->barrier_set_c2())
54 {
55 _exceptions = jvms->map()->next_exception();
56 if (_exceptions != NULL) jvms->map()->set_next_exception(NULL);
57 set_jvms(jvms);
58 }
59
60 // Private constructor for parser.
61 GraphKit::GraphKit()
62 : Phase(Phase::Parser),
63 _env(C->env()),
64 _gvn(*C->initial_gvn()),
65 _barrier_set(BarrierSet::barrier_set()->barrier_set_c2())
3721 Node* ccast = alloc->make_ideal_length(ary_type, &_gvn);
3722 if (ccast != length) {
3723 _gvn.set_type_bottom(ccast);
3724 record_for_igvn(ccast);
3725 replace_in_map(length, ccast);
3726 }
3727 }
3728
3729 return javaoop;
3730 }
3731
3732 // The following "Ideal_foo" functions are placed here because they recognize
3733 // the graph shapes created by the functions immediately above.
3734
3735 //---------------------------Ideal_allocation----------------------------------
3736 // Given an oop pointer or raw pointer, see if it feeds from an AllocateNode.
3737 AllocateNode* AllocateNode::Ideal_allocation(Node* ptr, PhaseTransform* phase) {
3738 if (ptr == NULL) { // reduce dumb test in callers
3739 return NULL;
3740 }
3741 if (ptr->is_CheckCastPP()) { // strip only one raw-to-oop cast
3742 ptr = ptr->in(1);
3743 if (ptr == NULL) return NULL;
3744 }
3745 // Return NULL for allocations with several casts:
3746 // j.l.reflect.Array.newInstance(jobject, jint)
3747 // Object.clone()
3748 // to keep more precise type from last cast.
3749 if (ptr->is_Proj()) {
3750 Node* allo = ptr->in(0);
3751 if (allo != NULL && allo->is_Allocate()) {
3752 return allo->as_Allocate();
3753 }
3754 }
3755 // Report failure to match.
3756 return NULL;
3757 }
3758
3759 // Fancy version which also strips off an offset (and reports it to caller).
3760 AllocateNode* AllocateNode::Ideal_allocation(Node* ptr, PhaseTransform* phase,
|
26 #include "ci/ciUtilities.hpp"
27 #include "compiler/compileLog.hpp"
28 #include "gc/shared/barrierSet.hpp"
29 #include "gc/shared/c2/barrierSetC2.hpp"
30 #include "interpreter/interpreter.hpp"
31 #include "memory/resourceArea.hpp"
32 #include "opto/addnode.hpp"
33 #include "opto/castnode.hpp"
34 #include "opto/convertnode.hpp"
35 #include "opto/graphKit.hpp"
36 #include "opto/idealKit.hpp"
37 #include "opto/intrinsicnode.hpp"
38 #include "opto/locknode.hpp"
39 #include "opto/machnode.hpp"
40 #include "opto/opaquenode.hpp"
41 #include "opto/parse.hpp"
42 #include "opto/rootnode.hpp"
43 #include "opto/runtime.hpp"
44 #include "runtime/deoptimization.hpp"
45 #include "runtime/sharedRuntime.hpp"
46 #include "utilities/macros.hpp"
47 #if INCLUDE_SHENANDOAHGC
48 #include "gc/shenandoah/c2/shenandoahBarrierSetC2.hpp"
49 #endif
50
51 //----------------------------GraphKit-----------------------------------------
52 // Main utility constructor.
53 GraphKit::GraphKit(JVMState* jvms)
54 : Phase(Phase::Parser),
55 _env(C->env()),
56 _gvn(*C->initial_gvn()),
57 _barrier_set(BarrierSet::barrier_set()->barrier_set_c2())
58 {
59 _exceptions = jvms->map()->next_exception();
60 if (_exceptions != NULL) jvms->map()->set_next_exception(NULL);
61 set_jvms(jvms);
62 }
63
64 // Private constructor for parser.
65 GraphKit::GraphKit()
66 : Phase(Phase::Parser),
67 _env(C->env()),
68 _gvn(*C->initial_gvn()),
69 _barrier_set(BarrierSet::barrier_set()->barrier_set_c2())
3725 Node* ccast = alloc->make_ideal_length(ary_type, &_gvn);
3726 if (ccast != length) {
3727 _gvn.set_type_bottom(ccast);
3728 record_for_igvn(ccast);
3729 replace_in_map(length, ccast);
3730 }
3731 }
3732
3733 return javaoop;
3734 }
3735
3736 // The following "Ideal_foo" functions are placed here because they recognize
3737 // the graph shapes created by the functions immediately above.
3738
3739 //---------------------------Ideal_allocation----------------------------------
3740 // Given an oop pointer or raw pointer, see if it feeds from an AllocateNode.
3741 AllocateNode* AllocateNode::Ideal_allocation(Node* ptr, PhaseTransform* phase) {
3742 if (ptr == NULL) { // reduce dumb test in callers
3743 return NULL;
3744 }
3745
3746 #if INCLUDE_SHENANDOAHGC
3747 if (UseShenandoahGC) {
3748 BarrierSetC2* bs = BarrierSet::barrier_set()->barrier_set_c2();
3749 ptr = bs->step_over_gc_barrier(ptr);
3750 }
3751 #endif
3752
3753 if (ptr->is_CheckCastPP()) { // strip only one raw-to-oop cast
3754 ptr = ptr->in(1);
3755 if (ptr == NULL) return NULL;
3756 }
3757 // Return NULL for allocations with several casts:
3758 // j.l.reflect.Array.newInstance(jobject, jint)
3759 // Object.clone()
3760 // to keep more precise type from last cast.
3761 if (ptr->is_Proj()) {
3762 Node* allo = ptr->in(0);
3763 if (allo != NULL && allo->is_Allocate()) {
3764 return allo->as_Allocate();
3765 }
3766 }
3767 // Report failure to match.
3768 return NULL;
3769 }
3770
3771 // Fancy version which also strips off an offset (and reports it to caller).
3772 AllocateNode* AllocateNode::Ideal_allocation(Node* ptr, PhaseTransform* phase,
|