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

Unified Diff: runtime/vm/class_table.cc

Issue 1765533003: Fix some potential data races based on output from tsan. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/bin/gen_snapshot.cc ('k') | runtime/vm/thread_interrupter.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/class_table.cc
diff --git a/runtime/vm/class_table.cc b/runtime/vm/class_table.cc
index 7129cf8f0ab3393ac35f09d913277797b0376e2c..8cb9fa192a50850752d0ab7c706c4aa1eadfcf4e 100644
--- a/runtime/vm/class_table.cc
+++ b/runtime/vm/class_table.cc
@@ -2,6 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+#include "vm/atomic.h"
#include "vm/class_table.h"
#include "vm/flags.h"
#include "vm/freelist.h"
@@ -106,11 +107,9 @@ void ClassTable::Register(const Class& cls) {
// Add the vtable for this predefined class into the static vtable registry
// if it has not been setup yet.
cpp_vtable cls_vtable = cls.handle_vtable();
- cpp_vtable table_entry = Object::builtin_vtables_[index];
- ASSERT((table_entry == 0) || (table_entry == cls_vtable));
- if (table_entry == 0) {
- Object::builtin_vtables_[index] = cls_vtable;
- }
+ AtomicOperations::CompareAndSwapWord(
+ &(Object::builtin_vtables_[index]), 0, cls_vtable);
+ ASSERT(Object::builtin_vtables_[index] == cls_vtable);
zra 2016/03/03 23:50:02 Is this asserting that the compare and swap was su
siva 2016/03/04 20:53:29 The ASSERT is to make sure the value of builtin_vt
} else {
if (top_ == capacity_) {
// Grow the capacity of the class table.
« no previous file with comments | « runtime/bin/gen_snapshot.cc ('k') | runtime/vm/thread_interrupter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698