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

Disable runtime assumption table on JITServer #9189

Merged
merged 1 commit into from Apr 14, 2020

Conversation

harryyu1994
Copy link
Contributor

JITServer should not create any runtime assumptions, instead it
should buffer them and send them to the client. In order to catch
all mistakes, it's better to disable RuntimeAssumptionTable on JITServer
so any misuses will be caught by crashes.

Issue: #8029

Signed-off-by: Harry Yu harryyu1994@gmail.com

@harryyu1994
Copy link
Contributor Author

#13 0x00007efc9972b004 in TR_RuntimeAssumptionTable::getBucketPtr (this=this@entry=0x7efc98572870, kind=kind@entry=RuntimeAssumptionOnMethodOverride, 
    hashIndex=hashIndex@entry=6704122591054430)
    at /root/Harry_Debug/openj9-openjdk-jdk8/build/linux-x86_64-normal-server-release/vm/compiler/../compiler/runtime/ClassUnloadAssumption.cpp:311
#14 0x00007efc99768047 in TR_PersistentCHTable::methodGotOverridden (this=0x7efc98470da0, fe=0x7efc98574330, persistentMemory=0x7efc98572790, 
    overriddingMethod=<optimized out>, overriddenMethod=0x9a26f8, smpFlag=<optimized out>)
    at /root/Harry_Debug/openj9-openjdk-jdk8/build/linux-x86_64-normal-server-release/vm/compiler/../compiler/runtime/RuntimeAssumptions.cpp:392
#15 0x00007efc99642b06 in jitUpdateMethodOverride (vmThread=0x8b2200, cl=<optimized out>, overriddenMethod=0x9a26f8, overriddingMethod=0x9aec28)
    at /root/Harry_Debug/openj9-openjdk-jdk8/build/linux-x86_64-normal-server-release/vm/compiler/../compiler/control/HookedByTheJit.cpp:3194
#16 0x00007efc99643526 in updateOverriddenFlag (cl=0x9ad800, vm=0x8b2200)
    at /root/Harry_Debug/openj9-openjdk-jdk8/build/linux-x86_64-normal-server-release/vm/compiler/../compiler/control/HookedByTheJit.cpp:3497
#17 updateCHTable (vmThread=vmThread@entry=0x8b2200, cl=cl@entry=0x9ad800)
    at /root/Harry_Debug/openj9-openjdk-jdk8/build/linux-x86_64-normal-server-release/vm/compiler/../compiler/control/HookedByTheJit.cpp:3610
#18 0x00007efc9964374e in jitHookClassPreinitialize (hookInterface=<optimized out>, eventNum=<optimized out>, eventData=0x7ffe12e3d940, userData=<optimized out>)
    at /root/Harry_Debug/openj9-openjdk-jdk8/build/linux-x86_64-normal-server-release/vm/compiler/../compiler/control/HookedByTheJit.cpp:4287
#19 0x00007efc9bbc539e in J9HookDispatch ()
   from /root/Harry_Debug/openj9-openjdk-jdk8/build/linux-x86_64-normal-server-release/images/j2sdk-image/jre/lib/amd64/compressedrefs/libj9hookable29.so
---Type <return> to continue, or q <return> to quit---
#20 0x00007efc9c01a21f in initializeImpl ()

@harryyu1994 harryyu1994 force-pushed the disableRAT branch 3 times, most recently from 9d0508a to e89e865 Compare April 8, 2020 22:00
@harryyu1994
Copy link
Contributor Author

#13 0x00007f95d1ef1014 in TR_RuntimeAssumptionTable::getBucketPtr (this=0x7f95d0d384d0, kind=kind@entry=RuntimeAssumptionOnRegisterNative, 
    hashIndex=hashIndex@entry=15651885773608022)
    at /root/Harry_Debug/openj9-openjdk-jdk8/build/linux-x86_64-normal-server-release/vm/compiler/../compiler/runtime/ClassUnloadAssumption.cpp:311
#14 0x00007f95d1e12865 in jitHookJNINativeRegistered (hookInterface=<optimized out>, eventNum=<optimized out>, eventData=<optimized out>, userData=<optimized out>)
    at /root/Harry_Debug/openj9-openjdk-jdk8/build/linux-x86_64-normal-server-release/vm/compiler/../compiler/control/HookedByTheJit.cpp:6727
#15 0x00007f95d438b39e in J9HookDispatch ()
   from /root/Harry_Debug/openj9-openjdk-jdk8/build/linux-x86_64-normal-server-release/images/j2sdk-image/jre/lib/amd64/compressedrefs/libj9hookable29.so
