Skip to content

Commit e209374

Browse files
authored
Merge branch 'master' into joachim/branch-protection
2 parents 1fc4621 + 00f045f commit e209374

24 files changed

Lines changed: 362 additions & 251 deletions

perf-delta.nix

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,10 @@ in
6363
nixpkgs.runCommandNoCC "perf-delta" {
6464
nativeBuildInputs = [ nixpkgs.coreutils diff-stats ];
6565
} ''
66-
cat > $out
66+
echo "Comparing from ${from} to ${to}:" > $out
6767
if cmp -s ${wasm-hash-base} ${wasm-hash-pr}
6868
then
69-
echo "This PR does not affect the produced WebAssembly code." >> $out
69+
echo "The produced WebAssembly code seems to be completely unchanged." >> $out
7070
else
7171
diff-stats ${baseJobs.tests.perf}/stats.csv ${prJobs.tests.perf}/stats.csv >> $out;
7272
fi

rts/motoko-rts-tests/src/bigint.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use crate::memory::TestMemory;
22

33
use motoko_rts::bigint::{self, *};
44
use motoko_rts::buf::Buf;
5-
use motoko_rts::types::{Bytes, SkewedPtr, Words};
5+
use motoko_rts::types::{Bytes, Value, Words};
66

77
// mp functions below are implemented separately for tests as we can't modify mp_int source code to
88
// pass a generic heap argument (then monomorphise it for IC).
@@ -67,7 +67,7 @@ pub unsafe fn test() {
6767
}
6868

