@@ -277,16 +277,6 @@ ROMClassBuilder::handleAnonClassName(J9CfrClassFile *classfile, ROMClassCreation
277277 PORT_ACCESS_FROM_PORT (_portLibrary);
278278
279279#if defined(J9VM_OPT_OPENJDK_METHODHANDLE)
280- /*
281- * Prevent generated LambdaForm classes from MethodHandles to be stored to the shared cache.
282- * When there are a large number of such classes in the shared cache, they trigger a lot of class comparisons.
283- * Performance can be much worse (compared to shared cache turned off).
284- */
285- if (isLambdaFormClassName (originalStringBytes, originalStringLength, NULL /* deterministicPrefixLength*/ )) {
286- context->addFindClassFlags (J9_FINDCLASS_FLAG_DO_NOT_SHARE);
287- context->addFindClassFlags (J9_FINDCLASS_FLAG_LAMBDAFORM);
288- }
289-
290280#if JAVA_SPEC_VERSION >= 15
291281 /* InjectedInvoker is a hidden class without the strong attribute set. It
292282 * is created by MethodHandleImpl.makeInjectedInvoker on the OpenJDK side.
@@ -417,22 +407,6 @@ ROMClassBuilder::handleAnonClassName(J9CfrClassFile *classfile, ROMClassCreation
417407 j9str_printf (PORTLIB, buf, ROM_ADDRESS_LENGTH + 1 , ROM_ADDRESS_FORMAT, 0 );
418408 memcpy (constantPool[newUtfCPEntry].bytes + newHostPackageLength + originalStringLength + 1 , buf, ROM_ADDRESS_LENGTH + 1 );
419409
420- /* Mark if the class is a Lambda class. */
421- #if defined(J9VM_OPT_OPENJDK_METHODHANDLE)
422- if (!context->isLambdaFormClass ()
423- && isLambdaClassName (reinterpret_cast <const char *>(_anonClassNameBuffer),
424- newAnonClassNameLength - 1 , NULL /* deterministicPrefixLength*/ )
425- ) {
426- context->addFindClassFlags (J9_FINDCLASS_FLAG_LAMBDA);
427- }
428- #else /* defined(J9VM_OPT_OPENJDK_METHODHANDLE) */
429- if (isLambdaClassName (reinterpret_cast <const char *>(_anonClassNameBuffer),
430- newAnonClassNameLength - 1 , NULL /* deterministicPrefixLength*/ )
431- ) {
432- context->addFindClassFlags (J9_FINDCLASS_FLAG_LAMBDA);
433- }
434- #endif /* defined(J9VM_OPT_OPENJDK_METHODHANDLE) */
435-
436410 /* search constantpool for all other identical classRefs. We have not actually
437411 * tested this scenario as javac will not output more than one classRef or utfRef of the
438412 * same kind.
@@ -590,18 +564,6 @@ ROMClassBuilder::prepareAndLaydown( BufferManager *bufferManager, ClassFileParse
590564 getSizeInfo (context, &romClassWriter, &srpOffsetTable, &countDebugDataOutOfLine, &sizeInformation);
591565
592566 U_32 romSize = 0 ;
593- #if JAVA_SPEC_VERSION < 21
594- U_32 sizeToCompareForLambda = 0 ;
595- if (context->isLambdaClass ()) {
596- /*
597- * romSize calculated from getSizeInfo() does not involve StringInternManager. It is only accurate for string intern disabled classes.
598- * Lambda classes in java 15 and up are strong hidden classes (defined with Option.STONG), which has the same lifecycle as its
599- * defining class loader. It is string intern enabled. So pass classFileSize instead of romSize to sizeToCompareForLambda.
600- */
601- sizeToCompareForLambda = classFileOracle.getClassFileSize ();
602- }
603- #endif /* JAVA_SPEC_VERSION < 21 */
604-
605567 if (context->shouldCompareROMClassForEquality ()) {
606568 ROMClassVerbosePhase v (context, CompareHashtableROMClass);
607569
@@ -624,9 +586,6 @@ ROMClassBuilder::prepareAndLaydown( BufferManager *bufferManager, ClassFileParse
624586 modifiers,
625587 extraModifiers,
626588 optionalFlags,
627- #if JAVA_SPEC_VERSION < 21
628- sizeToCompareForLambda,
629- #endif /* JAVA_SPEC_VERSION < 21 */
630589 context)
631590 ) {
632591 return OK;
@@ -720,9 +679,6 @@ ROMClassBuilder::prepareAndLaydown( BufferManager *bufferManager, ClassFileParse
720679 modifiers,
721680 extraModifiers,
722681 optionalFlags,
723- #if JAVA_SPEC_VERSION < 21
724- sizeToCompareForLambda,
725- #endif /* JAVA_SPEC_VERSION < 21 */
726682 context)
727683
728684 ) {
@@ -1479,55 +1435,19 @@ ROMClassBuilder::compareROMClassForEquality(
14791435 U_32 modifiers,
14801436 U_32 extraModifiers,
14811437 U_32 optionalFlags,
1482- #if JAVA_SPEC_VERSION < 21
1483- U_32 sizeToCompareForLambda,
1484- #endif /* JAVA_SPEC_VERSION < 21 */
14851438 ROMClassCreationContext *context)
14861439{
14871440 bool ret = false ;
1441+ ComparingCursor compareCursor (_javaVM, srpOffsetTable, srpKeyProducer, classFileOracle, romClass, romClassIsShared, context);
1442+ romClassWriter->writeROMClass (&compareCursor,
1443+ &compareCursor,
1444+ &compareCursor,
1445+ NULL ,
1446+ NULL ,
1447+ 0 , modifiers, extraModifiers, optionalFlags,
1448+ ROMClassWriter::WRITE);
14881449
1489- #if JAVA_SPEC_VERSION < 21
1490- if (context->isLambdaClass ()) {
1491- /*
1492- * Lambda class names are in the format of HostClassName$$Lambda$<IndexNumber>/<zeroed out ROM_ADDRESS>.
1493- * When we reach this check, the host class names will be the same for both the classes because
1494- * of the earlier hash-key check. So, the only difference in the size will be the difference
1495- * between the number of digits of the index number. The same lambda class might have a
1496- * different index number from run to run and when the number of digits of the index number
1497- * increases by 1, classFileSize also increases by 1. The indexNumber is the counter for the number of
1498- * lambda classes defined so far. It is an int in the JCL side. So the it cannot vary more than max
1499- * integer vs 0, which is maxVariance (9 bytes). This check is different than the romSize check because
1500- * when the number of digits of the index number increases by 1, classFileSize also increases by 1 but
1501- * romSize increases by 2.
1502- */
1503- int maxVariance = 9 ;
1504- int variance = abs (static_cast <int >((sizeToCompareForLambda - reinterpret_cast <J9ROMClass *>(romClass)->classFileSize )));
1505- if (variance <= maxVariance) {
1506- ComparingCursor compareCursor (_javaVM, srpOffsetTable, srpKeyProducer, classFileOracle, romClass, romClassIsShared, context);
1507- romClassWriter->writeROMClass (&compareCursor,
1508- &compareCursor,
1509- &compareCursor,
1510- NULL ,
1511- NULL ,
1512- 0 , modifiers, extraModifiers, optionalFlags,
1513- ROMClassWriter::WRITE);
1514-
1515- ret = compareCursor.isEqual ();
1516- }
1517- } else
1518- #endif /* JAVA_SPEC_VERSION < 21 */
1519- {
1520- ComparingCursor compareCursor (_javaVM, srpOffsetTable, srpKeyProducer, classFileOracle, romClass, romClassIsShared, context);
1521- romClassWriter->writeROMClass (&compareCursor,
1522- &compareCursor,
1523- &compareCursor,
1524- NULL ,
1525- NULL ,
1526- 0 , modifiers, extraModifiers, optionalFlags,
1527- ROMClassWriter::WRITE);
1528-
1529- ret = compareCursor.isEqual ();
1530- }
1450+ ret = compareCursor.isEqual ();
15311451 J9UTF8* name = J9ROMCLASS_CLASSNAME ((J9ROMClass *)romClass);
15321452 Trc_BCU_compareROMClassForEquality_event (ret, J9UTF8_LENGTH (name), J9UTF8_DATA (name));
15331453 return ret;
0 commit comments