Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
212 commits
Select commit Hold shift + click to select a range
86e2291
Add some checks for wasm64
vulkan101 Apr 4, 2025
03faf04
Initial changes for wasm64 build, minus logging
vulkan101 Apr 9, 2025
09261be
add DISABLE_JITERPRETER flag
vulkan101 Apr 10, 2025
ed5b41f
Cast to int to remove warning/error
vulkan101 Apr 10, 2025
d8edba1
build-native with MEMORY64. some extraneous stuff to pull out later
vulkan101 Apr 10, 2025
6b9cff6
logging only
vulkan101 Apr 10, 2025
808aa30
replace integer handles with a typedef depending on void pointer size
vulkan101 Apr 11, 2025
93c9c00
Conditional addition of MEMORY64 and wasm64 flags
vulkan101 Apr 11, 2025
0571b87
int handle replacement
vulkan101 Apr 11, 2025
6fa382c
Convert mono-threads-wasm.S to wasm64 and hard code compile to wasm6
vulkan101 Apr 14, 2025
bb1bd4c
remove libicu
vulkan101 Apr 14, 2025
44edcf7
remove libicu continued and compile timezone files with wasm64 (will …
vulkan101 Apr 14, 2025
dc4a292
set wasm64 target for System.Native. will need to come back and tidy …
vulkan101 Apr 14, 2025
0d1f3f5
add wasm64 target to more files
vulkan101 Apr 15, 2025
5ad12ae
remove setting of AOT_TARGET_TRIPLE - not appropriate for this target
vulkan101 Apr 15, 2025
4d46486
add stubs for jiterpreter functions
vulkan101 Apr 15, 2025
55bb3d7
jiterpreter stub in CMakeLists.txt - not being picked up atm
vulkan101 Apr 15, 2025
f1183f6
logging only
vulkan101 Apr 15, 2025
ef98c18
Make DISABLE_JITERPRETER independent of DISABLE_INTERPRETER, fix to j…
vulkan101 Apr 15, 2025
4c1f71f
Add missing function pointer
vulkan101 Apr 16, 2025
3583d31
Try removing System.Globalization.Native (doesn't work - committing s…
vulkan101 Apr 16, 2025
abe0091
Revert "Try removing System.Globalization.Native (doesn't work - comm…
vulkan101 Apr 16, 2025
aabe547
Add stubs for icu methods, hard code use of them for memory64
vulkan101 Apr 16, 2025
dbdb110
Add wasm64 target when building brotli compression
vulkan101 Apr 17, 2025
d032b31
Declare _scriptDir
vulkan101 Apr 25, 2025
1097581
Revert "Declare _scriptDir"
vulkan101 Apr 30, 2025
e361003
ensure wasm64 is used if uses_mem64 is set
vulkan101 May 2, 2025
2d8a5e7
turn off experimental warnings (for wasm64 + emscripten 3.1.56)
vulkan101 May 6, 2025
26f0bb8
set USES_MEM64
vulkan101 May 6, 2025
75029f2
Require WasmEnableMemory64 to set wasm64-unknown-none
vulkan101 May 6, 2025
e81160f
make memory64 flag setting conditional
vulkan101 May 6, 2025
30ea2fc
Addresses Emscripten build warnings and flags
vulkan101 May 6, 2025
d7ef8ed
Make --target=wasm64 conditional
vulkan101 May 6, 2025
705516d
make SIZEOF_VOID_P available in driver.c
vulkan101 May 7, 2025
b43ba2d
use stubs file regardless of MEMORY64 (BAD - FIXME)
vulkan101 May 7, 2025
6133305
only use MEMORY64 is USES_MEM64 AND host is wasm
vulkan101 May 7, 2025
bc24b97
Rename _scriptDir to _scriptName as used by emscripten 4.0.5
vulkan101 May 8, 2025
d8efce9
Assign readyPromise to Module
vulkan101 May 8, 2025
e35bd9e
Set WASM_ASYNC_COMPILATION=0
vulkan101 May 9, 2025
7163f64
Rename _scriptDir to _scriptName as used by emscripten 4.0.5
vulkan101 May 8, 2025
564c1dc
Assign readyPromise to Module
vulkan101 May 8, 2025
ebeebbb
Allow user to set EmscriptenPythonToolsPath
vulkan101 May 14, 2025
f93638c
Add a sample with WASM_ASYNC_COMPILATION disabled
vulkan101 May 14, 2025
a688f64
Turn on USE_CLOSURE_COMPILER by default
vulkan101 May 15, 2025
1e6327b
Remove sample showing WASM_ASYNC_COMPILATION=0
vulkan101 May 15, 2025
e3ef9d1
Logging
vulkan101 May 20, 2025
2097548
Remove TaskFactory specification
vulkan101 May 20, 2025
f645ffd
Revert "Remove TaskFactory specification"
vulkan101 May 20, 2025
44c3f11
Revert "Logging"
vulkan101 May 20, 2025
1d8a6f5
Merge branch 'emscripten-bump-4.0.5' into wasm64_MH
vulkan101 May 20, 2025
4f80511
Set wasm64 default properties
vulkan101 May 21, 2025
ceaadfc
use closure compiler
vulkan101 May 28, 2025
f6d496f
First change to pointer in fn_signatures
vulkan101 May 29, 2025
2ec098f
cwrap pointer conversions
vulkan101 May 29, 2025
c0d07ee
More debug output
vulkan101 Jun 2, 2025
b5d5ee9
change return type to pointer
vulkan101 Jun 2, 2025
30b1273
Debug output
vulkan101 Jun 2, 2025
d8db3c4
Logging function/macro
vulkan101 Jun 2, 2025
824f7a1
Add more mono logging at sample runtime
vulkan101 Jun 2, 2025
ecb36a9
More debug output
vulkan101 Jun 2, 2025
14d237c
debug logging
vulkan101 Jun 2, 2025
39f3f15
try removing -gsource-map to help with debug info (no work)
vulkan101 Jun 5, 2025
0364d18
logging and test function lookup
vulkan101 Jun 5, 2025
fb91356
remove -gsource-map
vulkan101 Jun 5, 2025
38b1825
hack to ensure void_p is 8
vulkan101 Jun 5, 2025
ab3ee58
use bigint
vulkan101 Jun 5, 2025
a5c7819
Debug Logging
vulkan101 Jun 5, 2025
e2fdea8
make -g default
vulkan101 Jun 5, 2025
30fa856
disable JITERP
vulkan101 Jun 5, 2025
a8e3a6f
Remove some hardcoded 4 byte assumptions
vulkan101 Jun 13, 2025
cb60ccb
Some signature changes
vulkan101 Jun 13, 2025
ff389a0
Move do_icall into separate file
vulkan101 Jun 18, 2025
7449f5a
Remove unnecessary logging
vulkan101 Jun 18, 2025
1c55b5f
Move do_icall into a separate file
vulkan101 Jun 18, 2025
0442479
Copies of interp.c for refactoring
vulkan101 Jun 19, 2025
616b1f2
separated and compiling ves_pinvoke
vulkan101 Jun 19, 2025
c939127
move ves_pinvoke
vulkan101 Jun 19, 2025
e48477a
WASM signature updates
vulkan101 Jun 23, 2025
f9c1c66
use L for signature mapping of pointers
vulkan101 Jun 23, 2025
c149c31
build settings I haven't committed previously
vulkan101 Jun 23, 2025
b375ca3
Increment arg count by 1 for long values if wasm64
vulkan101 Jun 23, 2025
03d2a96
Logging and ues L for MONO_TYPE_GENERICINST
vulkan101 Jun 23, 2025
da0fc43
Provide bigint option for table growth
vulkan101 Jun 23, 2025
c347311
Another few cases dealt with manually
vulkan101 Jun 24, 2025
93a6c81
Add generated string based signature checks
vulkan101 Jun 24, 2025
1948c76
Handles bigint type in pointer fixup
vulkan101 Jun 24, 2025
f042b14
Extends interp_type_as_ptr8 to valuetypes
vulkan101 Jun 24, 2025
8cdd1fe
Fixes potential offset overflows
vulkan101 Jun 24, 2025
88e5ef1
Copilot patch to use add_offset
vulkan101 Jun 24, 2025
c2cc68e
Marshalling updates. Browser sample runs!
vulkan101 Jun 24, 2025
3409e45
Fixes type size check order in logging
vulkan101 Jun 24, 2025
836e7a8
Updates method name return types
vulkan101 Jun 25, 2025
be207a9
Adds safe BigInt to Number conversion
vulkan101 Jun 25, 2025
a8aaa33
Some marshalling updates for WASM64
vulkan101 Jun 26, 2025
a2003fb
Make ptrChar and refVoid available to other methods
vulkan101 Jun 26, 2025
c715201
Logging update
vulkan101 Jun 26, 2025
28ce1b5
Logging
vulkan101 Jun 26, 2025
a774e89
Use data.p for MONO_TYPE_U and MONO_TYPE_I
vulkan101 Jun 26, 2025
8f9ca98
hardcode port
vulkan101 Jun 27, 2025
3e9bc1d
default jiterpreter options off
vulkan101 Jun 27, 2025
78df750
Build issue resolved
vulkan101 Jun 30, 2025
89869b4
remove problematic get_arg_intptr
vulkan101 Jun 30, 2025
aa337f4
Keep consistent with heap access method
vulkan101 Jun 30, 2025
9736e25
remove unnecessary type check
vulkan101 Jun 30, 2025
08c0554
logging
vulkan101 Jun 30, 2025
49aac1f
Temp logging & replace assert in profiler/browser.c with warning
vulkan101 Jun 30, 2025
97bfc3c
Move loop ahead of promise for simpler testing
vulkan101 Jun 30, 2025
fc913f2
remove interp-pinvoke
vulkan101 Jul 1, 2025
8b7cb03
Move enum logging into mh_log
vulkan101 Jul 1, 2025
2ce66f0
As previous
vulkan101 Jul 1, 2025
15b5022
Don't truncate pointer to 32bits for wasm64
vulkan101 Jul 1, 2025
5b56751
Move mh_log to public header location
vulkan101 Jul 2, 2025
72b97f6
Improves string handling with zero buffer
vulkan101 Jul 2, 2025
63fc34a
Adapts JSMarshalerArgument for WASM64
vulkan101 Jul 7, 2025
fba2a87
Return intptr from mono_jiterp_get_opcode_info
vulkan101 Jul 8, 2025
6726c0d
Adjusts double argument handling in I2N
vulkan101 Jul 8, 2025
21db670
Add switch to turn off MH_LOG
vulkan101 Jul 8, 2025
3101586
WIP finding offset issue
vulkan101 Jul 11, 2025
f7e3744
More WIP
vulkan101 Jul 11, 2025
98ccdc5
Added test method to isolate array read issue
vulkan101 Jul 15, 2025
4689b63
logging and test methods
vulkan101 Jul 15, 2025
76697cd
Try forcing alignment/packing (makes no appreciable difference)
vulkan101 Jul 15, 2025
d140d56
Test method, logging
vulkan101 Jul 15, 2025
adf3fda
Hardcode is64bit to set IntPtr internal size
vulkan101 Jul 15, 2025
f1e4a56
More logging before I start rolling back
vulkan101 Jul 15, 2025
ad33554
Temporary error if 64bit not set
vulkan101 Jul 15, 2025
2418945
Advanced sample working
vulkan101 Jul 29, 2025
81d3a48
Remove some logging
vulkan101 Jul 29, 2025
bb01317
Undo macro expansions
vulkan101 Jul 29, 2025
d444372
More log commenting
vulkan101 Jul 29, 2025
0b79c51
Don't try to strcmp null sig cookie
vulkan101 Jul 29, 2025
dab6a8a
Update IntPtr arg set/get
vulkan101 Jul 29, 2025
da7f99e
Reverts to delayed meaning resolution
vulkan101 Jul 29, 2025
ae9cdfb
Comments out interpreter debug logging
vulkan101 Jul 29, 2025
9feff08
Merge branch 'MH_wasm64_offset' into wasm64_mh
vulkan101 Jul 29, 2025
7d8818e
Remove test class
vulkan101 Jul 31, 2025
16de776
Updates to roots.ts for wasm64
vulkan101 Aug 5, 2025
cddf56d
Pass the string length, not the end of the buffer
vulkan101 Aug 5, 2025
410011c
Use string length, not buffer length
vulkan101 Aug 5, 2025
8a1b70a
Set CMAKE_C_FLAGS to include CONFIGURATION_EMCC_FLAGS
vulkan101 Aug 6, 2025
8f4f4a1
Remove hardcoded SIZEOF_VOID_P
vulkan101 Aug 6, 2025
4aae68b
Temporary error out if wrong pointer size
vulkan101 Aug 6, 2025
8a5ab87
Debug logging
vulkan101 Aug 7, 2025
352b469
Explicitly handle bigint type in _set_address
vulkan101 Aug 7, 2025
8ad6e87
Test Project (remove before PR)
vulkan101 Aug 8, 2025
8c62597
Update gc-handles to accept bigints
vulkan101 Aug 8, 2025
9081dcc
Update to testing sample output
vulkan101 Aug 8, 2025
7ab9592
Don't use bool to hide code
vulkan101 Aug 11, 2025
a4dc569
Update to marshalling - convert bigint to numbers for array access
vulkan101 Aug 11, 2025
7227c04
Update test app for array comparison
vulkan101 Aug 11, 2025
ada5190
Convert bigint to number for array access
vulkan101 Aug 11, 2025
8ee16a0
Add MH_LOG configurability
vulkan101 Aug 12, 2025
92766e3
Remove trailing whitespace
vulkan101 Aug 12, 2025
69dc144
Address function signature mismatch of RegisterGCRoot
vulkan101 Aug 12, 2025
1f68b36
Update Assert.True to behave like xunit, increase log verbosity
vulkan101 Aug 12, 2025
af7013e
Update test to check correct type
vulkan101 Aug 12, 2025
efcbd4c
Call GC.Collect on test disposal, prevents OOB access errors in later…
vulkan101 Aug 12, 2025
12ce1f3
Test app Assert methods
vulkan101 Aug 12, 2025
4799bea
Improve BigInt64 support for JS interop
vulkan101 Aug 14, 2025
e79ffac
Check length is defined
vulkan101 Aug 14, 2025
92e8a76
Add ability to set MH_log verbosity from JS
vulkan101 Aug 20, 2025
aa33f91
Test sample updates
vulkan101 Aug 20, 2025
fca7ca1
minor changes around debug; comments, log jsimport invocation
vulkan101 Aug 20, 2025
ada86e2
Removed some debugging output that's no longer required
vulkan101 Aug 28, 2025
03624c3
Debugging changes
vulkan101 Aug 28, 2025
4451ac5
WIP
vulkan101 Sep 8, 2025
932d210
Replace expansion of MINT_ICALLSIG to cookies with signature encoding
vulkan101 Sep 8, 2025
8101e94
Remove unused method
vulkan101 Sep 8, 2025
14d956d
Use the start address in subarray
vulkan101 Sep 9, 2025
58fcb3e
Replace section of interp.c that was somehow deleted
vulkan101 Sep 11, 2025
6456389
logging
vulkan101 Sep 11, 2025
69df26a
Replace section of interp.c that was somehow deleted
vulkan101 Sep 11, 2025
78ffd51
Use the start address in subarray
vulkan101 Sep 9, 2025
c9b9ac6
Turn off MH_LOG output
vulkan101 Sep 11, 2025
965c465
Amend icall logic. resolve string marshalling but breaking interop tests
vulkan101 Sep 11, 2025
73d2a3a
More logging
vulkan101 Sep 12, 2025
36ad349
Don't interpret MONO_TYPE_R8 as a pointer!
vulkan101 Sep 12, 2025
337e9ff
Interpret MONO_TYPE_U4 as 4 byte pointer
vulkan101 Sep 29, 2025
b5be87b
Logging
vulkan101 Sep 29, 2025
d80c8db
Test/debug
vulkan101 Sep 29, 2025
c3a9634
Update definition of icall Marshal_OffsetOf to match class, returning…
vulkan101 Sep 29, 2025
e5fbcce
Default log level
vulkan101 Sep 29, 2025
8a57a6a
Enforce limit on number of parameters for icall encoding
vulkan101 Sep 29, 2025
9d33f97
Test updates
vulkan101 Sep 30, 2025
49289e2
Fix icall signature handling
vulkan101 Sep 30, 2025
925bdae
remove logging from SystemNative_GetSystemTimeAsTicks
vulkan101 Sep 30, 2025
ad1dfb9
remove logging
vulkan101 Oct 2, 2025
5e91c1a
Correctly reject a return value that isn't a pointer or a MONO_TYPE_VOID
vulkan101 Oct 2, 2025
08360be
Test sample changes
vulkan101 Oct 2, 2025
a82eccd
Delete file
vulkan101 Nov 7, 2025
6f2dbe6
Runtime.c cleanup
vulkan101 Nov 7, 2025
4579eeb
Tidying
vulkan101 Nov 7, 2025
3a3f098
Tidying
vulkan101 Nov 7, 2025
79ea870
Tidying
vulkan101 Nov 7, 2025
c40c682
Delete .bak files
vulkan101 Nov 7, 2025
8392d65
more tidying
vulkan101 Nov 7, 2025
2ef447c
Remove all mh_log header includes
vulkan101 Nov 7, 2025
0aff8ed
Remove MH_LOG
vulkan101 Nov 7, 2025
fc21032
Tidying
vulkan101 Nov 7, 2025
394d84f
Test push
vulkan101 Nov 7, 2025
095adce
revert test comment
vulkan101 Nov 7, 2025
f984e51
Tidying
vulkan101 Nov 7, 2025
bd6e698
Tidying
vulkan101 Nov 7, 2025
543ea8e
Tidying
vulkan101 Nov 7, 2025
db18614
Tidying
vulkan101 Nov 7, 2025
05836e7
More tidying
vulkan101 Nov 7, 2025
3b98f8d
Tidying
vulkan101 Nov 10, 2025
cfc521c
Fix BigInt issues raised by http tests
vulkan101 Nov 10, 2025
d62e0ae
Update init-vs-env for 2026
vulkan101 Nov 10, 2025
4f0fcd3
Tidying
vulkan101 Nov 10, 2025
16f89a6
Restoring struct location in file
vulkan101 Nov 10, 2025
d662075
Remove logging
vulkan101 Nov 10, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -363,3 +363,7 @@ src/coreclr/System.Private.CoreLib/common
.dotnet-daily/
run-stress-*
test:.cs

src/mono/System.Private.CoreLib/CompatibilitySuppressions.xml

src/mono/mono/offsets/wasm64-unknown-none.h
1 change: 1 addition & 0 deletions eng/native/configurecompiler.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ elseif (CLR_CMAKE_HOST_UNIX)
add_compile_options(-Wno-unused-parameter)
add_compile_options(-Wno-alloca)
add_compile_options(-Wno-implicit-int-float-conversion)
add_compile_options(-Wno-experimental)
endif()
endif(MSVC)

Expand Down
5 changes: 5 additions & 0 deletions eng/native/init-vs-env.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ if "%VisualStudioVersion%"=="17.0" (
set __PlatformToolset=v143
goto :SetVCEnvironment
)
if "%VisualStudioVersion%"=="18.0" (
set __VSVersion=vs2026
set __PlatformToolset=v143
goto :SetVCEnvironment
)

:VSMissing
echo %__MsgPrefix%Error: Visual Studio 2022 with C++ tools required. ^
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ internal static unsafe partial class Runtime

#if !ENABLE_JS_INTEROP_BY_VALUE
[MethodImpl(MethodImplOptions.InternalCall)]
public static extern nint RegisterGCRoot(void* start, int bytesSize, IntPtr name);
public static extern int RegisterGCRoot(void* start, nint bytesSize, IntPtr name);
[MethodImpl(MethodImplOptions.InternalCall)]
public static extern void DeregisterGCRoot(nint handle);
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<Nullable>enable</Nullable>
<TargetFrameworks>$(NetCoreAppCurrent)-browser;$(NetCoreAppCurrent)-wasi;$(NetCoreAppCurrent)</TargetFrameworks>
</PropertyGroup>

<!-- DesignTimeBuild requires all the TargetFramework Derived Properties to not be present in the first property group. -->
<PropertyGroup>
<TargetPlatformIdentifier>$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)'))</TargetPlatformIdentifier>
Expand All @@ -12,6 +13,6 @@
</PropertyGroup>
<ItemGroup>
<Compile Include="WasmTestRunner.cs" />
<PackageReference Include="Microsoft.DotNet.XHarness.TestRunners.Xunit" Version="$(MicrosoftDotNetXHarnessTestRunnersXunitVersion)" />
<PackageReference Include="Microsoft.DotNet.XHarness.TestRunners.Xunit" Version="10.0.0-dev" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<TestRuntime>true</TestRuntime>
<IncludeRemoteExecutor>true</IncludeRemoteExecutor>
<TargetFramework>$(NetCoreAppCurrent)</TargetFramework>
<TargetFramework>$(NetCoreAppCurrent)</TargetFramework>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
<NotSupportedOnMono Condition="'$(FeatureMono)' == 'true'">.PlatformNotSupported</NotSupportedOnMono>
<ILLinkSharedDirectory>$(MSBuildThisFileDirectory)ILLink\</ILLinkSharedDirectory>
<IsBigEndian Condition="'$(Platform)' == 's390x'">true</IsBigEndian>
<Is64Bit Condition="'$(Platform)' == 'arm64' or '$(Platform)' == 'x64' or '$(Platform)' == 's390x' or '$(Platform)' == 'loongarch64' or '$(Platform)' == 'ppc64le' or '$(Platform)' == 'riscv64'">true</Is64Bit>
<!--<Is64Bit Condition="'$(Platform)' == 'arm64' or '$(Platform)' == 'x64' or '$(Platform)' == 's390x' or '$(Platform)' == 'loongarch64' or '$(Platform)' == 'ppc64le' or '$(Platform)' == 'riscv64'">true</Is64Bit>-->
<Is64Bit>true</Is64Bit>
<UseMinimalGlobalizationData Condition="'$(TargetsBrowser)' == 'true' or '$(TargetsWasi)' == 'true'">true</UseMinimalGlobalizationData>
<EnableLibraryImportGenerator>true</EnableLibraryImportGenerator>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,7 @@ public static void WriteIntPtr(IntPtr ptr, int ofs, IntPtr val)
#if TARGET_64BIT
WriteInt64(ptr, ofs, (long)val);
#else // 32

#pragma warning disable CA2020 // Prevent from behavioral change
WriteInt32(ptr, ofs, (int)val);
#pragma warning restore CA2020
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ internal partial struct ThreadId

public bool IsInitialized => _id != 0;
public static ThreadId Current_NoInitialize => new ThreadId(t_threadId);

public void InitializeForCurrentThread()
{
Debug.Assert(!IsInitialized);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

// FIXME: Make this dynamic!
#define WASM64
using System.ComponentModel;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices.JavaScript;
using System.Runtime.Versioning;
using System.Threading;



namespace System.Runtime.InteropServices.JavaScript
{
/// <summary>
Expand All @@ -19,9 +23,8 @@ namespace System.Runtime.InteropServices.JavaScript
public partial struct JSMarshalerArgument
{
internal JSMarshalerArgumentImpl slot;

// keep in sync with JSMarshalerArgumentOffsets in marshal.ts
[StructLayout(LayoutKind.Explicit, Pack = 32, Size = 32)]
[StructLayout(LayoutKind.Explicit, Pack = 32, Size = 64)]
internal struct JSMarshalerArgumentImpl
{
[FieldOffset(0)]
Expand All @@ -42,36 +45,35 @@ internal struct JSMarshalerArgumentImpl
internal double DoubleValue;// must be aligned to 8 because of Module.HEAPF64 view alignment
[FieldOffset(0)]
internal IntPtr IntPtrValue;

[FieldOffset(4)]
[FieldOffset(8)]
internal IntPtr JSHandle;
[FieldOffset(4)]
[FieldOffset(8)]
internal IntPtr GCHandle;

[FieldOffset(8)]
[FieldOffset(16)]
internal int Length;

/// <summary>
/// Discriminators
/// </summary>
[FieldOffset(12)]
[FieldOffset(24)]
internal MarshalerType Type;
[FieldOffset(13)]
[FieldOffset(25)]
internal MarshalerType ElementType;

#if FEATURE_WASM_MANAGED_THREADS
[FieldOffset(16)]
internal IntPtr ContextHandle;
#if FEATURE_WASM_MANAGED_THREADS
[FieldOffset(32)]
internal IntPtr ContextHandle;

[FieldOffset(20)]
internal bool ReceiverShouldFree; // note this is 1 byte
[FieldOffset(40)]
internal bool ReceiverShouldFree; // note this is 1 byte

[FieldOffset(24)]
internal IntPtr CallerNativeTID;
[FieldOffset(48)]
internal IntPtr CallerNativeTID;

[FieldOffset(28)]
internal IntPtr SyncDoneSemaphorePtr;
#endif
[FieldOffset(56)]
internal IntPtr SyncDoneSemaphorePtr;
#endif
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ public unsafe void ToManaged(out object? value)
ToManaged(out double v);
value = v;
}
else if (slot.Type == MarshalerType.BigInt64)
{
ToManagedBig(out long v);
value = v;
}
else if (slot.Type == MarshalerType.JSObject)
{
ToManaged(out JSObject? val);
Expand Down Expand Up @@ -378,7 +383,7 @@ public unsafe void ToJS(object?[] value)
JSMarshalerArgument* payload = (JSMarshalerArgument*)Marshal.AllocHGlobal(bytes);
Unsafe.InitBlock(payload, 0, (uint)bytes);
#if !ENABLE_JS_INTEROP_BY_VALUE
Interop.Runtime.RegisterGCRoot(payload, bytes, IntPtr.Zero);
Interop.Runtime.RegisterGCRoot(payload, (nint)bytes, IntPtr.Zero);
#endif
for (int i = 0; i < slot.Length; i++)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public unsafe void ToJS(string?[] value)
JSMarshalerArgument* payload = (JSMarshalerArgument*)Marshal.AllocHGlobal(bytes);
Unsafe.InitBlock(payload, 0, (uint)bytes);
#if !ENABLE_JS_INTEROP_BY_VALUE
Interop.Runtime.RegisterGCRoot(payload, bytes, IntPtr.Zero);
Interop.Runtime.RegisterGCRoot(payload, (nint)bytes, IntPtr.Zero);
#endif
for (int i = 0; i < slot.Length; i++)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<TargetFramework>$(NetCoreAppCurrent)-browser</TargetFramework>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<TestRuntime>true</TestRuntime>
<WasmXHarnessArgs>$(WasmXHarnessArgs) --engine-arg=--expose-gc --web-server-use-cop</WasmXHarnessArgs>
<WasmXHarnessArgs>$(WasmXHarnessArgs) --engine-arg=--expose-gc --web-server-use-cop</WasmXHarnessArgs>
<EnableAggressiveTrimming>true</EnableAggressiveTrimming>
<PublishTrimmed>true</PublishTrimmed>
<FeatureWasmManagedThreads Condition="'$(WasmEnableThreads)' == 'true'">true</FeatureWasmManagedThreads>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class JSImportTest : JSInteropTestBase, IAsyncLifetime
[Fact]
public unsafe void StructSize()
{
Assert.Equal(32, sizeof(JSMarshalerArgument));
Assert.Equal(64, sizeof(JSMarshalerArgument));
}

[Fact]
Expand Down Expand Up @@ -665,13 +665,14 @@ public void JsImportSingle(float value)
[MemberData(nameof(MarshalIntPtrCases))]
public void JsImportIntPtr(IntPtr value)
{
string expectedType = IntPtr.Size == 4 ? "number" : "bigint";
JsImportTest(value,
JavaScriptTestHelper.store1_IntPtr,
JavaScriptTestHelper.retrieve1_IntPtr,
JavaScriptTestHelper.echo1_IntPtr,
JavaScriptTestHelper.throw1_IntPtr,
JavaScriptTestHelper.identity1_IntPtr,
"number");
expectedType);
}

#endregion IntPtr
Expand All @@ -691,7 +692,8 @@ public unsafe void JsImportVoidPtr(IntPtr xvalue)
Assert.True(value == res);

var actualJsType = JavaScriptTestHelper.getType1();
Assert.Equal("number", actualJsType);
string expectedType = IntPtr.Size == 4 ? "number" : "bigint";
Assert.Equal(expectedType, actualJsType);
}

#endregion VoidPtr
Expand Down Expand Up @@ -781,13 +783,14 @@ public void JsImportNullableBigInt64(long? value)
[MemberData(nameof(MarshalNullableIntPtrCases))]
public void JsImportNullableIntPtr(IntPtr? value)
{
string expectedType = IntPtr.Size == 4 ? "number" : "bigint";
JsImportTest(value,
JavaScriptTestHelper.store1_NullableIntPtr,
JavaScriptTestHelper.retrieve1_NullableIntPtr,
JavaScriptTestHelper.echo1_NullableIntPtr,
JavaScriptTestHelper.throw1_NullableIntPtr,
JavaScriptTestHelper.identity1_NullableIntPtr,
"number");
expectedType);
}

#endregion NullableIntPtr
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1074,10 +1074,12 @@ public static async Task InitializeAsync()
}
}

