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

Fix IL interpreter to run on Hello World #37825

Merged
merged 33 commits into from
Jun 19, 2020

Conversation

yuchong-pan
Copy link
Contributor

@yuchong-pan yuchong-pan commented Jun 12, 2020

  1. Bug fix: Fix type casts in interpreter.cpp to make the codebase compile on Windows when FEATURE_INTERPRETER is turned on.
  2. Bug fix: Special case get_IsSupported in the interpreter to semantically correctly interpret hardware intrinsics.
  3. Bug fix: Fix bugs for the asynchronous promotion to Tier 1 in Tiered Compilation.
  4. Improvement: Add two COMPlus_ environment variables ForceInterpreterTier0 and ForceInterpreterAlways to force the interpreter to be used as Tier 0 and always, respectively. Note that these two environment variables respect others; for instance, if InterpreterFallback is set to 1, then JIT is still the default option. (Hence please check if the descriptions of the two environment variables are accurate.)

Fixes #13759.

With the above changes to the codebase, the interpreter runs on the following Hello World sample program. The number of calls to Not is used to trigger the promotion to Tier 1 in Tiered Compilation.

using System;

namespace ConsoleApp
{
    class Program
    {
        static bool Not(bool p)
        {
            bool q = p;
            q = !q;
            return q;
        }

        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");
            bool b = true;
            bool bb = Not(b);

            bb = Not(bb);
            bb = Not(bb);
            bb = Not(bb);
            bb = Not(bb);
            bb = Not(bb);
            bb = Not(bb);
            bb = Not(bb);
            bb = Not(bb);
            bb = Not(bb);
            bb = Not(bb);
            bb = Not(bb);
            bb = Not(bb);
            bb = Not(bb);
            bb = Not(bb);
            bb = Not(bb);
            bb = Not(bb);
            bb = Not(bb);
            bb = Not(bb);
            bb = Not(bb);
            bb = Not(bb);
            bb = Not(bb);
            bb = Not(bb);
            bb = Not(bb);
            bb = Not(bb);
            bb = Not(bb);
            bb = Not(bb);
            bb = Not(bb);
            bb = Not(bb);
            bb = Not(bb);
            bb = Not(bb);
            bb = Not(bb);
            bb = Not(bb);
            bb = Not(bb);
            bb = Not(bb);
            bb = Not(bb);
            bb = Not(bb);

            Console.WriteLine(bb);
        }
    }
}

The following steps reproduce the result on the Hello World sample program (on Windows):

  • Replace line 20 with set(FEATURE_INTERPRETER 0) in src\coreclr\clrfeatures.cmake.
  • Build the Runtime by .\build.cmd -subset clr.runtime.
  • Built the C# program below in Release.
  • Set the COMPlus_ environment variables by the following (e.g. in Powershell):
$env:COMPlus_Interpret='*'
$env:COMPlus_ZapDisable=1
$env:COMPlus_InterpreterJITThreshold=10
$env:COMPlus_TC_CallCountThreshold=10
$env:COMPlus_TieredCompilation=1
$env:COMPlus_InterpreterHWIntrinsicsIsSupportedFalse=1
$env:COMPlus_InterpreterDoLoopMethods=1

# tracing
$env:COMPlus_InterpreterPrintPostMortem=1
$env:COMPlus_TraceInterpreterVerbose=0
$env:COMPlus_TraceInterpreterIL=0
$env:COMPlus_TraceInterpreterEntries=0
$env:COMPlus_DumpInterpreterStubs=0
$env:COMPlus_JitFunctionTrace=0
$env:COMPlus_TraceInterpreterJITTransition=1
  • Use the built Runtime to execute the C# program.

Current Priority 0 passing rate:

  === TEST EXECUTION SUMMARY ===
     baseservices.compilerservices.XUnitWrapper           Total:    2, Errors: 0, Failed:   0, Skipped: 0, Time:     2.552s
     baseservices.exceptions.XUnitWrapper.dll             Total:    0
     baseservices.mono.XUnitWrapper.dll                   Total:    0
     baseservices.threading.XUnitWrapper                  Total:    4, Errors: 0, Failed:   0, Skipped: 0, Time:     9.893s
     baseservices.TieredCompilation.XUnitWrapper          Total:   11, Errors: 0, Failed:   1, Skipped: 0, Time:     9.210s
     baseservices.typeequivalence.XUnitWrapper            Total:    1, Errors: 0, Failed:   0, Skipped: 0, Time:     0.952s
     baseservices.varargs.XUnitWrapper.dll                Total:    0
     CoreMangLib.system.XUnitWrapper                      Total:    1, Errors: 0, Failed:   0, Skipped: 0, Time:     0.837s
     Exceptions.ForeignThread.XUnitWrapper                Total:    1, Errors: 0, Failed:   1, Skipped: 0, Time:     1.669s
     GC.API.XUnitWrapper                                  Total:   33, Errors: 0, Failed:   2, Skipped: 0, Time:   916.993s
     GC.Coverage.XUnitWrapper                             Total:    2, Errors: 0, Failed:   1, Skipped: 0, Time:   900.149s
     GC.Features.XUnitWrapper                             Total:   21, Errors: 0, Failed:   8, Skipped: 0, Time:   984.539s
     GC.LargeMemory.XUnitWrapper                          Total:    3, Errors: 0, Failed:   0, Skipped: 0, Time:    21.050s
     GC.Regressions.XUnitWrapper                          Total:   10, Errors: 0, Failed:   1, Skipped: 0, Time:   901.862s
     GC.Scenarios.XUnitWrapper                            Total:   37, Errors: 0, Failed:   8, Skipped: 0, Time:  1035.292s
     GC.Stress.XUnitWrapper                               Total:    1, Errors: 0, Failed:   0, Skipped: 0, Time:     0.256s
     ilasm.System.XUnitWrapper                            Total:    1, Errors: 0, Failed:   1, Skipped: 0, Time:    18.275s
     Interop.ArrayMarshalling.XUnitWrapper                Total:    2, Errors: 0, Failed:   2, Skipped: 0, Time:    15.158s
     Interop.COM.XUnitWrapper                             Total:   19, Errors: 0, Failed:  14, Skipped: 0, Time:    64.475s
     Interop.DllImportAttribute.XUnitWrapper              Total:    2, Errors: 0, Failed:   0, Skipped: 0, Time:    12.541s
     Interop.ExecInDefAppDom.XUnitWrapper                 Total:    1, Errors: 0, Failed:   1, Skipped: 0, Time:     5.589s
     Interop.ICastable.XUnitWrapper                       Total:    1, Errors: 0, Failed:   1, Skipped: 0, Time:     8.021s
     Interop.ICustomMarshaler.XUnitWrapper                Total:    4, Errors: 0, Failed:   2, Skipped: 0, Time:    75.785s
     Interop.IJW.XUnitWrapper                             Total:    6, Errors: 0, Failed:   4, Skipped: 0, Time:    24.053s
     Interop.LayoutClass.XUnitWrapper                     Total:    1, Errors: 0, Failed:   1, Skipped: 0, Time:   901.902s
     Interop.MarshalAPI.XUnitWrapper                      Total:    3, Errors: 0, Failed:   2, Skipped: 0, Time:    22.342s
     Interop.NativeLibrary.XUnitWrapper                   Total:    5, Errors: 0, Failed:   0, Skipped: 0, Time:    10.118s
     Interop.PInvoke.XUnitWrapper                         Total:   85, Errors: 0, Failed:  18, Skipped: 0, Time:   978.328s
     Interop.StringMarshalling.XUnitWrapper               Total:    4, Errors: 0, Failed:   3, Skipped: 0, Time:     5.075s
     Interop.StructMarshalling.XUnitWrapper               Total:    5, Errors: 0, Failed:   5, Skipped: 0, Time:     9.618s
     Interop.StructPacking.XUnitWrapper                   Total:    1, Errors: 0, Failed:   0, Skipped: 0, Time:     3.478s
     Interop.WinRT.XUnitWrapper                           Total:    1, Errors: 0, Failed:   0, Skipped: 0, Time:     2.959s
     JIT.CheckProjects.XUnitWrapper                       Total:    1, Errors: 0, Failed:   0, Skipped: 0, Time:     2.264s
     JIT.CodeGenBringUpTests.XUnitWrapper                 Total:   32, Errors: 0, Failed:   0, Skipped: 0, Time:    48.442s
     JIT.Directed.XUnitWrapper                            Total:  138, Errors: 0, Failed:  25, Skipped: 0, Time:   947.426s
     JIT.Generics.XUnitWrapper                            Total:   41, Errors: 0, Failed:   4, Skipped: 0, Time:    29.733s
     JIT.HardwareIntrinsics.XUnitWrapper                  Total:  302, Errors: 0, Failed:  94, Skipped: 0, Time:   209.510s
     JIT.IL_Conformance.XUnitWrapper                      Total:  104, Errors: 0, Failed:   0, Skipped: 0, Time:    62.196s
     JIT.Intrinsics.XUnitWrapper                          Total:   23, Errors: 0, Failed:   2, Skipped: 0, Time:    24.198s
     JIT.jit64.XUnitWrapper                               Total:  105, Errors: 0, Failed:  36, Skipped: 0, Time:   970.743s
     JIT.Methodical.XUnitWrapper                          Total:  763, Errors: 0, Failed: 108, Skipped: 0, Time:  3857.773s
     JIT.opt.XUnitWrapper                                 Total:   68, Errors: 0, Failed:   4, Skipped: 0, Time:   146.098s
     JIT.Performance.XUnitWrapper                         Total:   85, Errors: 0, Failed:  16, Skipped: 0, Time:  2027.139s
     JIT.Regression.XUnitWrapper                          Total:  606, Errors: 0, Failed:  29, Skipped: 0, Time:  2371.085s
     JIT.RyuJIT.XUnitWrapper                              Total:    1, Errors: 0, Failed:   0, Skipped: 0, Time:     2.940s
     JIT.SIMD.XUnitWrapper                                Total:   99, Errors: 0, Failed:  37, Skipped: 0, Time:  2262.503s
     JIT.Stress.XUnitWrapper                              Total:    5, Errors: 0, Failed:   0, Skipped: 0, Time:     3.411s
     JIT.superpmi.XUnitWrapper                            Total:    3, Errors: 0, Failed:   2, Skipped: 0, Time:   901.856s
     Loader.AssemblyDependencyResolver.XUnitWrapper       Total:    1, Errors: 0, Failed:   1, Skipped: 0, Time:    15.791s
     Loader.AssemblyLoadContext30Extensions.XUnitWrapper  Total:    1, Errors: 0, Failed:   0, Skipped: 0, Time:    10.845s
     Loader.binding.XUnitWrapper                          Total:    2, Errors: 0, Failed:   2, Skipped: 0, Time:    13.222s
     Loader.classloader.XUnitWrapper                      Total:  106, Errors: 0, Failed:  10, Skipped: 0, Time:   289.772s
     Loader.ContextualReflection.XUnitWrapper             Total:    1, Errors: 0, Failed:   1, Skipped: 0, Time:     5.957s
     Loader.regressions.XUnitWrapper                      Total:    1, Errors: 0, Failed:   0, Skipped: 0, Time:     4.141s
     managed.Compilation.XUnitWrapper                     Total:    1, Errors: 0, Failed:   1, Skipped: 0, Time:    79.046s
     profiler.eventpipe.XUnitWrapper                      Total:    1, Errors: 0, Failed:   1, Skipped: 0, Time:    14.825s
     profiler.gc.XUnitWrapper                             Total:    1, Errors: 0, Failed:   0, Skipped: 0, Time:     8.556s
     profiler.rejit.XUnitWrapper                          Total:    1, Errors: 0, Failed:   0, Skipped: 0, Time:     0.177s
     profiler.unittest.XUnitWrapper                       Total:    2, Errors: 0, Failed:   1, Skipped: 0, Time:    13.039s
     readytorun.coreroot_determinism.XUnitWrapper         Total:    1, Errors: 0, Failed:   1, Skipped: 0, Time:    24.766s
     readytorun.crossgen2.XUnitWrapper                    Total:    1, Errors: 0, Failed:   0, Skipped: 0, Time:    21.276s
     readytorun.determinism.XUnitWrapper                  Total:    1, Errors: 0, Failed:   0, Skipped: 0, Time:    25.744s
     readytorun.DynamicMethodGCStress.XUnitWrapper.dll    Total:    0
     readytorun.r2rdump.XUnitWrapper.dll                  Total:    0
     readytorun.tests.XUnitWrapper                        Total:    3, Errors: 0, Failed:   0, Skipped: 0, Time:     7.662s
     reflection.DefaultInterfaceMethods.XUnitWrapper      Total:    3, Errors: 0, Failed:   1, Skipped: 0, Time:   901.236s
     reflection.Modifiers.XUnitWrapper                    Total:    1, Errors: 0, Failed:   0, Skipped: 0, Time:     3.851s
     reflection.SetValue.XUnitWrapper                     Total:    1, Errors: 0, Failed:   0, Skipped: 0, Time:     4.970s
     reflection.StaticInterfaceMembers.XUnitWrapper       Total:    1, Errors: 0, Failed:   0, Skipped: 0, Time:     3.612s
     Regressions.coreclr.XUnitWrapper                     Total:   20, Errors: 0, Failed:   9, Skipped: 0, Time:    29.335s
     tracing.eventactivityidcontrol.XUnitWrapper          Total:    1, Errors: 0, Failed:   0, Skipped: 0, Time:     3.301s
     tracing.eventcounter.XUnitWrapper                    Total:    5, Errors: 0, Failed:   0, Skipped: 0, Time:     0.495s
     tracing.eventlistener.XUnitWrapper                   Total:    1, Errors: 0, Failed:   0, Skipped: 0, Time:     4.143s
     tracing.eventpipe.XUnitWrapper                       Total:    5, Errors: 0, Failed:   1, Skipped: 0, Time:     6.415s
     tracing.eventsource.XUnitWrapper                     Total:    1, Errors: 0, Failed:   0, Skipped: 0, Time:     0.166s
     tracing.regress.XUnitWrapper                         Total:    1, Errors: 0, Failed:   0, Skipped: 0, Time:     3.275s
     tracing.tracecontrol.XUnitWrapper.dll                Total:    0
     tracing.tracevalidation.XUnitWrapper                 Total:    4, Errors: 0, Failed:   3, Skipped: 0, Time:    66.634s
                                                                 ----          -          ---           -        ----------
                                                    GRAND TOTAL: 2812          0          465           0        22372.537s (22411.881s)

@yuchong-pan yuchong-pan added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Jun 12, 2020
@yuchong-pan yuchong-pan self-assigned this Jun 12, 2020
Copy link
Member

@noahfalk noahfalk left a comment

Choose a reason for hiding this comment

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

Is this the first runtime PR? Congrats :D

I made some suggestions inline and happy to chat anytime if you've got questions

src/coreclr/src/vm/interpreter.cpp Show resolved Hide resolved
src/coreclr/src/vm/interpreter.cpp Show resolved Hide resolved
src/coreclr/src/inc/clrconfigvalues.h Outdated Show resolved Hide resolved
src/coreclr/src/vm/method.cpp Outdated Show resolved Hide resolved
src/coreclr/src/vm/interpreter.cpp Outdated Show resolved Hide resolved
@jkotas
Copy link
Member

jkotas commented Jun 13, 2020

@jkotas, I had been thinking of IsSupported as a property that could vary when different code generators run the same method.

If we want to allow arbitrary combinations of different code generators in the same process, the IsSupported values cannot vary between them. For example, somebody writes code like:

readonly static RenderingEngine s_engine = Avx.IsSupported ? new AvxRenderingEngine() : new GenericRenderingEngine();

class GenericRenderingEngine : RenderingEngine
{
...
    virtual void Render()
    {
        Debug.Assert(!Avx.IsSupported); 
        ...
    }
...
}

Consider what happens when the interpretation of the Avx.IsSupported returns false during startup and we later switch the Render method to be JITed.

A similar problem exists with crossgen. We had bugs where IsSupported returned different values in crossgened core and JITed code, and it showed up as a real problem.

I do not think we should be special casing the individual hardware intrinsics in the interpreter. As you have said, there is a lot of them. We should depend on fallback to JIT for the hardware intrinsics methods. The JIT does generate valid body for the hardware intrinsics methods that can be called e.g. via reflection.

check in this current design under a config switch

I am fine with that - as long it is well documented that it is not a production quality solution.

Copy link
Member

@BruceForstall BruceForstall left a comment

Choose a reason for hiding this comment

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

This LGTM. I'd prefer if @noahfalk and/or @josalem also chime in before merging, though.

Copy link
Contributor

@josalem josalem left a comment

Choose a reason for hiding this comment

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

Left some comments inline. I think the name may need to be clarified a little for the INTERNAL_EnableJitOptimization flag, but other than that, this is a great first PR!

src/coreclr/src/vm/interpreter.cpp Outdated Show resolved Hide resolved
Co-authored-by: John Salem <josalem@microsoft.com>
@yuchong-pan
Copy link
Contributor Author

Given discussions with @noahfalk, @BruceForstall and @jkotas, I think that removing the COMPlus variable that triggers the interpreter as Tier 0 only (i.e. EnableJitOptimization) is probably a good solution since there exhibit many complications and confusions by introducing this variable. Also, @noahfalk mentioned here that the two major use scenarios of the interpreter do not require this variable. Any thoughts on this?

