[debug] Remove unnecessary handle scopes in v8::debug::Script.

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 <bmeurer@chromium.org>
Auto-Submit: Benedikt Meurer <bmeurer@chromium.org>
Reviewed-by: Simon Zünd <szuend@chromium.org>
Commit-Queue: Simon Zünd <szuend@chromium.org>
Cr-Commit-Position: refs/heads/main@{#79301}
This commit is contained in:
Benedikt Meurer 2022-02-28 08:24:03 +01:00 committed by V8 LUCI CQ
parent 99ef16000c
commit 84f14bdeab

View File

@ -347,37 +347,29 @@ std::vector<int> Script::LineEnds() const {
MaybeLocal<String> Script::Name() const {
i::Handle<i::Script> script = Utils::OpenHandle(this);
i::Isolate* isolate = script->GetIsolate();
i::HandleScope handle_scope(isolate);
i::Handle<i::Object> value(script->name(), isolate);
if (!value->IsString()) return MaybeLocal<String>();
return Utils::ToLocal(
handle_scope.CloseAndEscape(i::Handle<i::String>::cast(value)));
return Utils::ToLocal(i::Handle<i::String>::cast(value));
}
MaybeLocal<String> Script::SourceURL() const {
i::Handle<i::Script> script = Utils::OpenHandle(this);
i::Isolate* isolate = script->GetIsolate();
i::HandleScope handle_scope(isolate);
i::Handle<i::Object> value(script->source_url(), isolate);
i::Handle<i::PrimitiveHeapObject> value(script->source_url(), isolate);
if (!value->IsString()) return MaybeLocal<String>();
return Utils::ToLocal(
handle_scope.CloseAndEscape(i::Handle<i::String>::cast(value)));
return Utils::ToLocal(i::Handle<i::String>::cast(value));
}
MaybeLocal<String> Script::SourceMappingURL() const {
i::Handle<i::Script> script = Utils::OpenHandle(this);
i::Isolate* isolate = script->GetIsolate();
i::HandleScope handle_scope(isolate);
i::Handle<i::Object> value(script->source_mapping_url(), isolate);
if (!value->IsString()) return MaybeLocal<String>();
return Utils::ToLocal(
handle_scope.CloseAndEscape(i::Handle<i::String>::cast(value)));
return Utils::ToLocal(i::Handle<i::String>::cast(value));
}
Maybe<int> Script::ContextId() const {
i::Handle<i::Script> 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<int>();
@ -386,11 +378,9 @@ Maybe<int> Script::ContextId() const {
MaybeLocal<String> Script::Source() const {
i::Handle<i::Script> script = Utils::OpenHandle(this);
i::Isolate* isolate = script->GetIsolate();
i::HandleScope handle_scope(isolate);
i::Handle<i::Object> value(script->source(), isolate);
i::Handle<i::PrimitiveHeapObject> value(script->source(), isolate);
if (!value->IsString()) return MaybeLocal<String>();
return Utils::ToLocal(
handle_scope.CloseAndEscape(i::Handle<i::String>::cast(value)));
return Utils::ToLocal(i::Handle<i::String>::cast(value));
}
#if V8_ENABLE_WEBASSEMBLY