-
Notifications
You must be signed in to change notification settings - Fork 128
8371915: [lworld] LayoutKind enum should have helper methods #1745
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
base: lworld
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -26,6 +26,7 @@ | |
| #define SHARE_OOPS_ARRAYKLASS_HPP | ||
|
|
||
| #include "oops/klass.hpp" | ||
| #include "oops/layoutKind.hpp" | ||
|
|
||
| class fieldDescriptor; | ||
| class klassVtable; | ||
|
|
@@ -38,7 +39,7 @@ class ArrayKlass: public Klass { | |
|
|
||
| public: | ||
| enum ArrayProperties : uint32_t { | ||
| DEFAULT = 0, | ||
| DEFAULT = 0, // NULLABLE and ATOMIC | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does DEFAULT also apply to arrays of oops? The name "DEFAULT" is slightly concerning if we're only talking about non-oop cases. I'd be tempted to call this NULLABLE_ATOMIC rather than DEFAULT
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. An array of oops (non-flat array) can be either DEFAULT or NULL_RESTRICTED. |
||
| NULL_RESTRICTED = 1 << 0, | ||
| NON_ATOMIC = 1 << 1, | ||
| // FINAL = 1 << 2, | ||
|
|
@@ -50,6 +51,8 @@ class ArrayKlass: public Klass { | |
| static bool is_null_restricted(ArrayProperties props) { return (props & NULL_RESTRICTED) != 0; } | ||
| static bool is_non_atomic(ArrayProperties props) { return (props & NON_ATOMIC) != 0; } | ||
|
|
||
| static ArrayProperties array_properties_from_layout(LayoutKind lk); | ||
|
|
||
| private: | ||
| // If you add a new field that points to any metaspace object, you | ||
| // must add this field to ArrayKlass::metaspace_pointers_do(). | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -26,6 +26,7 @@ | |
| #define SHARE_OOPS_LAYOUTKIND_HPP | ||
|
|
||
| #include "utilities/globalDefinitions.hpp" | ||
| #include "memory/allStatic.hpp" | ||
|
|
||
| // LayoutKind is an enum used to indicate which layout has been used for a given value field. | ||
| // Each layout has its own properties and its own access protocol that is detailed below. | ||
|
|
@@ -81,4 +82,17 @@ enum class LayoutKind : uint32_t { | |
| UNKNOWN = 5 // used for uninitialized fields of type LayoutKind | ||
| }; | ||
|
|
||
| class LayoutKindHelper : AllStatic { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wonder if this would be nicer if LayoutKind was a class and these helpers were in that class and encapsulate the whole thing in LayoutKind, so the accessors could be lk->is_flat(), etc? less characters. The enum inside LayoutKind could be referenced as LayoutKind::Kind::REFERENCE if direct references to the value is needed. Other enum class types in the VM are used that way (like AccessFlags). Then also it wouldn't need a helper. |
||
| public: | ||
| static bool is_flat(LayoutKind lk) { | ||
| return lk == LayoutKind::NON_ATOMIC_FLAT || lk == LayoutKind::ATOMIC_FLAT || lk == LayoutKind::NULLABLE_ATOMIC_FLAT; | ||
| } | ||
| static bool is_atomic_flat(LayoutKind lk) { | ||
| return lk == LayoutKind::ATOMIC_FLAT || lk == LayoutKind::NULLABLE_ATOMIC_FLAT; | ||
| } | ||
| static bool is_nullable_flat(LayoutKind lk) { | ||
| return lk == LayoutKind::NULLABLE_ATOMIC_FLAT; | ||
| } | ||
| }; | ||
|
|
||
| #endif // SHARE_OOPS_LAYOUTKIND_HPP | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a good refactoring. nit: I think the coding style has the break indented with the props = lines.