8227369: pd_disjoint_words_atomic() needs to be atomic

Reviewed-by: eosterlund, mikael, shade, kbarrett, mdoerr
This commit is contained in:
David Holmes 2022-03-01 12:07:21 +00:00
parent eff396f397
commit 44d599aad3
5 changed files with 30 additions and 64 deletions
src/hotspot
cpu
os_cpu/windows_aarch64
share/utilities

@ -1,5 +1,5 @@
/*
* Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2000, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2013 SAP SE. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
@ -53,21 +53,7 @@ static void pd_disjoint_words(const HeapWord* from, HeapWord* to, size_t count)
}
static void pd_disjoint_words_atomic(const HeapWord* from, HeapWord* to, size_t count) {
switch (count) {
case 8: to[7] = from[7];
case 7: to[6] = from[6];
case 6: to[5] = from[5];
case 5: to[4] = from[4];
case 4: to[3] = from[3];
case 3: to[2] = from[2];
case 2: to[1] = from[1];
case 1: to[0] = from[0];
case 0: break;
default: while (count-- > 0) {
*to++ = *from++;
}
break;
}
shared_disjoint_words_atomic(from, to, count);
}
static void pd_aligned_conjoint_words(const HeapWord* from, HeapWord* to, size_t count) {

@ -148,22 +148,7 @@ static void pd_disjoint_words(const HeapWord* from, HeapWord* to, size_t count)
static void pd_disjoint_words_atomic(const HeapWord* from, HeapWord* to, size_t count) {
#ifdef AMD64
switch (count) {
case 8: to[7] = from[7];
case 7: to[6] = from[6];
case 6: to[5] = from[5];
case 5: to[4] = from[4];
case 4: to[3] = from[3];
case 3: to[2] = from[2];
case 2: to[1] = from[1];
case 1: to[0] = from[0];
case 0: break;
default:
while (count-- > 0) {
*to++ = *from++;
}
break;
}
shared_disjoint_words_atomic(from, to, count);
#else
// pd_disjoint_words is word-atomic in this implementation.
pd_disjoint_words(from, to, count);

@ -1,5 +1,5 @@
/*
* Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright 2007 Red Hat, Inc.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
@ -52,22 +52,7 @@ static void pd_disjoint_words(const HeapWord* from, HeapWord* to, size_t count)
static void pd_disjoint_words_atomic(const HeapWord* from,
HeapWord* to,
size_t count) {
switch (count) {
case 8: to[7] = from[7];
case 7: to[6] = from[6];
case 6: to[5] = from[5];
case 5: to[4] = from[4];
case 4: to[3] = from[3];
case 3: to[2] = from[2];
case 2: to[1] = from[1];
case 1: to[0] = from[0];
case 0: break;
default:
while (count-- > 0) {
*to++ = *from++;
}
break;
}
shared_disjoint_words_atomic(from, to, count);
}
static void pd_aligned_conjoint_words(const HeapWord* from,

@ -1,5 +1,6 @@
/*
* Copyright (c) 2020, Microsoft Corporation. All rights reserved.
* Copyright (c) 2022, Oracle and/or its affiliates. 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
@ -49,21 +50,7 @@ static void pd_disjoint_words(const HeapWord* from, HeapWord* to, size_t count)
}
static void pd_disjoint_words_atomic(const HeapWord* from, HeapWord* to, size_t count) {
switch (count) {
case 8: to[7] = from[7];
case 7: to[6] = from[6];
case 6: to[5] = from[5];
case 5: to[4] = from[4];
case 4: to[3] = from[3];
case 3: to[2] = from[2];
case 2: to[1] = from[1];
case 1: to[0] = from[0];
case 0: break;
default: while (count-- > 0) {
*to++ = *from++;
}
break;
}
shared_disjoint_words_atomic(from, to, count);
}
static void pd_aligned_conjoint_words(const HeapWord* from, HeapWord* to, size_t count) {

@ -26,6 +26,7 @@
#define SHARE_UTILITIES_COPY_HPP
#include "oops/oopsHierarchy.hpp"
#include "runtime/atomic.hpp"
#include "runtime/globals.hpp"
#include "utilities/align.hpp"
#include "utilities/bytes.hpp"
@ -297,6 +298,28 @@ class Copy : AllStatic {
pd_zero_to_bytes(to, count);
}
protected:
inline static void shared_disjoint_words_atomic(const HeapWord* from,
HeapWord* to, size_t count) {
switch (count) {
case 8: Atomic::store(&to[7], Atomic::load(&from[7]));
case 7: Atomic::store(&to[6], Atomic::load(&from[6]));
case 6: Atomic::store(&to[5], Atomic::load(&from[5]));
case 5: Atomic::store(&to[4], Atomic::load(&from[4]));
case 4: Atomic::store(&to[3], Atomic::load(&from[3]));
case 3: Atomic::store(&to[2], Atomic::load(&from[2]));
case 2: Atomic::store(&to[1], Atomic::load(&from[1]));
case 1: Atomic::store(&to[0], Atomic::load(&from[0]));
case 0: break;
default:
while (count-- > 0) {
Atomic::store(to++, Atomic::load(from++));
}
break;
}
}
private:
static bool params_disjoint(const HeapWord* from, HeapWord* to, size_t count) {
if (from < to) {