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

Unified Diff: src/vm/immutable_heap.h

Issue 1263043007: Add ImmutableHeap class consisting of parts (Closed) Base URL: git@github.com:dart-lang/fletch.git@master
Patch Set: Created 5 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: src/vm/immutable_heap.h
diff --git a/src/vm/immutable_heap.h b/src/vm/immutable_heap.h
new file mode 100644
index 0000000000000000000000000000000000000000..d4340940372d89e7e2a1186a3fb04359b777c0a9
--- /dev/null
+++ b/src/vm/immutable_heap.h
@@ -0,0 +1,68 @@
+// Copyright (c) 2015, the Fletch project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE.md file.
+
+#ifndef SRC_VM_IMMUTABLE_HEAP_H_
+#define SRC_VM_IMMUTABLE_HEAP_H_
+
+#include "src/shared/globals.h"
+#include "src/vm/heap.h"
+
+namespace fletch {
+
+class ImmutableHeap {
+ public:
+ ImmutableHeap();
+ ~ImmutableHeap();
+
+ // Will return a [Heap] which will have an allocation budget which is
+ // ``.
Mads Ager (google) 2015/08/05 10:19:02 Finish comment please.
kustermann 2015/08/05 11:11:46 Done.
+ Heap* AcquirePart();
+ // 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.
+ //
+ // 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.
+ bool ReleasePart(Heap* part);
+ void MergeParts();
Mads Ager (google) 2015/08/05 10:19:03 Document this one as well?
kustermann 2015/08/05 11:11:46 Done.
+
+ // This method can only be called if
+ // * all acquired parts were released again
+ // * all cached parts were merged via [MergeParts]
+ void IterateProgramPointers(PointerVisitor* visitor);
+
+ // This method can only be called if
+ // * all acquired parts were released again
+ // * all cached parts were merged via [MergeParts]
+ Heap* heap() {
+ ASSERT(outstanding_parts_ == 0 && cached_parts_ == NULL);
+ return &heap_;
+ }
+
+ private:
+ // TODO(kustermann): Instead of having a linked list which requires heap
+ // allocations we should make a simple version of `std::vector` and use it
+ // here.
+ // [The number of parts is almost always fixed (i.e. the number of threads)]
+ 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
+ CachedHeapPart() : heap_part_(NULL), next_(NULL) {}
+ Heap* heap_part_;
+ struct CachedHeapPart* next_;
+ };
+
+ private:
Mads Ager (google) 2015/08/05 10:19:03 Remove extra 'private:'
kustermann 2015/08/05 11:11:46 Done.
+ bool HasCachedParts() { return cached_parts_ != NULL; }
+ void AddCachedPart(Heap* heap);
+ Heap* RemoveCachedPart();
+
+ int number_of_hw_threads_;
+
+ Mutex* heap_mutex_;
+ Heap heap_;
+ int outstanding_parts_;
+ 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
+ int ticks_;
+};
+
+} // namespace fletch
+
+
+#endif // SRC_VM_IMMUTABLE_HEAP_H_
« no previous file with comments | « src/vm/heap.h ('k') | src/vm/immutable_heap.cc » ('j') | src/vm/immutable_heap.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698