Skip to content

Commit d4a53ff

Browse files
authored
Merge pull request #167 from kelnishi/stack-switching
WASIp3: stack-switching + CM async ABI + WACS.WASI.Preview3
2 parents 606601b + 476aca4 commit d4a53ff

329 files changed

Lines changed: 69889 additions & 1586 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/ci.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,14 @@ jobs:
4141
run: dotnet test --configuration Release --no-build --verbosity normal Spec.Test/Spec.Test.csproj
4242

4343
- name: Run Core Tests
44+
# WACS_AOT_TEST=1 opts into AotAcceptanceTests, which
45+
# publishes Wacs.Bench.Aot with PublishAot=true and
46+
# asserts no new IL warnings originate from Wacs.Core.
47+
# See Wacs.Core.Test/AotAcceptanceTests.cs for the
48+
# baseline + policy. The test takes ~60-90s — kept
49+
# behind the env var so dev cycles stay fast.
50+
env:
51+
WACS_AOT_TEST: "1"
4452
run: dotnet test --configuration Release --no-build --verbosity normal Wacs.Core/Wacs.Core.Test/Wacs.Core.Test.csproj
4553

4654
- name: Run Compilation Tests

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,3 +100,6 @@ Spec.Test/TestResults/**
100100
Wacs.Compilation/Sample*.cs.txt
101101
Wacs.Core/Generated
102102
**/TestResults/
103+
104+
# Local-only Claude Code plan artifacts (moved out of docs/)
105+
.claude/plans/

CHANGELOG.md

Lines changed: 9436 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// Copyright 2026 Kelvin Nishikawa
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
6+
using Wacs.ComponentModel.Async;
7+
8+
namespace WitHarnessSpike.Aot
9+
{
10+
/// <summary>
11+
/// Source-generator-driven equivalent of the hand-written
12+
/// <see cref="HelloHarness"/>. The
13+
/// <c>AsyncComponentHarnessGenerator</c> emits the
14+
/// constructor + lazy invoker fields + the
15+
/// <c>StringCoding.LowerUtf8</c> + retArea-lift body for
16+
/// the <see cref="Greet"/> method. End-to-end NativeAOT
17+
/// verification that the generator's string-marshaling
18+
/// codegen matches the hand-written pattern.
19+
/// </summary>
20+
[AsyncComponentHarness]
21+
public partial class GeneratedHelloHarness
22+
{
23+
[SyncExport("greet")]
24+
public partial string Greet(string name);
25+
}
26+
}

Spec.Test/components/fixtures/wit-harness-spike-hello/Aot.Spike/HelloHarness.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ public string Greet(string name)
117117
/// <c>WACS.WASI.Preview2</c> bundle, or per-subsystem
118118
/// stubs the embedder ships). For the spike, throw.</para>
119119
/// </summary>
120-
private static void BindWasiStubs(WasmRuntime runtime)
120+
internal static void BindWasiStubs(WasmRuntime runtime)
121121
{
122122
// Type 3: (i32) -> ()
123123
Action<ExecContext, int> drop = (_, _) =>

Spec.Test/components/fixtures/wit-harness-spike-hello/Aot.Spike/Program.cs

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,28 @@ public static int Main(string[] args)
3333

3434
var harness = HelloHarness.LoadFrom(componentBytes);
3535
var greeting = harness.Greet("World");
36+
Console.WriteLine($"hand-written: {greeting}");
3637

37-
Console.WriteLine(greeting);
38-
return greeting == "Hello, World!" ? 0 : 1;
38+
// Run the generator-emitted equivalent too.
39+
// Should produce identical output — proves the
40+
// generator's string codegen matches the
41+
// hand-written hello-spike pattern end-to-end
42+
// under NativeAOT.
43+
// Reuse the hand-written harness's WASI stubs
44+
// — the generator only emits export-side
45+
// marshaling, leaving import-side bindings to
46+
// the consumer. (A future generator slice
47+
// could emit these too once we settle on a
48+
// typed-imports surface.)
49+
var gen = new GeneratedHelloHarness(
50+
componentBytes, HelloHarness.BindWasiStubs);
51+
var genGreeting = gen.Greet("World");
52+
Console.WriteLine($"generator-emit: {genGreeting}");
53+
54+
bool ok = greeting == "Hello, World!"
55+
&& genGreeting == "Hello, World!"
56+
&& greeting == genGreeting;
57+
return ok ? 0 : 1;
3958
}
4059
catch (Exception ex)
4160
{

Spec.Test/components/fixtures/wit-harness-spike-hello/Aot.Spike/WitHarnessSpike.Aot.csproj

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,25 @@
4242
<ProjectReference Include="..\..\..\..\..\Wacs.Core\Wacs.Core\Wacs.Core.csproj" />
4343
<ProjectReference Include="..\..\..\..\..\Wacs.ComponentModel\Wacs.ComponentModel.Parser\Wacs.ComponentModel.Parser.csproj" />
4444
<ProjectReference Include="..\..\..\..\..\Wacs.ComponentModel\Wacs.ComponentModel.Harness.Runtime\Wacs.ComponentModel.Harness.Runtime.csproj" />
45+
46+
<!-- Reflective ComponentInstance for the generator-
47+
driven harness. AOT-clean via
48+
ComponentInstance.InstantiateAot which the
49+
generator emits — the reflective Invoke() typed
50+
bridge is NOT reached. -->
51+
<ProjectReference Include="..\..\..\..\..\Wacs.ComponentModel\Wacs.ComponentModel\Wacs.ComponentModel.csproj"
52+
SetTargetFramework="TargetFramework=net8.0"
53+
UndefineProperties="PublishAot;PublishTrimmed;PublishReadyToRun;SelfContained;RuntimeIdentifier" />
54+
55+
<!-- The generator emits the
56+
[AsyncComponentHarness] / [SyncExport] partial
57+
class bodies — InstantiateAot wiring + the
58+
StringCoding.LowerUtf8 + retArea lift for
59+
string-returning exports. -->
60+
<ProjectReference Include="..\..\..\..\..\Wacs.ComponentModel\Wacs.ComponentModel.Async.SourceGen\Wacs.ComponentModel.Async.SourceGen.csproj"
61+
SetTargetFramework="TargetFramework=netstandard2.0"
62+
OutputItemType="Analyzer"
63+
ReferenceOutputAssembly="false" />
4564
</ItemGroup>
4665

4766
</Project>
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
; Shipped analyzer releases.
2+
; Format: https://github.com/dotnet/roslyn-analyzers/blob/main/src/Microsoft.CodeAnalysis.Analyzers/ReleaseTrackingAnalyzers.Help.md
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
; Unshipped analyzer releases.
2+
; Format: https://github.com/dotnet/roslyn-analyzers/blob/main/src/Microsoft.CodeAnalysis.Analyzers/ReleaseTrackingAnalyzers.Help.md
3+
4+
; This generator emits source only — no analyzer diagnostics.

0 commit comments

Comments
 (0)