Commit 170418b2 authored by Peter Marshall's avatar Peter Marshall Committed by Commit Bot

[cleanup] Remove GetFunctionName from StringsStorage

This distinction doesn't matter, they aren't treated any differently to
other strings.

Change-Id: I524a0a1c4089284af97aa507afc5bd5985fe6631
Reviewed-on: https://chromium-review.googlesource.com/1071628Reviewed-by: 's avatarCamillo Bruni <cbruni@chromium.org>
Commit-Queue: Peter Marshall <petermarshall@chromium.org>
Cr-Commit-Position: refs/heads/master@{#53329}
parent 71e4c573
...@@ -249,7 +249,7 @@ unsigned AllocationTracker::AddFunctionInfo(SharedFunctionInfo* shared, ...@@ -249,7 +249,7 @@ unsigned AllocationTracker::AddFunctionInfo(SharedFunctionInfo* shared,
reinterpret_cast<void*>(id), SnapshotObjectIdHash(id)); reinterpret_cast<void*>(id), SnapshotObjectIdHash(id));
if (entry->value == nullptr) { if (entry->value == nullptr) {
FunctionInfo* info = new FunctionInfo(); FunctionInfo* info = new FunctionInfo();
info->name = names_->GetFunctionName(shared->DebugName()); info->name = names_->GetName(shared->DebugName());
info->function_id = id; info->function_id = id;
if (shared->script()->IsScript()) { if (shared->script()->IsScript()) {
Script* script = Script::cast(shared->script()); Script* script = Script::cast(shared->script());
......
...@@ -37,10 +37,10 @@ void ProfilerListener::CodeCreateEvent(CodeEventListener::LogEventsAndTags tag, ...@@ -37,10 +37,10 @@ void ProfilerListener::CodeCreateEvent(CodeEventListener::LogEventsAndTags tag,
CodeEventsContainer evt_rec(CodeEventRecord::CODE_CREATION); CodeEventsContainer evt_rec(CodeEventRecord::CODE_CREATION);
CodeCreateEventRecord* rec = &evt_rec.CodeCreateEventRecord_; CodeCreateEventRecord* rec = &evt_rec.CodeCreateEventRecord_;
rec->start = code->address(); rec->start = code->address();
rec->entry = NewCodeEntry( rec->entry = NewCodeEntry(tag, GetName(name), CodeEntry::kEmptyResourceName,
tag, GetFunctionName(name), CodeEntry::kEmptyResourceName, CpuProfileNode::kNoLineNumberInfo,
CpuProfileNode::kNoLineNumberInfo, CpuProfileNode::kNoColumnNumberInfo, CpuProfileNode::kNoColumnNumberInfo, nullptr,
nullptr, code->InstructionStart()); code->InstructionStart());
RecordInliningInfo(rec->entry, code); RecordInliningInfo(rec->entry, code);
rec->size = code->ExecutableSize(); rec->size = code->ExecutableSize();
DispatchCodeEvent(evt_rec); DispatchCodeEvent(evt_rec);
...@@ -51,10 +51,10 @@ void ProfilerListener::CodeCreateEvent(CodeEventListener::LogEventsAndTags tag, ...@@ -51,10 +51,10 @@ void ProfilerListener::CodeCreateEvent(CodeEventListener::LogEventsAndTags tag,
CodeEventsContainer evt_rec(CodeEventRecord::CODE_CREATION); CodeEventsContainer evt_rec(CodeEventRecord::CODE_CREATION);
CodeCreateEventRecord* rec = &evt_rec.CodeCreateEventRecord_; CodeCreateEventRecord* rec = &evt_rec.CodeCreateEventRecord_;
rec->start = code->address(); rec->start = code->address();
rec->entry = NewCodeEntry( rec->entry = NewCodeEntry(tag, GetName(name), CodeEntry::kEmptyResourceName,
tag, GetFunctionName(name), CodeEntry::kEmptyResourceName, CpuProfileNode::kNoLineNumberInfo,
CpuProfileNode::kNoLineNumberInfo, CpuProfileNode::kNoColumnNumberInfo, CpuProfileNode::kNoColumnNumberInfo, nullptr,
nullptr, code->InstructionStart()); code->InstructionStart());
RecordInliningInfo(rec->entry, code); RecordInliningInfo(rec->entry, code);
rec->size = code->ExecutableSize(); rec->size = code->ExecutableSize();
DispatchCodeEvent(evt_rec); DispatchCodeEvent(evt_rec);
...@@ -67,7 +67,7 @@ void ProfilerListener::CodeCreateEvent(CodeEventListener::LogEventsAndTags tag, ...@@ -67,7 +67,7 @@ void ProfilerListener::CodeCreateEvent(CodeEventListener::LogEventsAndTags tag,
CodeEventsContainer evt_rec(CodeEventRecord::CODE_CREATION); CodeEventsContainer evt_rec(CodeEventRecord::CODE_CREATION);
CodeCreateEventRecord* rec = &evt_rec.CodeCreateEventRecord_; CodeCreateEventRecord* rec = &evt_rec.CodeCreateEventRecord_;
rec->start = code->address(); rec->start = code->address();
rec->entry = NewCodeEntry(tag, GetFunctionName(shared->DebugName()), rec->entry = NewCodeEntry(tag, GetName(shared->DebugName()),
GetName(InferScriptName(script_name, shared)), GetName(InferScriptName(script_name, shared)),
CpuProfileNode::kNoLineNumberInfo, CpuProfileNode::kNoLineNumberInfo,
CpuProfileNode::kNoColumnNumberInfo, nullptr, CpuProfileNode::kNoColumnNumberInfo, nullptr,
...@@ -102,7 +102,7 @@ void ProfilerListener::CodeCreateEvent(CodeEventListener::LogEventsAndTags tag, ...@@ -102,7 +102,7 @@ void ProfilerListener::CodeCreateEvent(CodeEventListener::LogEventsAndTags tag,
} }
} }
rec->entry = rec->entry =
NewCodeEntry(tag, GetFunctionName(shared->DebugName()), NewCodeEntry(tag, GetName(shared->DebugName()),
GetName(InferScriptName(script_name, shared)), line, column, GetName(InferScriptName(script_name, shared)), line, column,
std::move(line_table), abstract_code->InstructionStart()); std::move(line_table), abstract_code->InstructionStart());
RecordInliningInfo(rec->entry, abstract_code); RecordInliningInfo(rec->entry, abstract_code);
...@@ -119,7 +119,7 @@ void ProfilerListener::CodeCreateEvent(CodeEventListener::LogEventsAndTags tag, ...@@ -119,7 +119,7 @@ void ProfilerListener::CodeCreateEvent(CodeEventListener::LogEventsAndTags tag,
CodeCreateEventRecord* rec = &evt_rec.CodeCreateEventRecord_; CodeCreateEventRecord* rec = &evt_rec.CodeCreateEventRecord_;
rec->start = code->instruction_start(); rec->start = code->instruction_start();
rec->entry = NewCodeEntry( rec->entry = NewCodeEntry(
tag, GetFunctionName(name.start()), CodeEntry::kWasmResourceNamePrefix, tag, GetName(name.start()), CodeEntry::kWasmResourceNamePrefix,
CpuProfileNode::kNoLineNumberInfo, CpuProfileNode::kNoColumnNumberInfo, CpuProfileNode::kNoLineNumberInfo, CpuProfileNode::kNoColumnNumberInfo,
nullptr, code->instruction_start()); nullptr, code->instruction_start());
rec->size = code->instructions().length(); rec->size = code->instructions().length();
...@@ -237,7 +237,7 @@ void ProfilerListener::RecordInliningInfo(CodeEntry* entry, ...@@ -237,7 +237,7 @@ void ProfilerListener::RecordInliningInfo(CodeEntry* entry,
: CodeEntry::kEmptyResourceName; : CodeEntry::kEmptyResourceName;
CodeEntry* inline_entry = CodeEntry* inline_entry =
new CodeEntry(entry->tag(), GetFunctionName(shared_info->DebugName()), new CodeEntry(entry->tag(), GetName(shared_info->DebugName()),
resource_name, CpuProfileNode::kNoLineNumberInfo, resource_name, CpuProfileNode::kNoLineNumberInfo,
CpuProfileNode::kNoColumnNumberInfo, nullptr, CpuProfileNode::kNoColumnNumberInfo, nullptr,
code->InstructionStart()); code->InstructionStart());
......
...@@ -67,15 +67,12 @@ class ProfilerListener : public CodeEventListener { ...@@ -67,15 +67,12 @@ class ProfilerListener : public CodeEventListener {
const char* GetName(int args_count) { const char* GetName(int args_count) {
return function_and_resource_names_.GetName(args_count); return function_and_resource_names_.GetName(args_count);
} }
const char* GetName(const char* name) {
return function_and_resource_names_.GetCopy(name);
}
const char* GetConsName(const char* prefix, Name* name) { const char* GetConsName(const char* prefix, Name* name) {
return function_and_resource_names_.GetConsName(prefix, name); return function_and_resource_names_.GetConsName(prefix, name);
} }
const char* GetFunctionName(Name* name) {
return function_and_resource_names_.GetFunctionName(name);
}
const char* GetFunctionName(const char* name) {
return function_and_resource_names_.GetFunctionName(name);
}
private: private:
void RecordInliningInfo(CodeEntry* entry, AbstractCode* abstract_code); void RecordInliningInfo(CodeEntry* entry, AbstractCode* abstract_code);
......
...@@ -203,7 +203,7 @@ SamplingHeapProfiler::AllocationNode* SamplingHeapProfiler::AddStack() { ...@@ -203,7 +203,7 @@ SamplingHeapProfiler::AllocationNode* SamplingHeapProfiler::AddStack() {
// the first element in the list. // the first element in the list.
for (auto it = stack.rbegin(); it != stack.rend(); ++it) { for (auto it = stack.rbegin(); it != stack.rend(); ++it) {
SharedFunctionInfo* shared = *it; SharedFunctionInfo* shared = *it;
const char* name = this->names()->GetFunctionName(shared->DebugName()); const char* name = this->names()->GetName(shared->DebugName());
int script_id = v8::UnboundScript::kNoScriptId; int script_id = v8::UnboundScript::kNoScriptId;
if (shared->script()->IsScript()) { if (shared->script()->IsScript()) {
Script* script = Script::cast(shared->script()); Script* script = Script::cast(shared->script());
......
...@@ -107,14 +107,6 @@ const char* StringsStorage::GetConsName(const char* prefix, Name* name) { ...@@ -107,14 +107,6 @@ const char* StringsStorage::GetConsName(const char* prefix, Name* name) {
return ""; return "";
} }
const char* StringsStorage::GetFunctionName(Name* name) {
return GetName(name);
}
const char* StringsStorage::GetFunctionName(const char* name) {
return GetCopy(name);
}
base::HashMap::Entry* StringsStorage::GetEntry(const char* str, int len) { base::HashMap::Entry* StringsStorage::GetEntry(const char* str, int len) {
uint32_t hash = StringHasher::HashSequentialString(str, len, hash_seed_); uint32_t hash = StringHasher::HashSequentialString(str, len, hash_seed_);
return names_.LookupOrInsert(const_cast<char*>(str), hash); return names_.LookupOrInsert(const_cast<char*>(str), hash);
......
...@@ -35,10 +35,6 @@ class V8_EXPORT_PRIVATE StringsStorage { ...@@ -35,10 +35,6 @@ class V8_EXPORT_PRIVATE StringsStorage {
// Appends string resulting from name to prefix, then returns the stored // Appends string resulting from name to prefix, then returns the stored
// result. // result.
const char* GetConsName(const char* prefix, Name* name); const char* GetConsName(const char* prefix, Name* name);
// Does exactly the same thing as GetName(Name* name).
const char* GetFunctionName(Name* name);
// Does exactly the same thing as GetCopy(const char* name).
const char* GetFunctionName(const char* name);
private: private:
static bool StringsMatch(void* key1, void* key2); static bool StringsMatch(void* key1, void* key2);
......
...@@ -80,28 +80,6 @@ TEST_F(StringsStorageWithIsolate, GetNameFromInt) { ...@@ -80,28 +80,6 @@ TEST_F(StringsStorageWithIsolate, GetNameFromInt) {
CHECK(StringEq(str_negative_int, stored_str)); CHECK(StringEq(str_negative_int, stored_str));
} }
TEST_F(StringsStorageWithIsolate, GetFunctionNameFromString) {
StringsStorage storage(isolate()->heap()->HashSeed());
Handle<String> str = isolate()->factory()->NewStringFromAsciiChecked("xy");
const char* stored_str = storage.GetFunctionName(*str);
CHECK(StringEq("xy", stored_str));
// Check that GetName and GetFunctionName use the same storage.
const char* stored_str_twice = storage.GetName(*str);
CHECK_EQ(stored_str, stored_str_twice);
}
TEST_F(StringsStorageWithIsolate, GetFunctionNameFromCString) {
StringsStorage storage(isolate()->heap()->HashSeed());
const char* xy = "xy";
const char* stored_str = storage.GetFunctionName("xy");
CHECK(StringEq("xy", stored_str));
// Check that the string is copied.
CHECK_NE(xy, stored_str);
}
TEST_F(StringsStorageWithIsolate, Format) { TEST_F(StringsStorageWithIsolate, Format) {
StringsStorage storage(isolate()->heap()->HashSeed()); StringsStorage storage(isolate()->heap()->HashSeed());
......
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