Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Contributing to the JDK

...
Please see the [OpenJDK Developers' Guide](https://openjdk.org/guide/).
54 changes: 32 additions & 22 deletions src/hotspot/share/code/nmethod.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -268,26 +268,36 @@ class nmethod : public CodeBlob {
volatile signed char _state; // {not_installed, in_use, not_entrant}

public:
union Flags {
uint8_t _raw;
struct {
bool _has_unsafe_access:1; // May fault due to unsafe access.
bool _has_wide_vectors:1; // Preserve wide vectors at safepoints
bool _has_monitors:1; // Fastpath monitor detection for continuations
bool _has_scoped_access:1; // Used by shared scope closure (scopedMemoryAccess.cpp)
struct Flags {
uint8_t const _bits;

enum : uint8_t {
UNSAFE_ACCESS = 1 << 0,
WIDE_VECTORS = 1 << 1,
MONITORS = 1 << 2,
SCOPED_ACCESS = 1 << 3
};
Flags() {
_raw = 0;
}
Flags(bool has_unsafe_access, bool has_wide_vectors, bool has_monitors, bool has_scoped_access) : Flags() {
_has_unsafe_access = has_unsafe_access;
_has_wide_vectors = has_wide_vectors;
_has_monitors = has_monitors;
_has_scoped_access = has_scoped_access;
}
};

static_assert(sizeof(Flags) == sizeof(uint8_t), "Must fit exactly");
Flags() : _bits(0) {}
Flags(bool has_unsafe_access, bool has_wide_vectors, bool has_monitors, bool has_scoped_access) :
_bits((has_unsafe_access ? UNSAFE_ACCESS : 0) |
(has_wide_vectors ? WIDE_VECTORS : 0) |
(has_monitors ? MONITORS : 0) |
(has_scoped_access ? SCOPED_ACCESS : 0))
{}

// May fault due to unsafe access
bool has_unsafe_access() const { return (_bits & UNSAFE_ACCESS) != 0; }

// Preserve wide vectors at safepoints
bool has_wide_vectors() const { return (_bits & WIDE_VECTORS) != 0; }

// Fastpath monitor detection for continuations
bool has_monitors() const { return (_bits & MONITORS) != 0; }

// Used by shared scope closure (scopedMemoryAccess.cpp)
bool has_scoped_access() const { return (_bits & SCOPED_ACCESS) != 0; }
};

private:
// Persistent bits, set once during construction.
Expand Down Expand Up @@ -779,10 +789,10 @@ class nmethod : public CodeBlob {
template<typename T>
void set_gc_data(T* gc_data) { _gc_data = reinterpret_cast<void*>(gc_data); }

bool has_unsafe_access() const { return _flags._has_unsafe_access; }
bool has_monitors() const { return _flags._has_monitors; }
bool has_scoped_access() const { return _flags._has_scoped_access; }
bool has_wide_vectors() const { return _flags._has_wide_vectors; }
bool has_unsafe_access() const { return _flags.has_unsafe_access(); }
bool has_monitors() const { return _flags.has_monitors(); }
bool has_scoped_access() const { return _flags.has_scoped_access(); }
bool has_wide_vectors() const { return _flags.has_wide_vectors(); }

bool has_flushed_dependencies() const { return _has_flushed_dependencies; }
void set_has_flushed_dependencies(bool z) {
Expand Down
2 changes: 2 additions & 0 deletions src/hotspot/share/gc/shared/c2/barrierSetC2.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,8 @@ class BarrierSetC2: public CHeapObj<mtGC> {
virtual bool is_gc_pre_barrier_node(Node* node) const { return false; }
virtual bool is_gc_barrier_node(Node* node) const { return false; }
virtual Node* step_over_gc_barrier(Node* c) const { return c; }
// Allow barriers that depend on transitive inputs to be re-evaluated.
virtual void enqueue_dependent_gc_barriers(Unique_Node_List& worklist, Node* use) const {}

// Support for macro expanded GC barriers
virtual void register_potential_barrier_node(Node* node) const { }
Expand Down
30 changes: 30 additions & 0 deletions src/hotspot/share/gc/shenandoah/c2/shenandoahBarrierSetC2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -843,6 +843,36 @@ Node* ShenandoahBarrierSetC2::step_over_gc_barrier(Node* c) const {
return c;
}

static bool is_barrier_traversal_node(int op) {
// Node types that ShenandoahLoadReferenceBarrierNode::Identity traverses via needs_barrier_impl.
return op == Op_Phi || op == Op_DecodeN || op == Op_EncodeP || op == Op_CastPP ||
op == Op_CheckCastPP || op == Op_CMoveN || op == Op_CMoveP || op == Op_Proj;
}

void ShenandoahBarrierSetC2::enqueue_dependent_gc_barriers(Unique_Node_List& worklist, Node* n) const {
if (!is_barrier_traversal_node(n->Opcode())) {
return;
}
Unique_Node_List visited;
Unique_Node_List stack;
stack.push(n);
while (stack.size() > 0) {
Node* cur = stack.pop();
if (visited.member(cur)) {
continue;
}
visited.push(cur);
for (DUIterator_Fast imax, i = cur->fast_outs(imax); i < imax; i++) {
Node* u = cur->fast_out(i);
if (u->Opcode() == Op_ShenandoahLoadReferenceBarrier) {
worklist.push(u);
} else if (is_barrier_traversal_node(u->Opcode())) {
stack.push(u);
}
}
}
}

bool ShenandoahBarrierSetC2::expand_barriers(Compile* C, PhaseIterGVN& igvn) const {
return !ShenandoahBarrierC2Support::expand(C, igvn);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ class ShenandoahBarrierSetC2 : public BarrierSetC2 {
virtual bool is_gc_pre_barrier_node(Node* node) const;
virtual bool is_gc_barrier_node(Node* node) const;
virtual Node* step_over_gc_barrier(Node* c) const;
virtual void enqueue_dependent_gc_barriers(Unique_Node_List& worklist, Node* use) const;
virtual bool expand_barriers(Compile* C, PhaseIterGVN& igvn) const;
virtual bool optimize_loops(PhaseIdealLoop* phase, LoopOptsMode mode, VectorSet& visited, Node_Stack& nstack, Node_List& worklist) const;
virtual bool strip_mined_loops_expanded(LoopOptsMode mode) const { return mode == LoopOptsShenandoahExpand; }
Expand Down
5 changes: 5 additions & 0 deletions src/hotspot/share/opto/phaseX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2797,6 +2797,11 @@ void PhaseIterGVN::add_users_of_use_to_worklist(Node* n, Node* use, Unique_Node_
add_users_to_worklist_if(worklist, use, [](Node* u) { return u->Opcode() == Op_VectorMaskToLong; });
}

// Allow GC to enqueue barriers that depend on transitive inputs
if (has_load_barrier_nodes) {
bs->enqueue_dependent_gc_barriers(worklist, use);
}

// From CastX2PNode::Ideal
// CastX2P(AddX(x, y))
// CastX2P(SubX(x, y))
Expand Down
Loading