Skip to content

Commit

Permalink
Merge pull request #33 from kelnishi/OpStack-opt
Browse files Browse the repository at this point in the history
Op stack opt
  • Loading branch information
kelnishi authored Dec 4, 2024
2 parents 33b3f6d + ab58880 commit 5b30b5d
Show file tree
Hide file tree
Showing 84 changed files with 1,118 additions and 486 deletions.
2 changes: 1 addition & 1 deletion Spec.Test/BindingTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public void BindStackBinder()
var fa = runtime.GetExportedFunction(("binding", "4x4"));
var invoker = runtime.CreateStackInvoker(fa);

var result = invoker(new Value[]{1, 1, 1f, 1.0});
var result = invoker(new Value[]{1, 1L, 1f, 1.0});

Assert.Equal(1 * 2, (int)result[0]);
Assert.Equal(1 * 3, (long)result[1]);
Expand Down
19 changes: 19 additions & 0 deletions Spec.Test/ExtensionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,25 @@ public class ExtensionTests
public void TailCallFactorial()
{
var runtime = new WasmRuntime();
runtime.TranspileModules = false;

using var fileStream = new FileStream("../../../engine/tailcalls.wasm", FileMode.Open);
var module = BinaryModuleParser.ParseWasm(fileStream);
var moduleInst = runtime.InstantiateModule(module);
runtime.RegisterModule("tailcalls", moduleInst);

var fa = runtime.GetExportedFunction(("tailcalls", "factorial"));
var invoker = runtime.CreateInvoker<Func<long, long>>(fa);

Assert.Equal(479_001_600, invoker(12));
Assert.Equal(2_432_902_008_176_640_000 , invoker(20));
}

[Fact]
public void TailCallFactorialTranspiled()
{
var runtime = new WasmRuntime();
runtime.TranspileModules = true;

using var fileStream = new FileStream("../../../engine/tailcalls.wasm", FileMode.Open);
var module = BinaryModuleParser.ParseWasm(fileStream);
Expand Down
9 changes: 9 additions & 0 deletions Wacs.Console/CommandLineOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,23 @@
// * limitations under the License.
// */

using System;
using System.Diagnostics.CodeAnalysis;
using System.Collections.Generic;
using CommandLine;
using Wacs.Core.Runtime;

namespace Wacs.Console
{
// ReSharper disable once ClassNeverInstantiated.Global


public class CommandLineOptions
{
[DynamicDependency(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.PublicProperties,
typeof(CommandLineOptions))]
public CommandLineOptions() {}

[Option('e',"env", Separator = ',', HelpText = "Comma-separated list of environment variables (format: KEY=VALUE)")]
public IEnumerable<string> EnvironmentVars { get; set; } = new List<string>();

Expand Down Expand Up @@ -70,6 +78,7 @@ public class CommandLineOptions
public string WasmModule { get; set; } = "";

public IEnumerable<string> ExecutableArgs { get; set; } = new List<string>();

}

}
Loading

0 comments on commit 5b30b5d

Please sign in to comment.