6969
// Check leb128 encode/decode roundtrip
70-
unsafe fn test_bigint_leb128(n: SkewedPtr) {
70+
unsafe fn test_bigint_leb128(n: Value) {
7171
let mut buf = [0u8; 100];
7272
let s = bigint_leb128_size(n);
7373
let mut buf_ = Buf {
@@ -81,7 +81,7 @@ unsafe fn test_bigint_leb128(n: SkewedPtr) {
8181
}
8282

8383
// Check sleb128 encode/decode roundtrip
84-
unsafe fn test_bigint_sleb128(n: SkewedPtr) {
84+
unsafe fn test_bigint_sleb128(n: Value) {
8585
let mut buf = [0u8; 100];
8686
let s = bigint_sleb128_size(n);
8787
bigint_sleb128_encode(n, buf.as_mut_ptr());

rts/motoko-rts-tests/src/continuation_table.rs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use crate::memory::TestMemory;
33
use motoko_rts::continuation_table::{
44
continuation_count, recall_continuation, remember_continuation,
55
};
6-
use motoko_rts::types::{SkewedPtr, Words};
6+
use motoko_rts::types::{Value, Words};
77

88
pub unsafe fn test() {
99
println!("Testing continuation table ...");
@@ -18,25 +18,31 @@ pub unsafe fn test() {
1818

1919
let mut references: [u32; N] = [0; N];
2020
for i in 0..N {
21-
references[i] = remember_continuation(&mut heap, SkewedPtr((i << 2).wrapping_sub(1)));
21+
references[i] = remember_continuation(
22+
&mut heap,
23+
Value::from_raw(((i as u32) << 2).wrapping_sub(1)),
24+
);
2225
assert_eq!(continuation_count(), (i + 1) as u32);
2326
}
2427

2528
for i in 0..N / 2 {
2629
let c = recall_continuation(references[i]);
27-
assert_eq!(c.0, (i << 2).wrapping_sub(1));
30+
assert_eq!(c.get_raw(), (i << 2).wrapping_sub(1) as u32);
2831
assert_eq!(continuation_count(), (N - i - 1) as u32);
2932
}
3033

3134
for i in 0..N / 2 {
32-
references[i] = remember_continuation(&mut heap, SkewedPtr((i << 2).wrapping_sub(1)));
35+
references[i] = remember_continuation(
36+
&mut heap,
37+
Value::from_raw(((i as u32) << 2).wrapping_sub(1)),
38+
);
3339
assert_eq!(continuation_count(), (N / 2 + i + 1) as u32);
3440
}
3541

3642
for i in (0..N).rev() {
3743
assert_eq!(
38-
recall_continuation(references[i]).0,
39-
(i << 2).wrapping_sub(1)
44+
recall_continuation(references[i]).get_raw(),
45+
(i << 2).wrapping_sub(1) as u32,
4046
);
4147
assert_eq!(continuation_count(), i as u32);
4248
}

rts/motoko-rts-tests/src/gc.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -316,9 +316,8 @@ fn check_continuation_table(mut offset: usize, continuation_table: &[ObjectIdx],
316316
impl GC {
317317
fn run(&self, mut heap: MotokoHeap) {
318318
let heap_base = heap.heap_base_address() as u32;
319-
let static_roots = skew(heap.static_root_array_address());
320-
let continuation_table_ptr_address =
321-
heap.continuation_table_ptr_address() as *mut SkewedPtr;
319+
let static_roots = Value::from_ptr(heap.static_root_array_address());
320+
let continuation_table_ptr_address = heap.continuation_table_ptr_address() as *mut Value;
322321

323322
let heap_1 = heap.clone();
324323
let heap_2 = heap.clone();

rts/motoko-rts-tests/src/gc/heap.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ pub struct MotokoHeap {
2020
}
2121

2222
impl Memory for MotokoHeap {
23-
unsafe fn alloc_words(&mut self, n: Words<u32>) -> SkewedPtr {
23+
unsafe fn alloc_words(&mut self, n: Words<u32>) -> Value {
2424
self.inner.borrow_mut().alloc_words(n)
2525
}
2626
}
@@ -216,7 +216,7 @@ impl MotokoHeapInner {
216216
}
217217
}
218218

219-
unsafe fn alloc_words(&mut self, n: Words<u32>) -> SkewedPtr {
219+
unsafe fn alloc_words(&mut self, n: Words<u32>) -> Value {
220220
let bytes = n.to_bytes();
221221

222222
// Update heap pointer
@@ -227,7 +227,7 @@ impl MotokoHeapInner {
227227
// Grow memory if needed
228228
self.grow_memory(new_hp as usize);
229229

230-
skew(old_hp)
230+
Value::from_ptr(old_hp)
231231
}
232232

233233
unsafe fn grow_memory(&mut self, ptr: usize) {

rts/motoko-rts-tests/src/memory.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use motoko_rts::memory::Memory;
2-
use motoko_rts::types::{skew, SkewedPtr, Words};
2+
use motoko_rts::types::{Value, Words};
33

44
pub struct TestMemory {
55
heap: Box<[u8]>,
@@ -27,7 +27,7 @@ impl TestMemory {
2727
}
2828

2929
impl Memory for TestMemory {
30-
unsafe fn alloc_words(&mut self, n: Words<u32>) -> SkewedPtr {
30+
unsafe fn alloc_words(&mut self, n: Words<u32>) -> Value {
3131
let bytes = n.to_bytes();
3232

3333
// Update heap pointer
@@ -38,6 +38,6 @@ impl Memory for TestMemory {
3838
// Grow memory if needed
3939
self.grow_memory(new_hp as usize);
4040

41-
skew(old_hp)
41+
Value::from_ptr(old_hp)
4242
}
4343
}

rts/motoko-rts-tests/src/text.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use motoko_rts::text::{
88
text_singleton, text_size,
99
};
1010
use motoko_rts::text_iter::{text_iter, text_iter_done, text_iter_next};
11-
use motoko_rts::types::{Bytes, SkewedPtr, Words, TAG_BLOB};
11+
use motoko_rts::types::{Bytes, Value, Words, TAG_BLOB};
1212

1313
use std::convert::TryFrom;
1414

@@ -17,12 +17,12 @@ use proptest::test_runner::{Config, TestCaseError, TestCaseResult, TestRunner};
1717
static STR: &str = "abcdefgh";
1818

1919
struct TextIter<'a, M: Memory> {
20-
obj: SkewedPtr,
20+
obj: Value,
2121
mem: &'a mut M,
2222
}
2323

2424
impl<'a, M: Memory> TextIter<'a, M> {
25-
fn from_text(mem: &'a mut M, text: SkewedPtr) -> Self {
25+
fn from_text(mem: &'a mut M, text: Value) -> Self {
2626
TextIter {
2727
obj: unsafe { text_iter(mem, text) },
2828
mem,

0 commit comments

Comments
 (0)