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 Dec 26, 2023
1 parent 273513f commit 75eb372
Show file tree
Hide file tree
Showing 9 changed files with 276 additions and 286 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [0.6.0-beta.0] - Unreleased

### Fixed

- Fixed interpretation of live for opcodes, thus altering GC semantics for nifs. See also [UPDATING](UPDATING.md).

### Added
- Added `esp:get_default_mac/0` for retrieving the default MAC address on ESP32.
- Added support for `pico` and `poci` as an alternative to `mosi` and `miso` for SPI
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-beta.0

- 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 75eb372

Please sign in to comment.