Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

关于pr170的修改讨论 #338

Closed
axiangyushanhaijing opened this issue Feb 20, 2022 · 2 comments
Closed

关于pr170的修改讨论 #338

axiangyushanhaijing opened this issue Feb 20, 2022 · 2 comments

Comments

@axiangyushanhaijing
Copy link

pr170 其中修改了 公共区域代码,目前如果回退会报错,需要重新研究修改。

@axiangyushanhaijing
Copy link
Author

axiangyushanhaijing commented Feb 21, 2022

pr170 进行分析。
参考之前的修改讨论 消除warning的comment,在回退对公共代码的修改的同时,还需要考虑消除返回值的warning :“warning: no return statement in function returning non-void [-Wreturn-type]”,所以需要对Atomic::PlatformLoad以及Atomic::PlatformStore 修改。同时参考zero版本的实现:

template<>
template<typename T>
inline T Atomic::PlatformLoad<8>::operator()(T const volatile* src) const {
  STATIC_ASSERT(8 == sizeof(T));
  volatile int64_t dest;
  os::atomic_copy64(reinterpret_cast<const volatile int64_t*>(src), reinterpret_cast<volatile int64_t*>(&dest));
  return PrimitiveConversions::cast<T>(dest);
}

template<>
template<typename T>
inline void Atomic::PlatformStore<8>::operator()(T store_value,
                                                 T volatile* dest) const {
  STATIC_ASSERT(8 == sizeof(T));
  os::atomic_copy64(reinterpret_cast<const volatile int64_t*>(&store_value), reinterpret_cast<volatile int64_t*>(dest));
}

重新修改:

diff --git a/src/hotspot/os_cpu/linux_riscv32/atomic_linux_riscv32.hpp b/src/hotspot/os_cpu/linux_riscv32/atomic_linux_riscv32.hpp
index 6f211c80fb..436c6fc7e4 100644
--- a/src/hotspot/os_cpu/linux_riscv32/atomic_linux_riscv32.hpp
+++ b/src/hotspot/os_cpu/linux_riscv32/atomic_linux_riscv32.hpp
@@ -110,13 +110,21 @@ inline T Atomic::PlatformCmpxchg<4>::operator()(T exchange_value,
   return rv;
 }
 
-/*template<>
+template<>
 template<typename T>
-inline T Atomic::PlatformLoad<8>::operator()(T const volatile* src) const {}
+inline T Atomic::PlatformLoad<8>::operator()(T const volatile* src) const {
+  STATIC_ASSERT(8 == sizeof(T));
+  volatile int64_t dest;
+  os::atomic_copy64(reinterpret_cast<const volatile int64_t*>(src), reinterpret_cast<volatile int64_t*>(&dest));
+  return PrimitiveConversions::cast<T>(dest);
+}
 
 template<>
 template<typename T>
 inline void Atomic::PlatformStore<8>::operator()(T store_value,
-                                                 T volatile* dest) const {}
-*/
+                                                 T volatile* dest) const {
+  STATIC_ASSERT(8 == sizeof(T));
+  os::atomic_copy64(reinterpret_cast<const volatile int64_t*>(&store_value), reinterpret_cast<volatile int64_t*>(dest));
+  }
+
 #endif // OS_CPU_LINUX_RISCV32_VM_ATOMIC_LINUX_RISCV32_HPP
diff --git a/src/hotspot/share/runtime/atomic.hpp b/src/hotspot/share/runtime/atomic.hpp
index 5067031fa2..57bca10c21 100644
--- a/src/hotspot/share/runtime/atomic.hpp
+++ b/src/hotspot/share/runtime/atomic.hpp
@@ -416,7 +416,7 @@ template<size_t byte_size>
 struct Atomic::PlatformLoad {
   template<typename T>
   T operator()(T const volatile* dest) const {
-    //STATIC_ASSERT(sizeof(T) <= sizeof(void*)); // wide atomics need specialization
+    STATIC_ASSERT(sizeof(T) <= sizeof(void*)); // wide atomics need specialization
     return *dest;
   }
 };
@@ -486,7 +486,7 @@ struct Atomic::PlatformStore {
   template<typename T>
   void operator()(T new_value,
                   T volatile* dest) const {
-//    STATIC_ASSERT(sizeof(T) <= sizeof(void*)); // wide atomics need specialization
+  STATIC_ASSERT(sizeof(T) <= sizeof(void*)); // wide atomics need specialization
     (void)const_cast<T&>(*dest = new_value);
   }
 };

@axiangyushanhaijing
Copy link
Author

axiangyushanhaijing commented Feb 21, 2022

已提交 pr341,修复后对当前进度无影响。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants