-
Notifications
You must be signed in to change notification settings - Fork 396
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
Fix Adjust APIs #3753
Fix Adjust APIs #3753
Conversation
e70e788
to
02678cf
Compare
@genie-omr build all |
FYI @Leonardo2718 and @mstoodle |
@Leonardo2718 any thoughts? |
Shouldn't the right thing to be adjust by a Word sized integer? Int64 would only be the right choice on 64-bit platforms... |
@mstoodle the |
We could change that to a size_t or assert if a value that can't be represented in 32-bits it provided on a 32-bit platform. The resulting IL will be ill-formed if you add a 64-bit value to a 32-bit address. |
True. |
@genie-omr build all |
@genie-omr build all |
@genie-omr build xlinux |
@mstoodle I updated the code. Can you take another look? |
ping? |
ping @mstoodle |
Sorry for the delay here, @charliegracie . Every time I start reviewing the changes in At its core level, a In our private exchange, you pointed out that it's through Sorry again for the delay to fully wrap my brain around the issue and the back-and-forth on the proper solution! |
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.
Hopefully straight-forward changes....Thanks @charliegracie!
_integerTypeForAdjustments = pointerToRegisterType->baseType(); | ||
if (_integerTypeForAdjustments->isPointer()) | ||
TR::IlType *registerBaseType = pointerToRegisterType->baseType(); | ||
if (registerBaseType->isPointer()) |
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.
I think these conditionals can stay the way they are (keeping _integerTypeForAdjustments
). I prefer the register know what type to use based on the type of the register rather than relying on the datatype of the adjustment value passed in.
@@ -161,7 +161,8 @@ class VirtualMachineRegister : public TR::VirtualMachineState | |||
virtual void Adjust(TR::IlBuilder *b, TR::IlValue *amount) | |||
{ | |||
TR::IlValue *off=b->Mul(amount, | |||
b-> ConstInteger(_integerTypeForAdjustments, _adjustByStep)); | |||
b-> ConstInteger(b->typeDictionary()->PrimitiveType(amount->getDataType()), |
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 more dangerous, I think, because it requires the client to set up the type properly for every call to this Adjust service.
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.
Probably best to add a b->ConvertTo(_integerTypeForAdjustments, amount)
here too rather than just using amount
directly.
_integerTypeForAdjustments = _integerTypeForAdjustments->baseType(); | ||
if (_integerTypeForAdjustments->isPointer()) | ||
registerBaseType = registerBaseType->baseType(); | ||
if (registerBaseType->isPointer()) |
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.
I don't think this should dig into two levels of pointer here: it starts from the field type, which should only require one level of pointer to primitive type to do the right thing (i.e. if it's a pointer type use Word otherwise use the field's primitive type).
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.
It's possible this change may induce some required changes in our samples, but I would hope not.
946ee39
to
9ab435e
Compare
@mstoodle I made most of the changes you suggested but now my test is failing. I have purposely left out the ConvertTo call you suggested as it would not help for the failure I am seeing. When I run the new vmregister test (which does not use VirtualMachineRegisterInStruct) I get the following assertion which is being generated because of the Adjust call:
|
I think To have These I am, however, fairly certain something will break if we change the |
@genie-omr build all |
@mstoodle I think I got it :) If all of the tests pass I think I wrapped my head around everything and have the correct changes now |
compiler/ilgen/OMRIlBuilder.hpp
Outdated
TR::IlValue *Const(int32_t value) { return ConstInt32(value); } | ||
TR::IlValue *Const(int64_t value) { return ConstInt64(value); } | ||
|
||
template <typename T> |
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.
Would you consider moving this change into a separate commit, since it doesn't contribute to the main change you're making at this point?
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.
A separate commit in this PR or a new PR?
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.
@mstoodle I will just pull it out of this PR completely
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.
sorry, missed the question....either would have been fine, but since it's not related to the PR, feels like a separate PR is most appropriate.
Basically looks good to me at this point. @Leonardo2718 do you want to do a once over to see if anything still stands out to you? |
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.
LGTM 👍
JitBuilder math APIs like Add, Mul, etc. require that the left and right operands have the same type or if the left is a pointer that the right is an Int32 or Int64. Currently a VMRegister wrapping a int8_t * will fail when Adjust is called since _integerTypeForAdjustment will be Int8. It is incorrect to limit the adjustBy amount to the primitive type of the pointer since a user may want to adjust the value by a large value. The Adjust API now takes a `size_t` amount parameter and creates the correct constant for adjustment. This PR includes a new test called vmregister which verifies that VMRegisters wrapping a pInt8 work. This test failed before this PR. The Operand[Array,Stack]Tests verify that the code continues to work for larger types. Signed-off-by: Charlie Gracie <charlie.gracie@gmail.com>
@genie-omr build all |
@mstoodle and @Leonardo2718 I have removed the new APIs that were no longer used. |
LGTM , merging. Thanks @charliegracie !! |
JitBuilder math APIs like Add, Mul, etc. require that the left and
right operands have the same type or if the left is a pointer that
the right is an Int32 or Int64. Currently a VMRegister wrapping a
int8_t * will fail when Adjust is called since
_integerTypeForAdjustment will be Int8. It is incorrect to limit
the adjustBy amount to the primite type of the pointer since a user
may want to adjust the value by a large value. The solution is to
adjust by an Int64 not matter what the primitive register type is.
This PR includes a new test called vmregister which verifies that
VMRegisters wrapping a pInt8 work. This test failed before this
PR. The Operand[Array,Stack]Tests verify that the code continues
to work for larger types.
Signed-off-by: Charlie Gracie charlie.gracie@gmail.com