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

Atomic-free JNI work #2039

Merged
merged 1 commit into from
Jun 1, 2018
Merged

Atomic-free JNI work #2039

merged 1 commit into from
Jun 1, 2018

Conversation

gacholio
Copy link
Contributor

@gacholio gacholio commented May 31, 2018

Fix releaseVMAccess on PPC to properly use compare instead of and.
Assert if the VM access bit doesn't fit into an immediate to prevent a
constant change from unknowingly bloating the direct JNI path.

Also add the immediate value assertion on AMD64.

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

@gacholio gacholio requested a review from zl-wang May 31, 2018 19:29
@gacholio
Copy link
Contributor Author

gacholio commented May 31, 2018

I've examined the 32-bit and 64-bit generated code, and they are correct for both entering and exitting the VM.

// ctor for Trg1Src2 + condReg only has the preced form, if you don't pass a preceding instruction the following instruction will end up as the first instruction after the prologue
generateTrg1Src2Instruction(cg(), TR::InstOpCode::and_r, callNode, tempReg2, tempReg1, tempReg2, cr0Reg, /* FIXME */ cg()->getAppendInstruction());
}
TR_ASSERT(J9_PUBLIC_FLAGS_VM_ACCESS >= LOWER_IMMED && J9_PUBLIC_FLAGS_VM_ACCESS <= UPPER_IMMED, "VM access bit must be immediate");
Copy link
Contributor

Choose a reason for hiding this comment

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

This assert will not fire unless we are in a debug build. If you want something that runs in production use TR_ASSERT_FATAL.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Which is preferred here do you think? If the value gets out of range, we'll encode a bogus instruction and likely crash, at which point a debug build would show the problem. On the other hand, these two asserts aren't likely to have any effect on codegen performance.

Copy link
Contributor

@fjeremic fjeremic Jun 1, 2018

Choose a reason for hiding this comment

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

I would think we want a TR_ASSERT_FATAL here. I'd rather us fail the compilation right away with a full backtrace than almost surely crash at runtime, or yet worse get undefined behavior. We'll make the same assert on Z.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sounds good - I'll make the change (and add it to X where I'm already assuming it, but not asserting it).

Fix releaseVMAccess on PPC to properly use compare instead of and.
Assert if the VM access bit doesn't fit into an immediate to prevent a
constant change from unknowingly bloating the direct JNI path.

Also add the immediate value assertion on AMD64.

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

gacholio commented Jun 1, 2018

@fjeremic Ready for re-review. If you're comfortable merging this, I'll remove Julian.

@gacholio gacholio removed the request for review from zl-wang June 1, 2018 19:08
@fjeremic fjeremic self-assigned this Jun 1, 2018
@fjeremic
Copy link
Contributor

fjeremic commented Jun 1, 2018

Jenkins test sanity xlinux,plinux,aix,win

@fjeremic
Copy link
Contributor

fjeremic commented Jun 1, 2018

Windows builds failed due to infrastructure issues on the machine:

NPT ERROR: Cannot open library

@fjeremic fjeremic merged commit 175a98e into eclipse-openj9:master Jun 1, 2018
@gacholio gacholio deleted the ppcjnifix branch June 1, 2018 22:16
// FIXME: Apparently I'm the first one to ever use a Trg1Src2 record-form instruction...
// ctor for Trg1Src2 + condReg only has the preced form, if you don't pass a preceding instruction the following instruction will end up as the first instruction after the prologue
generateTrg1Src2Instruction(cg(), TR::InstOpCode::and_r, callNode, tempReg2, tempReg1, tempReg2, cr0Reg, /* FIXME */ cg()->getAppendInstruction());
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Although not applicable anymore, andis_r instruction can be used for the case where J9_PUBLIC_FLAGS_VM_ACCESS falls in the upper 16-bit.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

On the off chance we ever feel the need to change the bit value, we can re-assess. It didn't seem like a good idea to maintain a bunch of dead code in these functions. I think every platform will be able to represent 0x20 as an immediate today.

@pshipton pshipton mentioned this pull request Sep 5, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants