diff options
author | Michaël Zasso <targos@protonmail.com> | 2018-12-04 08:20:37 +0100 |
---|---|---|
committer | Michaël Zasso <targos@protonmail.com> | 2018-12-06 15:23:33 +0100 |
commit | 9b4bf7de6c9a7c25f116c7a502384c20b5cfaea3 (patch) | |
tree | 2b0c843168dafb939d8df8a15b2aa72b76dee51d /deps/v8/src/counters.cc | |
parent | b8fbe69db1292307adb2c2b2e0d5ef48c4ab2faf (diff) | |
download | android-node-v8-9b4bf7de6c9a7c25f116c7a502384c20b5cfaea3.tar.gz android-node-v8-9b4bf7de6c9a7c25f116c7a502384c20b5cfaea3.tar.bz2 android-node-v8-9b4bf7de6c9a7c25f116c7a502384c20b5cfaea3.zip |
deps: update V8 to 7.1.302.28
PR-URL: https://github.com/nodejs/node/pull/23423
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Myles Borins <myles.borins@gmail.com>
Diffstat (limited to 'deps/v8/src/counters.cc')
-rw-r--r-- | deps/v8/src/counters.cc | 62 |
1 files changed, 61 insertions, 1 deletions
diff --git a/deps/v8/src/counters.cc b/deps/v8/src/counters.cc index bcea9e0f42..a4b08127cd 100644 --- a/deps/v8/src/counters.cc +++ b/deps/v8/src/counters.cc @@ -118,7 +118,8 @@ Counters::Counters(Isolate* isolate) STATS_COUNTER_TS_LIST(SC) #undef SC // clang format on - runtime_call_stats_() { + runtime_call_stats_(), + worker_thread_runtime_call_stats_() { static const struct { Histogram Counters::*member; const char* caption; @@ -529,5 +530,64 @@ void RuntimeCallStats::Dump(v8::tracing::TracedValue* value) { in_use_ = false; } +WorkerThreadRuntimeCallStats::WorkerThreadRuntimeCallStats() + : tls_key_(base::Thread::CreateThreadLocalKey()) {} + +WorkerThreadRuntimeCallStats::~WorkerThreadRuntimeCallStats() { + base::Thread::DeleteThreadLocalKey(tls_key_); +} + +RuntimeCallStats* WorkerThreadRuntimeCallStats::NewTable() { + DCHECK(FLAG_runtime_stats); + std::unique_ptr<RuntimeCallStats> new_table = + base::make_unique<RuntimeCallStats>(); + RuntimeCallStats* result = new_table.get(); + + base::LockGuard<base::Mutex> lock(&mutex_); + tables_.push_back(std::move(new_table)); + return result; +} + +void WorkerThreadRuntimeCallStats::AddToMainTable( + RuntimeCallStats* main_call_stats) { + base::LockGuard<base::Mutex> lock(&mutex_); + for (auto& worker_stats : tables_) { + DCHECK_NE(main_call_stats, worker_stats.get()); + main_call_stats->Add(worker_stats.get()); + worker_stats->Reset(); + } +} + +WorkerThreadRuntimeCallStatsScope::WorkerThreadRuntimeCallStatsScope( + WorkerThreadRuntimeCallStats* worker_stats) + : table_(nullptr) { + if (V8_LIKELY(!FLAG_runtime_stats)) return; + + table_ = reinterpret_cast<RuntimeCallStats*>( + base::Thread::GetThreadLocal(worker_stats->GetKey())); + if (table_ == nullptr) { + table_ = worker_stats->NewTable(); + base::Thread::SetThreadLocal(worker_stats->GetKey(), table_); + } + + if (FLAG_runtime_stats & + v8::tracing::TracingCategoryObserver::ENABLED_BY_TRACING) { + table_->Reset(); + } +} + +WorkerThreadRuntimeCallStatsScope::~WorkerThreadRuntimeCallStatsScope() { + if (V8_LIKELY(table_ == nullptr)) return; + + if ((FLAG_runtime_stats & + v8::tracing::TracingCategoryObserver::ENABLED_BY_TRACING)) { + auto value = v8::tracing::TracedValue::Create(); + table_->Dump(value.get()); + TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("v8.runtime_stats"), + "V8.RuntimeStats", TRACE_EVENT_SCOPE_THREAD, + "runtime-call-stats", std::move(value)); + } +} + } // namespace internal } // namespace v8 |