@yuchong-pan
Copy link
Contributor Author

Having discussed this with @noahfalk and @jkotas, I removed the EnableJitOptimization environment variable in commit e9a94f1.

Copy link
Member

@noahfalk noahfalk left a comment

Choose a reason for hiding this comment

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

Looks good to me! Happy interpretting : )

(Make sure to squash before merging)

@yuchong-pan yuchong-pan merged commit e866b21 into dotnet:master Jun 19, 2020
@yuchong-pan yuchong-pan deleted the yuchong-pan/interp branch June 19, 2020 11:59
@xiangzhai
Copy link
Contributor

Hi,

But how to prove the Interpreter whether or not work?

./build-runtime.sh cmakeargs "-DFEATURE_INTERPRETER=1"

export CORE_LIBRARIES=/home/zhaixiang/project/runtime/.dotnet/shared/Microsoft.NETCore.App/5.0.0-preview.6.20305.6

# interpreter
export COMPlus_DumpInterpreterStubs=1
export COMPlus_Interpret=*
export COMPlus_InterpreterJITThreshold=20 # or 999999
export COMPlus_InterpreterPrintPostMortem=1
export COMPlus_InterpreterDoLoopMethods=1
export COMPlus_TraceInterpreterEntries=1
export COMPlus_TieredCompilation=1
export COMPlus_JITMinOpts=1
export COMPlus_ZapDisable=1

# jit
export COMPlus_JitFunctionTrace=1

/home/zhaixiang/project/runtime/artifacts/bin/coreclr/Linux.x64.Debug/corerun /home/zhaixiang/project/HelloWorld/bin/Debug/netcoreapp3.1/HelloWorld.dll

Please have a look at debug.log

Thanks,
Leslie Zhai

@yuchong-pan
Copy link
Contributor Author

Hello @xiangzhai,

Thanks for asking! Could you please share me with the Hello World sample program that you use for testing?

Best,
Yuchong

@xiangzhai
Copy link
Contributor

Hi @yuchong-pan

Thanks for your response! I just dotnet new console -o HelloWorld and then dotnet run, I didn't modify the Program.cs.

Thanks,
Leslie Zhai

@yuchong-pan
Copy link
Contributor Author

Hi @xiangzhai,

Thanks for sharing me with this information! To see that the interpreter is actually used, one of the approaches would be to look at the information printed by InterpreterPrintPostMortem (specifically, the total number of calls from interpreted code).

I also tested this PR on your Hello World sample program, and it seems that the program is not interpreted because you set COMPlus_JITMinOpts=1. With JITMinOpts, Tiered Compilation is not eligible (see here and here). Since the interpreter is dependent upon Tiered Compilation, the interpreter is hence disabled as well.

With COMPlus_JITMinOpts=0, the interpreter is triggered for Hello World on my local (Windows) machine. I believe that it would be the same for other platforms.

Please let me know if you have further questions!

Best,
Yuchong

@BruceForstall
Copy link
Member

It's a little unfortunate that setting JITMinOpts disables the interpreter. What if you wanted to use the interpreter to bring up a new platform, where the JIT compiler is very immature? In that case, you might want to force JITMinOpts so the JIT does not invoke any optimization phases, but you would also want the interpreter as the "phase 0" of tiering. Maybe we need to rethink this MinOpts disabling tiering, in the presence of the interpreter.

@yuchong-pan
Copy link
Contributor Author

yuchong-pan commented Jun 23, 2020

