Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

upgrade hvmc version #243

Merged
merged 2 commits into from
Mar 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ cli = ["dep:clap"]
chumsky = { version = "= 1.0.0-alpha.4", features = ["label"] }
clap = { version = "4.4.1", features = ["derive"], optional = true }
highlight_error = "0.1.1"
hvm-core = { git = "https://github.com/HigherOrderCO/hvm-core.git", branch = "feature/sc-506/smart-pointer-def-api" }
hvm-core = { git = "https://github.com/HigherOrderCO/hvm-core.git" }
indexmap = "2.2.3"
interner = "0.2.1"
itertools = "0.11.0"
Expand Down
10 changes: 5 additions & 5 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ pub fn compile_book(
let mut core_book = nets_to_hvmc(nets, &mut diagnostics)?;

if opts.pre_reduce {
core_book.pre_reduce(&|x| x == book.hvmc_entrypoint(), 1 << 24, 100_000);
core_book.pre_reduce(&|x| x == book.hvmc_entrypoint(), None, 100_000);
}
if opts.prune {
prune_defs(&mut core_book, book.hvmc_entrypoint().to_string());
Expand Down Expand Up @@ -153,7 +153,7 @@ pub fn desugar_book(

pub fn run_book(
mut book: Book,
max_memory: usize,
max_memory: Option<usize>,
run_opts: RunOpts,
compile_opts: CompileOpts,
diagnostics_cfg: DiagnosticsConfig,
Expand Down Expand Up @@ -209,12 +209,12 @@ pub fn count_nodes<'l>(net: &'l hvmc::ast::Net) -> usize {

pub fn run_compiled(
host: Arc<Mutex<Host>>,
mem_size: usize,
mem_size: Option<usize>,
run_opts: RunOpts,
hook: Option<impl FnMut(&Net)>,
entrypoint: &str,
) -> (Net, RunStats) {
let heap = Heap::new_bytes(mem_size);
let heap = Heap::new(mem_size).expect("memory allocation failed");
let mut root = DynNet::new(&heap, run_opts.lazy_mode);
let max_rwts = run_opts.max_rewrites.map(|x| x.clamp(usize::MIN, usize::MAX));
// Expect won't be reached because there's
Expand Down Expand Up @@ -293,7 +293,7 @@ pub struct RunOpts {
pub debug: bool,
pub linear: bool,
pub lazy_mode: bool,
pub max_memory: usize,
pub max_memory: Option<usize>,
pub max_rewrites: Option<usize>,
}

Expand Down
4 changes: 2 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ enum Mode {
},
/// Compiles the program and runs it with the hvm.
Run {
#[arg(short = 'm', long = "mem", help = "How much memory to allocate for the runtime", default_value = "1G", value_parser = mem_parser)]
max_memory: usize,
#[arg(short = 'm', long = "mem", help = "How much memory to allocate for the runtime", value_parser = mem_parser)]
max_memory: Option<usize>,

#[arg(short = 'r', long = "rwts", help = "Maximum amount of rewrites", value_parser = mem_parser)]
max_rewrites: Option<usize>,
Expand Down
10 changes: 4 additions & 6 deletions tests/golden_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ fn linear_readback() {
let book = do_parse_book(code, path)?;
let (res, info) = run_book(
book,
1 << 20,
None,
RunOpts { linear: true, ..Default::default() },
CompileOpts::heavy(),
diagnostics_cfg,
Expand Down Expand Up @@ -183,7 +183,7 @@ fn run_lazy() {
desugar_opts.lazy_mode();

// 1 million nodes for the test runtime. Smaller doesn't seem to make it any faster
let (res, info) = run_book(book, 1 << 24, run_opts, desugar_opts, diagnostics_cfg, None)?;
let (res, info) = run_book(book, None, run_opts, desugar_opts, diagnostics_cfg, None)?;
Ok(format!("{}{}", info.diagnostics, res))
})
}
Expand Down Expand Up @@ -293,7 +293,7 @@ fn hangs() {
let book = do_parse_book(code, path)?;

let thread = std::thread::spawn(move || {
run_book(book, 1 << 20, RunOpts::default(), CompileOpts::heavy(), diagnostics_cfg, None)
run_book(book, None, RunOpts::default(), CompileOpts::heavy(), diagnostics_cfg, None)
});
std::thread::sleep(std::time::Duration::from_secs(expected_normalization_time));

Expand All @@ -318,9 +318,7 @@ fn run_entrypoint() {
let diagnostics_cfg = DiagnosticsConfig::new(Severity::Error, true);
let mut book = do_parse_book(code, path)?;
book.entrypoint = Some(Name::from("foo"));
// 1 million nodes for the test runtime. Smaller doesn't seem to make it any faster
let (res, info) =
run_book(book, 1 << 24, RunOpts::default(), CompileOpts::heavy(), diagnostics_cfg, None)?;
let (res, info) = run_book(book, None, RunOpts::default(), CompileOpts::heavy(), diagnostics_cfg, None)?;
Ok(format!("{}{}", info.diagnostics, res))
})
}
Expand Down
7 changes: 5 additions & 2 deletions tests/snapshots/cli__compile_all.hvm.snap
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@ source: tests/golden_tests.rs
input_file: tests/golden_tests/cli/compile_all.hvm
---
@Pair = (a (b {2 {2 a {2 b c}} c}))

@Pair.get = (a ({2 @Pair.get$C0 (a b)} b))

@Pair.get$C0 = {2 a {2 b ((a (b c)) c)}}

@main = a
& @Pair.get ~ ((<+ b c> (b c)) (d a))
& @Pair ~ (#40 (#2 d))
& @Pair.get ~ ((<+ b c> (b c)) (d a))
& @Pair ~ (#40 (#2 d))
1 change: 1 addition & 0 deletions tests/snapshots/cli__compile_pre_reduce.hvm.snap
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ In definition 'I':
Definition is unused.

@I = #5

@main = *
4 changes: 2 additions & 2 deletions tests/snapshots/compile_entrypoint__foo.hvm.snap
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ source: tests/golden_tests.rs
input_file: tests/golden_tests/compile_entrypoint/foo.hvm
---
@bar = (a a)
@foo = a
& @bar ~ (#2 a)

@foo = a
& @bar ~ (#2 a)
3 changes: 2 additions & 1 deletion tests/snapshots/compile_file__add_args.hvm.snap
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@ source: tests/golden_tests.rs
input_file: tests/golden_tests/compile_file/add_args.hvm
---
@add = (<+ a b> (a b))

@main = (a (b c))
& @add ~ (a (b c))
& @add ~ (a (b c))
3 changes: 1 addition & 2 deletions tests/snapshots/compile_file__addition_const.hvm.snap
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,4 @@ source: tests/golden_tests.rs
input_file: tests/golden_tests/compile_file/addition_const.hvm
---
@main = a
& #1 ~ <+ #2 a>

& #1 ~ <+ #2 a>
1 change: 1 addition & 0 deletions tests/snapshots/compile_file__crlf.hvm.snap
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ In definition 'a':
Definition is unused.

@a = #1

@main = #2
Loading
Loading