boa icon indicating copy to clipboard operation
boa copied to clipboard

Spilt `Tagged<T>` into a utility crate

Open HalidOdat opened this issue 1 year ago • 8 comments

Depends on #3837

This makes Tagged<T> be usable in boa_string and boa_engine.

HalidOdat avatar May 12 '24 04:05 HalidOdat

Test262 conformance changes

Test result main count PR count difference
Total 50,254 50,254 0
Passed 46,615 46,615 0
Ignored 1,634 1,634 0
Failed 2,005 2,005 0
Panics 0 0 0
Conformance 92.76% 92.76% 0.00%

github-actions[bot] avatar May 12 '24 04:05 github-actions[bot]

General discussion on utility crates: how do we want to go about handling utilities in general that's going to be best for maintenance in the long term?

Should we have one general boa_utils crate or a utils directory with individual crates hosted inside it (I'm thinking of icu4x's structure as an example). We could also extract SmallMap into the utils as well. Both Tagged and SmallMap could then be standalone crates unto themselves.

There's some benefits to taking the utils directory approach.

  1. The code is more modular.
  2. Offers the libraries for generic use case for the Rust ecosystem as a whole.
  3. Could provide some soft "marketing" for boa, so to speak.

There could be a pretty big negative around the maintenance complexity utility crates may cause and managing separate releases may actually end being a large headache. :confused:

Any thoughts?

nekevss avatar May 13 '24 02:05 nekevss

Hmmm... Tagged<T> and SmallMap are very small (single file) so don't think it's going to need that much maintenance. Just a thought: we could put them in separate repos (like we do with ryu-js, and temporal_rs) may make it easier to separately publish the crates.

What does the rest of the team say? @jedel1043 @raskad @Razican

HalidOdat avatar May 13 '24 07:05 HalidOdat

From my side, in general, if the crate / code makes sense outside Boa, then we should make it separate, so that others can benefit from it. If not, I would keep it in.

For this case, it seems these types could be used outside of Boa, and they have no dependency on the engine, so I would make them separate if it's not too much maintenance burden (and we don't forget to maintain them 😅)

Razican avatar May 13 '24 07:05 Razican

I'm not sure what we should name the crate because tagged, tagged_ptr, tagged_pointer are all taken... Any ideas?

HalidOdat avatar May 28 '24 15:05 HalidOdat

I think separating small utility crates to separate repos is arguably worse for us. I would be in favour of having either a boa_utils or an utils directory here, but having to maintain a whole repo for only a single Tagged data structure sounds counter-productive.

jedel1043 avatar May 28 '24 15:05 jedel1043

From my side, in general, if the crate / code makes sense outside Boa, then we should make it separate, so that others can benefit from it. If not, I would keep it in.

We can do that and also maintain it as a separate crate on our main repo. That's what the ICU4X folks do with writeable, yoke, etc. and it's not too bad. I think it only makes sense to extract separate repos if there's a big incentive to do so.

jedel1043 avatar May 28 '24 16:05 jedel1043

As mentioned above, I'd be for the utils directory with any small utility crates in them.

I'm not sure what we should name the crate because tagged, tagged_ptr, tagged_pointer are all taken... Any ideas?

tagged_rs maybe? tag_ptr could work although not super accurate 😕.

nekevss avatar May 28 '24 17:05 nekevss

@boa-dev/maintainers This is done, just needs review/merge :)

HalidOdat avatar Mar 03 '25 20:03 HalidOdat

Removed the assertions because I realized the pointer could be unaligned even if the type must be aligned (std::mem::read_unaligned). That by itself cannot cause undefined behaviour though; at worst some memory leaks, but unaligned pointers will just be treated as integers.

jedel1043 avatar Mar 06 '25 01:03 jedel1043