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

Unified Diff: src/heap/scavenger.h

Issue 1323993004: [heap] Separate scavenger functionality into own file. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebased. Created 5 years, 3 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
« no previous file with comments | « src/heap/object-stats.h ('k') | src/heap/scavenger.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/heap/scavenger.h
diff --git a/src/heap/scavenger.h b/src/heap/scavenger.h
new file mode 100644
index 0000000000000000000000000000000000000000..44da98c86c73462e4dd579bd925eb4f984733698
--- /dev/null
+++ b/src/heap/scavenger.h
@@ -0,0 +1,72 @@
+// Copyright 2015 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef V8_HEAP_SCAVENGER_H_
+#define V8_HEAP_SCAVENGER_H_
+
+#include "src/heap/objects-visiting.h"
+
+namespace v8 {
+namespace internal {
+
+typedef void (*ScavengingCallback)(Map* map, HeapObject** slot,
+ HeapObject* object);
+
+class Scavenger {
+ public:
+ explicit Scavenger(Heap* heap) : heap_(heap) {}
+
+ // Initializes static visitor dispatch tables.
+ static void Initialize();
+
+ // Callback function passed to Heap::Iterate etc. Copies an object if
+ // necessary, the object might be promoted to an old space. The caller must
+ // ensure the precondition that the object is (a) a heap object and (b) in
+ // the heap's from space.
+ static inline void ScavengeObject(HeapObject** p, HeapObject* object);
+
+ // Slow part of {ScavengeObject} above.
+ static void ScavengeObjectSlow(HeapObject** p, HeapObject* object);
+
+ // Chooses an appropriate static visitor table depending on the current state
+ // of the heap (i.e. incremental marking, logging and profiling).
+ void SelectScavengingVisitorsTable();
+
+ Isolate* isolate();
+ Heap* heap() { return heap_; }
+
+ private:
+ Heap* heap_;
+ VisitorDispatchTable<ScavengingCallback> scavenging_visitors_table_;
+};
+
+
+// Helper class for turning the scavenger into an object visitor that is also
+// filtering out non-HeapObjects and objects which do not reside in new space.
+class ScavengeVisitor : public ObjectVisitor {
+ public:
+ explicit ScavengeVisitor(Heap* heap) : heap_(heap) {}
+
+ void VisitPointer(Object** p);
+ void VisitPointers(Object** start, Object** end);
+
+ private:
+ inline void ScavengePointer(Object** p);
+
+ Heap* heap_;
+};
+
+
+// Helper class for turning the scavenger into an object visitor that is also
+// filtering out non-HeapObjects and objects which do not reside in new space.
+class StaticScavengeVisitor
+ : public StaticNewSpaceVisitor<StaticScavengeVisitor> {
+ public:
+ static inline void VisitPointer(Heap* heap, Object** p);
+};
+
+} // namespace internal
+} // namespace v8
+
+#endif // V8_HEAP_SCAVENGER_H_
« no previous file with comments | « src/heap/object-stats.h ('k') | src/heap/scavenger.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698