#16 0x00007f95d4854b52 in registerNatives ()
   from /root/Harry_Debug/openj9-openjdk-jdk8/build/linux-x86_64-normal-server-release/images/j2sdk-image/jre/lib/amd64/compressedrefs/libj9vm29.so
#17 0x00007f95d0dd3de7 in Java_java_lang_invoke_ThunkTuple_registerNatives ()
   from /root/Harry_Debug/openj9-openjdk-jdk8/build/linux-x86_64-normal-server-release/images/j2sdk-image/jre/lib/amd64/compressedrefs/libjclse29.so
#18 0x00007f95d48e97a4 in ffi_call_unix64 ()
   from /root/Harry_Debug/openj9-openjdk-jdk8/build/linux-x86_64-normal-server-release/images/j2sdk-image/jre/lib/amd64/compressedrefs/libj9vm29.so
#19 0x00007f95d48e6e97 in ffi_call ()
   from /root/Harry_Debug/openj9-openjdk-jdk8/build/linux-x86_64-normal-server-release/images/j2sdk-image/jre/lib/amd64/compressedrefs/libj9vm29.so
#20 0x00007f95d47d0d76 in VM_BytecodeInterpreter::run(J9VMThread*) ()
---Type <return> to continue, or q <return> to quit---
   from /root/Harry_Debug/openj9-openjdk-jdk8/build/linux-x86_64-normal-server-release/images/j2sdk-image/jre/lib/amd64/compressedrefs/libj9vm29.so

@harryyu1994
Copy link
Contributor Author

#13 0x00007f0a9ff66074 in TR_RuntimeAssumptionTable::getBucketPtr(TR_RuntimeAssumptionKind, unsigned long) ()
   from /root/Harry_Debug/openj9-openjdk-jdk8/build/linux-x86_64-normal-server-release/images/j2sdk-image/jre/lib/amd64/compressedrefs/libj9jit29.so
#14 0x00007f0a9ff66a7c in TR_RuntimeAssumptionTable::notifyIllegalStaticFinalFieldModificationEvent(TR_FrontEnd*, void*) ()
   from /root/Harry_Debug/openj9-openjdk-jdk8/build/linux-x86_64-normal-server-release/images/j2sdk-image/jre/lib/amd64/compressedrefs/libj9jit29.so
#15 0x00007f0a9fe80546 in jitIllegalFinalFieldModification ()
   from /root/Harry_Debug/openj9-openjdk-jdk8/build/linux-x86_64-normal-server-release/images/j2sdk-image/jre/lib/amd64/compressedrefs/libj9jit29.so
#16 0x00007f0aa285433c in VM_BytecodeInterpreter::run(J9VMThread*) ()
   from /root/Harry_Debug/openj9-openjdk-jdk8/build/linux-x86_64-normal-server-release/images/j2sdk-image/jre/lib/amd64/compressedrefs/libj9vm29.so
#17 0x00007f0aa2832950 in bytecodeLoop ()
   from /root/Harry_Debug/openj9-openjdk-jdk8/build/linux-x86_64-normal-server-release/images/j2sdk-image/jre/lib/amd64/compressedrefs/libj9vm29.so
#18 0x00007f0aa28f51b2 in c_cInterpreter ()

@harryyu1994 harryyu1994 force-pushed the disableRAT branch 3 times, most recently from 67e71ba to 6ba79f7 Compare April 8, 2020 22:48
@mpirvu mpirvu added the comp:jitserver Artifacts related to JIT-as-a-Service project label Apr 8, 2020
@mpirvu mpirvu added this to In progress in JIT as a Service via automation Apr 8, 2020
@mpirvu mpirvu self-assigned this Apr 8, 2020
@harryyu1994 harryyu1994 changed the title WIP: Disable runtime assumption table on JITServer Disable runtime assumption table on JITServer Apr 9, 2020
@harryyu1994
Copy link
Contributor Author

Ready for review.

