Skip to content

Commit

Permalink
Fix usage of live in opcodes and no longer preserve registers by default
Browse files Browse the repository at this point in the history
Many opcodes have a live parameter which is the number of registers that should
be preserved by GC operations. Take this into account and conversely stop
preserving registers by default.

This affects significantly the safety of `memory_ensure_free` when writing nifs.
Indeed, arguments (which come from registers) are no longer preserved.
However, no platform-specific nif was found that needed to be fixed. If
required, calls to `memory_ensure_free` or `memory_ensure_free_opt` should be
replaced with calls to `memory_ensure_free_with_roots`.

Signed-off-by: Paul Guyot <[email protected]>
  • Loading branch information
pguyot committed Oct 26, 2023
1 parent 25c09a0 commit b623659
Show file tree
Hide file tree
Showing 9 changed files with 273 additions and 286 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Fixed support for big endian CPUs (such as some MIPS CPUs).
- Fixed STM32 not aborting when `AVM_ABORT()` is used
- Fixed a bug that would leave the STM32 trapped in a loop on hard faults, rather than aborting
- Fixed interpretation of live for opcodes, thus altering GC semantics for nifs. See also [UPDATING](UPDATING.md).

### Added

Expand Down
7 changes: 7 additions & 0 deletions UPDATING.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@

# AtomVM Update Instructions

## v0.6.0-alpha.1 -> v0.6.0-alpha.2

- Registers are no longer preserved by GC by default when invoking nifs, as part of the fix
of interpretation of the emulator of the live parameter of many opcodes. NIFs may need
to call `memory_ensure_free_with_roots` and pass their arguments are roots, instead of
`memory_ensure_free` or `memory_ensure_free_opt`.

## v0.6.0-alpha.0 -> v0.6.0-alpha.1

- **Libraries (or boot .avm file) from latest version must be used**. Standard library from
Expand Down
Loading

0 comments on commit b623659

Please sign in to comment.