 Chromium Code Reviews
 Chromium Code Reviews Issue 1765533003:
  Fix some potential data races based on output from tsan.  (Closed) 
  Base URL: git@github.com:dart-lang/sdk.git@master
    
  
    Issue 1765533003:
  Fix some potential data races based on output from tsan.  (Closed) 
  Base URL: git@github.com:dart-lang/sdk.git@master| OLD | NEW | 
|---|---|
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 #include "vm/atomic.h" | |
| 5 #include "vm/class_table.h" | 6 #include "vm/class_table.h" | 
| 6 #include "vm/flags.h" | 7 #include "vm/flags.h" | 
| 7 #include "vm/freelist.h" | 8 #include "vm/freelist.h" | 
| 8 #include "vm/growable_array.h" | 9 #include "vm/growable_array.h" | 
| 9 #include "vm/heap.h" | 10 #include "vm/heap.h" | 
| 10 #include "vm/object.h" | 11 #include "vm/object.h" | 
| 11 #include "vm/raw_object.h" | 12 #include "vm/raw_object.h" | 
| 12 #include "vm/visitor.h" | 13 #include "vm/visitor.h" | 
| 13 | 14 | 
| 14 namespace dart { | 15 namespace dart { | 
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 99 intptr_t index = cls.id(); | 100 intptr_t index = cls.id(); | 
| 100 if (index != kIllegalCid) { | 101 if (index != kIllegalCid) { | 
| 101 ASSERT(index > 0); | 102 ASSERT(index > 0); | 
| 102 ASSERT(index < kNumPredefinedCids); | 103 ASSERT(index < kNumPredefinedCids); | 
| 103 ASSERT(table_[index] == 0); | 104 ASSERT(table_[index] == 0); | 
| 104 ASSERT(index < capacity_); | 105 ASSERT(index < capacity_); | 
| 105 table_[index] = cls.raw(); | 106 table_[index] = cls.raw(); | 
| 106 // Add the vtable for this predefined class into the static vtable registry | 107 // Add the vtable for this predefined class into the static vtable registry | 
| 107 // if it has not been setup yet. | 108 // if it has not been setup yet. | 
| 108 cpp_vtable cls_vtable = cls.handle_vtable(); | 109 cpp_vtable cls_vtable = cls.handle_vtable(); | 
| 109 cpp_vtable table_entry = Object::builtin_vtables_[index]; | 110 AtomicOperations::CompareAndSwapWord( | 
| 110 ASSERT((table_entry == 0) || (table_entry == cls_vtable)); | 111 &(Object::builtin_vtables_[index]), 0, cls_vtable); | 
| 111 if (table_entry == 0) { | 112 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
 | |
| 112 Object::builtin_vtables_[index] = cls_vtable; | |
| 113 } | |
| 114 } else { | 113 } else { | 
| 115 if (top_ == capacity_) { | 114 if (top_ == capacity_) { | 
| 116 // Grow the capacity of the class table. | 115 // Grow the capacity of the class table. | 
| 117 // TODO(koda): Add ClassTable::Grow to share code. | 116 // TODO(koda): Add ClassTable::Grow to share code. | 
| 118 intptr_t new_capacity = capacity_ + capacity_increment_; | 117 intptr_t new_capacity = capacity_ + capacity_increment_; | 
| 119 RawClass** new_table = reinterpret_cast<RawClass**>( | 118 RawClass** new_table = reinterpret_cast<RawClass**>( | 
| 120 malloc(new_capacity * sizeof(RawClass*))); // NOLINT | 119 malloc(new_capacity * sizeof(RawClass*))); // NOLINT | 
| 121 memmove(new_table, table_, capacity_ * sizeof(RawClass*)); | 120 memmove(new_table, table_, capacity_ * sizeof(RawClass*)); | 
| 122 ClassHeapStats* new_stats_table = reinterpret_cast<ClassHeapStats*>( | 121 ClassHeapStats* new_stats_table = reinterpret_cast<ClassHeapStats*>( | 
| 123 realloc(class_heap_stats_table_, | 122 realloc(class_heap_stats_table_, | 
| (...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 549 | 548 | 
| 550 void ClassTable::UpdateLiveNew(intptr_t cid, intptr_t size) { | 549 void ClassTable::UpdateLiveNew(intptr_t cid, intptr_t size) { | 
| 551 ClassHeapStats* stats = PreliminaryStatsAt(cid); | 550 ClassHeapStats* stats = PreliminaryStatsAt(cid); | 
| 552 ASSERT(stats != NULL); | 551 ASSERT(stats != NULL); | 
| 553 ASSERT(size >= 0); | 552 ASSERT(size >= 0); | 
| 554 stats->post_gc.AddNew(size); | 553 stats->post_gc.AddNew(size); | 
| 555 } | 554 } | 
| 556 | 555 | 
| 557 | 556 | 
| 558 } // namespace dart | 557 } // namespace dart | 
| OLD | NEW |