Skip to content

Commit

Permalink
Garbage collection part 3
Browse files Browse the repository at this point in the history
Dispatched mode now works
  • Loading branch information
ecton committed Mar 26, 2024
1 parent 0b0f01c commit 9adc001
Show file tree
Hide file tree
Showing 5 changed files with 396 additions and 304 deletions.
3 changes: 3 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,6 @@ harness = false
debug = true
lto = true

[patch."https://github.com/khonsulabs/refuse"]
refuse = { path = "../refuse" }
refuse-pool = { path = "../refuse/refuse-pool" }
# [patch."https://github.com/khonsulabs/refuse"]
# refuse = { path = "../refuse" }
# refuse-pool = { path = "../refuse/refuse-pool" }
20 changes: 12 additions & 8 deletions src/vm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ use crate::string::MuseString;
use crate::symbol::{IntoOptionSymbol, Symbol, SymbolRef};
use crate::syntax::token::RegexLiteral;
use crate::syntax::{BitwiseKind, CompareKind, SourceRange};
use crate::value::{
AnyDynamic, ContextOrGuard, CustomType, Dynamic, RustType, StaticRustFunctionTable, Value,
};
#[cfg(not(feature = "dispatched"))]
use crate::value::ContextOrGuard;
use crate::value::{AnyDynamic, CustomType, Dynamic, RustType, StaticRustFunctionTable, Value};

pub mod bitcode;

Expand Down Expand Up @@ -1849,7 +1849,7 @@ impl CodeData {
#[allow(clippy::too_many_lines)]
pub fn push(&mut self, op: &Op, range: SourceRange, guard: &CollectionGuard) {
match op {
Op::Return => self.push_loaded(LoadedOp::Return, range),
Op::Return => self.push_loaded(LoadedOp::Return, range, guard),
Op::Label(label) => {
if self.labels.len() <= label.0 {
self.labels.resize(label.0 + 1, usize::MAX);
Expand All @@ -1873,6 +1873,7 @@ impl CodeData {
dest,
},
range,
guard,
);
}
Op::Unary {
Expand All @@ -1896,6 +1897,7 @@ impl CodeData {
UnaryKind::SetExceptionHandler => LoadedOp::SetExceptionHandler(unary),
},
range,
guard,
);
}
Op::BinOp {
Expand Down Expand Up @@ -1939,12 +1941,13 @@ impl CodeData {
},
},
range,
guard,
);
}
Op::Call { name, arity } => {
let name = self.load_source(name, guard);
let arity = self.load_source(arity, guard);
self.push_loaded(LoadedOp::Call { name, arity }, range);
self.push_loaded(LoadedOp::Call { name, arity }, range, guard);
}
Op::Invoke {
target,
Expand All @@ -1961,19 +1964,20 @@ impl CodeData {
arity,
},
range,
guard,
);
}
Op::LoadModule { module, dest } => {
let module = self.push_module(module);
let dest = self.load_dest(dest);
self.push_loaded(LoadedOp::LoadModule { module, dest }, range);
self.push_loaded(LoadedOp::LoadModule { module, dest }, range, guard);
}
Op::Throw(kind) => self.push_loaded(LoadedOp::Throw(*kind), range),
Op::Throw(kind) => self.push_loaded(LoadedOp::Throw(*kind), range, guard),
}
}

#[cfg(not(feature = "dispatched"))]
fn push_loaded(&mut self, loaded: LoadedOp, range: SourceRange) {
fn push_loaded(&mut self, loaded: LoadedOp, range: SourceRange, _guard: &CollectionGuard<'_>) {
self.instructions.push(loaded);
self.map.push(range);
}
Expand Down
Loading

0 comments on commit 9adc001

Please sign in to comment.