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

[NativeAOT-LLVM] Enable string interop by value #2550

Merged
merged 4 commits into from
Apr 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<GeneratePlatformNotSupportedAssemblyMessage Condition="'$(TargetPlatformIdentifier)' != 'browser'">SR.SystemRuntimeInteropServicesJavaScript_PlatformNotSupported</GeneratePlatformNotSupportedAssemblyMessage>
<FeatureWasmManagedThreads Condition="'$(TargetPlatformIdentifier)' == 'browser' and '$(WasmEnableThreads)' == 'true'">true</FeatureWasmManagedThreads>
<WasmEnableJsInteropByValue Condition="'$(TargetPlatformIdentifier)' == 'browser' and '$(WasmEnableJsInteropByValue)' == '' and '$(FeatureWasmManagedThreads)' == 'true'">true</WasmEnableJsInteropByValue>
<WasmEnableJsInteropByValue Condition="'$(TargetPlatformIdentifier)' == 'browser' and '$(RuntimeFlavor)' == 'CoreCLR'">true</WasmEnableJsInteropByValue><!-- TODO-LLVM: This is not upstreamable because it makes the build runtime-specific. -->
<WasmEnableJsInteropByValue Condition="'$(TargetPlatformIdentifier)' == 'browser' and '$(WasmEnableJsInteropByValue)' == ''">false</WasmEnableJsInteropByValue>
<DefineConstants Condition="'$(FeatureWasmManagedThreads)' == 'true'">$(DefineConstants);FEATURE_WASM_MANAGED_THREADS</DefineConstants>
<DefineConstants Condition="'$(WasmEnableJsInteropByValue)' == 'true'">$(DefineConstants);ENABLE_JS_INTEROP_BY_VALUE</DefineConstants>
Expand Down
1 change: 1 addition & 0 deletions src/mono/browser/browser.proj
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
<WasmEnableSIMD Condition="'$(WasmEnableSIMD)' == ''">true</WasmEnableSIMD>
<WasmEnableExceptionHandling Condition="'$(WasmEnableExceptionHandling)' == ''">true</WasmEnableExceptionHandling>
<WasmEnableJsInteropByValue Condition="'$(WasmEnableJsInteropByValue)' == '' and '$(WasmEnableThreads)' == 'true'">true</WasmEnableJsInteropByValue>
<WasmEnableJsInteropByValue Condition="'$(RuntimeFlavor)' == 'CoreCLR'">true</WasmEnableJsInteropByValue>
<WasmEnableJsInteropByValue Condition="'$(WasmEnableJsInteropByValue)' == ''">false</WasmEnableJsInteropByValue>
<FilterSystemTimeZones Condition="'$(FilterSystemTimeZones)' == ''">false</FilterSystemTimeZones>
<EmccCmd>emcc</EmccCmd>
Expand Down
8 changes: 8 additions & 0 deletions src/tests/nativeaot/SmokeTests/DotnetJs/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,14 @@ internal static int Square(int x)
return result;
}

[JSExport]
internal static string Concat(string a, string b)
{
var result = a + b;
Console.WriteLine($"Concatenating '{a}' and '{b}' with result '{result}'");
return result;
}

[JSExport]
internal static void Throw() => throw new Exception("This is a test exception");
}
Expand Down
5 changes: 5 additions & 0 deletions src/tests/nativeaot/SmokeTests/DotnetJs/wwwroot/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,10 @@ try {
console.log(`Thrown expected exception: ${e}`);
}

const concat = exports.DotnetJsApp.Program.Interop.Concat("Aaa", "Bbb");
if (concat != "AaaBbb") {
result = 15;
}

console.log(`Exit code ${result}`);
exit(result);