[cpu-profiler] Fix string length calculation for GetConsName
Currently, GetConsName incorrectly includes the null terminator as part of the length used in the string's hash. Exclude this to be consistent with GetCopy, GetName, etc. and permit coalescing. Bug: v8:0 Change-Id: I1e8a4eb7055637f3ed178014725b44e84d7788b6 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2578192 Reviewed-by: Peter Marshall <petermarshall@chromium.org> Commit-Queue: Andrew Comminos <acomminos@fb.com> Cr-Commit-Position: refs/heads/master@{#71667}
This commit is contained in:
parent
0b7769e393
commit
678afa3c04
@ -101,7 +101,7 @@ const char* StringsStorage::GetConsName(const char* prefix, Name name) {
|
||||
char* cons_result = NewArray<char>(cons_length);
|
||||
snprintf(cons_result, cons_length, "%s%s", prefix, data.get());
|
||||
|
||||
return AddOrDisposeString(cons_result, cons_length);
|
||||
return AddOrDisposeString(cons_result, cons_length - 1);
|
||||
} else if (name.IsSymbol()) {
|
||||
return "<symbol>";
|
||||
}
|
||||
|
@ -157,5 +157,17 @@ TEST_F(StringsStorageWithIsolate, InvalidRelease) {
|
||||
#endif // DEBUG
|
||||
}
|
||||
|
||||
TEST_F(StringsStorageWithIsolate, CopyAndConsShareStorage) {
|
||||
StringsStorage storage;
|
||||
|
||||
Handle<String> str = isolate()->factory()->NewStringFromAsciiChecked("foo");
|
||||
|
||||
const char* copy_str = storage.GetCopy("get foo");
|
||||
const char* cons_str = storage.GetConsName("get ", *str);
|
||||
|
||||
CHECK_EQ(storage.GetStringCountForTesting(), 1);
|
||||
CHECK_EQ(copy_str, cons_str);
|
||||
}
|
||||
|
||||
} // namespace internal
|
||||
} // namespace v8
|
||||
|
Loading…
Reference in New Issue
Block a user