the setup

This commit is contained in:
Folkert 2022-03-17 18:24:22 +01:00
parent dca9404772
commit 8144d7b390
No known key found for this signature in database
GPG Key ID: 1F17F6FFD112B97C
2 changed files with 80 additions and 1 deletions

View File

@ -2039,6 +2039,12 @@ fn finish_specialization(
subs: Subs,
exposed_to_host: ExposedToHost,
) -> Result<MonomorphizedModule, LoadingProblem> {
if true {
println!(
"total Type clones: {} ",
roc_types::types::get_type_clone_count()
);
}
let module_ids = Arc::try_unwrap(state.arc_modules)
.unwrap_or_else(|_| panic!("There were still outstanding Arc references to module_ids"))
.into_inner()

View File

@ -166,7 +166,7 @@ impl LambdaSet {
}
}
#[derive(PartialEq, Eq, Clone)]
#[derive(PartialEq, Eq)]
pub enum Type {
EmptyRec,
EmptyTagUnion,
@ -203,6 +203,79 @@ pub enum Type {
Erroneous(Problem),
}
#[derive(PartialEq, Eq, Clone)]
enum TypeExtension {
Open(Box<Type>),
Closed,
}
static mut TYPE_CLONE_COUNT: std::sync::atomic::AtomicUsize =
std::sync::atomic::AtomicUsize::new(0);
pub fn get_type_clone_count() -> usize {
unsafe { TYPE_CLONE_COUNT.load(std::sync::atomic::Ordering::SeqCst) }
}
impl Clone for Type {
fn clone(&self) -> Self {
match self {
Self::EmptyRec => {
unsafe { TYPE_CLONE_COUNT.fetch_add(1, std::sync::atomic::Ordering::SeqCst) };
Self::EmptyRec
}
Self::EmptyTagUnion => {
unsafe { TYPE_CLONE_COUNT.fetch_add(1, std::sync::atomic::Ordering::SeqCst) };
Self::EmptyTagUnion
}
Self::Function(arg0, arg1, arg2) => {
Self::Function(arg0.clone(), arg1.clone(), arg2.clone())
}
Self::Record(arg0, arg1) => Self::Record(arg0.clone(), arg1.clone()),
Self::TagUnion(arg0, arg1) => Self::TagUnion(arg0.clone(), arg1.clone()),
Self::FunctionOrTagUnion(arg0, arg1, arg2) => {
Self::FunctionOrTagUnion(arg0.clone(), arg1.clone(), arg2.clone())
}
Self::ClosureTag { name, ext } => Self::ClosureTag {
name: name.clone(),
ext: ext.clone(),
},
Self::Alias {
symbol,
type_arguments,
lambda_set_variables,
actual,
kind,
} => Self::Alias {
symbol: symbol.clone(),
type_arguments: type_arguments.clone(),
lambda_set_variables: lambda_set_variables.clone(),
actual: actual.clone(),
kind: kind.clone(),
},
Self::HostExposedAlias {
name,
type_arguments,
lambda_set_variables,
actual_var,
actual,
} => Self::HostExposedAlias {
name: name.clone(),
type_arguments: type_arguments.clone(),
lambda_set_variables: lambda_set_variables.clone(),
actual_var: actual_var.clone(),
actual: actual.clone(),
},
Self::RecursiveTagUnion(arg0, arg1, arg2) => {
Self::RecursiveTagUnion(arg0.clone(), arg1.clone(), arg2.clone())
}
Self::Apply(arg0, arg1, arg2) => Self::Apply(arg0.clone(), arg1.clone(), arg2.clone()),
Self::Variable(arg0) => Self::Variable(arg0.clone()),
Self::RangedNumber(arg0, arg1) => Self::RangedNumber(arg0.clone(), arg1.clone()),
Self::Erroneous(arg0) => Self::Erroneous(arg0.clone()),
}
}
}
impl fmt::Debug for Type {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self {