Skip to content

wasm: add v8 runtime.#66

Merged
PiotrSikora merged 18 commits intoistio:wasmfrom
PiotrSikora:wasm-v8
May 16, 2019
Merged

wasm: add v8 runtime.#66
PiotrSikora merged 18 commits intoistio:wasmfrom
PiotrSikora:wasm-v8

Conversation

@PiotrSikora
Copy link

Signed-off-by: Piotr Sikora piotrsikora@google.com

Signed-off-by: Piotr Sikora <piotrsikora@google.com>
Signed-off-by: Piotr Sikora <piotrsikora@google.com>
@PiotrSikora PiotrSikora requested a review from jplevyak May 9, 2019 23:41
Copy link

@lambdai lambdai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everything is good except for that I don't dare to look into the core v8.cc
Will get back to you next week.

} else if (wasm_vm == WasmVmNames::get().Wavm) {
return Wavm::createVm();
} else {
UNREFERENCED_PARAMETER(wasm_vm);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why wasm_vm is unreferenced? It is in above ifs

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. This was a leftover from another change that is allowing selection of one of the VMs (or none) at the build-time.

tar -zxf cmake-3.12.3-Linux-x86_64.tar.gz -C /usr --strip-components=1
# Install ninja 1.8.2.
curl -sLO https://github.com/ninja-build/ninja/releases/download/v1.8.2/ninja-linux.zip
echo "d2fea9ff33b3ef353161ed906f260d565ca55b8ca0568fa07b1d2cab90a84a07 ninja-linux.zip" | sha256sum --check
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reason? Do we need >= 1.8.2 or <=1.8.2 in this case?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

= 1.8.2.


// Helper functions.

const char* printValKind(wasm::ValKind kind) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, I guess this is not supposed be prepared for ADL, maybe you wanna declare it static, or put in anonymous namespace

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done (declared static).

}
}

std::string printValTypes(const wasm::vec<wasm::ValType*>& types) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done (declared static).

return s;
}

bool equalValTypes(const wasm::vec<wasm::ValType*>& left, const wasm::vec<wasm::ValType*>& right) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done (declared static).

Signed-off-by: Piotr Sikora <piotrsikora@google.com>
Signed-off-by: Piotr Sikora <piotrsikora@google.com>
Signed-off-by: Piotr Sikora <piotrsikora@google.com>
Signed-off-by: Piotr Sikora <piotrsikora@google.com>
Signed-off-by: Piotr Sikora <piotrsikora@google.com>
Signed-off-by: Piotr Sikora <piotrsikora@google.com>
Signed-off-by: Piotr Sikora <piotrsikora@google.com>
Signed-off-by: Piotr Sikora <piotrsikora@google.com>
Signed-off-by: Piotr Sikora <piotrsikora@google.com>
Signed-off-by: Piotr Sikora <piotrsikora@google.com>
Signed-off-by: Piotr Sikora <piotrsikora@google.com>
absl::StrCat("vm_config:\n vm: \"envoy.wasm.vm.wavm\"\n", " code: { inline_bytes: \"",
Base64::encode(code.data(), code.size()), "\" }\n");
const std::string yaml = absl::StrCat(R"EOF(
vm_config:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we turn this into a function?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be honest, I'd rather leave it as-is.

ASSERT(std::isnan(emscripten_NaN_->get()));
ASSERT(std::isinf(emscripten_Infinity_->get()));
// TODO(PiotrSikora): re-enable those checks after v8 starts returning globals.
// ASSERT(std::isnan(emscripten_NaN_->get()));

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Didn't you fix these?

Copy link
Author

@PiotrSikora PiotrSikora May 16, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did & I didn't... This is something I forgot to discuss with you yesterday.

The way globals are implemented in V8, the VM retains ownership of the global instance (same as functions), but the current model passes ownership back to the abstraction layer, where it's never used (other than for those 2 asserts). Do we need to do that?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There should be a way to get the value from v8 for a global so that the Global object is just a proxy for calls into v8?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could add a proxy, yes... My point is, that's an extra code that doesn't provide any value, since we never access globals from the host (outside of those 2 asserts).

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Depending on how and whether we end up supporting threads in the context of emscripten we may need to modify the internal emscripten value stack variables. So, while we are not using the globals right now it doesn't mean we will not use them in the future. That said, we don't need the support right now and I'd rather get v8 in, so let's leave a TODO and add it to the spreadsheet and resolve this conversation :)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added proxy, let me know if this works for you.

Signed-off-by: Piotr Sikora <piotrsikora@google.com>
Signed-off-by: Piotr Sikora <piotrsikora@google.com>
Signed-off-by: Piotr Sikora <piotrsikora@google.com>
Signed-off-by: Piotr Sikora <piotrsikora@google.com>
@PiotrSikora
Copy link
Author

@jplevyak @silentdai Please take another pass, I think all comments were addressed and this should be good to go. Thanks!

@jplevyak
Copy link

Let's get this in so I can do the merge and get the null vm in before kubecon.

@PiotrSikora PiotrSikora merged commit dba11f3 into istio:wasm May 16, 2019
@PiotrSikora PiotrSikora deleted the wasm-v8 branch October 11, 2019 02:46
brian-avery pushed a commit that referenced this pull request Jun 30, 2020
Signed-off-by: Lizan Zhou <lizan@tetrate.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants