store the start of the value for each variable in a table

This commit is contained in:
Folkert 2022-07-27 21:32:49 +02:00
parent 9920184232
commit 631c642950
No known key found for this signature in database
GPG Key ID: 1F17F6FFD112B97C
2 changed files with 36 additions and 2 deletions

View File

@ -110,7 +110,21 @@ pub(crate) fn clone_to_shared_memory<'a, 'ctx, 'env>(
offset = write_header(env, original_ptr, offset, condition, region);
let after_header = offset;
let space_for_offsets = env
.ptr_int()
.const_int((lookups.len() * env.target_info.ptr_size()) as _, false);
let mut lookup_starts = bumpalo::collections::Vec::with_capacity_in(lookups.len(), env.arena);
offset = env
.builder
.build_int_add(offset, space_for_offsets, "offset");
for lookup in lookups.iter() {
lookup_starts.push(offset);
let (value, layout) = load_symbol_and_layout(scope, lookup);
offset = build_clone(
@ -124,6 +138,20 @@ pub(crate) fn clone_to_shared_memory<'a, 'ctx, 'env>(
);
}
{
let mut offset = after_header;
for lookup_start in lookup_starts {
build_copy(env, original_ptr, offset, lookup_start.into());
let ptr_width = env
.ptr_int()
.const_int(env.target_info.ptr_size() as _, false);
offset = env.builder.build_int_add(offset, ptr_width, "offset")
}
}
let one = env.ptr_int().const_int(1, false);
let new_count = env.builder.build_int_add(count, one, "inc");
write_state(env, original_ptr, new_count, offset)

View File

@ -6,7 +6,10 @@ use roc_mono::{
layout::{CapturesNiche, LayoutCache},
};
use roc_parse::ast::Expr;
use roc_repl_eval::eval::{jit_to_ast, ToAstProblem};
use roc_repl_eval::{
eval::{jit_to_ast, ToAstProblem},
ReplAppMemory,
};
use roc_target::TargetInfo;
use roc_types::subs::{Subs, Variable};
@ -39,7 +42,10 @@ pub fn get_values<'a>(
let app = arena.alloc(app);
for variable in variables {
for (i, variable) in variables.iter().enumerate() {
let start = app.memory.deref_usize(start_offset + i * 8);
app.offset = start;
let expr = {
let variable = *variable;