Class ExecutionContext
Represents an execution context, which is used to manage the execution of WebAssembly functions. It contains a stack of frames and behaves like a thread of execution.
Assembly: WaaS.Core.dll
View Source
public class ExecutionContext : IDisposable
Implements:
System.IDisposable
Properties
Fuel
The remaining fuel, or null if the fuel is unlimited (default). Each executed WebAssembly instruction consumes one unit of fuel, and WaaS.Runtime.FuelExhaustedException is thrown when an instruction is about to be executed with no fuel left. The host can refill the fuel at any time, e.g. between invocations or while the execution is suspended.
View Source
public ulong? Fuel { get; set; }
FuelPerResume
If set, WaaS.Runtime.ExecutionContext.Fuel is reset to this value each time the execution starts or resumes, that is, at the start of an invocation and after each suspension on an asynchronous host function. This limits the number of instructions executed between two suspensions.
View Source
public ulong? FuelPerResume { get; set; }
MaxMemoryPages
If set, "memory.grow" executed on this context fails once the memory would exceed this number of pages, in addition to the maximum declared by the module.
View Source
public uint? MaxMemoryPages { get; set; }
CancellationToken
The token to abort the execution on this context. It is observed while WebAssembly code is running (at
branches and calls) and while the execution is suspended on an asynchronous host function.
When cancellation is requested, System.OperationCanceledException is thrown from the invocation and the
frames of the invocation are discarded.
View Source
public CancellationToken CancellationToken { get; set; }
DefaultDebugger
The debugger attached to the contexts when they are created, such as a debugger connected from an IDE.
View Source
public static IWasmDebugger DefaultDebugger { get; set; }
Debugger
The debugger observing the execution, or null. While a debugger is attached, the interpreter calls it before every instruction, which makes the execution several times slower.
View Source
public IWasmDebugger Debugger { get; set; }
LastFrame
View Source
public StackFrame LastFrame { get; }
ResultLength
View Source
public int ResultLength { get; }
Methods
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
View Source
public void Dispose()
Invoke(IInvocableFunction, ReadOnlySpan<StackValueItem>)
View Source
public void Invoke(IInvocableFunction function, ReadOnlySpan<StackValueItem> inputValues)
Parameters
| Type | Name |
|---|---|
| WaaS.Runtime.IInvocableFunction | function |
System.ReadOnlySpan<WaaS.Runtime.StackValueItem> | inputValues |
InvokeAsync(IInvocableFunction, ReadOnlySpan<StackValueItem>)
View Source
public ValueTask InvokeAsync(IInvocableFunction function, ReadOnlySpan<StackValueItem> inputValues)
Returns
System.Threading.Tasks.ValueTask
Parameters
| Type | Name |
|---|---|
| WaaS.Runtime.IInvocableFunction | function |
System.ReadOnlySpan<WaaS.Runtime.StackValueItem> | inputValues |
TakeResults(Span<StackValueItem>)
View Source
public void TakeResults(Span<StackValueItem> results)
Parameters
| Type | Name |
|---|---|
System.Span<WaaS.Runtime.StackValueItem> | results |
Implements
System.IDisposable