Skip to content

Commit

Permalink
Merge pull request #11330 from AlexeyKhrabrov/romclasswalk_fix
Browse files Browse the repository at this point in the history
Update ROMClass walk implementation to support ROMClass serialization in JITServer
  • Loading branch information
mpirvu committed Dec 4, 2020
2 parents fc28907 + 4ceb213 commit c757b51
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 20 deletions.
5 changes: 4 additions & 1 deletion runtime/oti/dbg.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 1991, 2017 IBM Corp. and others
* Copyright (c) 1991, 2020 IBM Corp. and others
*
* This program and the accompanying materials are made available under
* the terms of the Eclipse Public License 2.0 which accompanies this
Expand Down Expand Up @@ -190,8 +190,11 @@ typedef struct J9LineNumber {
} J9LineNumber;

typedef struct J9VariableInfoValues {
J9SRP* nameSrp;
struct J9UTF8* name;
J9SRP* signatureSrp;
struct J9UTF8* signature;
J9SRP* genericSignatureSrp;
struct J9UTF8* genericSignature;
U_32 startVisibility;
U_32 visibilityLength;
Expand Down
4 changes: 4 additions & 0 deletions runtime/util/optinfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -580,15 +580,19 @@ variableInfoNextDo(J9VariableInfoWalkState *state)
return NULL;
}

state->values.nameSrp = (J9SRP *)state->variableTablePtr;
state->values.name = READ_SRP(state->variableTablePtr, J9UTF8*);
state->variableTablePtr += sizeof(J9SRP);
state->values.signatureSrp = (J9SRP *)state->variableTablePtr;
state->values.signature = READ_SRP(state->variableTablePtr, J9UTF8*);
state->variableTablePtr += sizeof(J9SRP);

if (state->values.visibilityLength & J9_ROMCLASS_OPTINFO_VARIABLE_TABLE_HAS_GENERIC) {
state->values.genericSignatureSrp = (J9SRP *)state->variableTablePtr;
state->values.genericSignature = READ_SRP(state->variableTablePtr, J9UTF8*);
state->variableTablePtr += sizeof(J9SRP);
} else {
state->values.genericSignatureSrp = 0;
state->values.genericSignature = NULL;
}

