Skip to content

Conversation

@TomerStarkware
Copy link
Collaborator

@TomerStarkware TomerStarkware commented Jan 28, 2026

Title

Closes #NA

Introduces Breaking Changes?

No

These PRs should be merged after this one right away, in that order.

Checklist

  • Linked to Github Issue.
  • Unit tests added.
  • Integration tests added.
  • This change requires new documentation.
    • Documentation has been added/updated.

This change is Reviewable

@gabrielbosio
Copy link
Collaborator

@TomerStarkware there are some merge conflicts, could you please solve them? Thanks!

@TomerStarkware TomerStarkware force-pushed the tomer/move_array_metadata branch from eac395d to e0f8e0b Compare January 28, 2026 15:42
Copy link
Collaborator Author

@TomerStarkware TomerStarkware left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@TomerStarkware made 1 comment.
Reviewable status: 0 of 5 files reviewed, all discussions resolved (waiting on @azteca1998, @edg-l, @entropidelic, @gabrielbosio, @igaray, @jrchatruc, @Oppen, and @pefontana).

@gabrielbosio
Copy link
Collaborator

@TomerStarkware There are some failing CI jobs you have to fix

Copy link
Contributor

@JulianGCalderon JulianGCalderon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @TomerStarkware! I left some comments.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please update this file's top-level documentation with the updated layout.

Comment on lines +291 to 298
// Load max_len from metadata at offset 4 (after refcount)
let max_len_ptr = block.gep(
context,
location,
array_ptr,
&[GepIndex::Const(
-((refcount_offset - size_of::<u32>()) as i32),
)],
metadata_ptr,
&[GepIndex::Const(size_of::<u32>() as i32)],
IntegerType::new(context, 8).into(),
)?;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of calculating max_len_ptr manually, we can let LLVM do that by declaring a type !llvm.struct<i32, i32, i32, !llvm.ptr> and specifying the field index. Note that gep assumes that the type is an array, so you should specify (0, 1) as the index.

&[GepIndex::Const(-(refcount_offset as i32))],
IntegerType::new(context, 8).into(),
)?;
// Metadata struct: { refcount: u32, max_len: u32, capacity: u32, data_ptr: *mut u8 }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment includes capacity as a field, but the ArrayMetadata struct does not. What is the difference between max_len and capacity?

Comment on lines +1067 to +1071
struct ArrayMetadata<T> {
refcount: u32,
max_len: u32,
data_ptr: *mut T,
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we reuse ArrayMetadata from types::arrays?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants