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

[Linux] Fail to disable JIT when enabled Interpreter #12767

Closed
xiangzhai opened this issue May 29, 2019 · 2 comments
Closed

[Linux] Fail to disable JIT when enabled Interpreter #12767

xiangzhai opened this issue May 29, 2019 · 2 comments
Labels
area-VM-coreclr question Answer questions and provide assistance, not an issue with source code or documentation.
Milestone

Comments

@xiangzhai
Copy link
Contributor

Hi,

Just follow @kangaroo porting work dotnet/coreclr#1292 (comment) enabled interpreter and still tracking JitFunctionTrace to see whether or not disable JIT TOTALLY:

export COMPlus_DumpInterpreterStubs=1
export COMPlus_Interpret=*
export COMPlus_InterpreterPrintPostMortem=1
export COMPlus_InterpreterDoLoopMethods=1
export COMPlus_TieredCompilation=1
export COMPlus_JITMinOpts=1
export COMPlus_ZapDisable=1
export COMPlus_JitFunctionTrace=1

But it is still Start Jitting in the Jitted Entry when such Method doesn't meet the IsEligibleForTieredCompilation condition:

...
Generating interpretation stub (# 5 = 0x5, hash = 0x69bf8d7c) for <>c:.ctor.
START 5, <>c:.ctor()
     0: ldarg.0
   0x1: call
  Returning to method <>c:.ctor(), stub num 5.
   0x6: ret
DONE 5, <>c:.ctor()
  Returning to method <>c:.cctor(), stub num 4.
   0x5: stsfld
   0xa: ret
DONE 4, <>c:.cctor()
   0xa: dup
   0xb: brtrue.s
   0xd: pop
   0xe: ldsfld
  0x13: ldftn
  0x19: newobj
{ Start Jitting System.MulticastDelegate:CtorClosed(ref,long):this (MethodHash=ad3a8451)
} Jitted Entry 149 at 00007f7a`601cd0a0 method System.MulticastDelegate:CtorClosed(ref,long):this size 0000006f
  Returning to method System.Console:get_Out():class, stub num 3.
  0x1e: dup
  0x1f: stsfld
  0x24: call
{ Start Jitting DomainBoundILStubClass:IL_STUB_InstantiatingStub(byref,ref):ref (MethodHash=294d3ab2)
} Jitted Entry 14a at 00007f7a`601cd530 method DomainBoundILStubClass:IL_STUB_InstantiatingStub(byref,ref):ref size 0000003f
Generating interpretation stub (# 6 = 0x6, hash = 0xbf685470) for System.Console:EnsureInitialized.
START 6, System.Console:EnsureInitialized(byref,class):class
     0: ldarg.0
   0x1: ldsflda
...

Hacking JIT by commenting CompileMethodWithEtwWrapper to force disable JIT, but, of course, fail to initialize:

diff --git a/src/vm/jitinterface.cpp b/src/vm/jitinterface.cpp
index 502b5ada13..87de5f0e9e 100644
--- a/src/vm/jitinterface.cpp
+++ b/src/vm/jitinterface.cpp
@@ -12158,7 +12158,8 @@ CorJitResult invokeCompileMethodHelper(EEJitManager *jitMgr,
             }
         }
     }
