Skip to content

Commit 74a663b

Browse files
camillobruniCommit Bot
authored andcommitted
[runtime] Deduplicate the name between SFI and ScopeInfo
With this CL the name of an SFI is either stored directly on the SFI itself (for uncompiled ones) or on the related ScopeInfo if present. - Combine scope_info and name field on SFI into name_or_scope_info field - Change the name of a couple of SFI accessors: name => Name, has_shared_name => HasSharedName, set_name => SetName - Add Runtime::kGetFunctionName due to more complex SFI name accessing Bug: v8:7066 Cq-Include-Trybots: luci.chromium.try:linux_chromium_rel_ng Change-Id: Idcce158446c9447b92d9a15125d086952c6e0824 Reviewed-on: https://chromium-review.googlesource.com/964201 Commit-Queue: Camillo Bruni <[email protected]> Reviewed-by: Andreas Haas <[email protected]> Reviewed-by: Leszek Swirski <[email protected]> Reviewed-by: Jakob Gruber <[email protected]> Reviewed-by: Marja Hölttä <[email protected]> Cr-Commit-Position: refs/heads/master@{#52001}
1 parent 9f015e7 commit 74a663b

32 files changed

Lines changed: 173 additions & 135 deletions

src/accessors.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -628,7 +628,7 @@ void Accessors::ScriptEvalFromFunctionNameGetter(
628628
if (script->has_eval_from_shared()) {
629629
Handle<SharedFunctionInfo> shared(script->eval_from_shared());
630630
// Find the name of the function calling eval.
631-
result = Handle<Object>(shared->name(), isolate);
631+
result = Handle<Object>(shared->Name(), isolate);
632632
}
633633
info.GetReturnValue().Set(Utils::ToLocal(result));
634634
}

src/api-natives.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -626,7 +626,7 @@ Handle<JSFunction> ApiNatives::CreateApiFunction(
626626
FunctionTemplateInfo::GetOrCreateSharedFunctionInfo(isolate, obj,
627627
maybe_name);
628628
// To simplify things, API functions always have shared name.
629-
DCHECK(shared->has_shared_name());
629+
DCHECK(shared->HasSharedName());
630630

631631
Handle<JSFunction> result =
632632
isolate->factory()->NewFunctionFromSharedFunctionInfo(

src/api-natives.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class ApiNatives {
4141
static Handle<JSFunction> CreateApiFunction(
4242
Isolate* isolate, Handle<FunctionTemplateInfo> obj,
4343
Handle<Object> prototype, ApiInstanceType instance_type,
44-
MaybeHandle<Name> maybe_name = MaybeHandle<Name>());
44+
MaybeHandle<Name> name = MaybeHandle<Name>());
4545

4646
static void AddDataProperty(Isolate* isolate, Handle<TemplateInfo> info,
4747
Handle<Name> name, Handle<Object> value,

src/api.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5113,7 +5113,7 @@ void Function::SetName(v8::Local<v8::String> name) {
51135113
auto self = Utils::OpenHandle(this);
51145114
if (!self->IsJSFunction()) return;
51155115
auto func = i::Handle<i::JSFunction>::cast(self);
5116-
func->shared()->set_name(*Utils::OpenHandle(*name));
5116+
func->shared()->SetName(*Utils::OpenHandle(*name));
51175117
}
51185118

51195119

@@ -5130,7 +5130,7 @@ Local<Value> Function::GetName() const {
51305130
}
51315131
if (self->IsJSFunction()) {
51325132
auto func = i::Handle<i::JSFunction>::cast(self);
5133-
return Utils::ToLocal(handle(func->shared()->name(), isolate));
5133+
return Utils::ToLocal(handle(func->shared()->Name(), isolate));
51345134
}
51355135
return ToApiHandle<Primitive>(isolate->factory()->undefined_value());
51365136
}

src/bootstrapper.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4214,7 +4214,7 @@ void Genesis::InitializeGlobal_harmony_string_trimming() {
42144214
.ToHandleChecked());
42154215
JSObject::AddProperty(string_prototype, trim_start_name, trim_left_fun,
42164216
DONT_ENUM);
4217-
trim_left_fun->shared()->set_name(*trim_start_name);
4217+
trim_left_fun->shared()->SetName(*trim_start_name);
42184218
}
42194219

42204220
{
@@ -4226,7 +4226,7 @@ void Genesis::InitializeGlobal_harmony_string_trimming() {
42264226
.ToHandleChecked());
42274227
JSObject::AddProperty(string_prototype, trim_end_name, trim_right_fun,
42284228
DONT_ENUM);
4229-
trim_right_fun->shared()->set_name(*trim_end_name);
4229+
trim_right_fun->shared()->SetName(*trim_end_name);
42304230
}
42314231
}
42324232