Hi @BruceForstall! I think the point you make is a very good scenario to think of. However, if we force JITMinOpts, we can also set the newly added ForceInterpreter to use the interpreter even in the case where Tiered Compilation is ineligible (if we only consider the interpreter rather than Tiered Compilation). I agree that we probably need to rethink JITMinOpts disabling TC.

@xiangzhai
Copy link
Contributor

With COMPlus_JITMinOpts=0, the interpreter is triggered for Hello World on my local (Windows) machine. I believe that it would be the same for other platforms.

./build-runtime.sh cmakeargs "-DFEATURE_INTERPRETER=1"

export CORE_LIBRARIES=/home/zhaixiang/project/runtime/.dotnet/shared/Microsoft.NETCore.App/5.0.0-preview.6.20305.6

# interpreter
export COMPlus_DumpInterpreterStubs=1
export COMPlus_Interpret=*
export COMPlus_InterpreterJITThreshold=20
export COMPlus_InterpreterPrintPostMortem=1
export COMPlus_InterpreterDoLoopMethods=1
export COMPlus_TraceInterpreterEntries=1
export COMPlus_TieredCompilation=1
export COMPlus_JITMinOpts=0
export COMPlus_ZapDisable=1

# jit
export COMPlus_JitFunctionTrace=1

gdb -ex=r --args /home/zhaixiang/project/runtime/artifacts/bin/coreclr/Linux.x64.Debug/corerun /home/zhaixiang/project/HelloWorld/bin/Debug/netcoreapp3.1/HelloWorld.dll

It seems repro #13759

