Add support for WASM intrinsic globals. (STACKED on wasm-module, see commit messages)#36
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: If they are not already assigned, you can assign the PR to them by writing The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
There was a problem hiding this comment.
Is there a list of name in global module?
There was a problem hiding this comment.
Unfortunately the Emscripten ABI isn't stable. The best source for that information is the Emscripten source code for the various versions.
There was a problem hiding this comment.
"global", "NaN" and "Infinity" are core concept. Could you use const variable and aggregate them in single place?
source/extensions/common/wasm/wasm.h
Outdated
There was a problem hiding this comment.
A naive question
Where is makeGlobalWavm instantiated?
There was a problem hiding this comment.
It is in the wasm/wavm/wavm.cc file. It is encapsulated in that file. The idea is to make the details of the individual VM implementations private. I choose that because wavm/wavm.h is included in wasm/wasm.cc but not wasm/wasm.h to prevent circularizing the includes. I am planning on moving class WavmVm into a new file and reorganizing the includes here which would enable moving this declaration into the wavm/ directory, after clearing the current PR backlog.
source/extensions/common/wasm/wasm.h
Outdated
There was a problem hiding this comment.
Another naive question
Where can I find a inherited Global ?
There was a problem hiding this comment.
in wavm/wavm.cc. That is the private VM specific implementation of the Global class.
There was a problem hiding this comment.
Thanks! I didn't find it because github doesn't render large diff.
lambdai
left a comment
There was a problem hiding this comment.
Thank you for the explanation! This comment is targeted to only the top commit
source/extensions/common/wasm/wasm.h
Outdated
There was a problem hiding this comment.
Thanks! I didn't find it because github doesn't render large diff.
There was a problem hiding this comment.
virtual void set(const T& t) override;
BTW: is multiple line comment supported? I didn't find an approach to mark multiple lines that need attention.
There was a problem hiding this comment.
Feel free to ignore: This green area is quite isolated from the existing logic. It doesn't use any stack variable so it's reasonable to name this piece some other day.
There was a problem hiding this comment.
Yes, but it will fail to compile if is actually used because it doesn't return anything.
There was a problem hiding this comment.
This implementation remind me that the return type should be std::decay_t to avoid get reference (e.g, T = int32_t&)
There was a problem hiding this comment.
discussed offline. This is only used for templates explicitly instantiated in this file, so there is no chance of accidental &.
There was a problem hiding this comment.
Why are you doing this? You may always write as below. There is no penalty and it is exception safe.
auto g_ptr = std::make_unique<WavmGlobal<T>>(...);
wavm->intrinsicGlobals_[...] = g_ptr.get();
return g_ptr;
There was a problem hiding this comment.
It is a bit more complicated because the return type is std::unique_ptr<Global>> which the compiler will not auto-coerce from 'g'. Instead I have to do a std::static_pointer_cast<> and this works around that by using the automatic std::unique_ptr constructor coercion which does upcast "correctly" (IMO std::unique_ptr should do that was well, maybe in a later version of C++).
I'll change it.
There was a problem hiding this comment.
My bad. You are right. The problem only happens with shared_ptr. Done.
test/extensions/wasm/wasm_test.cc
Outdated
Signed-off-by: John Plevyak <jplevyak@gmail.com>
This patch separates the Resource class from the resource manager implementation and allows for resource limit tracking in other parts of the code base. Signed-off-by: Tony Allen <tony@allen.gg> Signed-off-by: Lizan Zhou <lizan@tetrate.io> Co-authored-by: Lizan Zhou <lizan@tetrate.io>
Add support for WASM intrinsic globals.