Skip to content

Commit 427b679

Browse files
committed
deps: V8: cherry-pick 8e374caa66ce
Original commit message: [profiler] Internalize string script names directly Avoid converting script names to UTF-8 by internalizing String names directly. Keep the existing conversion for Symbol names and use the canonical empty string for unnamed scripts. This improved profile retrieval performance by ~30% in local benchmarks. Change-Id: I5eb6e8fa79517dc4902ddc1f26d75a9dd228ef39 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/8449311 Reviewed-by: Camillo Bruni <cbruni@chromium.org> Reviewed-by: Dominik Inführ <dinfuehr@chromium.org> Commit-Queue: Dominik Inführ <dinfuehr@chromium.org> Cr-Commit-Position: refs/heads/main@{#110089} Refs: v8/v8@8e374ca
1 parent c56cb09 commit 427b679

2 files changed

Lines changed: 10 additions & 5 deletions

File tree

‎common.gypi‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444

4545
# Reset this number to 0 on major V8 upgrades.
4646
# Increment by one for each non-official patch applied to deps/v8.
47-
'v8_embedder_string': '-node.22',
47+
'v8_embedder_string': '-node.23',
4848

4949
##### V8 defaults for Node.js #####
5050

‎deps/v8/src/profiler/sampling-heap-profiler.cc‎

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ v8::AllocationProfile::Node* SamplingHeapProfiler::TranslateAllocationNode(
243243
// a GC kicks in during the tree retrieval.
244244
node->pinned_ = true;
245245
Local<v8::String> script_name =
246-
ToApiHandle<v8::String>(isolate_->factory()->InternalizeUtf8String(""));
246+
ToApiHandle<v8::String>(isolate_->factory()->empty_string());
247247
int line = v8::AllocationProfile::kNoLineNumberInfo;
248248
int column = v8::AllocationProfile::kNoColumnNumberInfo;
249249
std::vector<v8::AllocationProfile::Allocation> allocations;
@@ -252,10 +252,15 @@ v8::AllocationProfile::Node* SamplingHeapProfiler::TranslateAllocationNode(
252252
auto script_iterator = scripts.find(node->script_id_);
253253
if (script_iterator != scripts.end()) {
254254
DirectHandle<Script> script = script_iterator->second;
255-
if (IsName(script->name())) {
256-
Tagged<Name> name = Cast<Name>(script->name());
255+
if (IsString(script->name())) {
256+
script_name =
257+
ToApiHandle<v8::String>(isolate_->factory()->InternalizeString(
258+
direct_handle(Cast<String>(script->name()), isolate_)));
259+
} else if (IsSymbol(script->name())) {
260+
Tagged<Symbol> symbol = Cast<Symbol>(script->name());
257261
script_name = ToApiHandle<v8::String>(
258-
isolate_->factory()->InternalizeUtf8String(names_->GetName(name)));
262+
isolate_->factory()->InternalizeUtf8String(
263+
names_->GetName(symbol)));
259264
}
260265
Script::PositionInfo pos_info;
261266
Script::GetPositionInfo(script, node->script_position_, &pos_info);

0 commit comments

Comments
 (0)