-
Notifications
You must be signed in to change notification settings - Fork 712
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
Refactor VTable index/offset variable name #2436
Conversation
3155bc0
to
8e6dda8
Compare
@gacholio can you take a look? |
runtime/codert_vm/cnathelp.cpp
Outdated
@@ -990,12 +990,12 @@ old_slow_jitLookupInterfaceMethod(J9VMThread *currentThread) | |||
UDATA cpIndex = indexAndLiteralsEA[-1]; | |||
J9Class *interfaceClass = ((J9Class**)indexAndLiteralsEA)[0]; | |||
UDATA methodIndex = indexAndLiteralsEA[1]; | |||
UDATA vTableIndex = VM_VMHelpers::convertITableIndexToVTableIndex(currentThread, receiverClass, interfaceClass, methodIndex, ramConstantPool, cpIndex); | |||
UDATA vTableOffset = VM_VMHelpers::convertITableIndexToVTableIndex(currentThread, receiverClass, interfaceClass, methodIndex, ramConstantPool, cpIndex); |
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.
Should probably rename index to offset in the helper function as well.
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.
The change to this function name was good - it's not the native.
runtime/jit_vm/cthelpers.cpp
Outdated
} | ||
|
||
J9Method* | ||
jitGetInterfaceMethodFromCP(J9VMThread *currentThread, J9ConstantPool *constantPool, UDATA cpIndex, J9Class* lookupClass) | ||
{ | ||
UDATA vTableIndex = jitGetInterfaceVTableIndexFromCP(currentThread, constantPool, cpIndex, lookupClass); | ||
UDATA vTableOffset = jitGetInterfaceVTableIndexFromCP(currentThread, constantPool, cpIndex, lookupClass); |
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.
Again, function rename to reflect offset would be good.
runtime/oti/j9.h
Outdated
#define J9VTABLE_HEADER_FROM_RAM_CLASS(clazz) ((J9VTableHeader *)(((J9Class *)(clazz)) + 1)) | ||
#define J9VTABLE_FROM_HEADER(vtableHeader) ((J9Method **)(((J9VTableHeader *)(vtableHeader)) + 1)) | ||
#define J9VTABLE_FROM_RAM_CLASS(clazz) J9VTABLE_FROM_HEADER(J9VTABLE_HEADER_FROM_RAM_CLASS(clazz)) | ||
#define J9VTABLE_OFFSET_FROM_INDEX(index) (sizeof(J9Class) + sizeof(J9VTableHeader) + ((index) * sizeof(UDATA))) | ||
|
||
/* VTable constants offset */ | ||
#define J9VTABLE_INITIAL_VIRTUAL_OFFSET (sizeof(J9Class) + sizeof(UDATA)) |
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 should be expressed as VTABLE_HEADER + offsetof(the field).
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.
rather, "(sizeof(J9Class) + offsetof(J9VTableHeader, initialVirtualMethod))"
Once again, looks very good with a few nitpicks. Consider changing (UDATA)-1 to UDATA_MAX, and adding an assert to make sure that's never a successful return value. |
I'm unsure about the JIT/JCL changes (including the renaming of the VM-side native) at the moment - please remove those until we can discuss with the JIT team. |
re last comment - it's just the native I'm concerned about, the other changes in the JIT look fine. |
I've removed the renaming for native methods, also fixed the ddr vtable access functions |
Too much deleted! I like the function renames to Offset instead of Index - it's just the natives (and JCL caller) that should not be changed. |
UDATAPointer jitVTable = UDATAPointer.NULL; | ||
UDATA vTableMethodCount; | ||
UDATAPointer jitVTable = UDATAPointer.NULL; | ||
J9VTableHeaderPointer vTableHeader; |
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.
inconsistent spacing here
vTableSlotCount = vTable.at(0); | ||
vTableHeader = J9ClassHelper.vTableHeader(ramClass); | ||
vTableMethodCount = vTableHeader.size(); | ||
vTable = J9ClassHelper.vTable(vTableHeader); |
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.
spacing
runtime/codert_vm/cnathelp.cpp
Outdated
@@ -990,12 +990,12 @@ old_slow_jitLookupInterfaceMethod(J9VMThread *currentThread) | |||
UDATA cpIndex = indexAndLiteralsEA[-1]; | |||
J9Class *interfaceClass = ((J9Class**)indexAndLiteralsEA)[0]; | |||
UDATA methodIndex = indexAndLiteralsEA[1]; | |||
UDATA vTableIndex = VM_VMHelpers::convertITableIndexToVTableIndex(currentThread, receiverClass, interfaceClass, methodIndex, ramConstantPool, cpIndex); | |||
UDATA vTableOffset = VM_VMHelpers::convertITableIndexToVTableIndex(currentThread, receiverClass, interfaceClass, methodIndex, ramConstantPool, cpIndex); |
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.
The change to this function name was good - it's not the native.
fixed code spacing, re-added non-jcl name changes |
81ab3ff
to
a998fb3
Compare
- Change variable name to correctly reflect vtable index/name - Added new constant for InitialVirtualMethod offset - change initialVirtual constant to use offsetof() macro - change convertITableIndexToVTableIndex to convertITableIndexToVTableOffset - change jitGetInterfaceVTableIndexFromCP to jitGetInterfaceVTableOffsetFromCP - change getVTableIndexForMethod to getVTableOffsetForMethod Signed-off-by: Jack Lu <Jack.S.Lu@ibm.com>
jenkins test sanity plinux jdk8 |
Signed-off-by: Jack Lu Jack.S.Lu@ibm.com