TR_RuntimeAssumptionTable * rat = compInfo->getPersistentInfo()->getRuntimeAssumptionTable();
if (rat)
if (rat
#if defined(J9VM_OPT_JITSERVER)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we take this path at the server something is wrong.
Thus, i would rather place an ASSERT_FATAL here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We do take this path at the server. Investigating what's wrong here.

@@ -3550,9 +3555,6 @@ static bool updateCHTable(J9VMThread * vmThread, J9Class * cl)
TR_PersistentCHTable * table = 0;
if (TR::Options::getCmdLineOptions()->allowRecompilation()
&& !TR::Options::getCmdLineOptions()->getOption(TR_DisableCHOpts)
#if defined(J9VM_OPT_JITSERVER)
&& compInfo->getPersistentInfo()->getRemoteCompilationMode() != JITServer::SERVER
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this code removed. The idea is that, we don't want to update the CHTable at the server because it is not used for compilation anyway.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think persistentMemory->getPersistentInfo()->getRuntimeAssumptionTable()->init() is the only place where we call updateCHTable() at the server. Since that's disabled, updateCHTable() is no longer called at the server thus doesn't need a guard.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be sure let's add an ASSERT_FATAL

@harryyu1994
Copy link
Contributor Author

Path to jitIllegalFinalFieldModification()

#15 0x00007f857e4a64f5 in jitIllegalFinalFieldModification (currentThread=<optimized out>, 
    fieldClass=<optimized out>)
    at /root/Harry_Debug/openj9-openjdk-jdk8/build/linux-x86_64-normal-server-release/vm/compiler/../compiler/control/HookedByTheJit.cpp:3139
#16 0x00007f8580e7a33c in VM_VMHelpers::reportFinalFieldModified (
---Type <return> to continue, or q <return> to quit---
    fieldClass=<optimized out>, currentThread=<optimized out>) at ../oti/VMHelpers.hpp:1582
#17 VM_UnsafeAPI::putObject (value=<optimized out>, isVolatile=<optimized out>, 
    offset=<optimized out>, object=<optimized out>, objectAccessBarrier=<optimized out>, 
    currentThread=<optimized out>) at ../oti/UnsafeAPI.hpp:525
#18 VM_BytecodeInterpreter::inlUnsafePutObject (isVolatile=<optimized out>, 
    _pc=<optimized out>, _sp=<optimized out>, this=<optimized out>)
    at BytecodeInterpreter.hpp:3782
#19 VM_BytecodeInterpreter::run (this=0x3fcc, this@entry=0x7fff26c4e7e0, vmThread=0x0)
    at BytecodeInterpreter.hpp:9535
#20 0x00007f8580e58950 in bytecodeLoop (currentThread=<optimized out>)
    at BytecodeInterpreter.cpp:109
#21 0x00007f8580f1b1b2 in c_cInterpreter () at xcinterp.s:160
#22 0x00007f8580ec7eb6 in initializeAttachedThreadImpl (
    currentThread=currentThread@entry=0xb90200, name=name@entry=0x0, group=0x0, daemon=0, 
    initializee=0xb90200) at callin.cpp:555
#23 0x00007f8580ecd759 in initializeAttachedThread (currentThread=0xb90200, name=0x0, 
    group=<optimized out>, daemon=<optimized out>, initializee=<optimized out>)
    at callin.cpp:1285
#24 0x00007f857d4962db in standardInit (vm=vm@entry=0xb37610, 
    dllName=dllName@entry=0x7f857d4b93d1 "jclse29") at common/stdinit.c:188
#25 0x00007f857d4a3065 in scarInit (vm=0xb37610) at common/vm_scar.c:312
#26 0x00007f857d4a386d in J9VMDllMain (vm=0xb37610, stage=<optimized out>, 
    reserved=<optimized out>) at common/vm_scar.c:376
#27 0x00007f8580ef1271 in runJ9VMDllMain (dllLoadInfo=0xb46438, 
    userDataTemp=0x7fff26c4ecb0) at jvminit.c:3445
#28 0x00007f8580f895d0 in pool_do (pool=0xb45ce0, 
    doFunction=0x7f8580ef11a0 <runJ9VMDllMain>, userData=0x7fff26c4ecb0) at pool.c:648
#29 0x00007f8580e57c34 in runInitializationStage (vm=vm@entry=0xb37610, 
    stage=stage@entry=14) at jvminit.c:3395
#30 0x00007f8580efa624 in protectedInitializeJavaVM (portLibrary=<optimized out>, 
    userData=<optimized out>) at jvminit.c:6259
#31 0x00007f85802cff53 in omrsig_protect ()
   from /root/Harry_Debug/openj9-openjdk-jdk8/build/linux-x86_64-normal-server-release/images/j2sdk-image/jre/lib/amd64/compressedrefs/libj9prt29.so
#32 0x00007f8580ef3b38 in initializeJavaVM (osMainThread=<optimized out>, 
    vmPtr=vmPtr@entry=0x7f85818332a0 <BFUjavaVM>, 
    createParams=createParams@entry=0x7fff26c4f1c0) at jvminit.c:1005
#33 0x00007f8580eeaae5 in J9_CreateJavaVM (p_vm=0x7f85818332a0 <BFUjavaVM>, 
    p_env=0x7fff26c502e8, createParams=0x7fff26c4f1c0) at jniinv.c:146
#34 0x00007f858160b008 in JNI_CreateJavaVM_impl ()
   from /root/Harry_Debug/openj9-openjdk-jdk8/build/linux-x86_64-normal-server-release/images/j2sdk-image/jre/lib/amd64/compressedrefs/libjvm.so
