8274322: Problems with oopDesc construction

Reviewed-by: dholmes, stefank
This commit is contained in:
Kim Barrett 2021-10-01 00:25:35 +00:00
parent a8edd1b360
commit 2e690ba8bd
5 changed files with 35 additions and 4 deletions

View file

@ -31,7 +31,9 @@
#include "oops/markWord.hpp"
#include "oops/metadata.hpp"
#include "runtime/atomic.hpp"
#include "utilities/globalDefinitions.hpp"
#include "utilities/macros.hpp"
#include <type_traits>
// oopDesc is the top baseclass for objects classes. The {name}Desc classes describe
// the format of Java objects so the fields can be accessed from C++.
@ -57,7 +59,14 @@ class oopDesc {
narrowKlass _compressed_klass;
} _metadata;
// There may be ordering constraints on the initialization of fields that
// make use of the C++ copy/assign incorrect.
NONCOPYABLE(oopDesc);
public:
// Must be trivial; see verifying static assert after the class.
oopDesc() = default;
inline markWord mark() const;
inline markWord mark_acquire() const;
inline markWord* mark_addr() const;
@ -311,4 +320,11 @@ class oopDesc {
DEBUG_ONLY(bool get_UseG1GC();)
};
// An oopDesc is not initialized via a constructor. Space is allocated in
// the Java heap, and static functions provided here on HeapWord* are used
// to fill in certain parts of that memory. The allocated memory is then
// treated as referring to an oopDesc. For that to be valid, the oopDesc
// class must have a trivial default constructor (C++14 3.8/1).
static_assert(std::is_trivially_default_constructible<oopDesc>::value, "required");
#endif // SHARE_OOPS_OOP_HPP