Commit c5b4810d authored by Leszek Swirski's avatar Leszek Swirski Committed by Commit Bot

[object-stats] Avoid mislabelling script source data

The existing script source tracking was racing with general external
script resource tracking, resulting in heap-order-dependent labels.

Bug: v8:8218
Change-Id: Ib09c28ca1e13768b328ecef7f8ee3ea5131ba12e
Reviewed-on: https://chromium-review.googlesource.com/1238927Reviewed-by: 's avatarMichael Lippautz <mlippautz@chromium.org>
Commit-Queue: Leszek Swirski <leszeks@chromium.org>
Cr-Commit-Position: refs/heads/master@{#56191}
parent 738deb5d
......@@ -678,8 +678,6 @@ void ObjectStatsCollectorImpl::CollectStatistics(
RecordVirtualContext(Context::cast(obj));
} else if (obj->IsScript()) {
RecordVirtualScriptDetails(Script::cast(obj));
} else if (obj->IsExternalString()) {
RecordVirtualExternalStringDetails(ExternalString::cast(obj));
} else if (obj->IsArrayBoilerplateDescription()) {
RecordVirtualArrayBoilerplateDescription(
ArrayBoilerplateDescription::cast(obj));
......@@ -689,6 +687,11 @@ void ObjectStatsCollectorImpl::CollectStatistics(
}
break;
case kPhase2:
if (obj->IsExternalString()) {
// This has to be in Phase2 to avoid conflicting with recording Script
// sources. We still want to run RecordObjectStats after though.
RecordVirtualExternalStringDetails(ExternalString::cast(obj));
}
RecordObjectStats(obj, map->instance_type(), obj->Size());
if (collect_field_stats == CollectFieldStats::kYes) {
field_stats_collector_.RecordStats(obj);
......@@ -809,7 +812,7 @@ void ObjectStatsCollectorImpl::RecordVirtualScriptDetails(Script* script) {
} else if (raw_source->IsString()) {
String* source = String::cast(raw_source);
RecordSimpleVirtualObjectStats(
script, HeapObject::cast(raw_source),
script, source,
source->IsOneByteRepresentation()
? ObjectStats::SCRIPT_SOURCE_NON_EXTERNAL_ONE_BYTE_TYPE
: ObjectStats::SCRIPT_SOURCE_NON_EXTERNAL_TWO_BYTE_TYPE);
......
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