-
Notifications
You must be signed in to change notification settings - Fork 304
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
HPCC-33154 Refactor WebAssembly Support #19375
base: master
Are you sure you want to change the base?
HPCC-33154 Refactor WebAssembly Support #19375
Conversation
Jira Issue: https://hpccsystems.atlassian.net//browse/HPCC-33154 Jirabot Action Result: |
233c948
to
0505cc9
Compare
Added list / set support Signed-off-by: Gordon Smith <[email protected]>
0505cc9
to
75808aa
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.
A few comments. Some may be invalid as I gradually understood the code better.
My main thought is that I'm not sure the string functions are correct - latin1 v utf8 v utf16. It wasn't clear what encoding were in use, where, and some of the tests against 1<<8 looked wrong. It needs test cases for i) ascii ii) latin1, iii) extended unicode.
} | ||
|
||
template <Float T> | ||
T maybe_scramble_nan(T f) |
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.
identical to the function above - is that deliberate?
WasmValVector lower_flat(CallContext &cx, const list_t<T> &v) | ||
{ | ||
std::size_t maybe_length = 0; | ||
if (maybe_length) |
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.
Is this planned to be implemented later? Currently it will always be 0
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.
FYI - looking at the ref, it is for future support of fixed length arrays. Will remove for now.
{ | ||
assert(maybe_length == v.size()); | ||
WasmValVector flat; | ||
for (auto e : v) |
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.
auto &? If T is non trivial then cloning the items may be expensive.
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.
Removed for now (fixed length array support)
list_t<T> lift_flat(const CallContext &cx, const WasmValVectorIterator &vi) | ||
{ | ||
std::size_t maybe_length = 0; | ||
if (maybe_length) |
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.
same question about about maybe_length always being 0
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.
Removed for now.
std::tuple<offset, size> store_into_range(CallContext &cx, const list_t<T> &v) | ||
{ | ||
auto elem_type = ValTrait<T>::type; | ||
size_t nbytes = ValTrait<T>::size; |
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 don't think this copes with sets of variable length strings - that would need a different implementation.
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.
Strings should be stored as a pair of uint32_t, (its trait size is 8) one is a ptr to var length string and the other is its length.
{ | ||
case Encoding::Latin1: | ||
case Encoding::Utf8: | ||
std::memcpy(dest, src, byte_len); |
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.
careful if src_len is 0 - this can lead to src being null, which can cause an internal error when sanitizing is enabled.
{ | ||
case Encoding::Latin1: | ||
case Encoding::Utf8: | ||
std::memcpy(dest, src, byte_len); |
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.
Utf8 is not the same encoding as latin1 - some conversion is needed.
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.
This is just a "fake host" for the unit tests, so was only concerned with utf8 <-> utf8 conversion, but I can either flesh this out (with an off the shelf lib) or fail when not utf8 (for now).
{ | ||
case Encoding::Latin1: | ||
case Encoding::Utf8: | ||
// { |
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.
Work in progress? Same above.
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.
Yes I need to pick a unicode lib for the fake host...
case type_boolean: | ||
memIdxVar = wasmStore->callRealloc(wasmName, {0, 0, 1, (int32_t)numElems}); | ||
memIdx = memIdxVar[0].i32(); | ||
assert(elemSize == sizeof(int32_t)); |
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.
Will this be relaxed later to support other sizes?
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.
Yes wasm + 64bit addressable memory is being rolled out currently, but our version of the wasmtime runtime does not support it (their latest does).
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.
There is also a concept of "Flags" in wit, which translates to bit fields.
} | ||
} | ||
|
||
void hpcc_scalar_test_list_bool_test_bool(hpcc_scalar_test_list_bool_t *a, hpcc_scalar_test_list_bool_t *ret) |
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 isn't very clear from these function names what the functions do. For instance this seems to reverse a list.
Added list / set support
Type of change:
Checklist:
Smoketest:
Testing: