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

Prevent allocation of replaced classes #3143

Merged
merged 1 commit into from
Oct 4, 2018

Conversation

gacholio
Copy link
Contributor

@gacholio gacholio commented Oct 4, 2018

Objects on the heap must always point to the most current version of the
J9Class. Prevent allocation of replaced classes by causing fast path
allocations to fail for replaced classes. The final (slow path)
allocator will use the most current version of the requested class to
fix any callers who unwittingly passes a replaced class.

[ci skip]

Signed-off-by: Graham Chapman graham_chapman@ca.ibm.com

Objects on the heap must always point to the most current version of the
J9Class. Prevent allocation of replaced classes by causing fast path
allocations to fail for replaced classes. The final (slow path)
allocator will use the most current version of the requested class to
fix any callers who unwittingly passes a replaced class.

[ci skip]

Signed-off-by: Graham Chapman <graham_chapman@ca.ibm.com>
@gacholio
Copy link
Contributor Author

gacholio commented Oct 4, 2018

jenkins test all zlinux jdk8

@@ -77,7 +77,7 @@ class MM_JavaObjectAllocationModel : public MM_AllocateInitialization
if (NULL != objectPtr) {
/* Initialize class pointer in object header -- preserve flags set by base class */
MM_GCExtensions *extensions = MM_GCExtensions::getExtensions(env);
extensions->objectModel.setObjectClass(objectPtr, _class);
extensions->objectModel.setObjectClass(objectPtr, getClass());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should the protected _class field become private to prevent subclass's from reaching for it directly? And likely commented to indicate the issue.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Making the field private means modifying a lot of code. Any users of the field before a GC has occurred really don't need to get the current class (the OM is used in the faster path NoGC code as well).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tempted to add a new accessor getCurrentClass() for people who are aware that the class may change during a GC, and leave getClass() as it is (there are actually no callers - all access is by direct field fetch).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dmitripivkine I'm OK with taking this change as is. Do you want a followup issue to make the _class field private?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, we will take care about this

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will not make the accessor change now - you can decide if you want it when changing the field visibility.

Copy link
Contributor

@dmitripivkine dmitripivkine left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@DanHeidinga DanHeidinga self-assigned this Oct 4, 2018
@DanHeidinga
Copy link
Member

Once the testing passes, whoever sees it first can merge

@DanHeidinga
Copy link
Member

Jenkins is struggling to complete builds. Merging now as the Sanity passed.

@DanHeidinga DanHeidinga merged commit 7b4ace6 into eclipse-openj9:master Oct 4, 2018
@gacholio gacholio deleted the alloc branch October 4, 2018 18:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants