mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-28 06:14:46 +00:00
Add LayoutInterner to LayoutCache
Adds a thread-local interner of layouts to LayoutCache, and updates all references appropriately. This is a bit suboptimal for single-threaded workloads that will look at creating layout caches again, like the REPL, but I think that's okay for now - since the global interner will be uncontested for those workloads, it should still be plenty fast to access the interner, even behind a lock.
This commit is contained in:
parent
9d170be5c7
commit
c5466810a4
19 changed files with 177 additions and 86 deletions
|
@ -1,9 +1,10 @@
|
|||
#[cfg(not(windows))]
|
||||
use {
|
||||
roc_intern::GlobalInterner,
|
||||
roc_module::symbol::Interns,
|
||||
roc_mono::{
|
||||
ir::ProcLayout,
|
||||
layout::{CapturesNiche, LayoutCache},
|
||||
layout::{CapturesNiche, Layout, LayoutCache},
|
||||
},
|
||||
roc_parse::ast::Expr,
|
||||
roc_repl_eval::{
|
||||
|
@ -12,6 +13,7 @@ use {
|
|||
},
|
||||
roc_target::TargetInfo,
|
||||
roc_types::subs::{Subs, Variable},
|
||||
std::sync::Arc,
|
||||
};
|
||||
|
||||
#[cfg(not(windows))]
|
||||
|
@ -29,6 +31,7 @@ pub fn get_values<'a>(
|
|||
arena: &'a bumpalo::Bump,
|
||||
subs: &Subs,
|
||||
interns: &'a Interns,
|
||||
layout_interner: &Arc<GlobalInterner<'a, Layout<'a>>>,
|
||||
start: *const u8,
|
||||
start_offset: usize,
|
||||
variables: &[Variable],
|
||||
|
@ -53,7 +56,8 @@ pub fn get_values<'a>(
|
|||
|
||||
let content = subs.get_content_without_compacting(variable);
|
||||
|
||||
let mut layout_cache = LayoutCache::new(target_info);
|
||||
// TODO: pass layout_cache to jit_to_ast directly
|
||||
let mut layout_cache = LayoutCache::new(layout_interner.fork(), target_info);
|
||||
let layout = layout_cache.from_var(arena, variable, subs).unwrap();
|
||||
|
||||
let proc_layout = ProcLayout {
|
||||
|
@ -70,6 +74,7 @@ pub fn get_values<'a>(
|
|||
content,
|
||||
subs,
|
||||
interns,
|
||||
layout_interner.fork(),
|
||||
target_info,
|
||||
)?
|
||||
};
|
||||
|
@ -132,7 +137,7 @@ mod test {
|
|||
|
||||
let interns = loaded.interns.clone();
|
||||
|
||||
let (lib, expects) = expect_mono_module_to_dylib(
|
||||
let (lib, expects, layout_interner) = expect_mono_module_to_dylib(
|
||||
arena,
|
||||
target.clone(),
|
||||
loaded,
|
||||
|
@ -160,6 +165,7 @@ mod test {
|
|||
RenderTarget::ColorTerminal,
|
||||
arena,
|
||||
interns,
|
||||
&layout_interner.into_global(),
|
||||
&lib,
|
||||
&mut expectations,
|
||||
expects,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue