Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(153)

Side by Side Diff: src/isolate.cc

Issue 2887193002: Create a thread safe version of StatsCounters and use. (Closed)
Patch Set: fix nits of mtrofin Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/isolate.h" 5 #include "src/isolate.h"
6 6
7 #include <stdlib.h> 7 #include <stdlib.h>
8 8
9 #include <fstream> // NOLINT(readability/streams) 9 #include <fstream> // NOLINT(readability/streams)
10 #include <sstream> 10 #include <sstream>
(...skipping 2531 matching lines...) Expand 10 before | Expand all | Expand 10 after
2542 code_aging_helper_ = NULL; 2542 code_aging_helper_ = NULL;
2543 delete stats_table_; 2543 delete stats_table_;
2544 stats_table_ = NULL; 2544 stats_table_ = NULL;
2545 2545
2546 delete materialized_object_store_; 2546 delete materialized_object_store_;
2547 materialized_object_store_ = NULL; 2547 materialized_object_store_ = NULL;
2548 2548
2549 delete logger_; 2549 delete logger_;
2550 logger_ = NULL; 2550 logger_ = NULL;
2551 2551
2552 delete counters_;
2553 counters_ = NULL; 2552 counters_ = NULL;
2554 2553
2555 delete handle_scope_implementer_; 2554 delete handle_scope_implementer_;
2556 handle_scope_implementer_ = NULL; 2555 handle_scope_implementer_ = NULL;
2557 2556
2558 delete code_tracer(); 2557 delete code_tracer();
2559 set_code_tracer(NULL); 2558 set_code_tracer(NULL);
2560 2559
2561 delete compilation_cache_; 2560 delete compilation_cache_;
2562 compilation_cache_ = NULL; 2561 compilation_cache_ = NULL;
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
2628 handler->has_terminated_ = false; 2627 handler->has_terminated_ = false;
2629 handler->exception_ = pending_exception(); 2628 handler->exception_ = pending_exception();
2630 // Propagate to the external try-catch only if we got an actual message. 2629 // Propagate to the external try-catch only if we got an actual message.
2631 if (thread_local_top_.pending_message_obj_->IsTheHole(this)) return true; 2630 if (thread_local_top_.pending_message_obj_->IsTheHole(this)) return true;
2632 2631
2633 handler->message_obj_ = thread_local_top_.pending_message_obj_; 2632 handler->message_obj_ = thread_local_top_.pending_message_obj_;
2634 } 2633 }
2635 return true; 2634 return true;
2636 } 2635 }
2637 2636
2637 static base::LazyMutex initialize_counters_mutex = LAZY_MUTEX_INITIALIZER;
2638
2639 bool Isolate::InitializeCounters() {
2640 if (counters_ != nullptr) return false;
Clemens Hammacher 2017/06/02 13:08:49 This pattern is not safe in general. A thread obse
kschimpf 2017/06/02 15:01:02 I was probably too concerned about this, since the
kschimpf 2017/06/02 17:06:27 Fixed in cl https://codereview.chromium.org/291995
2641 base::LockGuard<base::Mutex> guard(initialize_counters_mutex.Pointer());
2642 if (counters_ != nullptr) return false;
2643 counters_shared_ = std::make_shared<Counters>(this);
2644 counters_ = counters_shared_.get();
2645 return true;
2646 }
2638 2647
2639 void Isolate::InitializeLoggingAndCounters() { 2648 void Isolate::InitializeLoggingAndCounters() {
2640 if (logger_ == NULL) { 2649 if (logger_ == NULL) {
2641 logger_ = new Logger(this); 2650 logger_ = new Logger(this);
2642 } 2651 }
2643 if (counters_ == NULL) { 2652 InitializeCounters();
2644 counters_ = new Counters(this);
2645 }
2646 } 2653 }
2647 2654
2648 2655
2649 bool Isolate::Init(Deserializer* des) { 2656 bool Isolate::Init(Deserializer* des) {
2650 TRACE_ISOLATE(init); 2657 TRACE_ISOLATE(init);
2651 2658
2652 stress_deopt_count_ = FLAG_deopt_every_n_times; 2659 stress_deopt_count_ = FLAG_deopt_every_n_times;
2653 2660
2654 has_fatal_error_ = false; 2661 has_fatal_error_ = false;
2655 2662
(...skipping 1105 matching lines...) Expand 10 before | Expand all | Expand 10 after
3761 // Then check whether this scope intercepts. 3768 // Then check whether this scope intercepts.
3762 if ((flag & intercept_mask_)) { 3769 if ((flag & intercept_mask_)) {
3763 intercepted_flags_ |= flag; 3770 intercepted_flags_ |= flag;
3764 return true; 3771 return true;
3765 } 3772 }
3766 return false; 3773 return false;
3767 } 3774 }
3768 3775
3769 } // namespace internal 3776 } // namespace internal
3770 } // namespace v8 3777 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698