Extract common code from runtime implementations.#152
Extract common code from runtime implementations.#152PiotrSikora merged 18 commits intoproxy-wasm:masterfrom
Conversation
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
ad1909c to
700d5b8
Compare
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.
(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.
@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.
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.
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.
so we cannot avoid copying the original bytecode anyway.. thanks for suggestion.
There was a problem hiding this comment.
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 <takeshi@tetrate.io>
PiotrSikora
left a comment
There was a problem hiding this comment.
Thanks for working on this!
-
Wavmis an odd duck now. We're using its internal parsing to extract precompiled module inWavm::load, but replacedWavm::getCustomSectionwithWasmUtil. I think we should either replace the iterator inWavm::loadwithWasmUtil::getCustomSectionor retaingetCustomSectionas part of the interface, and useWasmUtil-based default, so thatWavmcould override it. -
Could you also extact code responsible for mapping ABI versions? Right now, we do the same
string_viewtoAbiVersionconversion in each runtime.
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
|
changed to use BytecodeUtil::getCustomSection in WAVM: d807f06 |
|
OK verified that WAVM change also passes Envoy tests (locally😄). |
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
6534a25 to
41a9ac6
Compare
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
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.
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 <takeshi@tetrate.io>
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
PiotrSikora
left a comment
There was a problem hiding this comment.
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 takeshi@tetrate.io
still wip since I haven't tested on Envoy yet