24
25 #include "precompiled.hpp"
26 #include "gc/shared/c2/barrierSetC2.hpp"
27 #include "opto/arraycopynode.hpp"
28 #include "opto/graphKit.hpp"
29 #include "opto/idealKit.hpp"
30 #include "opto/narrowptrnode.hpp"
31 #include "utilities/macros.hpp"
32
33 // By default this is a no-op.
34 void BarrierSetC2::resolve_address(C2Access& access) const { }
35
36 void* C2Access::barrier_set_state() const {
37 return _kit->barrier_set_state();
38 }
39
40 bool C2Access::needs_cpu_membar() const {
41 bool mismatched = (_decorators & C2_MISMATCHED) != 0;
42 bool is_unordered = (_decorators & MO_UNORDERED) != 0;
43 bool anonymous = (_decorators & C2_UNSAFE_ACCESS) != 0;
44 bool on_heap = (_decorators & IN_HEAP) != 0;
45
46 bool is_write = (_decorators & C2_WRITE_ACCESS) != 0;
47 bool is_read = (_decorators & C2_READ_ACCESS) != 0;
48 bool is_atomic = is_read && is_write;
49
50 if (is_atomic) {
51 // Atomics always need to be wrapped in CPU membars
52 return true;
53 }
54
55 if (anonymous) {
56 // We will need memory barriers unless we can determine a unique
57 // alias category for this reference. (Note: If for some reason
58 // the barriers get omitted and the unsafe reference begins to "pollute"
59 // the alias analysis of the rest of the graph, either Compile::can_alias
60 // or Compile::must_alias will throw a diagnostic assert.)
61 if (!on_heap || !is_unordered || (mismatched && !_addr.type()->isa_aryptr())) {
62 return true;
63 }
64 }
65
66 return false;
67 }
68
69 Node* BarrierSetC2::store_at_resolved(C2Access& access, C2AccessValue& val) const {
70 DecoratorSet decorators = access.decorators();
71 GraphKit* kit = access.kit();
72
73 bool mismatched = (decorators & C2_MISMATCHED) != 0;
74 bool unaligned = (decorators & C2_UNALIGNED) != 0;
75 bool requires_atomic_access = (decorators & MO_UNORDERED) == 0;
76
77 bool in_native = (decorators & IN_NATIVE) != 0;
78 assert(!in_native, "not supported yet");
79
80 if (access.type() == T_DOUBLE) {
81 Node* new_val = kit->dstore_rounding(val.node());
|
24
25 #include "precompiled.hpp"
26 #include "gc/shared/c2/barrierSetC2.hpp"
27 #include "opto/arraycopynode.hpp"
28 #include "opto/graphKit.hpp"
29 #include "opto/idealKit.hpp"
30 #include "opto/narrowptrnode.hpp"
31 #include "utilities/macros.hpp"
32
33 // By default this is a no-op.
34 void BarrierSetC2::resolve_address(C2Access& access) const { }
35
36 void* C2Access::barrier_set_state() const {
37 return _kit->barrier_set_state();
38 }
39
40 bool C2Access::needs_cpu_membar() const {
41 bool mismatched = (_decorators & C2_MISMATCHED) != 0;
42 bool is_unordered = (_decorators & MO_UNORDERED) != 0;
43 bool anonymous = (_decorators & C2_UNSAFE_ACCESS) != 0;
44 bool in_heap = (_decorators & IN_HEAP) != 0;
45
46 bool is_write = (_decorators & C2_WRITE_ACCESS) != 0;
47 bool is_read = (_decorators & C2_READ_ACCESS) != 0;
48 bool is_atomic = is_read && is_write;
49
50 if (is_atomic) {
51 // Atomics always need to be wrapped in CPU membars
52 return true;
53 }
54
55 if (anonymous) {
56 // We will need memory barriers unless we can determine a unique
57 // alias category for this reference. (Note: If for some reason
58 // the barriers get omitted and the unsafe reference begins to "pollute"
59 // the alias analysis of the rest of the graph, either Compile::can_alias
60 // or Compile::must_alias will throw a diagnostic assert.)
61 if (!in_heap || !is_unordered || (mismatched && !_addr.type()->isa_aryptr())) {
62 return true;
63 }
64 }
65
66 return false;
67 }
68
69 Node* BarrierSetC2::store_at_resolved(C2Access& access, C2AccessValue& val) const {
70 DecoratorSet decorators = access.decorators();
71 GraphKit* kit = access.kit();
72
73 bool mismatched = (decorators & C2_MISMATCHED) != 0;
74 bool unaligned = (decorators & C2_UNALIGNED) != 0;
75 bool requires_atomic_access = (decorators & MO_UNORDERED) == 0;
76
77 bool in_native = (decorators & IN_NATIVE) != 0;
78 assert(!in_native, "not supported yet");
79
80 if (access.type() == T_DOUBLE) {
81 Node* new_val = kit->dstore_rounding(val.node());
|