Skip to content

Commit

Permalink
Revert more changes
Browse files Browse the repository at this point in the history
  • Loading branch information
osa1 committed Sep 10, 2021
1 parent e131e61 commit b86b821
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 17 deletions.
2 changes: 1 addition & 1 deletion rts/motoko-rts/src/bigint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ pub unsafe fn mp_realloc<M: Memory>(
) -> *mut libc::c_void {
let bigint = BigInt::from_payload(ptr as *mut mp_digit);

debug_assert_eq!({ (*bigint).header.tag }, TAG_BIGINT);
debug_assert_eq!((*bigint).header.tag, TAG_BIGINT);
debug_assert_eq!(bigint.len(), old_size);

if new_size > bigint.len() {
Expand Down
16 changes: 8 additions & 8 deletions rts/motoko-rts/src/debug.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,8 @@ pub(crate) unsafe fn print_boxed_object(buf: &mut WriteBuf, p: usize) {
let _ = write!(
buf,
"<Object size={:#x} hash_ptr={:#x} field=[",
{ (*object).size },
{ (*object).hash_ptr },
(*object).size,
(*object).hash_ptr
);
for i in 0..object.size() {
let val = object.get(i);
Expand All @@ -161,7 +161,7 @@ pub(crate) unsafe fn print_boxed_object(buf: &mut WriteBuf, p: usize) {
}
TAG_ARRAY => {
let array = obj as *mut Array;
let _ = write!(buf, "<Array len={:#x}", { (*array).len });
let _ = write!(buf, "<Array len={:#x}", (*array).len);

for i in 0..::core::cmp::min(10, (*array).len) {
let _ = write!(buf, " {:#x}", array.get(i).get_raw());
Expand All @@ -175,15 +175,15 @@ pub(crate) unsafe fn print_boxed_object(buf: &mut WriteBuf, p: usize) {
}
TAG_BITS64 => {
let bits64 = obj as *const Bits64;
let _ = write!(buf, "<Bits64 {:#x}>", { (*bits64).bits() });
let _ = write!(buf, "<Bits64 {:#x}>", (*bits64).bits());
}
TAG_MUTBOX => {
let mutbox = obj as *const MutBox;
let _ = write!(buf, "<MutBox field={:#x}>", (*mutbox).field.get_raw());
}
TAG_CLOSURE => {
let closure = obj as *const Closure;
let _ = write!(buf, "<Closure size={:#x}>", { (*closure).size });
let _ = write!(buf, "<Closure size={:#x}>", (*closure).size);
}
TAG_SOME => {
let some = obj as *const Some;
Expand All @@ -194,7 +194,7 @@ pub(crate) unsafe fn print_boxed_object(buf: &mut WriteBuf, p: usize) {
let _ = write!(
buf,
"<Variant tag={:#x} field={:#x}>",
{ (*variant).tag },
(*variant).tag,
(*variant).field.get_raw()
);
}
Expand All @@ -208,7 +208,7 @@ pub(crate) unsafe fn print_boxed_object(buf: &mut WriteBuf, p: usize) {
}
TAG_BITS32 => {
let bits32 = obj as *const Bits32;
let _ = write!(buf, "<Bits32 {:#x}>", { (*bits32).bits });
let _ = write!(buf, "<Bits32 {:#x}>", (*bits32).bits);
}
TAG_BIGINT => {
// Add more details here as needed
Expand All @@ -221,7 +221,7 @@ pub(crate) unsafe fn print_boxed_object(buf: &mut WriteBuf, p: usize) {
"<Concat n_bytes={:#x} obj1={:#x} obj2={:#x}>",
(*concat).n_bytes.0,
(*concat).text1.get_raw(),
(*concat).text2.get_raw(),
(*concat).text2.get_raw()
);
}
TAG_ONE_WORD_FILLER => {
Expand Down
4 changes: 1 addition & 3 deletions rts/motoko-rts/src/gc/mark_compact.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ use crate::visitor::{pointer_to_dynamic_heap, visit_pointer_fields};

use motoko_rts_macros::ic_mem_fn;

use core::ptr::addr_of_mut;

#[ic_mem_fn(ic_only)]
unsafe fn schedule_compacting_gc<M: Memory>(mem: &mut M) {
if super::should_do_gc() {
Expand Down Expand Up @@ -163,7 +161,7 @@ unsafe fn mark_fields<M: Memory>(mem: &mut M, obj: *mut Obj, obj_tag: Tag, heap_

/// Specialized version of `mark_fields` for root `MutBox`es.
unsafe fn mark_root_mutbox_fields<M: Memory>(mem: &mut M, mutbox: *mut MutBox, heap_base: u32) {
let field_addr = addr_of_mut!((*mutbox).field);
let field_addr = &mut (*mutbox).field;
// TODO: Not sure if this check is necessary?
if pointer_to_dynamic_heap(field_addr, heap_base as usize) {
// TODO: We should be able to omit the "already marked" check here as no two root MutBox
Expand Down
9 changes: 4 additions & 5 deletions rts/motoko-rts/src/types.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
use crate::constants::WORD_SIZE;
use crate::rts_trap_with;
use crate::tommath_bindings::{mp_digit, mp_int};

use core::ops::{Add, AddAssign, Div, Mul, Sub, SubAssign};
use core::ptr::addr_of;

use crate::constants::WORD_SIZE;
use crate::rts_trap_with;

pub fn size_of<T>() -> Words<u32> {
Bytes(::core::mem::size_of::<T>() as u32).to_words()
Expand Down Expand Up @@ -492,7 +491,7 @@ impl BigInt {
/// output parameters of mp_add() this way.
pub unsafe fn mp_int_ptr(self: *mut BigInt) -> *const mp_int {
(*self).mp_int.dp = self.payload_addr();
addr_of!((*self).mp_int)
&(*self).mp_int
}
}

Expand Down

0 comments on commit b86b821

Please sign in to comment.