Commit d4afb5f3 authored by Michael Starzinger's avatar Michael Starzinger Committed by Commit Bot

[wasm] Simplify code modification scope for wrapper compilation.

R=clemensh@chromium.org

Change-Id: Idb11b07df72f2d9d1c606d04af701cb4e9853664
Reviewed-on: https://chromium-review.googlesource.com/c/1335549Reviewed-by: 's avatarClemens Hammacher <clemensh@chromium.org>
Commit-Queue: Michael Starzinger <mstarzinger@chromium.org>
Cr-Commit-Position: refs/heads/master@{#57494}
parent 06587445
...@@ -6,7 +6,6 @@ ...@@ -6,7 +6,6 @@
#include "src/api.h" #include "src/api.h"
#include "src/asmjs/asm-js.h" #include "src/asmjs/asm-js.h"
#include "src/base/optional.h"
#include "src/base/template-utils.h" #include "src/base/template-utils.h"
#include "src/base/utils/random-number-generator.h" #include "src/base/utils/random-number-generator.h"
#include "src/compiler/wasm-compiler.h" #include "src/compiler/wasm-compiler.h"
...@@ -977,11 +976,6 @@ MaybeHandle<WasmModuleObject> CompileToModuleObject( ...@@ -977,11 +976,6 @@ MaybeHandle<WasmModuleObject> CompileToModuleObject(
isolate->CountUsage(v8::Isolate::UseCounterFeature::kWasmSharedMemory); isolate->CountUsage(v8::Isolate::UseCounterFeature::kWasmSharedMemory);
} }
// TODO(6792): No longer needed once WebAssembly code is off heap. Use
// base::Optional to be able to close the scope before notifying the debugger.
base::Optional<CodeSpaceMemoryModificationScope> modification_scope(
base::in_place_t(), isolate->heap());
// Create heap objects for script, module bytes and asm.js offset table to // Create heap objects for script, module bytes and asm.js offset table to
// be stored in the module object. // be stored in the module object.
Handle<Script> script; Handle<Script> script;
...@@ -1021,9 +1015,6 @@ MaybeHandle<WasmModuleObject> CompileToModuleObject( ...@@ -1021,9 +1015,6 @@ MaybeHandle<WasmModuleObject> CompileToModuleObject(
// If we created a wasm script, finish it now and make it public to the // If we created a wasm script, finish it now and make it public to the
// debugger. // debugger.
if (asm_js_script.is_null()) { if (asm_js_script.is_null()) {
// Close the CodeSpaceMemoryModificationScope before calling into the
// debugger.
modification_scope.reset();
isolate->debug()->OnAfterCompile(script); isolate->debug()->OnAfterCompile(script);
} }
...@@ -2735,8 +2726,6 @@ class AsyncCompileJob::CompileWrappers : public CompileStep { ...@@ -2735,8 +2726,6 @@ class AsyncCompileJob::CompileWrappers : public CompileStep {
// and the wrappers for the function table elements. // and the wrappers for the function table elements.
void RunInForeground(AsyncCompileJob* job) override { void RunInForeground(AsyncCompileJob* job) override {
TRACE_COMPILE("(5) Compile wrappers...\n"); TRACE_COMPILE("(5) Compile wrappers...\n");
// TODO(6792): No longer needed once WebAssembly code is off heap.
CodeSpaceMemoryModificationScope modification_scope(job->isolate_->heap());
// Compile JS->wasm wrappers for exported functions. // Compile JS->wasm wrappers for exported functions.
CompileJsToWasmWrappers(job->isolate_, job->module_object_); CompileJsToWasmWrappers(job->isolate_, job->module_object_);
job->DoSync<FinishModule>(); job->DoSync<FinishModule>();
...@@ -3223,6 +3212,10 @@ void CompileJsToWasmWrappers(Isolate* isolate, ...@@ -3223,6 +3212,10 @@ void CompileJsToWasmWrappers(Isolate* isolate,
Handle<FixedArray> export_wrappers(module_object->export_wrappers(), isolate); Handle<FixedArray> export_wrappers(module_object->export_wrappers(), isolate);
NativeModule* native_module = module_object->native_module(); NativeModule* native_module = module_object->native_module();
const WasmModule* module = native_module->module(); const WasmModule* module = native_module->module();
// TODO(6792): Wrappers below are allocated with {Factory::NewCode}. As an
// optimization we keep the code space unlocked to avoid repeated unlocking
// because many such wrapper are allocated in sequence below.
CodeSpaceMemoryModificationScope modification_scope(isolate->heap());
for (auto exp : module->export_table) { for (auto exp : module->export_table) {
if (exp.kind != kExternalFunction) continue; if (exp.kind != kExternalFunction) continue;
auto& function = module->functions[exp.index]; auto& function = module->functions[exp.index];
......
...@@ -194,11 +194,6 @@ Handle<WasmModuleObject> WasmEngine::ImportNativeModule( ...@@ -194,11 +194,6 @@ Handle<WasmModuleObject> WasmEngine::ImportNativeModule(
size_t code_size = shared_module->committed_code_space(); size_t code_size = shared_module->committed_code_space();
Handle<WasmModuleObject> module_object = WasmModuleObject::New( Handle<WasmModuleObject> module_object = WasmModuleObject::New(
isolate, std::move(shared_module), script, code_size); isolate, std::move(shared_module), script, code_size);
// TODO(6792): Wrappers below might be cloned using {Factory::CopyCode}.
// This requires unlocking the code space here. This should eventually be
// moved into the allocator.
CodeSpaceMemoryModificationScope modification_scope(isolate->heap());
CompileJsToWasmWrappers(isolate, module_object); CompileJsToWasmWrappers(isolate, module_object);
return module_object; return module_object;
} }
......
...@@ -573,10 +573,6 @@ MaybeHandle<WasmModuleObject> DeserializeNativeModule( ...@@ -573,10 +573,6 @@ MaybeHandle<WasmModuleObject> DeserializeNativeModule(
Reader reader(data + kVersionSize); Reader reader(data + kVersionSize);
if (!deserializer.Read(&reader)) return {}; if (!deserializer.Read(&reader)) return {};
// TODO(6792): Wrappers below might be cloned using {Factory::CopyCode}. This
// requires unlocking the code space here. This should eventually be moved
// into the allocator.
CodeSpaceMemoryModificationScope modification_scope(isolate->heap());
CompileJsToWasmWrappers(isolate, module_object); CompileJsToWasmWrappers(isolate, module_object);
// Log the code within the generated module for profiling. // Log the code within the generated module for profiling.
......
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