[wasm] Validate sequentially in --single-threaded mode

Do not post a task if --single-threaded is enabled. Instead, execute
the task synchronously.

R=ahaas@chromium.org

Bug: v8:13447
Change-Id: I853125325953a750cb32984db449b3e07ccc4dce
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4026342
Reviewed-by: Andreas Haas <ahaas@chromium.org>
Commit-Queue: Clemens Backes <clemensb@chromium.org>
Cr-Commit-Position: refs/heads/main@{#84251}
This commit is contained in:
Clemens Backes 2022-11-14 16:32:06 +01:00 committed by V8 LUCI CQ
parent 1aa2263d69
commit d7b4e86f9e

View File

@ -1622,12 +1622,31 @@ class ModuleDecoderTemplate : public Decoder {
void ValidateAllFunctions() {
DCHECK(ok());
// Spawn a {ValidateFunctionsTask} and join it. The earliest error found
// will be set on this decoder.
std::unique_ptr<JobHandle> job_handle = V8::GetCurrentPlatform()->CreateJob(
TaskPriority::kUserVisible,
std::make_unique<ValidateFunctionsTask>(this));
job_handle->Join();
class NeverYieldDelegate final : public JobDelegate {
public:
bool ShouldYield() override { return false; }
bool IsJoiningThread() const override { UNIMPLEMENTED(); }
void NotifyConcurrencyIncrease() override { UNIMPLEMENTED(); }
uint8_t GetTaskId() override { UNIMPLEMENTED(); }
};
// Create a {ValidateFunctionsTask} to validate all functions. The earliest
// error found will be set on this decoder.
std::unique_ptr<JobTask> validate_job =
std::make_unique<ValidateFunctionsTask>(this);
if (v8_flags.single_threaded) {
// In single-threaded mode, run the {ValidateFunctionsTask} synchronously.
NeverYieldDelegate delegate;
validate_job->Run(&delegate);
} else {
// Spawn the task and join it.
std::unique_ptr<JobHandle> job_handle =
V8::GetCurrentPlatform()->CreateJob(TaskPriority::kUserVisible,
std::move(validate_job));
job_handle->Join();
}
}
// Decodes an entire module.