Skip to content

Commit

Permalink
Update (2024.01.26, 2nd)
Browse files Browse the repository at this point in the history
33245: Fix string_comp out-of-bounds load when cnt1 is 0
33227: ppc64el build failed
  • Loading branch information
loongson-jvm authored Jan 26, 2024
1 parent 33c606e commit 88a9d9b
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 28 deletions.
20 changes: 19 additions & 1 deletion hotspot/src/cpu/loongarch/vm/copy_loongarch.hpp
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -45,6 +45,24 @@

// Contains inline asm implementations

// Template for atomic, element-wise copy.
template <class T>
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;
Expand Down
3 changes: 1 addition & 2 deletions hotspot/src/cpu/loongarch/vm/loongarch_64.ad
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
20 changes: 19 additions & 1 deletion hotspot/src/cpu/mips/vm/copy_mips.hpp
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -45,6 +45,24 @@

// Contains inline asm implementations

// Template for atomic, element-wise copy.
template <class T>
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;
Expand Down
3 changes: 2 additions & 1 deletion hotspot/src/cpu/mips/vm/mips_64.ad
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
25 changes: 2 additions & 23 deletions hotspot/src/share/vm/utilities/copy.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/

Expand Down Expand Up @@ -337,27 +337,6 @@ class Copy : AllStatic {
#endif
}


// SAPJVM AS 2011-09-20. Template for atomic copy.
template <class T> 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"
Expand Down

0 comments on commit 88a9d9b

Please sign in to comment.