Reland "[wasm] Turn deferred handles into global handles"
This is a reland of 8a91484619
.
No modifications, this CL was not the culprit.
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}
Bug: v8:7921, v8:8423
Tbr: ahaas@chromium.org
Change-Id: I9111eb6405c2624779b9eaa65353ab5f438e9daf
Reviewed-on: https://chromium-review.googlesource.com/c/1451930
Reviewed-by: Clemens Hammacher <clemensh@chromium.org>
Commit-Queue: Clemens Hammacher <clemensh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#59363}
This commit is contained in:
parent
97068800fe
commit
61a758c11f
@ -786,11 +786,9 @@ AsyncCompileJob::AsyncCompileJob(
|
||||
v8::Isolate* v8_isolate = reinterpret_cast<v8::Isolate*>(isolate);
|
||||
v8::Platform* platform = V8::GetCurrentPlatform();
|
||||
foreground_task_runner_ = platform->GetForegroundTaskRunner(v8_isolate);
|
||||
// The handle for the context must be deferred.
|
||||
DeferredHandleScope deferred(isolate);
|
||||
native_context_ = Handle<Context>(context->native_context(), isolate);
|
||||
native_context_ =
|
||||
isolate->global_handles()->Create(context->native_context());
|
||||
DCHECK(native_context_->IsNativeContext());
|
||||
deferred_handles_.push_back(deferred.Detach());
|
||||
}
|
||||
|
||||
void AsyncCompileJob::Start() {
|
||||
@ -862,7 +860,10 @@ AsyncCompileJob::~AsyncCompileJob() {
|
||||
// https://crbug.com/888170.
|
||||
if (stream_) stream_->NotifyCompilationEnded();
|
||||
CancelPendingForegroundTask();
|
||||
for (auto d : deferred_handles_) delete d;
|
||||
isolate_->global_handles()->Destroy(native_context_.location());
|
||||
if (!module_object_.is_null()) {
|
||||
isolate_->global_handles()->Destroy(module_object_.location());
|
||||
}
|
||||
}
|
||||
|
||||
void AsyncCompileJob::CreateNativeModule(
|
||||
@ -902,14 +903,10 @@ void AsyncCompileJob::PrepareRuntimeObjects() {
|
||||
|
||||
size_t code_size_estimate =
|
||||
wasm::WasmCodeManager::EstimateNativeModuleCodeSize(module);
|
||||
module_object_ = WasmModuleObject::New(isolate_, native_module_, script,
|
||||
code_size_estimate);
|
||||
Handle<WasmModuleObject> module_object = WasmModuleObject::New(
|
||||
isolate_, native_module_, script, code_size_estimate);
|
||||
|
||||
{
|
||||
DeferredHandleScope deferred(isolate_);
|
||||
module_object_ = handle(*module_object_, isolate_);
|
||||
deferred_handles_.push_back(deferred.Detach());
|
||||
}
|
||||
module_object_ = isolate_->global_handles()->Create(*module_object);
|
||||
}
|
||||
|
||||
// This function assumes that it is executed in a HandleScope, and that a
|
||||
@ -1450,12 +1447,8 @@ 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_ = result.ToHandleChecked();
|
||||
{
|
||||
DeferredHandleScope deferred(job_->isolate_);
|
||||
job_->module_object_ = handle(*job_->module_object_, job_->isolate_);
|
||||
job_->deferred_handles_.push_back(deferred.Detach());
|
||||
}
|
||||
job_->module_object_ =
|
||||
job_->isolate_->global_handles()->Create(*result.ToHandleChecked());
|
||||
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,7 +159,6 @@ 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_;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user