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

Side by Side Diff: src/spaces.h

Issue 8537014: Simplify the write barrier. Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 9 years, 1 month 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
« no previous file with comments | « src/mark-compact-inl.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 class MemoryAllocator; 117 class MemoryAllocator;
118 class AllocationInfo; 118 class AllocationInfo;
119 class Space; 119 class Space;
120 class FreeList; 120 class FreeList;
121 class MemoryChunk; 121 class MemoryChunk;
122 122
123 class MarkBit { 123 class MarkBit {
124 public: 124 public:
125 typedef uint32_t CellType; 125 typedef uint32_t CellType;
126 126
127 inline MarkBit(CellType* cell, CellType mask, bool data_only) 127 inline MarkBit(CellType* cell, CellType mask)
128 : cell_(cell), mask_(mask), data_only_(data_only) { } 128 : cell_(cell), mask_(mask) { }
129 129
130 inline CellType* cell() { return cell_; } 130 inline CellType* cell() { return cell_; }
131 inline CellType mask() { return mask_; } 131 inline CellType mask() { return mask_; }
132 132
133 #ifdef DEBUG 133 #ifdef DEBUG
134 bool operator==(const MarkBit& other) { 134 bool operator==(const MarkBit& other) {
135 return cell_ == other.cell_ && mask_ == other.mask_; 135 return cell_ == other.cell_ && mask_ == other.mask_;
136 } 136 }
137 #endif 137 #endif
138 138
139 inline void Set() { *cell_ |= mask_; } 139 inline void Set() { *cell_ |= mask_; }
140 inline bool Get() { return (*cell_ & mask_) != 0; } 140 inline bool Get() { return (*cell_ & mask_) != 0; }
141 inline void Clear() { *cell_ &= ~mask_; } 141 inline void Clear() { *cell_ &= ~mask_; }
142 142
143 inline bool data_only() { return data_only_; }
144
145 inline MarkBit Next() { 143 inline MarkBit Next() {
146 CellType new_mask = mask_ << 1; 144 CellType new_mask = mask_ << 1;
147 if (new_mask == 0) { 145 if (new_mask == 0) {
148 return MarkBit(cell_ + 1, 1, data_only_); 146 return MarkBit(cell_ + 1, 1);
149 } else { 147 } else {
150 return MarkBit(cell_, new_mask, data_only_); 148 return MarkBit(cell_, new_mask);
151 } 149 }
152 } 150 }
153 151
154 private: 152 private:
155 CellType* cell_; 153 CellType* cell_;
156 CellType mask_; 154 CellType mask_;
157 // This boolean indicates that the object is in a data-only space with no
158 // pointers. This enables some optimizations when marking.
159 // It is expected that this field is inlined and turned into control flow
160 // at the place where the MarkBit object is created.
161 bool data_only_;
162 }; 155 };
163 156
164 157
165 // Bitmap is a sequence of cells each containing fixed number of bits. 158 // Bitmap is a sequence of cells each containing fixed number of bits.
166 class Bitmap { 159 class Bitmap {
167 public: 160 public:
168 static const uint32_t kBitsPerCell = 32; 161 static const uint32_t kBitsPerCell = 32;
169 static const uint32_t kBitsPerCellLog2 = 5; 162 static const uint32_t kBitsPerCellLog2 = 5;
170 static const uint32_t kBitIndexMask = kBitsPerCell - 1; 163 static const uint32_t kBitIndexMask = kBitsPerCell - 1;
171 static const uint32_t kBytesPerCell = kBitsPerCell / kBitsPerByte; 164 static const uint32_t kBytesPerCell = kBitsPerCell / kBitsPerByte;
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 } 200 }
208 201
209 INLINE(Address address()) { 202 INLINE(Address address()) {
210 return reinterpret_cast<Address>(this); 203 return reinterpret_cast<Address>(this);
211 } 204 }
212 205
213 INLINE(static Bitmap* FromAddress(Address addr)) { 206 INLINE(static Bitmap* FromAddress(Address addr)) {
214 return reinterpret_cast<Bitmap*>(addr); 207 return reinterpret_cast<Bitmap*>(addr);
215 } 208 }
216 209
217 inline MarkBit MarkBitFromIndex(uint32_t index, bool data_only = false) { 210 inline MarkBit MarkBitFromIndex(uint32_t index) {
218 MarkBit::CellType mask = 1 << (index & kBitIndexMask); 211 MarkBit::CellType mask = 1 << (index & kBitIndexMask);
219 MarkBit::CellType* cell = this->cells() + (index >> kBitsPerCellLog2); 212 MarkBit::CellType* cell = this->cells() + (index >> kBitsPerCellLog2);
220 return MarkBit(cell, mask, data_only); 213 return MarkBit(cell, mask);
221 } 214 }
222 215
223 static inline void Clear(MemoryChunk* chunk); 216 static inline void Clear(MemoryChunk* chunk);
224 217
225 static void PrintWord(uint32_t word, uint32_t himask = 0) { 218 static void PrintWord(uint32_t word, uint32_t himask = 0) {
226 for (uint32_t mask = 1; mask != 0; mask <<= 1) { 219 for (uint32_t mask = 1; mask != 0; mask <<= 1) {
227 if ((mask & himask) != 0) PrintF("["); 220 if ((mask & himask) != 0) PrintF("[");
228 PrintF((mask & word) ? "1" : "0"); 221 PrintF((mask & word) ? "1" : "0");
229 if ((mask & himask) != 0) PrintF("]"); 222 if ((mask & himask) != 0) PrintF("]");
230 } 223 }
(...skipping 2392 matching lines...) Expand 10 before | Expand all | Expand 10 after
2623 } 2616 }
2624 // Must be small, since an iteration is used for lookup. 2617 // Must be small, since an iteration is used for lookup.
2625 static const int kMaxComments = 64; 2618 static const int kMaxComments = 64;
2626 }; 2619 };
2627 #endif 2620 #endif
2628 2621
2629 2622
2630 } } // namespace v8::internal 2623 } } // namespace v8::internal
2631 2624
2632 #endif // V8_SPACES_H_ 2625 #endif // V8_SPACES_H_
OLDNEW
« no previous file with comments | « src/mark-compact-inl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698