You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/portingguide/src/howto/nogc.md
+3-1Lines changed: 3 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -18,7 +18,7 @@ You may want to take the following steps.
18
18
2. Change the VM build process to build and/or link MMTk
19
19
- It may be easier to simply build a static and/or dynamic binary for MMTk and link it to the language directly, manually building new binaries as necessary.
20
20
1.`cd binding_repo/mmtk`
21
-
2.`cargo build --features nogc` to build in debug mode or add `--release` for release mode
21
+
2.`cargo build` to build in debug mode or add `--release` for release mode
22
22
3. Copy the shared or static library from `target/debug` or `target/release` to your desired location
23
23
- Later, you can edit the language build process to build MMTk at the same time automatically.
24
24
3. Replace VM allocation with calloc
@@ -27,6 +27,8 @@ You may want to take the following steps.
27
27
4. Single Threaded MMTk Allocation
28
28
1. Create a `mmtk.h` header file which exposes the functions required to implement NoGC (`gc_init`, `alloc`, `bind_mutator`), and `include` it. You can use the [DummyVM `mmtk.h` header file](https://github.com/mmtk/mmtk-core/blob/master/vmbindings/dummyvm/api/mmtk.h) as an example.
29
29
2. Initialise MMTk by calling `gc_init`, with the size of the heap. In the future, you may wish to make this value configurable via a command line argument or environment variable.
30
+
2. You can set [options for MMTk](https://www.mmtk.io/mmtk-core/mmtk/util/options/struct.Options.html) by using `process` to pass options, or simply by setting environtment variables. For example, to
31
+
use the NoGC plan, you can set the env var `MMTK_PLAN=NoGC`.
30
32
3. Create a MMTk mutator instance using `bind_mutator` and pass the return value of `gc_init`.
31
33
4. Replace all previous `calloc` calls with `alloc` and optionally add a mutex around `alloc` if the VM is multi-threaded. The MMTk handle is the return value of the `bind_mutator` call.
32
34
- In order to perform allocations, you will need to know what object alignment the VM expects. VMs often align allocations at word boundaries (e.g. 4 or 8 bytes) as it allows the CPU to access the data faster at runtime. Additionally, the language may use the unused lowest order bits to store flags (e.g. type information), so it is important that MMTk respects these expectations.
0 commit comments