Skip to content

Commit ab72613

Browse files
committed
Merge remote-tracking branch 'upstream/jdk/master' into jdk-macos
2 parents 07a499c + b955f85 commit ab72613

82 files changed

Lines changed: 887 additions & 571 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/hotspot/share/classfile/classLoaderStats.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2014, 2020, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2014, 2021, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -30,7 +30,7 @@
3030
#include "oops/klass.hpp"
3131
#include "oops/oop.hpp"
3232
#include "oops/oopsHierarchy.hpp"
33-
#include "runtime/vmOperations.hpp"
33+
#include "runtime/vmOperation.hpp"
3434
#include "services/diagnosticCommand.hpp"
3535
#include "utilities/resourceHash.hpp"
3636

src/hotspot/share/code/debugInfo.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,11 +159,11 @@ void ObjectValue::read_object(DebugInfoReadStream* stream) {
159159
}
160160

161161
void ObjectValue::write_on(DebugInfoWriteStream* stream) {
162-
if (_visited) {
162+
if (is_visited()) {
163163
stream->write_int(OBJECT_ID_CODE);
164164
stream->write_int(_id);
165165
} else {
166-
_visited = true;
166+
set_visited(true);
167167
stream->write_int(is_auto_box() ? AUTO_BOX_OBJECT_CODE : OBJECT_CODE);
168168
stream->write_int(_id);
169169
_klass->write_on(stream);

src/hotspot/share/code/debugInfo.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -149,7 +149,7 @@ class ObjectValue: public ScopeValue {
149149
bool is_visited() const { return _visited; }
150150

151151
void set_value(oop value);
152-
void set_visited(bool visited) { _visited = false; }
152+
void set_visited(bool visited) { _visited = visited; }
153153

154154
// Serialization of debugging information
155155
void read_object(DebugInfoReadStream* stream);

src/hotspot/share/code/icBuffer.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -38,6 +38,7 @@
3838
#include "runtime/mutexLocker.hpp"
3939
#include "runtime/stubRoutines.hpp"
4040
#include "runtime/thread.inline.hpp"
41+
#include "runtime/vmOperations.hpp"
4142

4243
DEF_STUB_INTERFACE(ICStub);
4344

src/hotspot/share/compiler/compileBroker.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@
6464
#include "runtime/safepointVerifiers.hpp"
6565
#include "runtime/sharedRuntime.hpp"
6666
#include "runtime/sweeper.hpp"
67+
#include "runtime/threadSMR.hpp"
6768
#include "runtime/timerTrace.hpp"
6869
#include "runtime/vframe.inline.hpp"
6970
#include "utilities/debug.hpp"

src/hotspot/share/gc/g1/g1RootProcessor.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ void G1RootProcessor::evacuate_roots(G1ParScanThreadState* pss, uint worker_id)
7575
}
7676

7777
// CodeCache is already processed in java roots
78-
_process_strong_tasks.all_tasks_completed(n_workers(), G1RP_PS_CodeCache_oops_do);
78+
_process_strong_tasks.all_tasks_claimed(G1RP_PS_CodeCache_oops_do);
7979
}
8080

8181
// Adaptor to pass the closures to the strong roots in the VM.
@@ -106,9 +106,8 @@ void G1RootProcessor::process_strong_roots(OopClosure* oops,
106106

107107
// CodeCache is already processed in java roots
108108
// refProcessor is not needed since we are inside a safe point
109-
_process_strong_tasks.all_tasks_completed(n_workers(),
110-
G1RP_PS_CodeCache_oops_do,
111-
G1RP_PS_refProcessor_oops_do);
109+
_process_strong_tasks.all_tasks_claimed(G1RP_PS_CodeCache_oops_do,
110+
G1RP_PS_refProcessor_oops_do);
112111
}
113112

114113
// Adaptor to pass the closures to all the roots in the VM.
@@ -144,7 +143,7 @@ void G1RootProcessor::process_all_roots(OopClosure* oops,
144143
process_code_cache_roots(blobs, NULL, 0);
145144

146145
// refProcessor is not needed since we are inside a safe point
147-
_process_strong_tasks.all_tasks_completed(n_workers(), G1RP_PS_refProcessor_oops_do);
146+
_process_strong_tasks.all_tasks_claimed(G1RP_PS_refProcessor_oops_do);
148147
}
149148

150149
void G1RootProcessor::process_java_roots(G1RootClosures* closures,

src/hotspot/share/gc/shared/gcVMOperations.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
#include "prims/jvmtiExport.hpp"
3232
#include "runtime/handles.hpp"
3333
#include "runtime/synchronizer.hpp"
34-
#include "runtime/vmOperations.hpp"
34+
#include "runtime/vmOperation.hpp"
3535

3636
// The following class hierarchy represents
3737
// a set of operations (VM_Operation) related to GC.

src/hotspot/share/gc/shared/referenceProcessor.hpp

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -601,28 +601,6 @@ class ReferenceProcessorAtomicMutator: StackObj {
601601
}
602602
};
603603

604-
605-
// A utility class to temporarily change the MT processing
606-
// disposition of the given ReferenceProcessor instance
607-
// in the scope that contains it.
608-
class ReferenceProcessorMTProcMutator: StackObj {
609-
private:
610-
ReferenceProcessor* _rp;
611-
bool _saved_mt;
612-
613-
public:
614-
ReferenceProcessorMTProcMutator(ReferenceProcessor* rp,
615-
bool mt):
616-
_rp(rp) {
617-
_saved_mt = _rp->processing_is_mt();
618-
_rp->set_mt_processing(mt);
619-
}
620-
621-
~ReferenceProcessorMTProcMutator() {
622-
_rp->set_mt_processing(_saved_mt);
623-
}
624-
};
625-
626604
// This class is an interface used to implement task execution for the
627605
// reference processing.
628606
class AbstractRefProcTaskExecutor {

src/hotspot/share/gc/shared/workgroup.cpp

Lines changed: 8 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -352,26 +352,19 @@ void WorkGangBarrierSync::abort() {
352352
// SubTasksDone functions.
353353

354354
SubTasksDone::SubTasksDone(uint n) :
355-
_tasks(NULL), _n_tasks(n), _threads_completed(0) {
355+
_tasks(NULL), _n_tasks(n) {
356356
_tasks = NEW_C_HEAP_ARRAY(bool, n, mtInternal);
357-
clear();
358-
}
359-
360-
bool SubTasksDone::valid() {
361-
return _tasks != NULL;
362-
}
363-
364-
void SubTasksDone::clear() {
365357
for (uint i = 0; i < _n_tasks; i++) {
366358
_tasks[i] = false;
367359
}
368-
_threads_completed = 0;
369360
}
370361

371-
void SubTasksDone::all_tasks_completed_impl(uint n_threads,
372-
uint skipped[],
373-
size_t skipped_size) {
374362
#ifdef ASSERT
363+
void SubTasksDone::all_tasks_claimed_impl(uint skipped[], size_t skipped_size) {
364+
if (Atomic::cmpxchg(&_verification_done, false, true)) {
365+
// another thread has done the verification
366+
return;
367+
}
375368
// all non-skipped tasks are claimed
376369
for (uint i = 0; i < _n_tasks; ++i) {
377370
if (!_tasks[i]) {
@@ -391,26 +384,16 @@ void SubTasksDone::all_tasks_completed_impl(uint n_threads,
391384
assert(task_index < _n_tasks, "Array in range.");
392385
assert(!_tasks[task_index], "%d is both claimed and skipped.", task_index);
393386
}
394-
#endif
395-
uint observed = _threads_completed;
396-
uint old;
397-
do {
398-
old = observed;
399-
observed = Atomic::cmpxchg(&_threads_completed, old, old+1);
400-
} while (observed != old);
401-
// If this was the last thread checking in, clear the tasks.
402-
uint adjusted_thread_count = (n_threads == 0 ? 1 : n_threads);
403-
if (observed + 1 == adjusted_thread_count) {
404-
clear();
405-
}
406387
}
388+
#endif
407389

408390
bool SubTasksDone::try_claim_task(uint t) {
409391
assert(t < _n_tasks, "bad task id.");
410392
return !_tasks[t] && !Atomic::cmpxchg(&_tasks[t], false, true);
411393
}
412394

413395
SubTasksDone::~SubTasksDone() {
396+
assert(_verification_done, "all_tasks_claimed must have been called.");
414397
FREE_C_HEAP_ARRAY(bool, _tasks);
415398
}
416399

src/hotspot/share/gc/shared/workgroup.hpp

Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -305,24 +305,18 @@ class WorkGangBarrierSync : public StackObj {
305305
class SubTasksDone: public CHeapObj<mtInternal> {
306306
volatile bool* _tasks;
307307
uint _n_tasks;
308-
volatile uint _threads_completed;
309308

310-
// Set all tasks to unclaimed.
311-
void clear();
312-
313-
void all_tasks_completed_impl(uint n_threads, uint skipped[], size_t skipped_size);
309+
// make sure verification logic is run exactly once to avoid duplicate assertion failures
310+
DEBUG_ONLY(volatile bool _verification_done = false;)
311+
void all_tasks_claimed_impl(uint skipped[], size_t skipped_size) NOT_DEBUG_RETURN;
314312

315313
NONCOPYABLE(SubTasksDone);
316314

317315
public:
318316
// Initializes "this" to a state in which there are "n" tasks to be
319-
// processed, none of the which are originally claimed. The number of
320-
// threads doing the tasks is initialized 1.
317+
// processed, none of the which are originally claimed.
321318
SubTasksDone(uint n);
322319

323-
// True iff the object is in a valid state.
324-
bool valid();
325-
326320
// Attempt to claim the task "t", returning true if successful,
327321
// false if it has already been claimed. The task "t" is required
328322
// to be within the range of "this".
@@ -331,21 +325,17 @@ class SubTasksDone: public CHeapObj<mtInternal> {
331325
// The calling thread asserts that it has attempted to claim all the tasks
332326
// that it will try to claim. Tasks that are meant to be skipped must be
333327
// explicitly passed as extra arguments. Every thread in the parallel task
334-
// must execute this. (When the last thread does so, the task array is
335-
// cleared.)
336-
//
337-
// n_threads - Number of threads executing the sub-tasks.
338-
void all_tasks_completed(uint n_threads) {
339-
all_tasks_completed_impl(n_threads, nullptr, 0);
340-
}
341-
342-
// Augmented by variadic args, each for a skipped task.
328+
// must execute this.
343329
template<typename T0, typename... Ts,
344330
ENABLE_IF(Conjunction<std::is_same<T0, Ts>...>::value)>
345-
void all_tasks_completed(uint n_threads, T0 first_skipped, Ts... more_skipped) {
331+
void all_tasks_claimed(T0 first_skipped, Ts... more_skipped) {
346332
static_assert(std::is_convertible<T0, uint>::value, "not convertible");
347333
uint skipped[] = { static_cast<uint>(first_skipped), static_cast<uint>(more_skipped)... };
348-
all_tasks_completed_impl(n_threads, skipped, ARRAY_SIZE(skipped));
334+
all_tasks_claimed_impl(skipped, ARRAY_SIZE(skipped));
335+
}
336+
// if there are no skipped tasks.
337+
void all_tasks_claimed() {
338+
all_tasks_claimed_impl(nullptr, 0);
349339
}
350340

351341
// Destructor.

0 commit comments

Comments
 (0)