src/builtins/builtins-arraybuffer.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ BUILTIN(ArrayBufferConstructor) {
6060
if (args.new_target()->IsUndefined(isolate)) { // [[Call]]
6161
THROW_NEW_ERROR_RETURN_FAILURE(
6262
isolate, NewTypeError(MessageTemplate::kConstructorNotFunction,
63-
handle(target->shared()->name(), isolate)));
63+
handle(target->shared()->Name(), isolate)));
6464
} else { // [[Construct]]
6565
Handle<JSReceiver> new_target = Handle<JSReceiver>::cast(args.new_target());
6666
Handle<Object> length = args.atOrUndefined(isolate, 1);

src/builtins/builtins-typedarray-gen.cc

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -746,9 +746,7 @@ TF_BUILTIN(TypedArrayConstructor, TypedArrayBuiltinsAssembler) {
746746

747747
BIND(&throwtypeerror);
748748
{
749-
Node* shared =
750-
LoadObjectField(target, JSFunction::kSharedFunctionInfoOffset);
751-
Node* name = LoadObjectField(shared, SharedFunctionInfo::kNameOffset);
749+
Node* name = CallRuntime(Runtime::kGetFunctionName, context, target);
752750
ThrowTypeError(context, MessageTemplate::kConstructorNotFunction, name);
753751
}
754752
}

src/compiler-dispatcher/unoptimized-compile-job.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ void UnoptimizedCompileJob::PrepareOnMainThread(Isolate* isolate) {
212212
}
213213
parser_->DeserializeScopeChain(parse_info_.get(), outer_scope_info);
214214

215-
Handle<String> name(shared_->name());
215+
Handle<String> name(shared_->Name());
216216
parse_info_->set_function_name(
217217
parse_info_->ast_value_factory()->GetString(name));
218218
set_status(Status::kPrepared);

src/compiler.cc

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -295,15 +295,6 @@ void InstallUnoptimizedCode(CompilationInfo* compilation_info,
295295
shared->set_scope_info(*scope_info);
296296
Scope* outer_scope = compilation_info->scope()->GetOuterScopeWithContext();
297297
if (outer_scope) shared->set_outer_scope_info(*outer_scope->scope_info());
298-
if (scope_info->HasFunctionName()) {
299-
if (scope_info->HasPendingFunctionName()) {
300-
scope_info->SetPendingFunctionName(shared->name());
301-
} else {
302-
DCHECK_EQ(shared->name(), scope_info->FunctionName());
303-
}
304-
} else {
305-
DCHECK_EQ(shared->name(), isolate->heap()->empty_string());
306-
}
307298

308299
DCHECK(!compilation_info->code().is_null());
309300
shared->set_code(*compilation_info->code());

src/compiler/basic-block-instrumentor.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ BasicBlockProfiler::Data* BasicBlockInstrumentor::Instrument(
5757
// Set the function name.
5858
if (info->has_shared_info()) {
5959
std::ostringstream os;
60-
info->shared_info()->name()->PrintUC16(os);
60+
info->shared_info()->Name()->PrintUC16(os);
6161
data->SetFunctionName(&os);
6262
}
6363
// Capture the schedule string before instrumentation.

0 commit comments

Comments
 (0)