From 624566c2b0427ea7b72d5aca7b99cd5122df13ab Mon Sep 17 00:00:00 2001 From: Caio Raposo Date: Fri, 23 Sep 2022 16:07:19 -0300 Subject: [PATCH] Add #[unsafe_ignore_trace] to memoization table Using Gc for memo_table was degrading the runtime execution of some algorithms due to the garbage collector tracing the memoization table. Replacing Gc with Rc to prevent a panic caused by the macro. see: https://github.com/Manishearth/rust-gc/issues/52 --- src/runtime/value/function.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/runtime/value/function.rs b/src/runtime/value/function.rs index 3f243bb..3349a4f 100644 --- a/src/runtime/value/function.rs +++ b/src/runtime/value/function.rs @@ -1,8 +1,10 @@ use std::{ + cell::RefCell, cmp::Ordering, collections::HashMap, fmt::{self, Debug}, hash::{Hash, Hasher}, + rc::Rc, }; use gc::{Gc, GcCell, Finalize, Trace}; @@ -75,7 +77,8 @@ pub struct HushFun { // If memoization is active. pub is_memoized: bool, // Memoization table. - pub memo_table: Gc, Value>>>, + #[unsafe_ignore_trace] + pub memo_table: Rc, Value>>>, pub pos: SourcePos, } @@ -96,7 +99,7 @@ impl HushFun { body, context: Gc::new(context), is_memoized, - memo_table: Gc::new(GcCell::new(memo_table)), + memo_table: Rc::new(RefCell::new(memo_table)), pos, } }