Commit 1fa2b9ee authored by Clemens Backes's avatar Clemens Backes Committed by Commit Bot

[wasm][serialization] Publish all available units

Since publishing is sequential anyway, we can as well publish all
available units in one go. This avoids repeated locking in both the
queue and the NativeModule.

R=thibaudm@chromium.org

Bug: v8:11164
Change-Id: Ie4b8914caaafd8d1e3330cb30f427aee6e571e9b
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2644947
Commit-Queue: Clemens Backes <clemensb@chromium.org>
Reviewed-by: 's avatarThibaud Michaud <thibaudm@chromium.org>
Cr-Commit-Position: refs/heads/master@{#72332}
parent 4e9f6513
......@@ -500,6 +500,19 @@ class DeserializationQueue {
return batch;
}
std::vector<DeserializationUnit> PopAll() {
base::MutexGuard guard(&mutex_);
if (queue_.empty()) return {};
auto units = std::move(queue_.front());
queue_.pop();
while (!queue_.empty()) {
units.insert(units.end(), std::make_move_iterator(queue_.front().begin()),
std::make_move_iterator(queue_.front().end()));
queue_.pop();
}
return units;
}
size_t NumBatches() {
base::MutexGuard guard(&mutex_);
return queue_.size();
......@@ -584,9 +597,9 @@ class PublishTask : public JobTask {
void Run(JobDelegate* delegate) override {
WasmCodeRefScope code_scope;
do {
auto batch = from_queue_->Pop();
if (batch.empty()) break;
deserializer_->Publish(std::move(batch));
auto to_publish = from_queue_->PopAll();
if (to_publish.empty()) break;
deserializer_->Publish(std::move(to_publish));
} while (!delegate->ShouldYield());
}
......
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