public static Task DisposeAsync()
public static async Task<Task> DisposeAsync()
{
_module?.Dispose();
_module = null;
await Task.Yield();
GC.Collect();
return Task.CompletedTask;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<TargetFrameworks>$(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-unix;$(NetCoreAppCurrent)-browser</TargetFrameworks>
<TestRuntime>true</TestRuntime>
<IncludeRemoteExecutor>true</IncludeRemoteExecutor>
<IncludeRemoteExecutor>true</IncludeRemoteExecutor>
</PropertyGroup>
<ItemGroup>
<Compile Include="AssemblyInfo.cs" />
Expand Down
2 changes: 1 addition & 1 deletion src/libraries/System.Runtime/ref/System.Runtime.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public SafeWaitHandle(System.IntPtr existingHandle, bool ownsHandle) : base (def
}
}
namespace System
{
{
public partial class AccessViolationException : System.SystemException
{
public AccessViolationException() { }
Expand Down
32 changes: 26 additions & 6 deletions src/mono/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ endif()
######################################
# AOT CROSS COMPILER SUPPORT
######################################

if(NOT AOT_TARGET_TRIPLE STREQUAL "")
set(MONO_CROSS_COMPILE 1)
if(NOT AOT_OFFSETS_FILE STREQUAL "")
Expand All @@ -144,6 +143,9 @@ if(NOT AOT_TARGET_TRIPLE STREQUAL "")
elseif(AOT_TARGET_TRIPLE STREQUAL "wasm32-unknown-none")
set(TARGET_SYSTEM_NAME "emscripten")
set(TARGET_ARCH "wasm")
elseif(AOT_TARGET_TRIPLE STREQUAL "wasm64-unknown-none")
set(TARGET_SYSTEM_NAME "emscripten")
set(TARGET_ARCH "wasm64")
elseif(AOT_TARGET_TRIPLE STREQUAL "wasm32-unknown-wasip2")
set(TARGET_SYSTEM_NAME "wasi")
set(TARGET_ARCH "wasm")
Expand All @@ -169,7 +171,6 @@ if(NOT AOT_TARGET_TRIPLE STREQUAL "")
message(FATAL_ERROR "AOT target '${AOT_TARGET_TRIPLE}' not supported.")
endif()
endif()

######################################
# HOST OS CHECKS
######################################
Expand Down Expand Up @@ -403,7 +404,7 @@ elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "riscv64")
set(HOST_RISCV64 1)
elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "s390x")
set(HOST_S390X 1)
elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "wasm" OR CMAKE_SYSTEM_PROCESSOR STREQUAL "wasm32")
elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "wasm" OR CMAKE_SYSTEM_PROCESSOR STREQUAL "wasm32" OR CMAKE_SYSTEM_PROCESSOR STREQUAL "wasm64")
set(HOST_WASM 1)
elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "ppc64le")
set(HOST_POWERPC 1)
Expand All @@ -416,8 +417,20 @@ endif()
# TARGET ARCH CHECKS
######################################

