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

Reimplement translation of getstatic and putstatic following JVM spec. #591

Merged
merged 3 commits into from
Jan 12, 2021

Conversation

brianhuffman
Copy link
Contributor

According to the JVM spec, each of these instructions starts with the same two steps: "The referenced field is resolved (§5.4.3.2). On successful resolution of the field, the class or interface that declared the resolved field is initialized (§5.5) if that class or interface has not already been initialized."

@brianhuffman
Copy link
Contributor Author

Previously neither getstatic nor putstatic performed field resolution at all. This led to a translation error in a regression test introduced as part of GaloisInc/saw-script#981. This PR fixes that bug.

Copy link
Contributor

@robdockins robdockins left a comment

Choose a reason for hiding this comment

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

Seems good to me. One question: is it worth keeping the low-level setStaticFieldValue function that doesn't do resolution and init?

@brianhuffman
Copy link
Contributor Author

brianhuffman commented Jan 4, 2021

I originally tried to get rid of the non-resolving setStaticFieldValue variant. But it is actually necessary to use that variant for class initialization and implementing custom static initializers; otherwise translation goes into an infinite loop.

I suppose I could add some comments explaining why it's necessary and when to use it.

Brian Huffman added 3 commits January 11, 2021 19:13
…spec.

According to the JVM spec, each of these instructions starts with the
same two steps: "The referenced field is resolved (§5.4.3.2). On
successful resolution of the field, the class or interface that
declared the resolved field is initialized (§5.5) if that class or
interface has not already been initialized."
@brianhuffman brianhuffman merged commit 12a1fba into master Jan 12, 2021
brianhuffman pushed a commit to GaloisInc/saw-script that referenced this pull request Jan 12, 2021
This fixes a previously-broken example in test_jvm_static_fields.
brianhuffman pushed a commit to GaloisInc/saw-script that referenced this pull request Jan 12, 2021
This fixes a previously-broken example in test_jvm_static_fields.
@travitch travitch deleted the bh-jvm branch December 16, 2021 18:52
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

Successfully merging this pull request may close these issues.

2 participants