-    
+
+#if 0
     if (FAILED(ret) && jitMgr->m_jit)
     {
         ret = CompileMethodWithEtwWrapper(jitMgr, 
@@ -12168,6 +12169,7 @@ CorJitResult invokeCompileMethodHelper(EEJitManager *jitMgr,
                                           nativeEntry,
                                           nativeSizeOfCode);
     }
+#endif
 
     if (interpreterFallback == true)
     {

OpenJDK is able to just enable interpreter:

java -Xint

or just enable JIT compilers:

java -Xcomp

or mixed:

java -Xmixed

How to disable JIT when enabled Interpreter for corerun? Please give me some hint.

Thanks,
Leslie Zhai

@AndyAyersMS
Copy link
Member

The logic around when to interpret is currently tied into tiered compilation, so I think your will need to modify the logic.

If you change TieredCompilationManager::GetJitFlags to stop setting CORJIT_FLAG_MAKEFINALCODE and then set COMPlus_InterpreterJITThreshold to a very large number, you should be able to stop jitting.

@xiangzhai
Copy link
Contributor Author

xiangzhai commented May 30, 2019

Hi @AndyAyersMS

Thanks for your kind response!

The logic around when to interpret is currently tied into tiered compilation, so I think your will need to modify the logic.

If you change TieredCompilationManager::GetJitFlags to stop setting CORJIT_FLAG_MAKEFINALCODE and then set COMPlus_InterpreterJITThreshold to a very large number, you should be able to stop jitting.

Works 👍

diff --git a/src/vm/tieredcompilation.cpp b/src/vm/tieredcompilation.cpp
index b87d01af8d..596a599fa9 100644
--- a/src/vm/tieredcompilation.cpp
+++ b/src/vm/tieredcompilation.cpp
@@ -606,7 +606,7 @@ CORJIT_FLAGS TieredCompilationManager::GetJitFlags(NativeCodeVersion nativeCodeV
     if (!nativeCodeVersion.GetMethodDesc()->IsEligibleForTieredCompilation())
     {
 #ifdef FEATURE_INTERPRETER
-        flags.Set(CORJIT_FLAGS::CORJIT_FLAG_MAKEFINALCODE);
+        //flags.Set(CORJIT_FLAGS::CORJIT_FLAG_MAKEFINALCODE);
 #endif
         return flags;
     }
@@ -620,7 +620,7 @@ CORJIT_FLAGS TieredCompilationManager::GetJitFlags(NativeCodeVersion nativeCodeV
     {
         flags.Set(CORJIT_FLAGS::CORJIT_FLAG_TIER1);
 #ifdef FEATURE_INTERPRETER
-        flags.Set(CORJIT_FLAGS::CORJIT_FLAG_MAKEFINALCODE);
+        //flags.Set(CORJIT_FLAGS::CORJIT_FLAG_MAKEFINALCODE);
 #endif
     }
     return flags;
  • set COMPlus_InterpreterJITThreshold to a very large number
export COMPlus_DumpInterpreterStubs=1
export COMPlus_Interpret=*
export COMPlus_InterpreterJITThreshold=999999
export COMPlus_InterpreterPrintPostMortem=1
export COMPlus_InterpreterDoLoopMethods=1
export COMPlus_TieredCompilation=1
export COMPlus_JITMinOpts=1
export COMPlus_ZapDisable=1
export COMPlus_JitFunctionTrace=1

stop jitting now:

enerating interpretation stub (# 1 = 0x1, hash = 0xa5094c3c) for System.AppDomain:SetupDomain.
START 1, System.AppDomain:SetupDomain(bool,class,class,class,class)
     0: nop
   0x1: ldarg.0
   0x2: stloc.0
      loc0   :      class: null
      loc1   :       bool: false
      loc2   :       bool: false
   0x3: ldc.i4.0
   0x4: stloc.1
      loc0   :      class: null
      loc1   :       bool: false
      loc2   :       bool: false
   0x5: ldloc.0
   0x6: ldloca.s
   0x8: call
Generating interpretation stub (# 2 = 0x2, hash = 0x8f9d75e) for System.Threading.Monitor:Enter.
START 2, System.Threading.Monitor:Enter(class,byref)
     0: nop
   0x1: ldarg.1
   0x2: ldind.u1
   0x3: stloc.0
      loc0   :       bool: false
   0x4: ldloc.0
   0x5: brfalse.s
   0xd: ldarg.0
   0xe: ldarg.1
   0xf: call
Generating interpretation stub (# 3 = 0x3, hash = 0x361663e1) for System.ArgumentNullException:.ctor.
START 3, System.ArgumentNullException:.ctor()
     0: ldarg.0
   0x1: call
Generating interpretation stub (# 4 = 0x4, hash = 0xf1138cbc) for System.SR:.cctor.
START 4, System.SR:.cctor()
     0: newobj
Generating interpretation stub (# 5 = 0x5, hash = 0xd89717ab) for System.Object:.ctor.
START 5, System.Object:.ctor()
     0: nop
   0x1: ret
DONE 5, System.Object:.ctor()
  Returning to method System.SR:.cctor(), stub num 4.
   0x5: stsfld
   0xa: ldc.i4.0
   0xb: stsfld
  0x10: ldtoken
  0x15: call
  Returning to method System.SR:.cctor(), stub num 4.
  0x1a: stsfld
  0x1f: ret
DONE 4, System.SR:.cctor()
Generating interpretation stub (# 6 = 0x6, hash = 0xe89400d4) for System.SR:get_ArgumentNull_Generic.
START 6, System.SR:get_ArgumentNull_Generic():class
     0: nop
   0x1: ldstr
   0x6: ldnull
   0x7: call
Generating interpretation stub (# 7 = 0x7, hash = 0x7b33abb2) for System.SR:GetResourceString.
START 7, System.SR:GetResourceString(class,class):class
     0: nop
   0x1: ldnull
   0x2: stloc.0
      loc0   :      class: null
      loc1   :       bool: false
      loc2   :      class: null
   0x3: nop
   0x4: ldarg.0
   0x5: call
Generating interpretation stub (# 8 = 0x8, hash = 0x4976d6f5) for System.SR:InternalGetResourceString.
START 8, System.SR:InternalGetResourceString(class):class
     0: nop
   0x1: ldarg.0
   0x2: brfalse.s
   0x4: ldarg.0
   0x5: callvirt
  Returning to method System.SR:InternalGetResourceString(class):class, stub num 8.
   0xa: ldc.i4.0
   0xb: ceq
   0xd: br.s
  0x10: stloc.1
      loc0   :       bool: false
      loc1   :       bool: false
      loc2   :      class: null
      loc3   :      class: null
      loc4   :       bool: false
      loc5   :      class: null
      loc6   :       bool: false
      loc7   :       bool: false
      loc8   :       bool: false
      loc9   :       bool: false
      loc10  :       bool: false
      loc11  :       bool: false
  0x11: ldloc.1
  0x12: brfalse.s
  0x27: ldc.i4.0
  0x28: stloc.0
      loc0   :       bool: false
      loc1   :       bool: false
      loc2   :      class: null
      loc3   :      class: null
      loc4   :       bool: false
      loc5   :      class: null
      loc6   :       bool: false
      loc7   :       bool: false
      loc8   :       bool: false
      loc9   :       bool: false
      loc10  :       bool: false
      loc11  :       bool: false
  0x29: nop
  0x2a: ldsfld
  0x2f: ldloca.s
  0x31: call
START 2, System.Threading.Monitor:Enter(class,byref)
     0: nop
   0x1: ldarg.1
   0x2: ldind.u1
   0x3: stloc.0
      loc0   :       bool: false
   0x4: ldloc.0
   0x5: brfalse.s
   0xd: ldarg.0
   0xe: ldarg.1
   0xf: call
  Returning to method System.Threading.Monitor:Enter(class,byref), stub num 2.
  0x14: nop
  0x15: ldarg.1
  0x16: ldind.u1
  0x17: call
Generating interpretation stub (# 9 = 0x9, hash = 0x83ca9f76) for System.Diagnostics.Debug:.cctor.
START 9, System.Diagnostics.Debug:.cctor()
     0: newobj
START 5, System.Object:.ctor()
     0: nop
   0x1: ret
DONE 5, System.Object:.ctor()
  Returning to method System.Diagnostics.Debug:.cctor(), stub num 9.
   0x5: stsfld
   0xa: ldc.i4.4
   0xb: stsfld
  0x10: ldnull
  0x11: ldftn
  0x17: newobj
Generating interpretation stub (# 10 = 0xa, hash = 0x47033a56) for System.MulticastDelegate:CtorOpened.
START 10, System.MulticastDelegate:CtorOpened(class,nativeint,nativeint)
     0: nop
   0x1: ldarg.0
   0x2: ldarg.0
   0x3: stfld
   0x8: ldarg.0
   0x9: ldarg.3
   0xa: stfld
   0xf: ldarg.0
  0x10: ldarg.2
  0x11: stfld
  0x16: ret
DONE 10, System.MulticastDelegate:CtorOpened(class,nativeint,nativeint)
  Returning to method System.Diagnostics.Debug:.cctor(), stub num 9.
  0x1c: stsfld
  0x21: ldnull
  0x22: ldftn
  0x28: newobj
START 10, System.MulticastDelegate:CtorOpened(class,nativeint,nativeint)
     0: nop
   0x1: ldarg.0
   0x2: ldarg.0
   0x3: stfld
   0x8: ldarg.0
   0x9: ldarg.3
   0xa: stfld
   0xf: ldarg.0
  0x10: ldarg.2
  0x11: stfld
  0x16: ret
DONE 10, System.MulticastDelegate:CtorOpened(class,nativeint,nativeint)
  Returning to method System.Diagnostics.Debug:.cctor(), stub num 9.
  0x2d: stsfld
  0x32: ldstr
  0x37: call
Generating interpretation stub (# 11 = 0xb, hash = 0xcb2679a8) for System.Environment:.cctor.
START 11, System.Environment:.cctor()
     0: ldnull
   0x1: stsfld
   0x6: ret
DONE 11, System.Environment:.cctor()
Generating interpretation stub (# 12 = 0xc, hash = 0x95e7712a) for System.Environment:GetEnvironmentVariable.
START 12, System.Environment:GetEnvironmentVariable(class):class
     0: nop
   0x1: ldarg.0
   0x2: ldnull
   0x3: ceq
   0x5: stloc.0
      loc0   :       bool: false
      loc1   :      class: null
   0x6: ldloc.0
   0x7: brfalse.s
  0x15: ldarg.0
  0x16: call
Generating interpretation stub (# 13 = 0xd, hash = 0x82205fb1) for System.Environment:GetEnvironmentVariableCore.
START 13, System.Environment:GetEnvironmentVariableCore(class):class
     0: nop
   0x1: ldc.i4
   0x6: stloc.1
      loc0   : valueclass: <System.Span`1[Char]>: [0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00]
      loc1   :        int: 128
      loc2   :      class: null
   0x7: ldloc.1
   0x8: conv.u
   0x9: ldc.i4.2
   0xa: mul.ovf.un
   0xb: localloc
   0xd: ldloc.1
   0xe: newobj
Generating interpretation stub (# 14 = 0xe, hash = 0xec9f434b) for System.Span`1[Char][System.Char]:.ctor.
START 14, System.Span`1[Char][System.Char]:.ctor(ptr,int)
     0: nop
   0x1: call
Generating interpretation stub (# 15 = 0xf, hash = 0xa6b3b063) for System.Runtime.CompilerServices.RuntimeHelpers:IsReferenceOrContainsReferences.
START 15, System.Runtime.CompilerServices.RuntimeHelpers:IsReferenceOrContainsReferences():bool
     0: ldc.i4.0
   0x1: ret
DONE 15, System.Runtime.CompilerServices.RuntimeHelpers:IsReferenceOrContainsReferences():bool
  Returning to method System.Span`1[Char][System.Char]:.ctor(ptr,int), stub num 14.
   0x6: stloc.0
      loc0   :       bool: false
      loc1   :       bool: false
   0x7: ldloc.0
   0x8: brfalse.s
  0x1a: ldarg.2
  0x1b: ldc.i4.0
  0x1c: clt
  0x1e: stloc.1
      loc0   :       bool: false
      loc1   :       bool: false
  0x1f: ldloc.1
  0x20: brfalse.s
  0x28: ldarg.0
  0x29: ldarg.1
  0x2a: call
Generating interpretation stub (# 16 = 0x10, hash = 0xb7372003) for Internal.Runtime.CompilerServices.Unsafe:As.
START 16, Internal.Runtime.CompilerServices.Unsafe:As(byref):byref
     0: ldarg.0
   0x1: ret
DONE 16, Internal.Runtime.CompilerServices.Unsafe:As(byref):byref
  Returning to method System.Span`1[Char][System.Char]:.ctor(ptr,int), stub num 14.
  0x2f: newobj
Generating interpretation stub (# 17 = 0x11, hash = 0xfb475877) for System.ByReference`1[Char][System.Char]:.ctor.
START 17, System.ByReference`1[Char][System.Char]:.ctor(byref)
     0: nop
   0x1: newobj
Generating interpretation stub (# 18 = 0x12, hash = 0xd63f730d) for System.PlatformNotSupportedException:.ctor.
START 18, System.PlatformNotSupportedException:.ctor()
     0: ldarg.0
   0x1: call
Generating interpretation stub (# 19 = 0x13, hash = 0xe3079d7d) for System.SR:get_Arg_PlatformNotSupported.
START 19, System.SR:get_Arg_PlatformNotSupported():class
     0: nop
   0x1: ldstr
   0x6: ldnull
   0x7: call
START 7, System.SR:GetResourceString(class,class):class
     0: nop
   0x1: ldnull
   0x2: stloc.0
      loc0   :      class: null
      loc1   :       bool: false
      loc2   :      class: null
   0x3: nop
   0x4: ldarg.0
   0x5: call
START 8, System.SR:InternalGetResourceString(class):class
     0: nop
   0x1: ldarg.0
   0x2: brfalse.s
   0x4: ldarg.0
   0x5: callvirt
  Returning to method System.SR:InternalGetResourceString(class):class, stub num 8.
   0xa: ldc.i4.0
   0xb: ceq
   0xd: br.s
  0x10: stloc.1
      loc0   :       bool: false
      loc1   :       bool: false
      loc2   :      class: null
      loc3   :      class: null
      loc4   :       bool: false
      loc5   :      class: null
      loc6   :       bool: false
      loc7   :       bool: false
      loc8   :       bool: false
      loc9   :       bool: false
      loc10  :       bool: false
      loc11  :       bool: false
  0x11: ldloc.1
  0x12: brfalse.s
  0x27: ldc.i4.0
  0x28: stloc.0
      loc0   :       bool: false
      loc1   :       bool: false
      loc2   :      class: null
      loc3   :      class: null
      loc4   :       bool: false
      loc5   :      class: null
      loc6   :       bool: false
      loc7   :       bool: false
      loc8   :       bool: false
      loc9   :       bool: false
      loc10  :       bool: false
      loc11  :       bool: false
  0x29: nop
  0x2a: ldsfld
  0x2f: ldloca.s
  0x31: call
START 2, System.Threading.Monitor:Enter(class,byref)
     0: nop
   0x1: ldarg.1
   0x2: ldind.u1
   0x3: stloc.0
      loc0   :       bool: false
   0x4: ldloc.0
   0x5: brfalse.s
   0xd: ldarg.0
   0xe: ldarg.1
   0xf: call
  Returning to method System.Threading.Monitor:Enter(class,byref), stub num 2.
  0x14: nop
  0x15: ldarg.1
  0x16: ldind.u1
  0x17: call
Generating interpretation stub (# 20 = 0x14, hash = 0xd2802453) for System.Diagnostics.Debug:Assert.
START 20, System.Diagnostics.Debug:Assert(bool)
     0: nop
   0x1: ldarg.0
   0x2: ldsfld
   0x7: ldsfld
   0xc: call
Generating interpretation stub (# 21 = 0x15, hash = 0xd2802453) for System.Diagnostics.Debug:Assert.
START 21, System.Diagnostics.Debug:Assert(bool,class,class)
     0: nop
   0x1: ldarg.0
   0x2: ldc.i4.0
   0x3: ceq
   0x5: stloc.0
      loc0   :       bool: false
      loc1   :      class: null
   0x6: ldloc.0
   0x7: brfalse.s
  0x49: ret
DONE 21, System.Diagnostics.Debug:Assert(bool,class,class)
  Returning to method System.Diagnostics.Debug:Assert(bool), stub num 20.
  0x11: nop
  0x12: ret
DONE 20, System.Diagnostics.Debug:Assert(bool)
  Returning to method System.Threading.Monitor:Enter(class,byref), stub num 2.
  0x1c: nop
  0x1d: ret
DONE 2, System.Threading.Monitor:Enter(class,byref)
  Returning to method System.SR:InternalGetResourceString(class):class, stub num 8.
  0x36: nop
  0x37: ldsfld
  0x3c: brfalse.s
  0x5e: ldc.i4.0
  0x5f: stloc.s
      loc0   :       bool: true
      loc1   :       bool: false
      loc2   :      class: null
      loc3   :      class: null
      loc4   :       bool: false
      loc5   :      class: null
      loc6   :       bool: false
      loc7   :       bool: false
      loc8   :       bool: false
      loc9   :       bool: false
      loc10  :       bool: false
      loc11  :       bool: false
  0x61: ldloc.s
  0x63: brfalse.s
  0xa8: ldsfld
  0xad: ldnull
  0xae: ceq
  0xb0: stloc.s
      loc0   :       bool: true
      loc1   :       bool: false
      loc2   :      class: null
      loc3   :      class: null
      loc4   :       bool: false
      loc5   :      class: null
      loc6   :       bool: false
      loc7   :       bool: true
      loc8   :       bool: false
      loc9   :       bool: false
      loc10  :       bool: false
      loc11  :       bool: false
  0xb2: ldloc.s
  0xb4: brfalse.s
  0xb6: newobj
Generating interpretation stub (# 22 = 0x16, hash = 0x7b6b2111) for System.Collections.Generic.List`1[__Canon][System.__Canon]:.ctor.
START 22, System.Collections.Generic.List`1[__Canon][System.__Canon]:.ctor()
     0: ldarg.0
   0x1: call
START 5, System.Object:.ctor()
     0: nop
   0x1: ret
DONE 5, System.Object:.ctor()
  Returning to method System.Collections.Generic.List`1[__Canon][System.__Canon]:.ctor(), stub num 22.
   0x6: nop
   0x7: nop
   0x8: ldarg.0
   0x9: ldsfld
Generating interpretation stub (# 23 = 0x17, hash = 0x2a6d7f72) for System.Collections.Generic.List`1[__Canon][System.__Canon]:.cctor.
START 23, System.Collections.Generic.List`1[__Canon][System.__Canon]:.cctor()
     0: ldc.i4.0
   0x1: newarr
...

Cheers,
Leslie Zhai

@xiangzhai xiangzhai changed the title [X86/Linux] Fail to disable JIT when enabled Interpreter [Linux] Fail to disable JIT when enabled Interpreter Nov 7, 2019
@msftgits msftgits transferred this issue from dotnet/coreclr Jan 31, 2020
@msftgits msftgits added this to the Future milestone Jan 31, 2020
@ghost ghost locked as resolved and limited conversation to collaborators Dec 13, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-VM-coreclr question Answer questions and provide assistance, not an issue with source code or documentation.
Projects
None yet
Development

No branches or pull requests

3 participants