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

Side by Side Diff: src/objects-visiting.h

Issue 3397021: [Isolates] StaticVisitor::VisitPointer gets Heap* as additional argument (Closed)
Patch Set: Added CODE_POINTER_ALIGN per Vitaly's suggestion. Created 10 years, 2 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
« no previous file with comments | « src/objects.h ('k') | src/spaces.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2006-2009 the V8 project authors. All rights reserved. 1 // Copyright 2006-2009 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 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 } 180 }
181 181
182 private: 182 private:
183 Callback callbacks_[StaticVisitorBase::kVisitorIdCount]; 183 Callback callbacks_[StaticVisitorBase::kVisitorIdCount];
184 }; 184 };
185 185
186 186
187 template<typename StaticVisitor> 187 template<typename StaticVisitor>
188 class BodyVisitorBase : public AllStatic { 188 class BodyVisitorBase : public AllStatic {
189 public: 189 public:
190 static inline void IteratePointers(HeapObject* object, 190 static inline void IteratePointers(Heap* heap,
191 HeapObject* object,
191 int start_offset, 192 int start_offset,
192 int end_offset) { 193 int end_offset) {
193 Object** start_slot = reinterpret_cast<Object**>(object->address() + 194 Object** start_slot = reinterpret_cast<Object**>(object->address() +
194 start_offset); 195 start_offset);
195 Object** end_slot = reinterpret_cast<Object**>(object->address() + 196 Object** end_slot = reinterpret_cast<Object**>(object->address() +
196 end_offset); 197 end_offset);
197 StaticVisitor::VisitPointers(start_slot, end_slot); 198 StaticVisitor::VisitPointers(heap, start_slot, end_slot);
198 } 199 }
199 }; 200 };
200 201
201 202
202 template<typename StaticVisitor, typename BodyDescriptor, typename ReturnType> 203 template<typename StaticVisitor, typename BodyDescriptor, typename ReturnType>
203 class FlexibleBodyVisitor : public BodyVisitorBase<StaticVisitor> { 204 class FlexibleBodyVisitor : public BodyVisitorBase<StaticVisitor> {
204 public: 205 public:
205 static inline ReturnType Visit(Map* map, HeapObject* object) { 206 static inline ReturnType Visit(Map* map, HeapObject* object) {
206 int object_size = BodyDescriptor::SizeOf(map, object); 207 int object_size = BodyDescriptor::SizeOf(map, object);
207 BodyVisitorBase<StaticVisitor>::IteratePointers( 208 BodyVisitorBase<StaticVisitor>::IteratePointers(
208 object, BodyDescriptor::kStartOffset, object_size); 209 map->heap(),
210 object,
211 BodyDescriptor::kStartOffset,
212 object_size);
209 return static_cast<ReturnType>(object_size); 213 return static_cast<ReturnType>(object_size);
210 } 214 }
211 215
212 template<int object_size> 216 template<int object_size>
213 static inline ReturnType VisitSpecialized(Map* map, HeapObject* object) { 217 static inline ReturnType VisitSpecialized(Map* map, HeapObject* object) {
214 ASSERT(BodyDescriptor::SizeOf(map, object) == object_size); 218 ASSERT(BodyDescriptor::SizeOf(map, object) == object_size);
215 BodyVisitorBase<StaticVisitor>::IteratePointers( 219 BodyVisitorBase<StaticVisitor>::IteratePointers(
216 object, BodyDescriptor::kStartOffset, object_size); 220 map->heap(),
221 object,
222 BodyDescriptor::kStartOffset,
223 object_size);
217 return static_cast<ReturnType>(object_size); 224 return static_cast<ReturnType>(object_size);
218 } 225 }
219 }; 226 };
220 227
221 228
222 template<typename StaticVisitor, typename BodyDescriptor, typename ReturnType> 229 template<typename StaticVisitor, typename BodyDescriptor, typename ReturnType>
223 class FixedBodyVisitor : public BodyVisitorBase<StaticVisitor> { 230 class FixedBodyVisitor : public BodyVisitorBase<StaticVisitor> {
224 public: 231 public:
225 static inline ReturnType Visit(Map* map, HeapObject* object) { 232 static inline ReturnType Visit(Map* map, HeapObject* object) {
226 BodyVisitorBase<StaticVisitor>::IteratePointers( 233 BodyVisitorBase<StaticVisitor>::IteratePointers(
227 object, BodyDescriptor::kStartOffset, BodyDescriptor::kEndOffset); 234 map->heap(),
235 object,
236 BodyDescriptor::kStartOffset,
237 BodyDescriptor::kEndOffset);
228 return static_cast<ReturnType>(BodyDescriptor::kSize); 238 return static_cast<ReturnType>(BodyDescriptor::kSize);
229 } 239 }
230 }; 240 };
231 241
232 242
233 // Base class for visitors used for a linear new space iteration. 243 // Base class for visitors used for a linear new space iteration.
234 // IterateBody returns size of visited object. 244 // IterateBody returns size of visited object.
235 // Certain types of objects (i.e. Code objects) are not handled 245 // Certain types of objects (i.e. Code objects) are not handled
236 // by dispatch table of this visitor because they cannot appear 246 // by dispatch table of this visitor because they cannot appear
237 // in the new space. 247 // in the new space.
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 kVisitJSObjectGeneric>(); 298 kVisitJSObjectGeneric>();
289 table_.RegisterSpecializations<StructVisitor, 299 table_.RegisterSpecializations<StructVisitor,
290 kVisitStruct, 300 kVisitStruct,
291 kVisitStructGeneric>(); 301 kVisitStructGeneric>();
292 } 302 }
293 303
294 static inline int IterateBody(Map* map, HeapObject* obj) { 304 static inline int IterateBody(Map* map, HeapObject* obj) {
295 return table_.GetVisitor(map)(map, obj); 305 return table_.GetVisitor(map)(map, obj);
296 } 306 }
297 307
298 static inline void VisitPointers(Object** start, Object** end) { 308 static inline void VisitPointers(Heap* heap, Object** start, Object** end) {
299 for (Object** p = start; p < end; p++) StaticVisitor::VisitPointer(p); 309 for (Object** p = start; p < end; p++) StaticVisitor::VisitPointer(heap, p);
300 } 310 }
301 311
302 private: 312 private:
303 static inline int VisitByteArray(Map* map, HeapObject* object) { 313 static inline int VisitByteArray(Map* map, HeapObject* object) {
304 return reinterpret_cast<ByteArray*>(object)->ByteArraySize(); 314 return reinterpret_cast<ByteArray*>(object)->ByteArraySize();
305 } 315 }
306 316
307 static inline int VisitSeqAsciiString(Map* map, HeapObject* object) { 317 static inline int VisitSeqAsciiString(Map* map, HeapObject* object) {
308 return SeqAsciiString::cast(object)-> 318 return SeqAsciiString::cast(object)->
309 SeqAsciiStringSize(map->instance_type()); 319 SeqAsciiStringSize(map->instance_type());
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
361 kRelocationInfoOffset, 371 kRelocationInfoOffset,
362 kRelocationInfoOffset + kPointerSize); 372 kRelocationInfoOffset + kPointerSize);
363 373
364 for (; !it.done(); it.next()) { 374 for (; !it.done(); it.next()) {
365 it.rinfo()->Visit(v); 375 it.rinfo()->Visit(v);
366 } 376 }
367 } 377 }
368 378
369 379
370 template<typename StaticVisitor> 380 template<typename StaticVisitor>
371 void Code::CodeIterateBody() { 381 void Code::CodeIterateBody(Heap* heap) {
372 int mode_mask = RelocInfo::kCodeTargetMask | 382 int mode_mask = RelocInfo::kCodeTargetMask |
373 RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT) | 383 RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT) |
374 RelocInfo::ModeMask(RelocInfo::EXTERNAL_REFERENCE) | 384 RelocInfo::ModeMask(RelocInfo::EXTERNAL_REFERENCE) |
375 RelocInfo::ModeMask(RelocInfo::JS_RETURN) | 385 RelocInfo::ModeMask(RelocInfo::JS_RETURN) |
376 RelocInfo::ModeMask(RelocInfo::DEBUG_BREAK_SLOT) | 386 RelocInfo::ModeMask(RelocInfo::DEBUG_BREAK_SLOT) |
377 RelocInfo::ModeMask(RelocInfo::RUNTIME_ENTRY); 387 RelocInfo::ModeMask(RelocInfo::RUNTIME_ENTRY);
378 388
379 // Use the relocation info pointer before it is visited by 389 // Use the relocation info pointer before it is visited by
380 // the heap compaction in the next statement. 390 // the heap compaction in the next statement.
381 RelocIterator it(this, mode_mask); 391 RelocIterator it(this, mode_mask);
382 392
383 StaticVisitor::VisitPointer( 393 StaticVisitor::VisitPointer(
394 heap,
384 reinterpret_cast<Object**>(this->address() + kRelocationInfoOffset)); 395 reinterpret_cast<Object**>(this->address() + kRelocationInfoOffset));
385 396
386 for (; !it.done(); it.next()) { 397 for (; !it.done(); it.next()) {
387 it.rinfo()->template Visit<StaticVisitor>(); 398 it.rinfo()->template Visit<StaticVisitor>(heap);
388 } 399 }
389 } 400 }
390 401
391 402
392 } } // namespace v8::internal 403 } } // namespace v8::internal
393 404
394 #endif // V8_OBJECTS_ITERATION_H_ 405 #endif // V8_OBJECTS_ITERATION_H_
OLDNEW
« no previous file with comments | « src/objects.h ('k') | src/spaces.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698