if (CMAKE_C_FLAGS MATCHES "wasm64")
set(USES_MEM64 TRUE)
endif()

if (CMAKE_C_FLAGS MATCHES "MEMORY64")
set(USES_MEM64 TRUE)
endif()

if(NOT TARGET_ARCH)
set(TARGET_ARCH "${CMAKE_SYSTEM_PROCESSOR}")
if (CMAKE_SYSTEM_PROCESSOR STREQUAL "wasm" AND USES_MEM64)
set(TARGET_ARCH "wasm64")
else()
set(TARGET_ARCH "${CMAKE_SYSTEM_PROCESSOR}")
endif()
endif()

# Unify naming
Expand Down Expand Up @@ -481,11 +494,16 @@ elseif(TARGET_ARCH STREQUAL "s390x")
set(MONO_ARCHITECTURE "\"s390x\"")
set(TARGET_SIZEOF_VOID_P 8)
set(SIZEOF_REGISTER 8)
elseif(TARGET_ARCH STREQUAL "wasm" OR TARGET_ARCH STREQUAL "wasm32")
elseif(TARGET_ARCH STREQUAL "wasm" OR TARGET_ARCH STREQUAL "wasm32")
set(TARGET_WASM 1)
set(MONO_ARCHITECTURE "\"wasm\"")
set(TARGET_SIZEOF_VOID_P 4)
set(SIZEOF_REGISTER 4)
elseif(TARGET_ARCH STREQUAL "wasm64" )
set(TARGET_WASM 1)
set(MONO_ARCHITECTURE "\"wasm\"")
set(TARGET_SIZEOF_VOID_P 8)
set(SIZEOF_REGISTER 8)
elseif(TARGET_ARCH STREQUAL "ppc64le")
set(TARGET_POWERPC 1)
set(TARGET_POWERPC64 1)
Expand Down Expand Up @@ -587,6 +605,8 @@ if(LLVM_PREFIX)
set(llvm_codegen_libs "armcodegen")
elseif(TARGET_ARCH STREQUAL "wasm")
set(llvm_codegen_libs "")
elseif(TARGET_ARCH STREQUAL "wasm64")
set(llvm_codegen_libs "")
else()
message(FATAL_ERROR "FIXME: ${TARGET_ARCH}")
endif()
Expand Down Expand Up @@ -657,7 +677,7 @@ if(LLVM_PREFIX)

# Check codegen libs and add needed libraries.
set(llvm_extra ${MONO_llvm_extra_libs_${llvm_codegen_libs}})
if("${llvm_extra}" STREQUAL "" AND NOT "${TARGET_ARCH}" STREQUAL "wasm")
if("${llvm_extra}" STREQUAL "" AND NOT "${TARGET_ARCH}" STREQUAL "wasm" AND NOT "${TARGET_ARCH}" STREQUAL "wasm64" )
message(FATAL_ERROR "FIXME: ${TARGET_ARCH}")
endif()

Expand Down
2 changes: 2 additions & 0 deletions src/mono/System.Private.CoreLib/src/Mono/RuntimeHandles.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

namespace Mono
{
Expand Down Expand Up @@ -205,6 +206,7 @@ public override int GetHashCode()
}
}

[StructLayout(LayoutKind.Sequential, Pack = 8)]
internal unsafe struct RuntimeGPtrArrayHandle
{
private RuntimeStructs.GPtrArray* value;
Expand Down
Loading