Skip to content

Commit

Permalink
Fix compiler errors
Browse files Browse the repository at this point in the history
  • Loading branch information
JonasWanke committed Jul 23, 2023
1 parent c381007 commit c46127b
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 14 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions compiler/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ clap = { version = "4.1.8", features = ["derive"] }
colored = "2.0.0"
diffy = "0.3.0"
itertools = "0.11.0"
lazy_static = "1.4.0"
notify = "5.1.0"
notify-debouncer-mini = { version = "0.2.1", default-features = false }
regex = "1.9.1"
Expand Down
30 changes: 16 additions & 14 deletions compiler/cli/src/debug.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ use clap::{Parser, ValueHint};
use colored::{Color, Colorize};
use diffy::{create_patch, PatchFormatter};
use itertools::Itertools;
use lazy_static::lazy_static;
use regex::{Captures, Regex, RegexBuilder};
use rustc_hash::FxHashMap;
use std::{
cell::LazyCell,
env, fs, io,
path::{Path, PathBuf},
};
Expand Down Expand Up @@ -340,19 +340,7 @@ impl GoldPath {

// Replace addresses of constants with content hashes since addresses
// are random.
static address_regex: LazyCell<Regex> = LazyCell::new(|| {
const ADDRESS_REGEX: &str = "0x[0-9a-f]{1,16}";
// Addresses of constants in the constant heap.
let constant_heap_regex = format!(r"^({}): ", ADDRESS_REGEX);
// Addresses of constants in pushConstant instructions.
let push_constant_regex = format!(r"^ *\d+: pushConstant ({}) ", ADDRESS_REGEX);

RegexBuilder::new(&format!("{constant_heap_regex}|{push_constant_regex}"))
.multi_line(true)
.build()
.unwrap()
});
let lir = address_regex.replace_all(&rich_ir.text, |captures: &Captures| {
let lir = ADDRESS_REGEX.replace_all(&rich_ir.text, |captures: &Captures| {
let full_match = captures.get(0).unwrap();
let full_match_str = full_match.as_str();
let address = captures.iter().skip(1).find_map(|it| it).unwrap();
Expand Down Expand Up @@ -382,3 +370,17 @@ impl GoldPath {
lines.iter().join("\n")
}
}

lazy_static! {
static ref ADDRESS_REGEX: Regex = {
const ADDRESS: &str = "0x[0-9a-f]{1,16}";
// Addresses of constants in the constant heap.
let constant_heap = format!(r"^({ADDRESS}): ");
// Addresses of constants in pushConstant instructions.
let push_constant = format!(r"^ *\d+: pushConstant ({ADDRESS}) ");
RegexBuilder::new(&format!("{constant_heap}|{push_constant}"))
.multi_line(true)
.build()
.unwrap()
};
}

1 comment on commit c46127b

@jwbot
Copy link
Collaborator

@jwbot jwbot commented on c46127b Jul 23, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Compiler

Benchmark suite Current: c46127b Previous: 97c7f9b Ratio
Time: Compiler/hello_world 16963491 ns/iter (± 544752) 22021853 ns/iter (± 523376) 0.77
Time: Compiler/fibonacci 154197080 ns/iter (± 1069624) 166949210 ns/iter (± 1382723) 0.92
Time: VM Runtime/hello_world 61999 ns/iter (± 3774) 68703 ns/iter (± 41175) 0.90
Time: VM Runtime/fibonacci/15 474066571 ns/iter (± 10444984) 494167458 ns/iter (± 2123797) 0.96
Time: VM Runtime/PLB/binarytrees/6 2140605846 ns/iter (± 25718755) 2258841087 ns/iter (± 17504194) 0.95

This comment was automatically generated by workflow using github-action-benchmark.

Please sign in to comment.