Skip to content

Commit

Permalink
8255019: Shenandoah: Split STW and concurrent mark into separate classes
Browse files Browse the repository at this point in the history
Reviewed-by: rkennke, shade
  • Loading branch information
zhengyu123 committed Jan 14, 2021
1 parent aba3431 commit da6bcf9
Show file tree
Hide file tree
Showing 20 changed files with 932 additions and 620 deletions.
421 changes: 89 additions & 332 deletions src/hotspot/share/gc/shenandoah/shenandoahConcurrentMark.cpp

Large diffs are not rendered by default.

69 changes: 19 additions & 50 deletions src/hotspot/share/gc/shenandoah/shenandoahConcurrentMark.hpp
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2013, 2020, Red Hat, Inc. All rights reserved.
* Copyright (c) 2013, 2021, Red Hat, Inc. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -27,69 +27,38 @@

#include "gc/shared/taskqueue.hpp"
#include "gc/shared/taskTerminator.hpp"
#include "gc/shenandoah/shenandoahMark.hpp"
#include "gc/shenandoah/shenandoahOopClosures.hpp"
#include "gc/shenandoah/shenandoahPhaseTimings.hpp"
#include "gc/shenandoah/shenandoahTaskqueue.hpp"

class ShenandoahStrDedupQueue;
class ShenandoahReferenceProcessor;

class ShenandoahConcurrentMark: public CHeapObj<mtGC> {
private:
ShenandoahHeap* _heap;
ShenandoahObjToScanQueueSet* _task_queues;
class ShenandoahConcurrentMark: public ShenandoahMark {
friend class ShenandoahConcurrentMarkingTask;
friend class ShenandoahFinalMarkingTask;

public:
void initialize(uint workers);
void cancel();

// ---------- Marking loop and tasks
//
private:
template <class T>
inline void do_task(ShenandoahObjToScanQueue* q, T* cl, ShenandoahLiveData* live_data, ShenandoahMarkTask* task);
ShenandoahConcurrentMark();

template <class T>
inline void do_chunked_array_start(ShenandoahObjToScanQueue* q, T* cl, oop array, bool weak);
// When concurrent stack processing is not supported
void mark_stw_roots();
void mark_concurrent_roots();

template <class T>
inline void do_chunked_array(ShenandoahObjToScanQueue* q, T* cl, oop array, int chunk, int pow, bool weak);
// Concurrent mark
void concurrent_mark();
// Finish mark at a safepoint
void finish_mark();

inline void count_liveness(ShenandoahLiveData* live_data, oop obj);

template <class T, bool CANCELLABLE>
void mark_loop_work(T* cl, ShenandoahLiveData* live_data, uint worker_id, TaskTerminator *t);

template <bool CANCELLABLE>
void mark_loop_prework(uint worker_id, TaskTerminator *terminator, ShenandoahReferenceProcessor* rp, bool strdedup);

public:
void mark_loop(uint worker_id, TaskTerminator* terminator, ShenandoahReferenceProcessor* rp,
bool cancellable, bool strdedup) {
if (cancellable) {
mark_loop_prework<true>(worker_id, terminator, rp, strdedup);
} else {
mark_loop_prework<false>(worker_id, terminator, rp, strdedup);
}
}
static void cancel();

template<class T, UpdateRefsMode UPDATE_REFS, StringDedupMode STRING_DEDUP>
static inline void mark_through_ref(T* p, ShenandoahHeap* heap, ShenandoahObjToScanQueue* q, ShenandoahMarkingContext* const mark_context, bool weak);

void mark_from_roots();
void finish_mark_from_roots(bool full_gc);

void mark_roots(ShenandoahPhaseTimings::Phase root_phase);
void update_roots(ShenandoahPhaseTimings::Phase root_phase);
void update_thread_roots(ShenandoahPhaseTimings::Phase root_phase);

// ---------- Helpers
// Used from closures, need to be public
//
public:
ShenandoahObjToScanQueue* get_queue(uint worker_id);
ShenandoahObjToScanQueueSet* task_queues() { return _task_queues; }
// TODO: where to put them
static void update_roots(ShenandoahPhaseTimings::Phase root_phase);
static void update_thread_roots(ShenandoahPhaseTimings::Phase root_phase);

private:
void finish_mark_work();
};

#endif // SHARE_GC_SHENANDOAH_SHENANDOAHCONCURRENTMARK_HPP
9 changes: 7 additions & 2 deletions src/hotspot/share/gc/shenandoah/shenandoahControlThread.cpp
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2013, 2020, Red Hat, Inc. All rights reserved.
* Copyright (c) 2013, 2021, Red Hat, Inc. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand All @@ -24,12 +24,13 @@

#include "precompiled.hpp"

#include "gc/shenandoah/shenandoahConcurrentMark.inline.hpp"
#include "gc/shenandoah/shenandoahConcurrentMark.hpp"
#include "gc/shenandoah/shenandoahCollectorPolicy.hpp"
#include "gc/shenandoah/shenandoahControlThread.hpp"
#include "gc/shenandoah/shenandoahFreeSet.hpp"
#include "gc/shenandoah/shenandoahPhaseTimings.hpp"
#include "gc/shenandoah/shenandoahHeap.inline.hpp"
#include "gc/shenandoah/shenandoahMark.inline.hpp"
#include "gc/shenandoah/shenandoahMonitoringSupport.hpp"
#include "gc/shenandoah/shenandoahRootProcessor.inline.hpp"
#include "gc/shenandoah/shenandoahUtils.hpp"
Expand Down Expand Up @@ -397,6 +398,10 @@ void ShenandoahControlThread::service_concurrent_normal_cycle(GCCause::Cause cau
// Start initial mark under STW
heap->vmop_entry_init_mark();

// Concurrent mark roots
heap->entry_mark_roots();
if (check_cancellation_or_degen(ShenandoahHeap::_degenerated_outside_cycle)) return;

// Continue concurrent mark
heap->entry_mark();
if (check_cancellation_or_degen(ShenandoahHeap::_degenerated_mark)) return;
Expand Down

1 comment on commit da6bcf9

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.