mun-lang / mun

Source code for the Mun language and runtime.
https://mun-lang.org
Other
1.83k stars 73 forks source link

feat: add `Type` API to mitigate issues around memory #427

Closed baszalmstra closed 2 years ago

baszalmstra commented 2 years ago

This PR refactors the Type system. It exposes only: Type which is now your one and only handle for type information. Internally it uses reference counting and a system to ensure that cross-referencing types are not deallocated.

I also had to rewrite the FFI code for types because of this so I also made all the FFI code and tests a little more ergonomic/easy to use.

The only thing missing currently is the C++ code that accompanies the changes.

This does fix issue #423 .

Closes #423

codecov[bot] commented 2 years ago

Codecov Report

Merging #427 (78a967a) into main (778fa5a) will increase coverage by 0.08%. The diff coverage is 92.37%.

@@            Coverage Diff             @@
##             main     #427      +/-   ##
==========================================
+ Coverage   83.04%   83.13%   +0.08%     
==========================================
  Files         280      281       +1     
  Lines       16520    16648     +128     
==========================================
+ Hits        13719    13840     +121     
- Misses       2801     2808       +7     
Impacted Files Coverage Δ
crates/mun/src/ops/start.rs 0.00% <0.00%> (ø)
crates/mun_memory/src/gc.rs 100.00% <ø> (ø)
crates/mun_memory/tests/gc/alloc.rs 100.00% <ø> (ø)
crates/mun_runtime/tests/memory.rs 100.00% <ø> (ø)
crates/mun_runtime/src/reflection.rs 50.00% <33.33%> (ø)
crates/mun_runtime/src/adt.rs 79.27% <70.58%> (-0.11%) :arrow_down:
crates/mun_memory/src/type_table.rs 77.55% <78.57%> (+1.08%) :arrow_up:
crates/mun_memory/src/type/ffi/pointer.rs 86.25% <86.25%> (ø)
crates/mun_memory/src/type/mod.rs 88.32% <88.32%> (ø)
crates/mun_runtime/src/assembly.rs 82.66% <91.30%> (-2.05%) :arrow_down:
... and 23 more

Help us with your feedback. Take ten seconds to tell us how you rate us.