From 84f14bdeab8f4b795d487e9432a9aadca21389b4 Mon Sep 17 00:00:00 2001 From: Benedikt Meurer Date: Mon, 28 Feb 2022 08:24:03 +0100 Subject: [PATCH] [debug] Remove unnecessary handle scopes in v8::debug::Script. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Nowadays these methods allocate a single handle, so there's no point in having a dedicated handle scope just to close it immediately and escape the single allocated handle. Bug: chromium:1162229 Change-Id: I695d8c5577db43b8974b28bdfa6e0600eb41cce9 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3494156 Commit-Queue: Benedikt Meurer Auto-Submit: Benedikt Meurer Reviewed-by: Simon Zünd Commit-Queue: Simon Zünd Cr-Commit-Position: refs/heads/main@{#79301} --- src/debug/debug-interface.cc | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/src/debug/debug-interface.cc b/src/debug/debug-interface.cc index fde37eba6f..b7dd735d3e 100644 --- a/src/debug/debug-interface.cc +++ b/src/debug/debug-interface.cc @@ -347,37 +347,29 @@ std::vector Script::LineEnds() const { MaybeLocal Script::Name() const { i::Handle script = Utils::OpenHandle(this); i::Isolate* isolate = script->GetIsolate(); - i::HandleScope handle_scope(isolate); i::Handle value(script->name(), isolate); if (!value->IsString()) return MaybeLocal(); - return Utils::ToLocal( - handle_scope.CloseAndEscape(i::Handle::cast(value))); + return Utils::ToLocal(i::Handle::cast(value)); } MaybeLocal Script::SourceURL() const { i::Handle script = Utils::OpenHandle(this); i::Isolate* isolate = script->GetIsolate(); - i::HandleScope handle_scope(isolate); - i::Handle value(script->source_url(), isolate); + i::Handle value(script->source_url(), isolate); if (!value->IsString()) return MaybeLocal(); - return Utils::ToLocal( - handle_scope.CloseAndEscape(i::Handle::cast(value))); + return Utils::ToLocal(i::Handle::cast(value)); } MaybeLocal Script::SourceMappingURL() const { i::Handle script = Utils::OpenHandle(this); i::Isolate* isolate = script->GetIsolate(); - i::HandleScope handle_scope(isolate); i::Handle value(script->source_mapping_url(), isolate); if (!value->IsString()) return MaybeLocal(); - return Utils::ToLocal( - handle_scope.CloseAndEscape(i::Handle::cast(value))); + return Utils::ToLocal(i::Handle::cast(value)); } Maybe Script::ContextId() const { i::Handle script = Utils::OpenHandle(this); - i::Isolate* isolate = script->GetIsolate(); - i::HandleScope handle_scope(isolate); i::Object value = script->context_data(); if (value.IsSmi()) return Just(i::Smi::ToInt(value)); return Nothing(); @@ -386,11 +378,9 @@ Maybe Script::ContextId() const { MaybeLocal Script::Source() const { i::Handle script = Utils::OpenHandle(this); i::Isolate* isolate = script->GetIsolate(); - i::HandleScope handle_scope(isolate); - i::Handle value(script->source(), isolate); + i::Handle value(script->source(), isolate); if (!value->IsString()) return MaybeLocal(); - return Utils::ToLocal( - handle_scope.CloseAndEscape(i::Handle::cast(value))); + return Utils::ToLocal(i::Handle::cast(value)); } #if V8_ENABLE_WEBASSEMBLY