From 88a9d9bd868e50e8462125c9cacd582ae934fac9 Mon Sep 17 00:00:00 2001 From: loongson-jvm Date: Fri, 26 Jan 2024 18:27:25 +0800 Subject: [PATCH] Update (2024.01.26, 2nd) 33245: Fix string_comp out-of-bounds load when cnt1 is 0 33227: ppc64el build failed --- .../src/cpu/loongarch/vm/copy_loongarch.hpp | 20 ++++++++++++++- hotspot/src/cpu/loongarch/vm/loongarch_64.ad | 3 +-- hotspot/src/cpu/mips/vm/copy_mips.hpp | 20 ++++++++++++++- hotspot/src/cpu/mips/vm/mips_64.ad | 3 ++- hotspot/src/share/vm/utilities/copy.hpp | 25 ++----------------- 5 files changed, 43 insertions(+), 28 deletions(-) diff --git a/hotspot/src/cpu/loongarch/vm/copy_loongarch.hpp b/hotspot/src/cpu/loongarch/vm/copy_loongarch.hpp index 1b40eab95bc..cb655401395 100644 --- a/hotspot/src/cpu/loongarch/vm/copy_loongarch.hpp +++ b/hotspot/src/cpu/loongarch/vm/copy_loongarch.hpp @@ -1,6 +1,6 @@ /* * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2015, 2020, Loongson Technology. All rights reserved. + * Copyright (c) 2015, 2023, Loongson Technology. 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 @@ -45,6 +45,24 @@ // Contains inline asm implementations +// Template for atomic, element-wise copy. +template +static void copy_conjoint_atomic(const T* from, T* to, size_t count) { + if (from > to) { + while (count-- > 0) { + // Copy forwards + *to++ = *from++; + } + } else { + from += count - 1; + to += count - 1; + while (count-- > 0) { + // Copy backwards + *to-- = *from--; + } + } +} + static void pd_fill_to_words(HeapWord* tohw, size_t count, juint value) { julong* to = (julong*) tohw; julong v = ((julong) value << 32) | value; diff --git a/hotspot/src/cpu/loongarch/vm/loongarch_64.ad b/hotspot/src/cpu/loongarch/vm/loongarch_64.ad index 6db00bf642c..fa4bf6e1703 100644 --- a/hotspot/src/cpu/loongarch/vm/loongarch_64.ad +++ b/hotspot/src/cpu/loongarch/vm/loongarch_64.ad @@ -8213,9 +8213,8 @@ instruct string_compare(a4_RegP str1, mA5RegI cnt1, a6_RegP str2, mA7RegI cnt2, // Now the shorter length is in cnt1 and cnt2 can be used as a tmp register __ bind(Loop); // Loop begin - __ ld_hu(AT, str1, 0); __ beq(cnt1, R0, done); - + __ ld_hu(AT, str1, 0); // compare current character __ ld_hu(cnt2, str2, 0); __ addi_d(str1, str1, 2); diff --git a/hotspot/src/cpu/mips/vm/copy_mips.hpp b/hotspot/src/cpu/mips/vm/copy_mips.hpp index 49fde17923d..4442e1dc716 100644 --- a/hotspot/src/cpu/mips/vm/copy_mips.hpp +++ b/hotspot/src/cpu/mips/vm/copy_mips.hpp @@ -1,6 +1,6 @@ /* * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2015, 2016, Loongson Technology. All rights reserved. + * Copyright (c) 2015, 2023, Loongson Technology. 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 @@ -45,6 +45,24 @@ // Contains inline asm implementations +// Template for atomic, element-wise copy. +template +static void copy_conjoint_atomic(const T* from, T* to, size_t count) { + if (from > to) { + while (count-- > 0) { + // Copy forwards + *to++ = *from++; + } + } else { + from += count - 1; + to += count - 1; + while (count-- > 0) { + // Copy backwards + *to-- = *from--; + } + } +} + static void pd_fill_to_words(HeapWord* tohw, size_t count, juint value) { julong* to = (julong*) tohw; julong v = ((julong) value << 32) | value; diff --git a/hotspot/src/cpu/mips/vm/mips_64.ad b/hotspot/src/cpu/mips/vm/mips_64.ad index 2d714c8be16..29125913a4f 100644 --- a/hotspot/src/cpu/mips/vm/mips_64.ad +++ b/hotspot/src/cpu/mips/vm/mips_64.ad @@ -9827,7 +9827,8 @@ instruct string_compare(a4_RegP str1, mA5RegI cnt1, a6_RegP str2, mA7RegI cnt2, // Now the shorter length is in cnt1 and cnt2 can be used as a tmp register __ bind(Loop); // Loop begin __ beq(cnt1, R0, done); - __ delayed()->lhu(AT, str1, 0);; + __ delayed()->nop(); + __ lhu(AT, str1, 0); // compare current character __ lhu(cnt2, str2, 0); diff --git a/hotspot/src/share/vm/utilities/copy.hpp b/hotspot/src/share/vm/utilities/copy.hpp index 1279319a17d..73b858b86e0 100644 --- a/hotspot/src/share/vm/utilities/copy.hpp +++ b/hotspot/src/share/vm/utilities/copy.hpp @@ -23,8 +23,8 @@ */ /* - * This file has been modified by Loongson Technology in 2020. These - * modifications are Copyright (c) 2015, 2020, Loongson Technology, and are made + * This file has been modified by Loongson Technology in 2023. These + * modifications are Copyright (c) 2015, 2023, Loongson Technology, and are made * available on the same license terms set forth above. */ @@ -337,27 +337,6 @@ class Copy : AllStatic { #endif } - - // SAPJVM AS 2011-09-20. Template for atomic copy. - template static void copy_conjoint_atomic(T* from, T* to, size_t count) - { - if (from > to) { - while (count-- > 0) { - // Copy forwards - *to++ = *from++; - } - } else { - from += count - 1; - to += count - 1; - while (count-- > 0) { - // Copy backwards - *to-- = *from--; - } - } - } - - - // Platform dependent implementations of the above methods. #ifdef TARGET_ARCH_x86 # include "copy_x86.hpp"