mirror of
https://github.com/fluencelabs/assemblyscript
synced 2025-06-20 10:16:37 +00:00
baseline
This commit is contained in:
@ -7,7 +7,7 @@ Common
|
||||
------
|
||||
|
||||
* **__ref_collect**()<br />
|
||||
Triggers a full garbage collection cycle.
|
||||
Triggers a full garbage collection cycle. Also indicates the presence of a GC.
|
||||
|
||||
Tracing
|
||||
-------
|
||||
@ -24,14 +24,15 @@ Tracing
|
||||
Reference counting
|
||||
------------------
|
||||
|
||||
* **__ref_register**(ref: `usize`)<br />
|
||||
Sets up a new reference. Implementation is optional for reference counting GCs.
|
||||
|
||||
* **__ref_retain**(ref: `usize`)<br />
|
||||
Retains a reference, usually incrementing RC.
|
||||
|
||||
* **__ref_release**(ref: `usize`)<br />
|
||||
Releases a reference, usually decrementing RC.
|
||||
|
||||
Reference counting may also implement `__ref_register` if necessary.
|
||||
|
||||
Typical patterns
|
||||
----------------
|
||||
|
||||
|
@ -1,8 +1,8 @@
|
||||
// A dummy GC for looking at generated GC code without actually implementing it.
|
||||
// A tracing dummy GC.
|
||||
|
||||
// @ts-ignore: decorator
|
||||
@inline
|
||||
const TRACE = false;
|
||||
const TRACE = isDefined(GC_TRACE);
|
||||
|
||||
// @ts-ignore: decorator
|
||||
@global @unsafe
|
||||
@ -29,17 +29,3 @@ function __ref_link(ref: usize, parentRef: usize): void {
|
||||
function __ref_unlink(ref: usize, parentRef: usize): void {
|
||||
if (TRACE) trace("dummy.unlink", 2, ref, parentRef);
|
||||
}
|
||||
|
||||
// Reference counting
|
||||
|
||||
// // @ts-ignore: decorator
|
||||
// @global @unsafe
|
||||
// function __ref_retain(ref: usize): void {
|
||||
// if (TRACE) trace("dummy.retain", 1, ref);
|
||||
// }
|
||||
|
||||
// // @ts-ignore: decorator
|
||||
// @global @unsafe
|
||||
// function __ref_release(ref: usize): void {
|
||||
// if (TRACE) trace("dummy.release", 1, ref);
|
||||
// }
|
||||
|
29
std/assembly/collector/dummyrc.ts
Normal file
29
std/assembly/collector/dummyrc.ts
Normal file
@ -0,0 +1,29 @@
|
||||
// A reference counting dummy GC.
|
||||
|
||||
// @ts-ignore: decorator
|
||||
@inline
|
||||
const TRACE = isDefined(GC_TRACE);
|
||||
|
||||
// @ts-ignore: decorator
|
||||
@global @unsafe
|
||||
function __ref_register(ref: usize): void {
|
||||
if (TRACE) trace("dummyrc.register", 1, ref);
|
||||
}
|
||||
|
||||
// @ts-ignore: decorator
|
||||
@global @unsafe
|
||||
function __ref_collect(): void {
|
||||
if (TRACE) trace("dummyrc.collect");
|
||||
}
|
||||
|
||||
// @ts-ignore: decorator
|
||||
@global @unsafe
|
||||
function __ref_retain(ref: usize): void {
|
||||
if (TRACE) trace("dummyrc.retain", 1, ref);
|
||||
}
|
||||
|
||||
// @ts-ignore: decorator
|
||||
@global @unsafe
|
||||
function __ref_release(ref: usize): void {
|
||||
if (TRACE) trace("dummyrc.release", 1, ref);
|
||||
}
|
@ -4,7 +4,7 @@
|
||||
@inline
|
||||
const TRACE = false;
|
||||
|
||||
import { ITERATEROOTS, HEADER_SIZE } from "../runtime";
|
||||
import { iterateRoots, HEADER_SIZE } from "../runtime";
|
||||
|
||||
/** Collector states. */
|
||||
const enum State {
|
||||
@ -141,7 +141,7 @@ function step(): void {
|
||||
}
|
||||
case State.IDLE: {
|
||||
if (TRACE) trace("gc~step/IDLE");
|
||||
ITERATEROOTS((ref: usize): void => {
|
||||
iterateRoots((ref: usize): void => {
|
||||
var obj = refToObj(ref);
|
||||
if (obj.color == white) obj.makeGray();
|
||||
});
|
||||
@ -165,7 +165,7 @@ function step(): void {
|
||||
obj.hookFn(objToRef(obj));
|
||||
} else {
|
||||
if (TRACE) trace("gc~step/MARK finish");
|
||||
ITERATEROOTS((ref: usize): void => {
|
||||
iterateRoots((ref: usize): void => {
|
||||
var obj = refToObj(ref);
|
||||
if (obj.color == white) obj.makeGray();
|
||||
});
|
||||
|
Reference in New Issue
Block a user