-
Notifications
You must be signed in to change notification settings - Fork 76
Extract common code from runtime implementations. #152
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
Conversation
Signed-off-by: Takeshi Yoneda <[email protected]>
Signed-off-by: Takeshi Yoneda <[email protected]>
Signed-off-by: Takeshi Yoneda <[email protected]>
ad1909c
to
700d5b8
Compare
Signed-off-by: Takeshi Yoneda <[email protected]>
src/v8/v8.cc
Outdated
wasm::vec<byte_t> code_vec = wasm::vec<byte_t>::invalid(); | ||
if (stripped.empty()) { | ||
// Use the original bytecode. | ||
code_vec = wasm::vec<byte_t>::make(code.size(), (char *)(code.data())); |
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.
(char *)(code.data())
is a temporary workaround for now to pass build and we should fix. This is necessary since wasm::vec<byte_t>::make requires us to pass char vector instead of const char vector. If we want to do zero copy, we need to do cast like this or change the arg type of code
to std::string&
.. but I'm not sure why ::make require non-const bytes code since V8 seems to copy the code internally anyway..
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.
@PiotrSikora I need your inputs here.. Should we change the signature of load
to std::string &code
from const std::string &code
so that we can have char *
instead of const char*
from code.data()
, or we allow (char *)(code.data())
..?
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.
The following is the error we get without modifying signature and just pass code.data()
external/com_googlesource_chromium_v8/wee8/third_party/wasm-api/wasm.hh:149:18: error: cannot initialize an array element of type 'char' with an rvalue of type 'typename std::remove_reference<const char *&>::type' (aka 'const char *')
T data[] = { std::move(args)... };
^~~~~~~~~~~~~~~
external/proxy_wasm_cpp_host/src/v8/v8.cc:293:37: note: in instantiation of function template specialization 'wasm::vec<char>::make<unsigned long, const char *>' requested here
code_vec = wasm::vec<byte_t>::make(code.size(), code.data());
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 think this might be the reason why we originally copied the bytecode. Perhaps make getStrippedSource
always return std::string
(either stripped version or a copy of the original bytecode) and then use it as input here?
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.
so we cannot avoid copying the original bytecode anyway.. thanks for suggestion.
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.
done ed0f3a5
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.
The bytecode read from the configuration is passed to both: canary and base WasmVMs at startup, so I'm afraid that we have to copy it, unfortunately.
Perhaps we can rewrite this logic somehow, but that should probably be done in a separate PR.
made ready for review at least now this passes Envoy tests |
Signed-off-by: Takeshi Yoneda <[email protected]>
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.
Thanks for working on this!
-
Wavm
is an odd duck now. We're using its internal parsing to extract precompiled module inWavm::load
, but replacedWavm::getCustomSection
withWasmUtil
. I think we should either replace the iterator inWavm::load
withWasmUtil::getCustomSection
or retaingetCustomSection
as part of the interface, and useWasmUtil
-based default, so thatWavm
could override it. -
Could you also extact code responsible for mapping ABI versions? Right now, we do the same
string_view
toAbiVersion
conversion in each runtime.
Signed-off-by: Takeshi Yoneda <[email protected]>
Signed-off-by: Takeshi Yoneda <[email protected]>
Signed-off-by: Takeshi Yoneda <[email protected]>
Signed-off-by: Takeshi Yoneda <[email protected]>
Signed-off-by: Takeshi Yoneda <[email protected]>
Signed-off-by: Takeshi Yoneda <[email protected]>
changed to use BytecodeUtil::getCustomSection in WAVM: d807f06 |
OK verified that WAVM change also passes Envoy tests (locally😄). |
Signed-off-by: Takeshi Yoneda <[email protected]>
Signed-off-by: Takeshi Yoneda <[email protected]>
Signed-off-by: Takeshi Yoneda <[email protected]>
6534a25
to
41a9ac6
Compare
Signed-off-by: Takeshi Yoneda <[email protected]>
src/v8/v8.cc
Outdated
wasm::vec<byte_t> code_vec = wasm::vec<byte_t>::invalid(); | ||
if (stripped.empty()) { | ||
// Use the original bytecode. | ||
code_vec = wasm::vec<byte_t>::make(code.size(), (char *)(code.data())); |
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 think this might be the reason why we originally copied the bytecode. Perhaps make getStrippedSource
always return std::string
(either stripped version or a copy of the original bytecode) and then use it as input here?
Signed-off-by: Takeshi Yoneda <[email protected]>
Signed-off-by: Takeshi Yoneda <[email protected]>
Signed-off-by: Takeshi Yoneda <[email protected]>
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.
Thanks! Could you update Envoy PR to make sure it passes with latest changes?
Thanks! Once the test passes in Envoy, I will merge this and update Envoy to point to the main branch here. |
We probably shouldn't update every single commit in Enovy, especially since sometimes they get merged out-of-order. This is mostly refactoring, so I'd skip it. |
Yeah agreed👍
…On Tue, Apr 13, 2021 at 17:13 Piotr Sikora ***@***.***> wrote:
Thanks! Once the test passes in Envoy, I will merge this and update Envoy
to point to the main branch here.
We probably shouldn't update every single commit in Enovy, especially
since sometimes they get merged out-of-order.
This is mostly refactoring, so I'd skip it.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#152 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ADHDJ6JJDMTOEBOOQDDJ4ZLTIP4J7ANCNFSM42YZ22BQ>
.
|
Well, that was terrible timing on my part... For anything that requires changes to code and/or tests, even if it's only because of refactoring, we need to update Envoy as well, otherwise we're might be blocking other PRs. Do you mind reopening that Envoy PR? |
yeah will do |
fixes #148
Signed-off-by: Takeshi Yoneda [email protected]
still wip since I haven't tested on Envoy yet