mirror of
https://github.com/roc-lang/roc.git
synced 2025-10-03 00:24:34 +00:00
Revert "Try out converting subs to use soa stuff directly"
This reverts commit 4a7d7e42d6
.
This commit is contained in:
parent
4a7d7e42d6
commit
586959780b
31 changed files with 731 additions and 539 deletions
|
@ -668,7 +668,7 @@ trait DerivableVisitor {
|
|||
|
||||
macro_rules! push_var_slice {
|
||||
($slice:expr) => {
|
||||
stack.extend(subs.get_slice($slice))
|
||||
stack.extend(subs.get_subs_slice($slice))
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -702,7 +702,7 @@ trait DerivableVisitor {
|
|||
subs.set_content(var, Content::FlexAbleVar(opt_name, merged_abilites));
|
||||
}
|
||||
RigidAbleVar(_, abilities) => {
|
||||
if !subs.get_slice(abilities).contains(&Self::ABILITY) {
|
||||
if !subs.get_subs_slice(abilities).contains(&Self::ABILITY) {
|
||||
return Err(NotDerivable {
|
||||
var,
|
||||
context: NotDerivableContext::NoContext,
|
||||
|
|
|
@ -194,7 +194,7 @@ fn deep_copy_var_help(
|
|||
|
||||
// When copying a let-generalized record to a specialized region, rigid
|
||||
// optionals just become optionals.
|
||||
let field_types = subs.get_slice(fields.record_fields());
|
||||
let field_types = subs.get_subs_slice(fields.record_fields());
|
||||
let has_rigid_optional_field = field_types
|
||||
.iter()
|
||||
.any(|f| matches!(f, RecordField::RigidOptional(..)));
|
||||
|
|
|
@ -1550,17 +1550,17 @@ fn open_tag_union(env: &mut InferenceEnv, var: Variable) {
|
|||
|
||||
Structure(Record(fields, _)) => {
|
||||
// Open up all nested tag unions.
|
||||
stack.extend(env.subs.get_slice(fields.variables()));
|
||||
stack.extend(env.subs.get_subs_slice(fields.variables()));
|
||||
}
|
||||
|
||||
Structure(Tuple(elems, _)) => {
|
||||
// Open up all nested tag unions.
|
||||
stack.extend(env.subs.get_slice(elems.variables()));
|
||||
stack.extend(env.subs.get_subs_slice(elems.variables()));
|
||||
}
|
||||
|
||||
Structure(Apply(Symbol::LIST_LIST, args)) => {
|
||||
// Open up nested tag unions.
|
||||
stack.extend(env.subs.get_slice(args));
|
||||
stack.extend(env.subs.get_subs_slice(args));
|
||||
}
|
||||
|
||||
_ => {
|
||||
|
@ -1627,12 +1627,12 @@ fn close_pattern_matched_tag_unions(subs: &mut Subs, var: Variable) {
|
|||
|
||||
Structure(Record(fields, _)) => {
|
||||
// Close up all nested tag unions.
|
||||
stack.extend(subs.get_slice(fields.variables()));
|
||||
stack.extend(subs.get_subs_slice(fields.variables()));
|
||||
}
|
||||
|
||||
Structure(Apply(Symbol::LIST_LIST, args)) => {
|
||||
// Close up nested tag unions.
|
||||
stack.extend(subs.get_slice(args));
|
||||
stack.extend(subs.get_subs_slice(args));
|
||||
}
|
||||
|
||||
Alias(_, _, real_var, _) => {
|
||||
|
|
|
@ -19,7 +19,6 @@ use roc_types::{
|
|||
types::{AliasKind, MemberImpl, Polarity, Uls},
|
||||
};
|
||||
use roc_unify::unify::{unify, MustImplementConstraints};
|
||||
use soa::GetSlice;
|
||||
|
||||
use crate::{
|
||||
ability::builtin_module_with_unlisted_ability_impl,
|
||||
|
@ -341,7 +340,7 @@ pub fn compact_lambda_sets_of_vars<P: Phase>(
|
|||
ambient_function,
|
||||
} = env.subs.get_lambda_set(lambda_set);
|
||||
let lambda_set_rank = env.subs.get_rank(lambda_set);
|
||||
let unspecialized = env.subs.get_slice(unspecialized);
|
||||
let unspecialized = env.subs.get_subs_slice(unspecialized);
|
||||
// TODO: is it faster to traverse once, see if we only have one concrete lambda, and
|
||||
// bail in that happy-path, rather than always splitting?
|
||||
let (concrete, mut not_concrete): (Vec<_>, Vec<_>) = unspecialized
|
||||
|
@ -405,10 +404,10 @@ pub fn compact_lambda_sets_of_vars<P: Phase>(
|
|||
uls_a.sort_by(|v1, v2| {
|
||||
let unspec_1 = env
|
||||
.subs
|
||||
.get_slice(env.subs.get_lambda_set(*v1).unspecialized);
|
||||
.get_subs_slice(env.subs.get_lambda_set(*v1).unspecialized);
|
||||
let unspec_2 = env
|
||||
.subs
|
||||
.get_slice(env.subs.get_lambda_set(*v2).unspecialized);
|
||||
.get_subs_slice(env.subs.get_lambda_set(*v2).unspecialized);
|
||||
|
||||
let Uls(_, f1, r1) = unique_unspecialized_lambda(env.subs, c_a, unspec_1).unwrap();
|
||||
let Uls(_, f2, r2) = unique_unspecialized_lambda(env.subs, c_a, unspec_2).unwrap();
|
||||
|
@ -487,7 +486,7 @@ fn compact_lambda_set<P: Phase>(
|
|||
|
||||
debug_assert!(!unspecialized.is_empty());
|
||||
|
||||
let unspecialized = env.subs.get_slice(unspecialized);
|
||||
let unspecialized = env.subs.get_subs_slice(unspecialized);
|
||||
|
||||
// 1. Let `t_f1` be the directly ambient function of the lambda set containing `C:f:r`.
|
||||
let Uls(c, f, r) =
|
||||
|
|
|
@ -11,7 +11,7 @@ use roc_types::{
|
|||
subs::{
|
||||
self, AliasVariables, Content, FlatType, GetSubsSlice, LambdaSet, OptVariable, Rank,
|
||||
RecordFields, Subs, SubsSlice, TagExt, TupleElems, UnionLabels, UnionLambdas, UnionTags,
|
||||
Variable, VariableSlice,
|
||||
Variable, VariableSubsSlice,
|
||||
},
|
||||
types::{
|
||||
gather_fields_unsorted_iter, gather_tuple_elems_unsorted_iter, AliasKind, AliasShared,
|
||||
|
@ -329,7 +329,7 @@ pub(crate) fn type_to_var_help(
|
|||
region: _,
|
||||
} => {
|
||||
let arguments = types.get_type_arguments(typ_index);
|
||||
let new_arguments = VariableSlice::reserve_into_subs(env.subs, arguments.len());
|
||||
let new_arguments = VariableSubsSlice::reserve_into_subs(env.subs, arguments.len());
|
||||
for (target_index, var_index) in
|
||||
(new_arguments.indices()).zip(arguments.into_iter())
|
||||
{
|
||||
|
@ -403,7 +403,7 @@ pub(crate) fn type_to_var_help(
|
|||
// This case is important for the rank of boolean variables
|
||||
Function(closure_type, ret_type) => {
|
||||
let arguments = types.get_type_arguments(typ_index);
|
||||
let new_arguments = VariableSlice::reserve_into_subs(env.subs, arguments.len());
|
||||
let new_arguments = VariableSubsSlice::reserve_into_subs(env.subs, arguments.len());
|
||||
for (target_index, var_index) in
|
||||
(new_arguments.indices()).zip(arguments.into_iter())
|
||||
{
|
||||
|
@ -603,7 +603,8 @@ pub(crate) fn type_to_var_help(
|
|||
let all_vars_length = type_arguments.len()
|
||||
+ lambda_set_variables.len()
|
||||
+ infer_ext_in_output_variables.len();
|
||||
let new_variables = VariableSlice::reserve_into_subs(env.subs, all_vars_length);
|
||||
let new_variables =
|
||||
VariableSubsSlice::reserve_into_subs(env.subs, all_vars_length);
|
||||
|
||||
let type_arguments_offset = 0;
|
||||
let lambda_set_vars_offset = type_arguments_offset + type_arguments.len();
|
||||
|
@ -703,7 +704,8 @@ pub(crate) fn type_to_var_help(
|
|||
let lambda_set_vars_offset = type_arguments_offset + type_arguments.len();
|
||||
let infer_ext_vars_offset = lambda_set_vars_offset + lambda_set_variables.len();
|
||||
|
||||
let new_variables = VariableSlice::reserve_into_subs(env.subs, all_vars_length);
|
||||
let new_variables =
|
||||
VariableSubsSlice::reserve_into_subs(env.subs, all_vars_length);
|
||||
|
||||
for (((target_index, typ), region), abilities) in
|
||||
(new_variables.indices().skip(type_arguments_offset))
|
||||
|
@ -771,7 +773,7 @@ pub(crate) fn type_to_var_help(
|
|||
.set_content(var, Content::RigidAbleVar(a, abilities_slice));
|
||||
}
|
||||
Content::RigidAbleVar(_, abs)
|
||||
if (env.subs.get_slice(abs).iter()).eq(abilities.sorted_iter()) =>
|
||||
if (env.subs.get_subs_slice(abs).iter()).eq(abilities.sorted_iter()) =>
|
||||
{
|
||||
// pass, already bound
|
||||
}
|
||||
|
@ -1019,11 +1021,11 @@ fn register_tag_arguments(
|
|||
types: &mut Types,
|
||||
stack: &mut bumpalo::collections::Vec<'_, TypeToVar>,
|
||||
arguments: Slice<TypeTag>,
|
||||
) -> VariableSlice {
|
||||
) -> VariableSubsSlice {
|
||||
if arguments.is_empty() {
|
||||
VariableSlice::default()
|
||||
VariableSubsSlice::default()
|
||||
} else {
|
||||
let new_variables = VariableSlice::reserve_into_subs(env.subs, arguments.len());
|
||||
let new_variables = VariableSubsSlice::reserve_into_subs(env.subs, arguments.len());
|
||||
let it = new_variables.indices().zip(arguments.into_iter());
|
||||
|
||||
for (target_index, argument) in it {
|
||||
|
@ -1113,7 +1115,7 @@ fn insert_tags_slow_path(
|
|||
arena: &'_ bumpalo::Bump,
|
||||
types: &mut Types,
|
||||
union_tags: UnionTags,
|
||||
mut tag_vars: bumpalo::collections::Vec<(TagName, VariableSlice)>,
|
||||
mut tag_vars: bumpalo::collections::Vec<(TagName, VariableSubsSlice)>,
|
||||
stack: &mut bumpalo::collections::Vec<'_, TypeToVar>,
|
||||
) -> UnionTags {
|
||||
let (tags, payload_slices) = types.union_tag_slices(union_tags);
|
||||
|
@ -1122,7 +1124,7 @@ fn insert_tags_slow_path(
|
|||
{
|
||||
let tag_argument_types = &types[tag_argument_types_index];
|
||||
|
||||
let new_slice = VariableSlice::reserve_into_subs(env.subs, tag_argument_types.len());
|
||||
let new_slice = VariableSubsSlice::reserve_into_subs(env.subs, tag_argument_types.len());
|
||||
|
||||
for (i, arg) in (new_slice.indices()).zip(tag_argument_types.into_iter()) {
|
||||
let var = RegisterVariable::with_stack(env, rank, arena, types, arg, stack);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue