Commit e8587606 authored by Clemens Hammacher's avatar Clemens Hammacher Committed by Commit Bot

Revert "[wasm] Turn deferred handles into global handles"

This reverts commit 8a914846.

Reason for revert: Seems to cause layout test failures: https://ci.chromium.org/p/v8/builders/luci.v8.ci/V8-Blink%2520Mac/16246

Original change's description:
> [wasm] Turn deferred handles into global handles
> 
> Each instance of {DeferredHandles} only stores a single handle anyway,
> so turning them into global handles saves memory.
> 
> R=​ahaas@chromium.org
> 
> Bug: v8:7921, v8:8423
> Change-Id: I75e0cc6ecb6d0337f1695e6bfd4b5fdcb8a2039c
> Reviewed-on: https://chromium-review.googlesource.com/c/1402715
> Commit-Queue: Clemens Hammacher <clemensh@chromium.org>
> Reviewed-by: Andreas Haas <ahaas@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#59331}

TBR=ahaas@chromium.org,clemensh@chromium.org

Change-Id: I8996fd22702b5dd0485e59b54989788596293a1f
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: v8:7921, v8:8423
Reviewed-on: https://chromium-review.googlesource.com/c/1451888Reviewed-by: 's avatarClemens Hammacher <clemensh@chromium.org>
Commit-Queue: Clemens Hammacher <clemensh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#59342}
parent ce6b350a
......@@ -788,9 +788,11 @@ AsyncCompileJob::AsyncCompileJob(
v8::Isolate* v8_isolate = reinterpret_cast<v8::Isolate*>(isolate);
v8::Platform* platform = V8::GetCurrentPlatform();
foreground_task_runner_ = platform->GetForegroundTaskRunner(v8_isolate);
native_context_ =
isolate->global_handles()->Create(context->native_context());
// The handle for the context must be deferred.
DeferredHandleScope deferred(isolate);
native_context_ = Handle<Context>(context->native_context(), isolate);
DCHECK(native_context_->IsNativeContext());
deferred_handles_.push_back(deferred.Detach());
}
void AsyncCompileJob::Start() {
......@@ -862,10 +864,7 @@ AsyncCompileJob::~AsyncCompileJob() {
// https://crbug.com/888170.
if (stream_) stream_->NotifyCompilationEnded();
CancelPendingForegroundTask();
isolate_->global_handles()->Destroy(native_context_.location());
if (!module_object_.is_null()) {
isolate_->global_handles()->Destroy(module_object_.location());
}
for (auto d : deferred_handles_) delete d;
}
void AsyncCompileJob::CreateNativeModule(
......@@ -905,10 +904,14 @@ void AsyncCompileJob::PrepareRuntimeObjects() {
size_t code_size_estimate =
wasm::WasmCodeManager::EstimateNativeModuleCodeSize(module);
Handle<WasmModuleObject> module_object = WasmModuleObject::New(
isolate_, native_module_, script, code_size_estimate);
module_object_ = WasmModuleObject::New(isolate_, native_module_, script,
code_size_estimate);
module_object_ = isolate_->global_handles()->Create(*module_object);
{
DeferredHandleScope deferred(isolate_);
module_object_ = handle(*module_object_, isolate_);
deferred_handles_.push_back(deferred.Detach());
}
}
// This function assumes that it is executed in a HandleScope, and that a
......@@ -1449,8 +1452,12 @@ bool AsyncStreamingProcessor::Deserialize(Vector<const uint8_t> module_bytes,
DeserializeNativeModule(job_->isolate_, module_bytes, wire_bytes);
if (result.is_null()) return false;
job_->module_object_ =
job_->isolate_->global_handles()->Create(*result.ToHandleChecked());
job_->module_object_ = result.ToHandleChecked();
{
DeferredHandleScope deferred(job_->isolate_);
job_->module_object_ = handle(*job_->module_object_, job_->isolate_);
job_->deferred_handles_.push_back(deferred.Detach());
}
job_->native_module_ = job_->module_object_->shared_native_module();
auto owned_wire_bytes = OwnedVector<uint8_t>::Of(wire_bytes);
job_->wire_bytes_ = ModuleWireBytes(owned_wire_bytes.as_vector());
......
......@@ -159,6 +159,7 @@ class AsyncCompileJob {
Handle<Context> native_context_;
const std::shared_ptr<CompilationResultResolver> resolver_;
std::vector<DeferredHandles*> deferred_handles_;
Handle<WasmModuleObject> module_object_;
std::shared_ptr<NativeModule> native_module_;
......
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