{ Start Jitting Method  191 HelloWorld.Program:Main(System.String[]) (MethodHash=ab41dfb7) MinOpts
} Jitted Method  191 at 00007fff`7dd2aa60 method HelloWorld.Program:Main(System.String[]) size 0000003d
Generating interpretation stub (# 1 = 0x1, hash = 0xd758ab36) for System.Console:WriteLine.
[New Thread 0x7ffff41a5700 (LWP 2215)]
Generating interpretation stub (# 2 = 0x2, hash = 0xcd1b9c62) for System.Console:.cctor.
Entering method #1 (= 0x1): System.Console:.cctor().
 arguments:

Entering method #2 (= 0x2): System.Console:WriteLine(class).
 arguments:

Thread 1 "corerun" received signal SIGSEGV, Segmentation fault.
Object::GetMethodTable (this=0x6820f827d6bc0200) at /home/zhaixiang/project/runtime/src/coreclr/src/vm/object.h:175
175             _ASSERTE((dac_cast<TADDR>(m_pMethTab) & MARKED_BIT) == 0);

(gdb) bt
#0  Object::GetMethodTable (this=0x6820f827d6bc0200) at /home/zhaixiang/project/runtime/src/coreclr/src/vm/object.h:175
#1  0x00007ffff6cfb5e8 in Interpreter::PrintValue (this=0x7fffffffaf20, it=..., valAddr=0x7fffffffc740 "")
    at /home/zhaixiang/project/runtime/src/coreclr/src/vm/interpreter.cpp:11823
#2  0x00007ffff6cfba1b in Interpreter::PrintArgValue (this=0x7fffffffaf20, argNum=0)
    at /home/zhaixiang/project/runtime/src/coreclr/src/vm/interpreter.cpp:11753
#3  0x00007ffff6ce4e62 in Interpreter::PrintArgs (this=0x7fffffffaf20)
    at /home/zhaixiang/project/runtime/src/coreclr/src/vm/interpreter.cpp:11742
#4  0x00007ffff6ce003d in Interpreter::ExecuteMethod (this=0x7fffffffaf20, retVal=0x7fffffffaf08, pDoJmpCall=0x7fffffffc49f, 
    pJmpCallToken=0x7fffffffaf04) at /home/zhaixiang/project/runtime/src/coreclr/src/vm/interpreter.cpp:1928
#5  0x00007ffff6cdf8fc in Interpreter::ExecuteMethodWrapper (interpMethInfo=0x5555556a09b0, directCall=false, 
    ilArgs=0x7fffffffc740 "", stubContext=0x1dffffcc50, pDoJmpCall=0x7fffffffc49f, pResolvedToken=0x7fffffffc448)
    at /home/zhaixiang/project/runtime/src/coreclr/src/vm/interpreter.cpp:1556
#6  0x00007ffff6cfe032 in Interpreter::InterpretMethodBody (interpMethInfo=0x5555556a09b0, directCall=false, 
    ilArgs=0x7fffffffc740 "", stubContext=0x1dffffcc50) at /home/zhaixiang/project/runtime/src/coreclr/src/vm/interpreter.cpp:1591
#7  0x00007ffff6cdf197 in InterpretMethod (interpMethInfo=0x5555556a09b0, ilArgs=0x7fffffffc740 "", stubContext=0x1dffffcc50)
    at /home/zhaixiang/project/runtime/src/coreclr/src/vm/interpreter.cpp:1726
#8  0x00007fff7cdbd0c9 in ?? ()
#9  0x00007fffffffdb00 in ?? ()
#10 0x0000000000000000 in ?? ()
(gdb) x/22i 0x00007fff7cdbd0c9-44
   0x7fff7cdbd09d:      push   %rsp
   0x7fff7cdbd09e:      push   %rbp
   0x7fff7cdbd09f:      rex.X
   0x7fff7cdbd0a0:      mov    %rcx,0x8(%rsp)
   0x7fff7cdbd0a5:      lea    0x8(%rsp),%rsi
   0x7fff7cdbd0aa:      sub    $0x28,%rsp
   0x7fff7cdbd0ae:      xor    %edi,%edi
   0x7fff7cdbd0b0:      mov    %rdi,%r8
   0x7fff7cdbd0b3:      movabs $0x5555556a09b0,%rdi
   0x7fff7cdbd0bd:      movabs $0x7ffff6cdf040,%rax
=> 0x7fff7cdbd0c7:      callq  *%rax
   0x7fff7cdbd0c9:      nop
   0x7fff7cdbd0ca:      add    $0x28,%rsp
   0x7fff7cdbd0ce:      retq   
   0x7fff7cdbd0cf:      add    %cl,0x0(%rax)
   0x7fff7cdbd0d2:      add    %al,(%rax)
   0x7fff7cdbd0d4:      add    %al,(%rax)
   0x7fff7cdbd0d6:      add    %al,(%rax)
   0x7fff7cdbd0d8:      add    %eax,(%rax)
   0x7fff7cdbd0da:      add    %al,(%rax)
   0x7fff7cdbd0dc:      add    %al,(%rax)
   0x7fff7cdbd0de:      add    %al,(%rax)

@xiangzhai
Copy link
Contributor

What if you wanted to use the interpreter to bring up a new platform, where the JIT compiler is very immature?

It is just able to work for MIPS64 #4234 (comment) by disabled optimization:

# CoreFX && AspNetCore ALLIN1
export CORE_LIBRARIES=/home/loongson/corefx-3.1-Linux.mips64.Debug
# Optimization Disabled
export COMPlus_JITMinOpts=1

./bin/Product/Linux.mips64.Release/corerun /home/loongson/aspnet-samples/samples/aspnetcore/blazor/FlightFinder/FlightFinder.Server/bin/Debug/netcoreapp3.1/FlightFinder.Server.dll --urls http://10.2.5.91:5000

Yes, we are still fixing bugs to make it mature.

In that case, you might want to force JITMinOpts so the JIT does not invoke any optimization phases

There are some hardcode disabled some optimization for MIPS64:

#if defined(_TARGET_AMD64_) || defined(_TARGET_ARM64_)// || defined(_TARGET_MIPS64_)
// should confirm how optimize on mips64.

    // The struct parameter is a register candidate
    return PROMOTION_TYPE_INDEPENDENT;
#else
    // The struct parameter is not enregistered
    return PROMOTION_TYPE_DEPENDENT;
#endif
GenTree* Lowering::OptimizeConstCompare(GenTree* cmp)
{
    assert(cmp->gtGetOp2()->IsIntegralConst());

#if defined(_TARGET_XARCH_) || defined(_TARGET_ARM64_)// || defined(_TARGET_MIPS64_)
// should confirm how optimize on mips64.

We are implementing it for MIPS64.

Thanks,
Leslie Zhai

@ghost ghost locked as resolved and limited conversation to collaborators Dec 8, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Linux] mixed Interpreter and JIT compiler
6 participants