-
Notifications
You must be signed in to change notification settings - Fork 51
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
Use DiplomatSlice/etc instead of splitting params into data/len pairs #615
Conversation
01c58b5
to
1ccf792
Compare
@ambiguousname I'd like some help making the relevant changes here for JS. The change made here is that basically until now slices in structs and params were handled differently: in a struct a slice becomes a However I'm not super familiar with slice handling in your backend. It appears to be the case that the Kotlin backend already handles things correctly (previously it was incorrect), where it didn't know about this issue with slice params. Fortunately, now that things are uniform, Kotlin is automagically correct already. cc @jcrist1 just so you're aware I managed to make it work for Dart. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not an in-depth review
final (utf8StrData, utf8StrLength) = utf8Str._utf8AllocIn(utf8StrArena.arena); | ||
final utf8Str = ffi.Struct.create<_SliceUtf8>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd push the struct creation into allocIn
, but I can follow up
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd love that yeah.
@@ -75,6 +81,6 @@ final class BorrowedFields { | |||
} | |||
|
|||
@meta.ResourceIdentifier('BorrowedFields_from_bar_and_strings') | |||
@ffi.Native<_BorrowedFieldsFfi Function(ffi.Pointer<ffi.Opaque>, ffi.Pointer<ffi.Uint16>, ffi.Size, ffi.Pointer<ffi.Uint8>, ffi.Size)>(isLeaf: true, symbol: 'BorrowedFields_from_bar_and_strings') | |||
@ffi.Native<_BorrowedFieldsFfi Function(ffi.Pointer<ffi.Opaque>)>(isLeaf: true, symbol: 'BorrowedFields_from_bar_and_strings') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issue: the arguments disappeared
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed. The param_types_ffi_cast
etc stuff is kinda confusing, we generate a lot of different things in one function. I didn't bother to try and understand it too deeply but we should document this better if we get the chance.
(Also now that this is no longer doing two-parameter stuff we probably can clean things up)
79d11b2
to
a462c01
Compare
I'm signing off soon, but @robertbastian please do feel free to polish up the Dart section and push, I did a quick-and-dirty fix which still appears to be broken. (let me know if you've pushed though, so I don't overwrite) |
7b9435a
to
cfa3d00
Compare
I tried to fix some things but Dart's still broken |
I'll take a look and adjust the JS backend. We have a few open issues with how JS handles slices anyways (I believe to do with cleanup in particular), so maybe I can re-write the JS slices system to account for those issues in addition to your changes. I'll ping you before EOD today when I've got something. |
found a double free and also fixed the dart issues, but won't be able to push for another hour I think |
@Manishearth I did some review of the updated WASM output still requires a pointer and size, the new types are ignored: As for backend logic, JS uses the same For clarity, struct field conversion is done in The only change I can think of is renaming As a caveat, I can't seem to find tests in TL;DR JS already handles slices for structs and function parameters in the same way. If I'm missing something or you'd like additional changes, let me know. |
bf2a12a
to
44a2547
Compare
44a2547
to
65f889b
Compare
Oh yeah, that makes sense, the WASM abi hates structs so everything is done splatted out anyway. Nice to not have to worry about this! |
b14c6d2
to
cf81dc3
Compare
cf81dc3
to
340f0fa
Compare
And CI passes! |
That took less time than I expected. As a bonus, this simplifies the macro code so a lot of the gnarly DiplomatOption handling I wanted to do becomes really straightforward, and that reduces the amount of macro mess that was going to be in #558 ! (I never pushed the macro mess code because I was annoyed with it) |
34443be
to
42ad7e7
Compare
42ad7e7
to
8617720
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LG overall. Will work on the Dart simplifications so please no more force pushes.
Sounds good. I'll try to merge as soon as possible to avoid you needing to patch stack |
DiplomatStringView bn = {"bn", 2}; | ||
|
||
Locale* locale = icu4x_Locale_new_mv1(bn); | ||
Locale* locale = icu4x_Locale_new_mv1((DiplomatStringView){.data = "bn", .len = 2}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does this really need the cast? 😕
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it fails to parse without the cast. I don't understand it either.
C is weird and has terrible errors, if you can figure out how to avoid the cast be my guest 🙃🙃
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ew. in that case I'm not sure if the inline is actually nicer 🤷
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah feel free to change it back if you'd like. I'm very ambivalent here
Fixes #613
Things this does not do that it should, but I might do in a followup:
&[&DiplomatStr]
, they should just go all the way IMO.