Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make the layout specific to primitives and structs #443

Closed
baszalmstra opened this issue Aug 27, 2022 · 2 comments
Closed

Make the layout specific to primitives and structs #443

baszalmstra opened this issue Aug 27, 2022 · 2 comments
Assignees
Labels
good first issue Good for newcomers type: refactor Refactor existing code
Milestone

Comments

@baszalmstra
Copy link
Collaborator

Currently, all types store a layout which describes the size and alignment of storing a specific Type. For primitives and structs this is a dynamic value but for arrays and pointers this value is always the same (the layout of a *const c_void).

We should remove this from the TypeData struct and instead store the layout only in the TypeDataKind of structs and primitives.

@baszalmstra baszalmstra added good first issue Good for newcomers type: perf Changes that improve performance labels Aug 27, 2022
@baszalmstra baszalmstra added this to the Mun v0.5.0 milestone Jan 2, 2023
@Wodann Wodann self-assigned this Jan 2, 2023
@baszalmstra
Copy link
Collaborator Author

Im not sure if this is still needed. The ABI already doesn't store layouts for arrays or pointers since we use TypeIds for them now. The only place this is now stored is in the mun_memory::Type however there I think it makes sense because the layout refers to the stack size of storing the element.

These methods are implemented for mun_codegen::Type, maybe we could explain the difference a little better?

/// Returns the memory layout of the data of the type. This is the layout of the memory when
/// stored on the stack or in the heap.
pub fn value_layout(&self) -> Layout {
  ...
}

/// Returns the layout of the type when being referenced.
pub fn reference_layout(&self) -> Layout {
  ...
}

@Wodann
Copy link
Collaborator

Wodann commented Feb 6, 2023

The existing comments LGTM.

@Wodann Wodann closed this as completed Feb 6, 2023
@Wodann Wodann modified the milestones: Mun v0.5.0, Mun v0.4.0 Feb 6, 2023
@Wodann Wodann added type: refactor Refactor existing code and removed type: perf Changes that improve performance labels Dec 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers type: refactor Refactor existing code
Projects
None yet
Development

No branches or pull requests

2 participants