| 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/store_buffer.h" | 5 #include "vm/store_buffer.h" |
| 6 | 6 |
| 7 #include "platform/assert.h" | 7 #include "platform/assert.h" |
| 8 #include "vm/runtime_entry.h" | 8 #include "vm/runtime_entry.h" |
| 9 | 9 |
| 10 namespace dart { | 10 namespace dart { |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 } | 37 } |
| 38 } | 38 } |
| 39 return false; | 39 return false; |
| 40 } | 40 } |
| 41 | 41 |
| 42 | 42 |
| 43 StoreBuffer::~StoreBuffer() { | 43 StoreBuffer::~StoreBuffer() { |
| 44 DedupSet* current = dedup_sets_; | 44 DedupSet* current = dedup_sets_; |
| 45 dedup_sets_ = NULL; | 45 dedup_sets_ = NULL; |
| 46 while (current != NULL) { | 46 while (current != NULL) { |
| 47 DedupSet* next = current->next_; | 47 DedupSet* next = current->next(); |
| 48 delete current; |
| 49 current = next; |
| 50 } |
| 51 } |
| 52 |
| 53 |
| 54 void StoreBuffer::Reset() { |
| 55 DedupSet* current = DedupSets(); |
| 56 while (current != NULL) { |
| 57 DedupSet* next = current->next(); |
| 48 delete current; | 58 delete current; |
| 49 current = next; | 59 current = next; |
| 50 } | 60 } |
| 51 } | 61 } |
| 52 | 62 |
| 53 | 63 |
| 54 void StoreBuffer::AddPointer(uword address) { | 64 void StoreBuffer::AddPointer(uword address) { |
| 55 ASSERT(dedup_sets_ != NULL); | 65 ASSERT(dedup_sets_ != NULL); |
| 56 if (!dedup_sets_->set_->Add(address)) { | 66 if (!dedup_sets_->set()->Add(address)) { |
| 57 // TODO(iposva): Limit growth of deduplication sets until the rest of the | 67 // Add a new DedupSet. Schedule an interrupt if we have run over the max |
| 58 // mechanism is hooked up. | 68 // number of DedupSets. |
| 59 delete dedup_sets_; | 69 dedup_sets_ = new DedupSet(dedup_sets_); |
| 60 dedup_sets_ = NULL; | 70 count_++; |
| 61 | 71 // TODO(iposva): Fix magic number. |
| 62 DedupSet* fresh_element = new DedupSet(); | 72 if (count_ > 100) { |
| 63 fresh_element->next_ = dedup_sets_; | 73 Isolate::Current()->ScheduleInterrupts(Isolate::kStoreBufferInterrupt); |
| 64 dedup_sets_ = fresh_element; | 74 } |
| 65 } | 75 } |
| 66 } | 76 } |
| 67 | 77 |
| 68 } // namespace dart | 78 } // namespace dart |
| OLD | NEW |