[wasm] Deserialization: avoid repeated locking

Use the overload of NativeModule::PublishCode that accepts a vector of
codes to only lock/unlock once per batch.

R=ahaas@chromium.org

Bug: v8:11164
Change-Id: I6428d3d9cec8526bdfef223d7ba03b35bad9e1eb
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2562251
Reviewed-by: Andreas Haas <ahaas@chromium.org>
Commit-Queue: Thibaud Michaud <thibaudm@chromium.org>
Cr-Commit-Position: refs/heads/master@{#71431}
This commit is contained in:
Thibaud Michaud 2020-11-26 15:21:19 +01:00 committed by Commit Bot
parent 4ad08c82f7
commit bbaa91f37d

View File

@ -762,11 +762,14 @@ void NativeModuleDeserializer::CopyAndRelocate(
void NativeModuleDeserializer::Publish(
std::unique_ptr<std::vector<DeserializationUnit>> batch) {
DCHECK_NOT_NULL(batch);
std::vector<std::unique_ptr<WasmCode>> codes;
for (auto& unit : *batch) {
WasmCode* published_code =
native_module_->PublishCode(std::move(unit).code);
published_code->MaybePrint();
published_code->Validate();
codes.push_back(std::move(unit).code);
}
auto published_codes = native_module_->PublishCode(VectorOf(codes));
for (auto* wasm_code : published_codes) {
wasm_code->MaybePrint();
wasm_code->Validate();
}
#ifdef DEBUG
total_published_.fetch_add(1);