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

Side by Side Diff: vm/scavenger.h

Issue 9027017: - Promote objects from new gen to old space if they survived a scavenge. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 8 years, 12 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
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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_SCAVENGER_H_ 5 #ifndef VM_SCAVENGER_H_
6 #define VM_SCAVENGER_H_ 6 #define VM_SCAVENGER_H_
7 7
8 #include "vm/assert.h"
9 #include "vm/flags.h"
8 #include "vm/globals.h" 10 #include "vm/globals.h"
9 #include "vm/object.h" 11 #include "vm/raw_object.h"
10 #include "vm/utils.h" 12 #include "vm/utils.h"
11 #include "vm/virtual_memory.h" 13 #include "vm/virtual_memory.h"
14 #include "vm/visitor.h"
12 15
13 namespace dart { 16 namespace dart {
14 17
15 // Forward declarations. 18 // Forward declarations.
16 class Heap; 19 class Heap;
17 class Isolate; 20 class Isolate;
18 21
22 DECLARE_FLAG(bool, gc_at_alloc);
23
19 class Scavenger { 24 class Scavenger {
20 public: 25 public:
21 Scavenger(Heap* heap, intptr_t max_capacity, uword object_alignment); 26 Scavenger(Heap* heap, intptr_t max_capacity, uword object_alignment);
22 ~Scavenger(); 27 ~Scavenger();
23 28
24 // Check whether this Scavenger contains this address. 29 // Check whether this Scavenger contains this address.
25 // During scavenging both the to and from spaces contain "legal" objects. 30 // During scavenging both the to and from spaces contain "legal" objects.
26 // During a scavenge this function only returns true for addresses that will 31 // During a scavenge this function only returns true for addresses that will
27 // be part of the surviving objects. 32 // be part of the surviving objects.
28 bool Contains(uword addr) const { 33 bool Contains(uword addr) const {
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 void VisitObjectPointers(ObjectPointerVisitor* visitor) const; 72 void VisitObjectPointers(ObjectPointerVisitor* visitor) const;
68 73
69 private: 74 private:
70 uword FirstObjectStart() const { return to_->start() | object_alignment_; } 75 uword FirstObjectStart() const { return to_->start() | object_alignment_; }
71 void Prologue(); 76 void Prologue();
72 void IterateRoots(Isolate* isolate, ObjectPointerVisitor* visitor); 77 void IterateRoots(Isolate* isolate, ObjectPointerVisitor* visitor);
73 void IterateWeakRoots(Isolate* isolate, ObjectPointerVisitor* visitor); 78 void IterateWeakRoots(Isolate* isolate, ObjectPointerVisitor* visitor);
74 void ProcessToSpace(ObjectPointerVisitor* visitor); 79 void ProcessToSpace(ObjectPointerVisitor* visitor);
75 void Epilogue(); 80 void Epilogue();
76 81
82 // During a scavenge we need to remember the promoted objects.
83 // This is implemented as a stack of objects at the end of the to space. As
siva 2011/12/22 23:48:38 As object sizes are always greater than sizeof(uwo
Ivan Posva 2011/12/23 00:12:06 Done.
84 // promoted objects will not consume space in the to space they leave enough
85 // room for this stack.
86 void PushToPromotedStack(uword addr) {
87 end_ -= sizeof(addr);
88 ASSERT(end_ > top_);
89 *reinterpret_cast<uword*>(end_) = addr;
90 }
91 uword PopFromPromotedStack() {
92 uword result = *reinterpret_cast<uword*>(end_);
93 end_ += sizeof(result);
94 ASSERT(end_ <= to_->end());
95 return result;
96 }
97 bool PromotedStackHasMore() const {
98 return end_ < to_->end();
99 }
100
77 VirtualMemory* space_; 101 VirtualMemory* space_;
78 MemoryRegion* to_; 102 MemoryRegion* to_;
79 MemoryRegion* from_; 103 MemoryRegion* from_;
80 104
81 Heap* heap_; 105 Heap* heap_;
82 106
83 // Current allocation top and end. These values are being accessed directly 107 // Current allocation top and end. These values are being accessed directly
84 // from generated code. 108 // from generated code.
85 uword top_; 109 uword top_;
86 uword end_; 110 uword end_;
87 111
112 // Objects below this address have survived a scavenge.
113 uword survivor_end_;
114
88 // All object are aligned to this value. 115 // All object are aligned to this value.
89 uword object_alignment_; 116 uword object_alignment_;
90 117
91 // Scavenge cycle count. 118 // Scavenge cycle count.
92 int count_; 119 int count_;
93 // Keep track whether a scavenge is currently running. 120 // Keep track whether a scavenge is currently running.
94 bool scavenging_; 121 bool scavenging_;
122 // Keep track whether the scavenge had a promotion failure.
123 bool had_promotion_failure_;
95 124
96 friend class ScavengerVisitor; 125 friend class ScavengerVisitor;
97 friend class ScavengerWeakVisitor; 126 friend class ScavengerWeakVisitor;
98 127
99 DISALLOW_COPY_AND_ASSIGN(Scavenger); 128 DISALLOW_COPY_AND_ASSIGN(Scavenger);
100 }; 129 };
101 130
102 } // namespace dart 131 } // namespace dart
103 132
104 #endif // VM_SCAVENGER_H_ 133 #endif // VM_SCAVENGER_H_
OLDNEW
« vm/raw_object.h ('K') | « vm/raw_object.cc ('k') | vm/scavenger.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698