| Index: src/isolate.cc
|
| diff --git a/src/isolate.cc b/src/isolate.cc
|
| index cd4d077198d8ade2b7e46f8cda4dc7daaadaf5c0..0b63db0a2c4992b70feafeae99718c3ded9d8ab5 100644
|
| --- a/src/isolate.cc
|
| +++ b/src/isolate.cc
|
| @@ -2562,7 +2562,6 @@ Isolate::~Isolate() {
|
| delete logger_;
|
| logger_ = NULL;
|
|
|
| - delete counters_;
|
| counters_ = NULL;
|
|
|
| delete handle_scope_implementer_;
|
| @@ -2648,14 +2647,22 @@ bool Isolate::PropagatePendingExceptionToExternalTryCatch() {
|
| return true;
|
| }
|
|
|
| +static base::LazyMutex initialize_counters_mutex = LAZY_MUTEX_INITIALIZER;
|
| +
|
| +bool Isolate::InitializeCounters() {
|
| + if (counters_ != NULL) return false;
|
| + base::LockGuard<base::Mutex> guard(initialize_counters_mutex.Pointer());
|
| + if (counters_ != NULL) return false;
|
| + counters_shared_ = std::make_shared<Counters>(this);
|
| + counters_ = counters_shared_.get();
|
| + return true;
|
| +}
|
|
|
| void Isolate::InitializeLoggingAndCounters() {
|
| if (logger_ == NULL) {
|
| logger_ = new Logger(this);
|
| }
|
| - if (counters_ == NULL) {
|
| - counters_ = new Counters(this);
|
| - }
|
| + InitializeCounters();
|
| }
|
|
|
|
|
|
|