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

Side by Side Diff: runtime/vm/isolate.h

Issue 2191723002: Fix race condition with HasMutatorThread that was being used without a lock. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Address self review comments. Created 4 years, 4 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
« no previous file with comments | « runtime/vm/dart_api_impl.cc ('k') | runtime/vm/isolate.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #ifndef VM_ISOLATE_H_ 5 #ifndef VM_ISOLATE_H_
6 #define VM_ISOLATE_H_ 6 #define VM_ISOLATE_H_
7 7
8 #include "include/dart_api.h" 8 #include "include/dart_api.h"
9 #include "platform/assert.h" 9 #include "platform/assert.h"
10 #include "vm/atomic.h" 10 #include "vm/atomic.h"
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 return OFFSET_OF(Isolate, ic_miss_code_); 170 return OFFSET_OF(Isolate, ic_miss_code_);
171 } 171 }
172 172
173 Dart_MessageNotifyCallback message_notify_callback() const { 173 Dart_MessageNotifyCallback message_notify_callback() const {
174 return message_notify_callback_; 174 return message_notify_callback_;
175 } 175 }
176 void set_message_notify_callback(Dart_MessageNotifyCallback value) { 176 void set_message_notify_callback(Dart_MessageNotifyCallback value) {
177 message_notify_callback_ = value; 177 message_notify_callback_ = value;
178 } 178 }
179 179
180 // Limited public access to BaseIsolate::mutator_thread_ for code that 180 Thread* mutator_thread() const;
181 // must treat the mutator as the default or a special case. Prefer code
182 // that works uniformly across all threads.
183 bool HasMutatorThread() {
184 return mutator_thread_ != NULL;
185 }
186 Thread* mutator_thread() const {
187 return mutator_thread_;
Florian Schneider 2016/07/28 18:13:36 Can you remove mutator_thread_ in BaseIsolate? It
siva 2016/07/28 20:15:10 The field is still used in EnterIsolate to ensure
188 }
189 181
190 const char* name() const { return name_; } 182 const char* name() const { return name_; }
191 const char* debugger_name() const { return debugger_name_; } 183 const char* debugger_name() const { return debugger_name_; }
192 void set_debugger_name(const char* name); 184 void set_debugger_name(const char* name);
193 185
194 int64_t start_time() const { return start_time_; } 186 int64_t start_time() const { return start_time_; }
195 187
196 Dart_Port main_port() const { return main_port_; } 188 Dart_Port main_port() const { return main_port_; }
197 void set_main_port(Dart_Port port) { 189 void set_main_port(Dart_Port port) {
198 ASSERT(main_port_ == 0); // Only set main port once. 190 ASSERT(main_port_ == 0); // Only set main port once.
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
459 ASSERT(defer_finalization_count_ >= 0); 451 ASSERT(defer_finalization_count_ >= 0);
460 return defer_finalization_count_ == 0; 452 return defer_finalization_count_ == 0;
461 } 453 }
462 454
463 #ifndef PRODUCT 455 #ifndef PRODUCT
464 void PrintJSON(JSONStream* stream, bool ref = true); 456 void PrintJSON(JSONStream* stream, bool ref = true);
465 #endif 457 #endif
466 458
467 // Mutator thread is used to aggregate compiler stats. 459 // Mutator thread is used to aggregate compiler stats.
468 CompilerStats* aggregate_compiler_stats() { 460 CompilerStats* aggregate_compiler_stats() {
469 ASSERT(HasMutatorThread()); 461 return mutator_thread()->compiler_stats();
470 return mutator_thread_->compiler_stats();
471 } 462 }
472 463
473 VMTagCounters* vm_tag_counters() { 464 VMTagCounters* vm_tag_counters() {
474 return &vm_tag_counters_; 465 return &vm_tag_counters_;
475 } 466 }
476 467
477 bool IsReloading() const { 468 bool IsReloading() const {
478 return reload_context_ != NULL; 469 return reload_context_ != NULL;
479 } 470 }
480 471
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
686 const GrowableObjectArray& value); 677 const GrowableObjectArray& value);
687 678
688 Monitor* threads_lock() const; 679 Monitor* threads_lock() const;
689 Thread* ScheduleThread(bool is_mutator, bool bypass_safepoint = false); 680 Thread* ScheduleThread(bool is_mutator, bool bypass_safepoint = false);
690 void UnscheduleThread( 681 void UnscheduleThread(
691 Thread* thread, bool is_mutator, bool bypass_safepoint = false); 682 Thread* thread, bool is_mutator, bool bypass_safepoint = false);
692 683
693 // DEPRECATED: Use Thread's methods instead. During migration, these default 684 // DEPRECATED: Use Thread's methods instead. During migration, these default
694 // to using the mutator thread (which must also be the current thread). 685 // to using the mutator thread (which must also be the current thread).
695 Zone* current_zone() const { 686 Zone* current_zone() const {
696 ASSERT(Thread::Current() == mutator_thread_); 687 ASSERT(Thread::Current() == mutator_thread());
697 return mutator_thread_->zone(); 688 return mutator_thread()->zone();
698 } 689 }
699 690
700 // Accessed from generated code: 691 // Accessed from generated code:
701 StoreBuffer* store_buffer_; 692 StoreBuffer* store_buffer_;
702 Heap* heap_; 693 Heap* heap_;
703 uword user_tag_; 694 uword user_tag_;
704 RawUserTag* current_tag_; 695 RawUserTag* current_tag_;
705 RawUserTag* default_tag_; 696 RawUserTag* default_tag_;
706 RawCode* ic_miss_code_; 697 RawCode* ic_miss_code_;
707 ClassTable class_table_; 698 ClassTable class_table_;
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
994 intptr_t* spawn_count_; 985 intptr_t* spawn_count_;
995 986
996 Dart_IsolateFlags isolate_flags_; 987 Dart_IsolateFlags isolate_flags_;
997 bool paused_; 988 bool paused_;
998 bool errors_are_fatal_; 989 bool errors_are_fatal_;
999 }; 990 };
1000 991
1001 } // namespace dart 992 } // namespace dart
1002 993
1003 #endif // VM_ISOLATE_H_ 994 #endif // VM_ISOLATE_H_
OLDNEW
« no previous file with comments | « runtime/vm/dart_api_impl.cc ('k') | runtime/vm/isolate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698