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

Side by Side Diff: runtime/vm/store_buffer.cc

Issue 14348026: Drain StoreBufferBlock into store buffer instead of iterating over it directly. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: unify draining Created 7 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « runtime/vm/store_buffer.h ('k') | no next file » | 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) 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 {
11 11
12 DEFINE_LEAF_RUNTIME_ENTRY(void, StoreBufferBlockProcess, Isolate* isolate) { 12 DEFINE_LEAF_RUNTIME_ENTRY(void, StoreBufferBlockProcess, Isolate* isolate) {
13 isolate->store_buffer_block()->ProcessBuffer(isolate); 13 isolate->store_buffer_block()->ProcessBuffer(isolate);
14 } 14 }
15 END_LEAF_RUNTIME_ENTRY 15 END_LEAF_RUNTIME_ENTRY
16 16
17 17
18 void StoreBufferBlock::ProcessBuffer() { 18 void StoreBufferBlock::ProcessBuffer() {
19 ProcessBuffer(Isolate::Current()); 19 ProcessBuffer(Isolate::Current());
20 } 20 }
21 21
22 22
23 void StoreBufferBlock::ProcessBuffer(Isolate* isolate) { 23 void StoreBufferBlock::ProcessBuffer(Isolate* isolate) {
24 StoreBuffer* buffer = isolate->store_buffer(); 24 isolate->store_buffer()->ProcessBlock(this);
25 int32_t end = top_;
26 for (int32_t i = 0; i < end; i++) {
27 buffer->AddPointer(pointers_[i]);
28 }
29 top_ = 0; // Reset back to the beginning.
30 } 25 }
31 26
32 27
33 bool StoreBufferBlock::Contains(uword pointer) { 28 bool StoreBufferBlock::Contains(uword pointer) {
34 for (int32_t i = 0; i < top_; i++) { 29 for (int32_t i = 0; i < top_; i++) {
35 if (pointers_[i] == pointer) { 30 if (pointers_[i] == pointer) {
36 return true; 31 return true;
37 } 32 }
38 } 33 }
39 return false; 34 return false;
(...skipping 14 matching lines...) Expand all
54 void StoreBuffer::Reset() { 49 void StoreBuffer::Reset() {
55 DedupSet* current = DedupSets(); 50 DedupSet* current = DedupSets();
56 while (current != NULL) { 51 while (current != NULL) {
57 DedupSet* next = current->next(); 52 DedupSet* next = current->next();
58 delete current; 53 delete current;
59 current = next; 54 current = next;
60 } 55 }
61 } 56 }
62 57
63 58
59 bool StoreBuffer::AddPointerInternal(uword address) {
60 ASSERT(dedup_sets_ != NULL);
61 ASSERT(Isolate::Current()->heap()->OldContains(address));
62 ASSERT((address & kSmiTagMask) != kSmiTag);
63 if (!dedup_sets_->set()->Add(address)) {
64 // Add a new DedupSet.
65 dedup_sets_ = new DedupSet(dedup_sets_);
66 count_++;
67 return true;
68 }
69 return false;
70 }
71
72
64 void StoreBuffer::AddPointer(uword address) { 73 void StoreBuffer::AddPointer(uword address) {
65 ASSERT(dedup_sets_ != NULL); 74 if (AddPointerInternal(address)) {
66 ASSERT(Isolate::Current()->heap()->OldContains(address)); 75 // Had to create a new DedupSet.
67 ASSERT((address & kSmiTagMask) != kSmiTag); 76 CheckThreshold();
68 if (!dedup_sets_->set()->Add(address)) {
69 // Add a new DedupSet. Schedule an interrupt if we have run over the max
70 // number of DedupSets.
71 dedup_sets_ = new DedupSet(dedup_sets_);
72 count_++;
73 // TODO(iposva): Fix magic number.
74 if (count_ > 100) {
75 Isolate::Current()->ScheduleInterrupts(Isolate::kStoreBufferInterrupt);
76 }
77 } 77 }
78 } 78 }
79 79
80
81 bool StoreBuffer::DrainBlock(StoreBufferBlock* block) {
82 const intptr_t old_count = count_;
83 intptr_t entries = block->Count();
84 for (intptr_t i = 0; i < entries; i++) {
85 AddPointerInternal(block->At(i));
86 }
87 block->Reset();
88 return (count_ > old_count);
89 }
90
91
92 void StoreBuffer::CheckThreshold() {
93 // Schedule an interrupt if we have run over the max number of DedupSets.
94 // TODO(iposva): Fix magic number.
95 if (count_ > 100) {
96 Isolate::Current()->ScheduleInterrupts(Isolate::kStoreBufferInterrupt);
97 }
98 }
99
100
101 void StoreBuffer::ProcessBlock(StoreBufferBlock* block) {
102 if (DrainBlock(block)) {
103 CheckThreshold();
104 }
105 }
106
80 } // namespace dart 107 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/store_buffer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698