OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2015, the Fletch project authors. Please see the AUTHORS file | |
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.md file. | |
4 | |
5 #ifndef SRC_VM_IMMUTABLE_HEAP_H_ | |
6 #define SRC_VM_IMMUTABLE_HEAP_H_ | |
7 | |
8 #include "src/shared/globals.h" | |
9 #include "src/vm/heap.h" | |
10 | |
11 namespace fletch { | |
12 | |
13 class ImmutableHeap { | |
14 public: | |
15 ImmutableHeap(); | |
16 ~ImmutableHeap(); | |
17 | |
18 // Will return a [Heap] which will have an allocation budget which is | |
19 // ``. | |
Mads Ager (google)
2015/08/05 10:19:02
Finish comment please.
kustermann
2015/08/05 11:11:46
Done.
| |
20 Heap* AcquirePart(); | |
21 // Will return `true` if the caller should trigger an immutable GC. | |
Mads Ager (google)
2015/08/05 10:19:02
Newline before comment?
kustermann
2015/08/05 11:11:46
Done.
| |
22 // | |
23 // It is assumed that this function gets only called on allocation failures. | |
Mads Ager (google)
2015/08/05 10:19:02
gets only called -> is called only
kustermann
2015/08/05 11:11:46
Done.
| |
24 bool ReleasePart(Heap* part); | |
25 void MergeParts(); | |
Mads Ager (google)
2015/08/05 10:19:03
Document this one as well?
kustermann
2015/08/05 11:11:46
Done.
| |
26 | |
27 // This method can only be called if | |
28 // * all acquired parts were released again | |
29 // * all cached parts were merged via [MergeParts] | |
30 void IterateProgramPointers(PointerVisitor* visitor); | |
31 | |
32 // This method can only be called if | |
33 // * all acquired parts were released again | |
34 // * all cached parts were merged via [MergeParts] | |
35 Heap* heap() { | |
36 ASSERT(outstanding_parts_ == 0 && cached_parts_ == NULL); | |
37 return &heap_; | |
38 } | |
39 | |
40 private: | |
41 // TODO(kustermann): Instead of having a linked list which requires heap | |
42 // allocations we should make a simple version of `std::vector` and use it | |
43 // here. | |
44 // [The number of parts is almost always fixed (i.e. the number of threads)] | |
45 struct CachedHeapPart { | |
Mads Ager (google)
2015/08/05 10:19:02
Let's just use a class instead of a struct. It is
kustermann
2015/08/05 11:11:46
"Let's just use a class instead of a struct. It is
| |
46 CachedHeapPart() : heap_part_(NULL), next_(NULL) {} | |
47 Heap* heap_part_; | |
48 struct CachedHeapPart* next_; | |
49 }; | |
50 | |
51 private: | |
Mads Ager (google)
2015/08/05 10:19:03
Remove extra 'private:'
kustermann
2015/08/05 11:11:46
Done.
| |
52 bool HasCachedParts() { return cached_parts_ != NULL; } | |
53 void AddCachedPart(Heap* heap); | |
54 Heap* RemoveCachedPart(); | |
55 | |
56 int number_of_hw_threads_; | |
57 | |
58 Mutex* heap_mutex_; | |
59 Heap heap_; | |
60 int outstanding_parts_; | |
61 CachedHeapPart* cached_parts_; | |
Mads Ager (google)
2015/08/05 10:19:02
I guess these are the parts that are no longer out
kustermann
2015/08/05 11:11:46
Done.
Picked "number_of_unmerged_parts_" and remo
| |
62 int ticks_; | |
63 }; | |
64 | |
65 } // namespace fletch | |
66 | |
67 | |
68 #endif // SRC_VM_IMMUTABLE_HEAP_H_ | |
OLD | NEW |