C# Class MsieJavaScriptEngine.JsRt.Ie.IeJsRuntime

“IE” Chakra runtime

Each Chakra runtime has its own independent execution engine, JIT compiler, and garbage collected heap. As such, each runtime is completely isolated from other runtimes.

Runtimes can be used on any thread, but only one thread can call into a runtime at any time.

NOTE: A IeJsRuntime, unlike other objects in the Chakra hosting API, is not garbage collected since it contains the garbage collected heap itself. A runtime will continue to exist until Dispose is called.

Show file Open project: Taritsyn/MsieJavaScriptEngine Class Usage Examples

Public Methods

Method Description
CollectGarbage ( ) : void

Performs a full garbage collection

Create ( ) : IeJsRuntime

Creates a new runtime

Create ( JsRuntimeAttributes attributes, JsRuntimeVersion version ) : IeJsRuntime

Creates a new runtime

Create ( JsRuntimeAttributes attributes, JsRuntimeVersion version, JsThreadServiceCallback threadServiceCallback ) : IeJsRuntime

Creates a new runtime

CreateContext ( ) : IeJsContext

Creates a script context for running scripts

Each script context has its own global object that is isolated from all other script contexts.

CreateContext ( IDebugApplication32 debugApplication ) : IeJsContext

Creates a debug script context for running scripts

Each script context has its own global object that is isolated from all other script contexts.

CreateContext ( IDebugApplication64 debugApplication ) : IeJsContext

Creates a debug script context for running scripts

Each script context has its own global object that is isolated from all other script contexts.

Dispose ( ) : void

Disposes a runtime

Once a runtime has been disposed, all resources owned by it are invalid and cannot be used. If the runtime is active (i.e. it is set to be current on a particular thread), it cannot be disposed.

SetBeforeCollectCallback ( IntPtr callbackState, JsBeforeCollectCallback beforeCollectCallback ) : void

Sets a callback function that is called by the runtime before garbage collection

The callback is invoked on the current runtime execution thread, therefore execution is blocked until the callback completes.

The callback can be used by hosts to prepare for garbage collection. For example, by releasing unnecessary references on Chakra objects.

SetMemoryAllocationCallback ( IntPtr callbackState, JsMemoryAllocationCallback allocationCallback ) : void

Sets a memory allocation callback for specified runtime

Registering a memory allocation callback will cause the runtime to call back to the host whenever it acquires memory from, or releases memory to, the OS. The callback routine is called before the runtime memory manager allocates a block of memory. The allocation will be rejected if the callback returns false. The runtime memory manager will also invoke the callback routine after freeing a block of memory, as well as after allocation failures.

The callback is invoked on the current runtime execution thread, therefore execution is blocked until the callback completes.

The return value of the callback is not stored; previously rejected allocations will not prevent the runtime from invoking the callback again later for new memory allocations.

Method Details

CollectGarbage() public method

Performs a full garbage collection
public CollectGarbage ( ) : void
return void

Create() public static method

Creates a new runtime
public static Create ( ) : IeJsRuntime
return IeJsRuntime

Create() public static method

Creates a new runtime
public static Create ( JsRuntimeAttributes attributes, JsRuntimeVersion version ) : IeJsRuntime
attributes JsRuntimeAttributes The attributes of the runtime to be created
version JsRuntimeVersion The version of the runtime to be created
return IeJsRuntime

Create() public static method

Creates a new runtime
public static Create ( JsRuntimeAttributes attributes, JsRuntimeVersion version, JsThreadServiceCallback threadServiceCallback ) : IeJsRuntime
attributes JsRuntimeAttributes The attributes of the runtime to be created
version JsRuntimeVersion The version of the runtime to be created
threadServiceCallback JsThreadServiceCallback The thread service for the runtime. Can be null.
return IeJsRuntime

CreateContext() public method

Creates a script context for running scripts
Each script context has its own global object that is isolated from all other script contexts.
public CreateContext ( ) : IeJsContext
return IeJsContext

CreateContext() public method

Creates a debug script context for running scripts
Each script context has its own global object that is isolated from all other script contexts.
public CreateContext ( IDebugApplication32 debugApplication ) : IeJsContext
debugApplication IDebugApplication32 The debug application to use
return IeJsContext

CreateContext() public method

Creates a debug script context for running scripts
Each script context has its own global object that is isolated from all other script contexts.
public CreateContext ( IDebugApplication64 debugApplication ) : IeJsContext
debugApplication IDebugApplication64 The debug application to use
return IeJsContext

Dispose() public method

Disposes a runtime
Once a runtime has been disposed, all resources owned by it are invalid and cannot be used. If the runtime is active (i.e. it is set to be current on a particular thread), it cannot be disposed.
public Dispose ( ) : void
return void

SetBeforeCollectCallback() public method

Sets a callback function that is called by the runtime before garbage collection

The callback is invoked on the current runtime execution thread, therefore execution is blocked until the callback completes.

The callback can be used by hosts to prepare for garbage collection. For example, by releasing unnecessary references on Chakra objects.

public SetBeforeCollectCallback ( IntPtr callbackState, JsBeforeCollectCallback beforeCollectCallback ) : void
callbackState System.IntPtr User provided state that will be passed back to the callback
beforeCollectCallback JsBeforeCollectCallback The callback function being set
return void

SetMemoryAllocationCallback() public method

Sets a memory allocation callback for specified runtime

Registering a memory allocation callback will cause the runtime to call back to the host whenever it acquires memory from, or releases memory to, the OS. The callback routine is called before the runtime memory manager allocates a block of memory. The allocation will be rejected if the callback returns false. The runtime memory manager will also invoke the callback routine after freeing a block of memory, as well as after allocation failures.

The callback is invoked on the current runtime execution thread, therefore execution is blocked until the callback completes.

The return value of the callback is not stored; previously rejected allocations will not prevent the runtime from invoking the callback again later for new memory allocations.

public SetMemoryAllocationCallback ( IntPtr callbackState, JsMemoryAllocationCallback allocationCallback ) : void
callbackState System.IntPtr /// User provided state that will be passed back to the callback ///
allocationCallback JsMemoryAllocationCallback /// Memory allocation callback to be called for memory allocation events ///
return void