JSVirtualMachine

Superclass:
NSObject
Declared In:

Introduction

An instance of JSVirtualMachine represents a single JavaScript "object space" or set of execution resources. Thread safety is supported by locking the virtual machine, with concurrent JavaScript execution supported by allocating separate instances of JSVirtualMachine.



Groups

Creating New Virtual Machines

Group members:

-init

Create a new JSVirtualMachine.

 

Memory Management

Group members:

-addManagedReference:withOwner:

Notify the JSVirtualMachine of an external object relationship.

-removeManagedReference:withOwner:

Notify the JSVirtualMachine that a previous object relationship no longer exists.


Methods

-addManagedReference:withOwner:

Notify the JSVirtualMachine of an external object relationship.

-init

Create a new JSVirtualMachine.

-removeManagedReference:withOwner:

Notify the JSVirtualMachine that a previous object relationship no longer exists.


addManagedReference:withOwner:


Notify the JSVirtualMachine of an external object relationship.

- (void)addManagedReference:(id)object withOwner:(id)owner; 
Parameters
object

The object that the owner points to.

owner

The object that owns the pointed to object.

Discussion

Allows clients of JSVirtualMachine to make the JavaScript runtime aware of arbitrary external Objective-C object graphs. The runtime can then use this information to retain any JavaScript values that are referenced from somewhere in said object graph.

For correct behavior clients must make their external object graphs reachable from within the JavaScript runtime. If an Objective-C object is reachable from within the JavaScript runtime, all managed references transitively reachable from it as recorded using -addManagedReference:withOwner: will be scanned by the garbage collector.


init


Create a new JSVirtualMachine.

- (instancetype)init; 

removeManagedReference:withOwner:


Notify the JSVirtualMachine that a previous object relationship no longer exists.

- (void)removeManagedReference:(id)object withOwner:(id)owner; 
Parameters
object

The object that was formerly owned.

owner

The former owner.

Discussion

The JavaScript runtime will continue to scan any references that were reported to it by -addManagedReference:withOwner: until those references are removed.