OLD | NEW |
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 2270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2281 }; | 2281 }; |
2282 | 2282 |
2283 Isolate::Isolate(bool enable_serializer) | 2283 Isolate::Isolate(bool enable_serializer) |
2284 : embedder_data_(), | 2284 : embedder_data_(), |
2285 entry_stack_(NULL), | 2285 entry_stack_(NULL), |
2286 stack_trace_nesting_level_(0), | 2286 stack_trace_nesting_level_(0), |
2287 incomplete_message_(NULL), | 2287 incomplete_message_(NULL), |
2288 bootstrapper_(NULL), | 2288 bootstrapper_(NULL), |
2289 runtime_profiler_(NULL), | 2289 runtime_profiler_(NULL), |
2290 compilation_cache_(NULL), | 2290 compilation_cache_(NULL), |
2291 counters_(NULL), | |
2292 logger_(NULL), | 2291 logger_(NULL), |
2293 stats_table_(NULL), | 2292 stats_table_(NULL), |
2294 load_stub_cache_(NULL), | 2293 load_stub_cache_(NULL), |
2295 store_stub_cache_(NULL), | 2294 store_stub_cache_(NULL), |
2296 code_aging_helper_(NULL), | 2295 code_aging_helper_(NULL), |
2297 deoptimizer_data_(NULL), | 2296 deoptimizer_data_(NULL), |
2298 deoptimizer_lazy_throw_(false), | 2297 deoptimizer_lazy_throw_(false), |
2299 materialized_object_store_(NULL), | 2298 materialized_object_store_(NULL), |
2300 capture_stack_trace_for_uncaught_exceptions_(false), | 2299 capture_stack_trace_for_uncaught_exceptions_(false), |
2301 stack_trace_for_uncaught_exceptions_frame_limit_(0), | 2300 stack_trace_for_uncaught_exceptions_frame_limit_(0), |
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2545 delete code_aging_helper_; | 2544 delete code_aging_helper_; |
2546 code_aging_helper_ = NULL; | 2545 code_aging_helper_ = NULL; |
2547 stats_table_ = NULL; | 2546 stats_table_ = NULL; |
2548 | 2547 |
2549 delete materialized_object_store_; | 2548 delete materialized_object_store_; |
2550 materialized_object_store_ = NULL; | 2549 materialized_object_store_ = NULL; |
2551 | 2550 |
2552 delete logger_; | 2551 delete logger_; |
2553 logger_ = NULL; | 2552 logger_ = NULL; |
2554 | 2553 |
2555 counters_ = NULL; | |
2556 | |
2557 delete handle_scope_implementer_; | 2554 delete handle_scope_implementer_; |
2558 handle_scope_implementer_ = NULL; | 2555 handle_scope_implementer_ = NULL; |
2559 | 2556 |
2560 delete code_tracer(); | 2557 delete code_tracer(); |
2561 set_code_tracer(NULL); | 2558 set_code_tracer(NULL); |
2562 | 2559 |
2563 delete compilation_cache_; | 2560 delete compilation_cache_; |
2564 compilation_cache_ = NULL; | 2561 compilation_cache_ = NULL; |
2565 delete bootstrapper_; | 2562 delete bootstrapper_; |
2566 bootstrapper_ = NULL; | 2563 bootstrapper_ = NULL; |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2630 handler->has_terminated_ = false; | 2627 handler->has_terminated_ = false; |
2631 handler->exception_ = pending_exception(); | 2628 handler->exception_ = pending_exception(); |
2632 // 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. |
2633 if (thread_local_top_.pending_message_obj_->IsTheHole(this)) return true; | 2630 if (thread_local_top_.pending_message_obj_->IsTheHole(this)) return true; |
2634 | 2631 |
2635 handler->message_obj_ = thread_local_top_.pending_message_obj_; | 2632 handler->message_obj_ = thread_local_top_.pending_message_obj_; |
2636 } | 2633 } |
2637 return true; | 2634 return true; |
2638 } | 2635 } |
2639 | 2636 |
2640 static base::LazyMutex initialize_counters_mutex = LAZY_MUTEX_INITIALIZER; | |
2641 | |
2642 bool Isolate::InitializeCounters() { | 2637 bool Isolate::InitializeCounters() { |
2643 if (counters_ != nullptr) return false; | 2638 if (counters_shared_) return false; |
2644 base::LockGuard<base::Mutex> guard(initialize_counters_mutex.Pointer()); | |
2645 if (counters_ != nullptr) return false; | |
2646 counters_shared_ = std::make_shared<Counters>(this); | 2639 counters_shared_ = std::make_shared<Counters>(this); |
2647 counters_ = counters_shared_.get(); | |
2648 return true; | 2640 return true; |
2649 } | 2641 } |
2650 | 2642 |
2651 void Isolate::InitializeLoggingAndCounters() { | 2643 void Isolate::InitializeLoggingAndCounters() { |
2652 if (logger_ == NULL) { | 2644 if (logger_ == NULL) { |
2653 logger_ = new Logger(this); | 2645 logger_ = new Logger(this); |
2654 } | 2646 } |
2655 InitializeCounters(); | 2647 InitializeCounters(); |
2656 } | 2648 } |
2657 | 2649 |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2857 | 2849 |
2858 return true; | 2850 return true; |
2859 } | 2851 } |
2860 | 2852 |
2861 | 2853 |
2862 // Initialized lazily to allow early | 2854 // Initialized lazily to allow early |
2863 // v8::V8::SetAddHistogramSampleFunction calls. | 2855 // v8::V8::SetAddHistogramSampleFunction calls. |
2864 StatsTable* Isolate::stats_table() { | 2856 StatsTable* Isolate::stats_table() { |
2865 if (stats_table_ != nullptr) return stats_table_; | 2857 if (stats_table_ != nullptr) return stats_table_; |
2866 InitializeCounters(); | 2858 InitializeCounters(); |
2867 return stats_table_ = counters_->stats_table(); | 2859 stats_table_ = counters_shared_->stats_table(); |
| 2860 return stats_table_; |
2868 } | 2861 } |
2869 | 2862 |
2870 | 2863 |
2871 void Isolate::Enter() { | 2864 void Isolate::Enter() { |
2872 Isolate* current_isolate = NULL; | 2865 Isolate* current_isolate = NULL; |
2873 PerIsolateThreadData* current_data = CurrentPerIsolateThreadData(); | 2866 PerIsolateThreadData* current_data = CurrentPerIsolateThreadData(); |
2874 if (current_data != NULL) { | 2867 if (current_data != NULL) { |
2875 current_isolate = current_data->isolate_; | 2868 current_isolate = current_data->isolate_; |
2876 DCHECK(current_isolate != NULL); | 2869 DCHECK(current_isolate != NULL); |
2877 if (current_isolate == this) { | 2870 if (current_isolate == this) { |
(...skipping 909 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3787 // Then check whether this scope intercepts. | 3780 // Then check whether this scope intercepts. |
3788 if ((flag & intercept_mask_)) { | 3781 if ((flag & intercept_mask_)) { |
3789 intercepted_flags_ |= flag; | 3782 intercepted_flags_ |= flag; |
3790 return true; | 3783 return true; |
3791 } | 3784 } |
3792 return false; | 3785 return false; |
3793 } | 3786 } |
3794 | 3787 |
3795 } // namespace internal | 3788 } // namespace internal |
3796 } // namespace v8 | 3789 } // namespace v8 |
OLD | NEW |