Skip to content

Commit 61fac3b

Browse files
authored
Re-Enable JIT calls for Wasm Target in Crossgen (#122334)
This PR reverts the behavior from #122111 which stubs out a method instead of calling the JIT for the crossgen Wasm target. Now, the JIT will be invoked as normal so that the output of method codegen can be placed in a simple object file. Output code currently won't run (I tried this) because we aren't yet emitting a correct local count at the beginning of compiled methods.
1 parent e491efb commit 61fac3b

File tree

1 file changed

+2
-40
lines changed

1 file changed

+2
-40
lines changed

src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs

Lines changed: 2 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -317,36 +317,6 @@ IntPtr LocalObjectToHandle(object input)
317317
return null;
318318
}
319319

320-
private CorJitResult CompileWasmStub(out IntPtr exception, ref CORINFO_METHOD_INFO methodInfo, out uint codeSize)
321-
{
322-
byte[] stub =
323-
[
324-
0x00, // local variable count
325-
0x41, // i32.const
326-
0x0, // uleb128 0
327-
0x0F, // return
328-
0x0B, // end
329-
];
330-
AllocMemArgs args = new AllocMemArgs
331-
{
332-
hotCodeSize = (uint)stub.Length,
333-
coldCodeSize = (uint)0,
334-
roDataSize = (uint)0,
335-
xcptnsCount = _ehClauses != null ? (uint)_ehClauses.Length : 0,
336-
flag = CorJitAllocMemFlag.CORJIT_ALLOCMEM_DEFAULT_CODE_ALIGN,
337-
};
338-
allocMem(ref args);
339-
340-
_code = stub;
341-
342-
codeSize = (uint)stub.Length;
343-
exception = IntPtr.Zero;
344-
345-
_codeRelocs = new();
346-
347-
return CorJitResult.CORJIT_OK;
348-
}
349-
350320
private CompilationResult CompileMethodInternal(IMethodNode methodCodeNodeNeedingCode, MethodIL methodIL)
351321
{
352322
// methodIL must not be null
@@ -369,17 +339,9 @@ private CompilationResult CompileMethodInternal(IMethodNode methodCodeNodeNeedin
369339
IntPtr exception;
370340
IntPtr nativeEntry;
371341
uint codeSize;
372-
373-
TargetArchitecture architecture = _compilation.TypeSystemContext.Target.Architecture;
374-
var result = architecture switch
375-
{
376-
// We currently do not have WASM codegen support, but for testing, we will return a stub
377-
TargetArchitecture.Wasm32 => CompileWasmStub(out exception, ref methodInfo, out codeSize),
378-
_ => JitCompileMethod(out exception,
342+
var result = JitCompileMethod(out exception,
379343
_jit, (IntPtr)(&_this), _unmanagedCallbacks,
380-
ref methodInfo, (uint)CorJitFlag.CORJIT_FLAG_CALL_GETJITFLAGS, out nativeEntry, out codeSize)
381-
};
382-
344+
ref methodInfo, (uint)CorJitFlag.CORJIT_FLAG_CALL_GETJITFLAGS, out nativeEntry, out codeSize);
383345
if (exception != IntPtr.Zero)
384346
{
385347
if (_lastException != null)

0 commit comments

Comments
 (0)