Commit dceff4d9 authored by Clemens Backes's avatar Clemens Backes Committed by V8 LUCI CQ

[d8] Read flag values before disposing V8

{V8::Dispose} calls {FlagList::ResetAllFlags()}, which resets all flag
values. Thus the values of FLAG_dump_counters and FLAG_dump_counters_nvp
need to be read before disposing v8.

Drive-by: Two unrelated code simplifications / unifications.

R=mlippautz@chromium.org

Bug: chromium:1275117
Change-Id: Ie2bbe0c844efaf3ed50a62533c5ec08b6b423379
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3310881Reviewed-by: 's avatarMichael Lippautz <mlippautz@chromium.org>
Commit-Queue: Clemens Backes <clemensb@chromium.org>
Cr-Commit-Position: refs/heads/main@{#78199}
parent 55a26dc4
......@@ -2785,7 +2785,7 @@ Counter* Shell::GetCounter(const char* name, bool is_histogram) {
}
}
if (!counter) {
if (counter == nullptr) {
base::SharedMutexGuard<base::kExclusive> mutex_guard(&counter_mutex_);
counter = (*counter_map_)[name];
......@@ -2807,12 +2807,7 @@ Counter* Shell::GetCounter(const char* name, bool is_histogram) {
int* Shell::LookupCounter(const char* name) {
Counter* counter = GetCounter(name, false);
if (counter != nullptr) {
return counter->ptr();
} else {
return nullptr;
}
return counter ? counter->ptr() : nullptr;
}
void* Shell::CreateHistogram(const char* name, int min, int max,
......@@ -3365,18 +3360,22 @@ void Shell::OnExit(v8::Isolate* isolate, bool dispose) {
i::Isolate::Delete(reinterpret_cast<i::Isolate*>(shared_isolate));
}
// {V8::Dispose} resets flags, thus get the flag values before disposing.
bool dump_counters = i::FLAG_dump_counters;
bool dump_counters_nvp = i::FLAG_dump_counters_nvp;
if (dispose) {
V8::Dispose();
V8::DisposePlatform();
}
if (i::FLAG_dump_counters || i::FLAG_dump_counters_nvp) {
if (dump_counters || dump_counters_nvp) {
base::SharedMutexGuard<base::kShared> mutex_guard(&counter_mutex_);
std::vector<std::pair<std::string, Counter*>> counters(
counter_map_->begin(), counter_map_->end());
std::sort(counters.begin(), counters.end());
if (i::FLAG_dump_counters_nvp) {
if (dump_counters_nvp) {
// Dump counters as name-value pairs.
for (const auto& pair : counters) {
std::string key = pair.first;
......
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