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 #ifndef VM_STORE_BUFFER_H_ | 5 #ifndef VM_STORE_BUFFER_H_ |
6 #define VM_STORE_BUFFER_H_ | 6 #define VM_STORE_BUFFER_H_ |
7 | 7 |
8 #include "platform/assert.h" | 8 #include "platform/assert.h" |
9 #include "vm/globals.h" | 9 #include "vm/globals.h" |
10 #include "vm/hash_set.h" | |
10 | 11 |
11 namespace dart { | 12 namespace dart { |
12 | 13 |
13 class StoreBufferBlock { | 14 class StoreBufferBlock { |
14 public: | 15 public: |
15 // Each block contains kSize pointers. | 16 // Each block contains kSize pointers. |
16 static const int32_t kSize = 1024; | 17 static const int32_t kSize = 1024; |
17 | 18 |
18 StoreBufferBlock() : top_(0) {} | 19 StoreBufferBlock() : top_(0) {} |
19 | 20 |
(...skipping 13 matching lines...) Expand all Loading... | |
33 } | 34 } |
34 | 35 |
35 // Process this store buffer and remember its contents in the heap. | 36 // Process this store buffer and remember its contents in the heap. |
36 void ProcessBuffer(); | 37 void ProcessBuffer(); |
37 | 38 |
38 bool Contains(uword pointer); | 39 bool Contains(uword pointer); |
39 | 40 |
40 private: | 41 private: |
41 int32_t top_; | 42 int32_t top_; |
42 uword pointers_[kSize]; | 43 uword pointers_[kSize]; |
44 | |
45 friend class StoreBuffer; | |
46 }; | |
47 | |
48 | |
49 class StoreBuffer { | |
50 public: | |
51 StoreBuffer() : dedup_sets_(new DedupSet()) {} | |
52 ~StoreBuffer(); | |
53 | |
54 void AddPointer(uword address); | |
55 | |
56 void ProcessBlock(StoreBufferBlock* block); | |
57 | |
58 private: | |
59 // Simple linked list element containing a HashSet of old->new pointers. | |
60 class DedupSet { | |
61 public: | |
62 enum { | |
63 kSetSize = 1024, | |
64 kFillRatio = 80 | |
65 }; | |
66 | |
67 DedupSet() : set_(new HashSet(kSetSize, kFillRatio)) {} | |
siva
2012/07/02 20:57:42
: next_(NULL) {}
Ivan Posva
2012/07/03 00:10:24
Done.
| |
68 ~DedupSet() { | |
69 delete set_; | |
70 } | |
71 | |
72 DedupSet* next_; | |
73 HashSet* set_; | |
74 | |
75 private: | |
76 DISALLOW_COPY_AND_ASSIGN(DedupSet); | |
77 }; | |
78 | |
79 DedupSet* dedup_sets_; | |
43 }; | 80 }; |
44 | 81 |
45 } // namespace dart | 82 } // namespace dart |
46 | 83 |
47 #endif // VM_STORE_BUFFER_H_ | 84 #endif // VM_STORE_BUFFER_H_ |
OLD | NEW |