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

Rationalize allocation macros #4878

Merged
merged 1 commit into from
Feb 28, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions runtime/codert_vm/cnathelp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ fast_jitNewObjectImpl(J9VMThread *currentThread, J9Class *objectClass, bool chec
goto slow;
}
}
if (J9_UNEXPECTED(J9ROMCLASS_IS_ABSTRACT_OR_INTERFACE(objectClass->romClass))) {
if (J9_UNEXPECTED(!J9ROMCLASS_ALLOCATES_VIA_NEW(objectClass->romClass))) {
goto slow;
}
{
Expand Down Expand Up @@ -471,7 +471,7 @@ slow_jitNewObjectImpl(J9VMThread *currentThread, bool checkClassInit, bool nonZe
if (nonZeroTLH) {
allocationFlags |= J9_GC_ALLOCATE_OBJECT_NON_ZERO_TLH;
}
if (J9ROMCLASS_IS_ABSTRACT_OR_INTERFACE(objectClass->romClass)) {
if (!J9ROMCLASS_ALLOCATES_VIA_NEW(objectClass->romClass)) {
buildJITResolveFrameForRuntimeHelper(currentThread, parmCount);
addr = setCurrentExceptionFromJIT(currentThread, J9VMCONSTANTPOOL_JAVALANGINSTANTIATIONERROR | J9_EX_CTOR_CLASS, J9VM_J9CLASS_TO_HEAPCLASS(objectClass));
goto done;
Expand Down
9 changes: 7 additions & 2 deletions runtime/oti/j9modifiers_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,13 @@
#define J9ROMMETHOD_IS_NON_EMPTY_OBJECT_CONSTRUCTOR(romMethod) \
((((romMethod)->modifiers) & (J9AccMethodObjectConstructor | J9AccEmptyMethod)) == J9AccMethodObjectConstructor)

#define J9ROMCLASS_IS_ABSTRACT_OR_INTERFACE(romClass) \
J9_ARE_ANY_BITS_SET((romClass)->modifiers, J9AccAbstract | J9AccInterface)
/* Class instances are allocated via the new bytecode */
#define J9ROMCLASS_ALLOCATES_VIA_NEW(romClass) \
J9_ARE_NO_BITS_SET((romClass)->modifiers, J9AccAbstract | J9AccInterface | J9AccClassArray | J9AccValueType)

/* Class instances are allocated via J9RAMClass->totalInstanceSize */
#define J9ROMCLASS_ALLOCATE_USES_TOTALINSTANCESIZE(romClass) \
J9_ARE_NO_BITS_SET((romClass)->modifiers, J9AccAbstract | J9AccInterface | J9AccClassArray)

/* Only public vTable methods go into the iTable */
#define J9ROMMETHOD_IN_ITABLE(romMethod) \
Expand Down
2 changes: 1 addition & 1 deletion runtime/util/hshelp.c
Original file line number Diff line number Diff line change
Expand Up @@ -2034,7 +2034,7 @@ copyPreservedValues(J9VMThread * currentThread, J9HashTable * classPairs, UDATA
* Do not do this for abstract or interface classes, which can not be
* instantiated (and hence may reuse the totalInstanceSize field as something else).
*/
if (!J9ROMCLASS_IS_ABSTRACT_OR_INTERFACE(originalRAMClass->romClass)) {
if (J9ROMCLASS_ALLOCATE_USES_TOTALINSTANCESIZE(originalRAMClass->romClass)) {
originalRAMClass->totalInstanceSize = (UDATA)-256;
}
}
Expand Down
2 changes: 1 addition & 1 deletion runtime/vm/BytecodeInterpreter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7241,7 +7241,7 @@ done:;
J9ConstantPool *ramConstantPool = J9_CP_FROM_METHOD(_literals);
J9RAMClassRef *ramCPEntry = ((J9RAMClassRef*)ramConstantPool) + index;
J9Class* volatile resolvedClass = ramCPEntry->value;
if ((NULL != resolvedClass) && !J9ROMCLASS_IS_ABSTRACT_OR_INTERFACE(resolvedClass->romClass)) {
if ((NULL != resolvedClass) && J9ROMCLASS_ALLOCATES_VIA_NEW(resolvedClass->romClass)) {
if (!VM_VMHelpers::classRequiresInitialization(_currentThread, resolvedClass)) {
j9object_t instance = _objectAllocate.inlineAllocateObject(_currentThread, resolvedClass);
if (NULL == instance) {
Expand Down
4 changes: 2 additions & 2 deletions runtime/vm/resolvesupport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ resolveClassRef(J9VMThread *vmStruct, J9ConstantPool *ramCP, UDATA cpIndex, UDAT
ramClassRefWrapper = (J9RAMClassRef *)&ramCP[cpIndex];
resolvedClass = ramClassRefWrapper->value;
/* If resolving for "new", check if the class is instantiable */
if ((NULL != resolvedClass) && (J9_ARE_NO_BITS_SET(resolveFlags, J9_RESOLVE_FLAG_INSTANTIABLE) || !J9ROMCLASS_IS_ABSTRACT_OR_INTERFACE(resolvedClass->romClass))) {
if ((NULL != resolvedClass) && (J9_ARE_NO_BITS_SET(resolveFlags, J9_RESOLVE_FLAG_INSTANTIABLE) || J9ROMCLASS_ALLOCATES_VIA_NEW(resolvedClass->romClass))) {
gacholio marked this conversation as resolved.
Show resolved Hide resolved
/* ensure that the caller can safely read the modifiers field if it so desires */
issueReadBarrier();
goto done;
Expand Down Expand Up @@ -398,7 +398,7 @@ resolveClassRef(J9VMThread *vmStruct, J9ConstantPool *ramCP, UDATA cpIndex, UDAT

accessModifiers = resolvedClass->romClass->modifiers;
if (J9_ARE_ANY_BITS_SET(resolveFlags, J9_RESOLVE_FLAG_INSTANTIABLE)) {
if (J9_ARE_ANY_BITS_SET(accessModifiers, J9AccAbstract | J9AccInterface)) {
if (!J9ROMCLASS_ALLOCATES_VIA_NEW(resolvedClass->romClass)) {
if (canRunJavaCode) {
setCurrentException(vmStruct, J9_EX_CTOR_CLASS + J9VMCONSTANTPOOL_JAVALANGINSTANTIATIONERROR,
(UDATA *)resolvedClass->classObject);
Expand Down