Expand Down
41 changes: 22 additions & 19 deletions runtime/util/romclasswalk.c
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ void allSlotsInROMClassDo(J9ROMClass* romClass,
SLOT_CALLBACK(romClass, J9ROM_UTF8, romClass, className);
SLOT_CALLBACK(romClass, J9ROM_UTF8, romClass, superclassName);
SLOT_CALLBACK(romClass, J9ROM_U32, romClass, modifiers);
SLOT_CALLBACK(romClass, J9ROM_U32, romClass, extraModifiers);
SLOT_CALLBACK(romClass, J9ROM_U32, romClass, extraModifiers);
SLOT_CALLBACK(romClass, J9ROM_U32, romClass, interfaceCount);
SLOT_CALLBACK(romClass, J9ROM_SRP, romClass, interfaces);
SLOT_CALLBACK(romClass, J9ROM_U32, romClass, romMethodCount);
Expand All @@ -137,7 +137,7 @@ void allSlotsInROMClassDo(J9ROMClass* romClass,
SLOT_CALLBACK(romClass, J9ROM_U32, romClass, innerClassCount);
SLOT_CALLBACK(romClass, J9ROM_SRP, romClass, innerClasses);
#if JAVA_SPEC_VERSION >= 11
SLOT_CALLBACK(romClass, J9ROM_SRP, romClass, nestHost);
SLOT_CALLBACK(romClass, J9ROM_UTF8, romClass, nestHost);
SLOT_CALLBACK(romClass, J9ROM_U16, romClass, nestMemberCount);
SLOT_CALLBACK(romClass, J9ROM_U16, romClass, unused);
SLOT_CALLBACK(romClass, J9ROM_SRP, romClass, nestMembers);
Expand Down Expand Up @@ -1071,7 +1071,7 @@ static void allSlotsInStackMapDo(J9ROMClass* romClass, U_8 *stackMap, J9ROMClass
}


static UDATA
static UDATA
allSlotsInMethodParametersDataDo(J9ROMClass* romClass, U_8 * cursor, J9ROMClassWalkCallbacks* callbacks, void* userData)
{
J9MethodParametersData* methodParametersData = (J9MethodParametersData* )cursor;
Expand All @@ -1093,7 +1093,7 @@ allSlotsInMethodParametersDataDo(J9ROMClass* romClass, U_8 * cursor, J9ROMClassW
SLOT_CALLBACK(romClass, J9ROM_U8, methodParametersData, parameterCount);

for (; i < methodParametersData->parameterCount; i++) {
callbacks->slotCallback(romClass, J9ROM_SRP, &parameters[i].name, "methodParameterName", userData);
callbacks->slotCallback(romClass, J9ROM_UTF8, &parameters[i].name, "methodParameterName", userData);
callbacks->slotCallback(romClass, J9ROM_U16, &parameters[i].flags, "methodParameterFlag", userData);
}
}
Expand Down Expand Up @@ -1190,7 +1190,8 @@ allSlotsInMethodDebugInfoDo(J9ROMClass* romClass, U_32* cursor, J9ROMClassWalkCa
}

/* check for low tag to indicate inline or out of line debug information */
if (1 == (*cursor & 1)) {
BOOLEAN isInline = (1 == (*cursor & 1));
if (isInline) {
methodDebugInfo = (J9MethodDebugInfo *)cursor;
/* set the inline size to stored size in terms of U_32
* NOTE: stored size is aligned
Expand All @@ -1201,18 +1202,18 @@ allSlotsInMethodDebugInfoDo(J9ROMClass* romClass, U_32* cursor, J9ROMClassWalkCa
}

rangeValid = callbacks->validateRangeCallback(romClass, methodDebugInfo, sizeof(J9MethodDebugInfo), userData);
if (FALSE == rangeValid
/* if not low tagged skip walking the debug info since it is out of line and linear walker doesn't deal with out
* of line data very well */
|| (0 == (*cursor & 1))) {
if ( inlineSize == 1 ) {
if ((FALSE == rangeValid) || (FALSE == isInline)) {
if (1 == inlineSize) {
callbacks->slotCallback(romClass, J9ROM_SRP, cursor, "SRP to DebugInfo", userData);
callbacks->sectionCallback(romClass, cursor, inlineSize * sizeof(U_32), "methodDebugInfo", userData);
}
return inlineSize;
if (FALSE == rangeValid) {
/* linear walker will check that the range is within the ROMClass bounds
* so it will skip walking the debug info if it is out of line */
return inlineSize;
}
}


callbacks->slotCallback(romClass, J9ROM_U32, &methodDebugInfo->srpToVarInfo, "SizeOfDebugInfo(low tagged)", userData);
callbacks->slotCallback(romClass, J9ROM_U32, &methodDebugInfo->lineNumberCount, "lineNumberCount(low tagged)", userData);
SLOT_CALLBACK(romClass, J9ROM_U32, methodDebugInfo, varInfoCount);
Expand Down Expand Up @@ -1245,18 +1246,18 @@ allSlotsInMethodDebugInfoDo(J9ROMClass* romClass, U_32* cursor, J9ROMClassWalkCa

while (NULL != values) {
/* Need to walk the name and signature to add them to the UTF8 section */
rangeValid = callbacks->validateRangeCallback(romClass, values->name, sizeof(J9UTF8), userData);
rangeValid = callbacks->validateRangeCallback(romClass, values->nameSrp, sizeof(J9SRP), userData);
if (rangeValid) {
callbacks->slotCallback(romClass, J9ROM_UTF8_NOSRP, values->name, "name", userData);
callbacks->slotCallback(romClass, J9ROM_UTF8, values->nameSrp, "variableName", userData);
}
rangeValid = callbacks->validateRangeCallback(romClass, values->signature, sizeof(J9UTF8), userData);
rangeValid = callbacks->validateRangeCallback(romClass, values->signatureSrp, sizeof(J9SRP), userData);
if (rangeValid) {
callbacks->slotCallback(romClass, J9ROM_UTF8_NOSRP, values->signature, "signature", userData);
callbacks->slotCallback(romClass, J9ROM_UTF8, values->signatureSrp, "variableSignature", userData);
}
if (NULL != values->genericSignature) {
rangeValid = callbacks->validateRangeCallback(romClass, values->genericSignature, sizeof(J9UTF8), userData);
rangeValid = callbacks->validateRangeCallback(romClass, values->genericSignatureSrp, sizeof(J9SRP), userData);
if (rangeValid) {
callbacks->slotCallback(romClass, J9ROM_UTF8_NOSRP, values->genericSignature, "genericSignature", userData);
callbacks->slotCallback(romClass, J9ROM_UTF8, values->genericSignatureSrp, "variableGenericSignature", userData);
}
}

Expand All @@ -1272,7 +1273,9 @@ allSlotsInMethodDebugInfoDo(J9ROMClass* romClass, U_32* cursor, J9ROMClassWalkCa
}
callbacks->sectionCallback(romClass, variableTable, entryLength, "variableInfo", userData);
}
callbacks->sectionCallback(romClass, cursor, inlineSize * sizeof(U_32), "methodDebugInfo", userData);
if (isInline) { /* section callback was already called if debug info is out of line */
callbacks->sectionCallback(romClass, cursor, inlineSize * sizeof(U_32), "methodDebugInfo", userData);
}
return inlineSize;
}

Expand Down

0 comments on commit c757b51

Please sign in to comment.