Search Apps Documentation Source Content File Folder Download Copy Actions Download State String Boolean Number Struct Map Slice Pointer Function Closure Reference Nil Package Type Interface Unknown

crossrealm_d state

Back to all declarations

counter

int

Value

100

SetCounter

func(n int)

SetCounter: non-crossing. Calling this cross-realm triggers the readonly check because it directly assigns a package var.

Open
OID
0658f0…f414:6
SetCounter details

Inspect func

SetCounterCrossing

func(n int)

SetCounterCrossing: crossing version. This works correctly cross-realm because the caller enters this realm's context.

Open
OID
0658f0…f414:7
SetCounterCrossing details

Inspect func

DoubleCounter

func() int

DoubleCounter reads counter and doubles it. Used to show that if counter were silently corrupted in memory, subsequent crossing calls would act on the wrong value.

Open
OID
0658f0…f414:9
DoubleCounter details

Inspect func

MutateBytes

func(bz []uint8)

MutateBytes mutates the first byte of bz to 0xff. Used to test whether a foreign realm can write to caller-allocated bytes. Under storage=authority, bz has PkgID=caller; borrow rule #1 here makes m.Realm=crossrealm\_d (declaring realm); the write site (bz\[0] = ...) should fire readonly because bz.PkgID != m.Realm.ID.

Open
OID
0658f0…f414:10
MutateBytes details

Inspect func
counter : int =100
init.1 : func() Inspect
SetCounter : func(n int) Inspect
SetCounterCrossing : func(n int) Inspect
GetCounter : func() int Inspect
DoubleCounter : func() int Inspect
MutateBytes : func(bz []uint8) Inspect