mirror of
https://github.com/roc-lang/roc.git
synced 2024-11-13 09:49:11 +03:00
store the start of the value for each variable in a table
This commit is contained in:
parent
9920184232
commit
631c642950
@ -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)
|
||||
|
@ -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;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user