-
Notifications
You must be signed in to change notification settings - Fork 98
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This implements the current garbage collector in Rust. No changes were made to the GC design -- it's just ports the one implemented in code generator to Rust. The goals are: - Evaluate Rust for Motoko's RTS implementation - Make the collector easier to read, understand, modify, and extend. Current status: the code is complete in the sense that there aren't any missing features/passes etc., but it's has bugs. I'm not sure how to debug Wasm yet. There are also lots of TODOs in the code, mostly for documentation. Submitting a PR to get early feedback.
- Loading branch information
Showing
16 changed files
with
762 additions
and
160 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
_out | ||
_output | ||
_build | ||
target | ||
|
||
**/*~ | ||
/result* | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"rust-analyzer.cargo.target": "wasm32-unknown-emscripten" | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
[package] | ||
name = "motoko-rts" | ||
version = "0.1.0" | ||
authors = ["Ömer Sinan Ağacan <omeragacan@gmail.com>"] | ||
edition = "2018" | ||
|
||
[dependencies] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
use crate::common::rts_trap_with; | ||
use crate::types::{skew, Array, SkewedPtr}; | ||
|
||
/// Returns address of Nth payload field of an array | ||
#[no_mangle] | ||
pub unsafe extern "C" fn array_field_addr(array: SkewedPtr, idx: u32) -> SkewedPtr { | ||
let array_ptr = array.unskew() as *const Array; | ||
|
||
if idx >= (*array_ptr).len { | ||
rts_trap_with("Array index out of bounds\0".as_ptr()); | ||
} | ||
|
||
let payload_begin = array_ptr.offset(1) as *const u32; | ||
skew(payload_begin.offset(idx as isize) as usize) | ||
} | ||
|
||
/// Index an array. Does not check bounds. | ||
pub unsafe fn array_idx_unchecked(array_ptr: *const Array, idx: u32) -> SkewedPtr { | ||
let payload_begin = array_ptr.offset(1) as *const u32; | ||
SkewedPtr(*payload_begin.offset(idx as isize) as usize) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
extern "C" { | ||
pub fn rts_trap_with(msg: *const u8) -> !; | ||
} |
Oops, something went wrong.