#35 0x00007f858160c64f in JITServer_CreateServer ()
   from /root/Harry_Debug/openj9-openjdk-jdk8/build/linux-x86_64-normal-server-release/images/j2sdk-image/jre/lib/amd64/compressedrefs/libjvm.so
#36 0x0000000000400c38 in main ()

@harryyu1994
Copy link
Contributor Author

harryyu1994 commented Apr 13, 2020

So the hook was triggered by something from the "Unsafe" class from the sun.misc package (primarily designed for internal use within the core libraries). When the J9_SUN_STATIC_FIELD_OFFSET_TAG is set, we trigger a call to reportFinalFieldModified.
@mpirvu I think ignoring it on JITServer is sufficient. I will change the code in that hook temporally to return right away in JITServer mode. Then I will work on disabling all the JIT hooks on JITServer in another change. (Which will be tracked here: #7508)

static VMINLINE void
	putObject(J9VMThread *currentThread, MM_ObjectAccessBarrierAPI *objectAccessBarrier, j9object_t object, UDATA offset, bool isVolatile, j9object_t *value)
	{
		if (VM_VMHelpers::objectIsArray(currentThread, object)) {
			UDATA index = convertOffsetToIndex(currentThread, offset, logFJ9ObjectSize(currentThread));
			objectAccessBarrier->inlineIndexableObjectStoreObject(currentThread, object, index, *value, isVolatile);
		} else if (offset & J9_SUN_STATIC_FIELD_OFFSET_TAG) {
			/* Static field */
			J9Class *fieldClass = J9VM_J9CLASS_FROM_HEAPCLASS(currentThread, object);
			if (J9_ARE_ANY_BITS_SET(offset, J9_SUN_FINAL_FIELD_OFFSET_TAG)) {
				VM_VMHelpers::reportFinalFieldModified(currentThread, fieldClass);
			}
			void *valueAddress = (void*)((UDATA)fieldClass->ramStatics + (offset & ~(UDATA)J9_SUN_FIELD_OFFSET_MASK));
			objectAccessBarrier->inlineStaticStoreObject(currentThread, fieldClass, (j9object_t*)valueAddress, *value, isVolatile);
		} else {
			/* Instance field */
			objectAccessBarrier->inlineMixedObjectStoreObject(currentThread, object, offset, *value, isVolatile);
		}
	}

@harryyu1994
Copy link
Contributor Author

Ready for another review

@@ -3136,6 +3136,15 @@ void jitMethodBreakpointed(J9VMThread * vmThread, J9Method *j9method)
*/
void jitIllegalFinalFieldModification(J9VMThread *currentThread, J9Class *fieldClass)
{
#if defined(J9VM_OPT_JITSERVER)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

compInfo is not defined at this point

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should have got the jitConfig like below:
J9JITConfig * jitConfig = currentThread->javaVM->jitConfig;
Maybe it compiles because there is a global somewhere.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good eye! I can't believe that compiled.

@@ -3550,9 +3555,6 @@ static bool updateCHTable(J9VMThread * vmThread, J9Class * cl)
TR_PersistentCHTable * table = 0;
if (TR::Options::getCmdLineOptions()->allowRecompilation()
&& !TR::Options::getCmdLineOptions()->getOption(TR_DisableCHOpts)
#if defined(J9VM_OPT_JITSERVER)
&& compInfo->getPersistentInfo()->getRemoteCompilationMode() != JITServer::SERVER
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be sure let's add an ASSERT_FATAL

@mpirvu
Copy link
Contributor

mpirvu commented Apr 14, 2020

jenkins compile plinuxjit jdk11

JITServer should not create any runtime assumptions, instead it
should buffer them and send them to the client. In order to catch
all mistakes, it's better to disable RuntimeAssumptionTable on JITServer
so any misuses will be caught by crashes.

Issue: eclipse-openj9#8029

Signed-off-by: Harry Yu <harryyu1994@gmail.com>
Copy link
Contributor

@mpirvu mpirvu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@mpirvu
Copy link
Contributor

mpirvu commented Apr 14, 2020

jenkins test sanity plinuxjit,xlinuxjit jdk11

@mpirvu mpirvu merged commit a429b60 into eclipse-openj9:master Apr 14, 2020
JIT as a Service automation moved this from In progress to Done Apr 14, 2020
@harryyu1994 harryyu1994 deleted the disableRAT branch April 17, 2020 18:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
comp:jitserver Artifacts related to JIT-as-a-Service project
Projects
Development

Successfully merging this pull request may close these issues.

None yet

2 participants