mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-26 21:39:07 +00:00
Use Layout::NAKED_RECURSIVE_PTR and update comments
This commit is contained in:
parent
8edbd3b378
commit
efd7d71dc4
1 changed files with 12 additions and 8 deletions
|
@ -2252,8 +2252,11 @@ impl<'a, 'b> Env<'a, 'b> {
|
||||||
) -> Cacheable<LayoutResult<'a>> {
|
) -> Cacheable<LayoutResult<'a>> {
|
||||||
if self.is_seen(var) {
|
if self.is_seen(var) {
|
||||||
// Always return recursion pointers directly, NEVER cache them as naked!
|
// Always return recursion pointers directly, NEVER cache them as naked!
|
||||||
// TODO(recursive-layouts): after we have disjoint recursive pointers, change this
|
// When this recursion pointer gets used in a recursive union, it will be filled to
|
||||||
let rec_ptr = self.cache.put_in(Layout::RecursivePointer(Layout::VOID));
|
// looop back to the correct layout.
|
||||||
|
// TODO(recursive-layouts): after the naked pointer is updated, we can cache `var` to
|
||||||
|
// point to the updated layout.
|
||||||
|
let rec_ptr = Layout::NAKED_RECURSIVE_PTR;
|
||||||
return Cacheable(Ok(rec_ptr), NAKED_RECURSION_PTR);
|
return Cacheable(Ok(rec_ptr), NAKED_RECURSION_PTR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3105,8 +3108,9 @@ fn layout_from_flat_type<'a>(
|
||||||
}
|
}
|
||||||
Func(args, closure_var, ret_var) => {
|
Func(args, closure_var, ret_var) => {
|
||||||
if env.is_seen(closure_var) {
|
if env.is_seen(closure_var) {
|
||||||
// TODO(recursive-layouts): change after disjoint recursive layouts supported
|
// TODO(recursive-layouts): after the naked pointer is updated, we can cache `var` to
|
||||||
let rec_ptr = env.cache.put_in(Layout::RecursivePointer(Layout::VOID));
|
// point to the updated layout.
|
||||||
|
let rec_ptr = Layout::NAKED_RECURSIVE_PTR;
|
||||||
Cacheable(Ok(rec_ptr), NAKED_RECURSION_PTR)
|
Cacheable(Ok(rec_ptr), NAKED_RECURSION_PTR)
|
||||||
} else {
|
} else {
|
||||||
let mut criteria = CACHEABLE;
|
let mut criteria = CACHEABLE;
|
||||||
|
@ -3792,8 +3796,7 @@ where
|
||||||
&& is_recursive_tag_union(&layout);
|
&& is_recursive_tag_union(&layout);
|
||||||
|
|
||||||
let arg_layout = if self_recursion {
|
let arg_layout = if self_recursion {
|
||||||
// TODO(recursive-layouts): fix after disjoint recursive pointers supported
|
Layout::NAKED_RECURSIVE_PTR
|
||||||
env.cache.put_in(Layout::RecursivePointer(Layout::VOID))
|
|
||||||
} else {
|
} else {
|
||||||
in_layout
|
in_layout
|
||||||
};
|
};
|
||||||
|
@ -4058,8 +4061,9 @@ where
|
||||||
for &var in variables {
|
for &var in variables {
|
||||||
// TODO does this cause problems with mutually recursive unions?
|
// TODO does this cause problems with mutually recursive unions?
|
||||||
if rec_var == subs.get_root_key_without_compacting(var) {
|
if rec_var == subs.get_root_key_without_compacting(var) {
|
||||||
// TODO(recursive-layouts): fix after disjoint recursive pointers supported
|
// The naked pointer will get fixed-up to loopback to the union below when we
|
||||||
tag_layout.push(env.cache.put_in(Layout::RecursivePointer(Layout::VOID)));
|
// intern the union.
|
||||||
|
tag_layout.push(Layout::NAKED_RECURSIVE_PTR);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue