Commit b7930166 authored by Clemens Backes's avatar Clemens Backes Committed by V8 LUCI CQ

[wasm] Avoid switching write permissions per lazy function

Instead, open a single {CodeSpaceWriteScope} that covers all functions.
Note that the exact same thing is already done in
{InitializeLazyCompilation}.

R=thibaudm@chromium.org

Bug: v8:11974, chromium:1298552
Change-Id: I469757f0674a7b95ce56ffa4d42b5e0d9d5a0834
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3474671Reviewed-by: 's avatarThibaud Michaud <thibaudm@chromium.org>
Commit-Queue: Clemens Backes <clemensb@chromium.org>
Cr-Commit-Position: refs/heads/main@{#79181}
parent 489527d4
......@@ -3202,6 +3202,10 @@ void CompilationStateImpl::InitializeCompilationProgressAfterDeserialization(
auto* module = native_module_->module();
auto enabled_features = native_module_->enabled_features();
const bool lazy_module = IsLazyModule(module);
base::Optional<CodeSpaceWriteScope> lazy_code_space_write_scope;
if (lazy_module || !lazy_functions.empty()) {
lazy_code_space_write_scope.emplace(native_module_);
}
{
base::MutexGuard guard(&callbacks_mutex_);
DCHECK(compilation_progress_.empty());
......
......@@ -1135,9 +1135,11 @@ void NativeModule::UseLazyStub(uint32_t func_index) {
DCHECK_LE(module_->num_imported_functions, func_index);
DCHECK_LT(func_index,
module_->num_imported_functions + module_->num_declared_functions);
// Avoid opening a new write scope per function. The caller should hold the
// scope instead.
DCHECK(CodeSpaceWriteScope::IsInScope());
base::RecursiveMutexGuard guard(&allocation_mutex_);
CodeSpaceWriteScope code_space_write_scope(this);
if (!lazy_compile_table_) {
uint32_t num_slots = module_->num_declared_functions;
WasmCodeRefScope code_ref_scope;
......
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