Commit bb46048a authored by Andreas Haas's avatar Andreas Haas Committed by Commit Bot

[wasm] Notify streaming decoder when the native module is created

Originally, the NativeModule and the WasmModuleObject were created
together, and the streaming decoder was notified after the
WasmModuleObject was created. A recent CL (https://crrev.com/c/1402544),
however, changed that.  The NativeModule gets created before compilation
starts, the WasmModuleObject, however, gets created after compilation.

The streaming decoder only needs the NativeModule to register a callback
before compilation. Therefore this CL we change the notification of the
streaming decoder to receive only the NativeModule, not the
WasmModuleObject, before starting compilation.

R=clemensh@chromium.org
CC=bbudge@chromium.org

Bug: chromium:719172
Change-Id: I4ad879e4ebd2d88174d7e2a0c6359f2836926763
Reviewed-on: https://chromium-review.googlesource.com/c/1404442
Commit-Queue: Andreas Haas <ahaas@chromium.org>
Reviewed-by: 's avatarClemens Hammacher <clemensh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#58703}
parent 6165031b
......@@ -2469,6 +2469,8 @@ void AsyncCompileJob::CreateNativeModule(
wasm::NativeModule::kCanAllocateMoreMemory, std::move(module));
native_module_->SetWireBytes({std::move(bytes_copy_), wire_bytes_.length()});
native_module_->SetRuntimeStubs(isolate_);
if (stream_) stream_->NotifyNativeModuleCreated(native_module_);
}
void AsyncCompileJob::PrepareRuntimeObjects() {
......@@ -2488,8 +2490,6 @@ void AsyncCompileJob::PrepareRuntimeObjects() {
module_object_ = handle(*module_object_, isolate_);
deferred_handles_.push_back(deferred.Detach());
}
if (stream_) stream_->NotifyRuntimeObjectsCreated(module_object_);
}
// This function assumes that it is executed in a HandleScope, and that a
......
......@@ -149,12 +149,10 @@ class TopTierCompiledCallback {
} // namespace
void StreamingDecoder::NotifyRuntimeObjectsCreated(
Handle<WasmModuleObject> module_object) {
void StreamingDecoder::NotifyNativeModuleCreated(
const std::shared_ptr<NativeModule>& native_module) {
if (!module_compiled_callback_) return;
std::shared_ptr<NativeModule> native_module =
module_object->shared_native_module();
auto* comp_state = module_object->native_module()->compilation_state();
auto* comp_state = native_module->compilation_state();
comp_state->AddCallback(TopTierCompiledCallback{
std::move(native_module), std::move(module_compiled_callback_)});
module_compiled_callback_ = {};
......
......@@ -16,12 +16,8 @@
namespace v8 {
namespace internal {
template <typename T>
class Handle;
class WasmModuleObject;
namespace wasm {
class NativeModule;
// This class is an interface for the StreamingDecoder to start the processing
// of the incoming module bytes.
......@@ -90,7 +86,8 @@ class V8_EXPORT_PRIVATE StreamingDecoder {
// Passes previously compiled module bytes from the embedder's cache.
bool SetCompiledModuleBytes(Vector<const uint8_t> compiled_module_bytes);
void NotifyRuntimeObjectsCreated(Handle<WasmModuleObject>);
void NotifyNativeModuleCreated(
const std::shared_ptr<NativeModule>& native_module);
private:
// TODO(ahaas): Put the whole private state of the StreamingDecoder into the
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment