メインコンテンツまでスキップ

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​
Declaration
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​
Declaration
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​
Declaration
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​
Declaration
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​
Declaration
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​
Declaration
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​
Declaration
public IWasmDebugger Debugger { get; set; }

LastFrame​

View Source​
Declaration
public StackFrame LastFrame { get; }

ResultLength​

View Source​
Declaration
public int ResultLength { get; }

Methods​

Dispose()​

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

View Source​
Declaration
public void Dispose()

Invoke(IInvocableFunction, ReadOnlySpan<StackValueItem>)​

View Source​
Declaration
public void Invoke(IInvocableFunction function, ReadOnlySpan<StackValueItem> inputValues)
Parameters​
TypeName
WaaS.Runtime.IInvocableFunctionfunction
System.ReadOnlySpan<WaaS.Runtime.StackValueItem>inputValues

InvokeAsync(IInvocableFunction, ReadOnlySpan<StackValueItem>)​

View Source​
Declaration
public ValueTask InvokeAsync(IInvocableFunction function, ReadOnlySpan<StackValueItem> inputValues)
Returns​

System.Threading.Tasks.ValueTask

Parameters​
TypeName
WaaS.Runtime.IInvocableFunctionfunction
System.ReadOnlySpan<WaaS.Runtime.StackValueItem>inputValues

TakeResults(Span<StackValueItem>)​

View Source​
Declaration
public void TakeResults(Span<StackValueItem> results)
Parameters​
TypeName
System.Span<WaaS.Runtime.StackValueItem>results

Implements​

  • System.IDisposable