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

Side by Side Diff: src/mark-compact.h

Issue 11028027: Revert trunk to bleeding_edge at r12484 (Closed) Base URL: https://v8.googlecode.com/svn/trunk
Patch Set: Created 8 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 | Annotate | Revision Log
« no previous file with comments | « src/liveedit.cc ('k') | src/mark-compact.cc » ('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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 array_[bottom_] = object; 233 array_[bottom_] = object;
234 } 234 }
235 } 235 }
236 236
237 HeapObject** array() { return array_; } 237 HeapObject** array() { return array_; }
238 int bottom() { return bottom_; } 238 int bottom() { return bottom_; }
239 int top() { return top_; } 239 int top() { return top_; }
240 int mask() { return mask_; } 240 int mask() { return mask_; }
241 void set_top(int top) { top_ = top; } 241 void set_top(int top) { top_ = top; }
242 242
243 int space_left() {
244 // If we already overflowed we may as well just say there is lots of
245 // space left.
246 if (overflowed_) return mask_ + 1;
247 if (IsEmpty()) return mask_ + 1;
248 if (IsFull()) return 0;
249 return (bottom_ - top_) & mask_;
250 }
251
252 #ifdef DEBUG
253 const char* Status() {
254 if (overflowed_) return "Overflowed";
255 if (IsEmpty()) return "Empty";
256 if (IsFull()) return "Full";
257 int oct = (((top_ - bottom_) & mask_) * 8) / (mask_ + 1);
258 switch (oct) {
259 case 0: return "Almost empty";
260 case 1: return "1/8 full";
261 case 2: return "2/8 full";
262 case 3: return "3/8 full";
263 case 4: return "4/8 full";
264 case 5: return "5/8 full";
265 case 6: return "6/8 full";
266 case 7: return "7/8 full";
267 }
268 return "??";
269 }
270 #endif
271
272 private: 243 private:
273 HeapObject** array_; 244 HeapObject** array_;
274 // array_[(top - 1) & mask_] is the top element in the deque. The Deque is 245 // array_[(top - 1) & mask_] is the top element in the deque. The Deque is
275 // empty when top_ == bottom_. It is full when top_ + 1 == bottom 246 // empty when top_ == bottom_. It is full when top_ + 1 == bottom
276 // (mod mask + 1). 247 // (mod mask + 1).
277 int top_; 248 int top_;
278 int bottom_; 249 int bottom_;
279 int mask_; 250 int mask_;
280 bool overflowed_; 251 bool overflowed_;
281 252
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
425 private: 396 private:
426 static const int kChainLengthThreshold = 15; 397 static const int kChainLengthThreshold = 15;
427 398
428 intptr_t idx_; 399 intptr_t idx_;
429 intptr_t chain_length_; 400 intptr_t chain_length_;
430 SlotsBuffer* next_; 401 SlotsBuffer* next_;
431 ObjectSlot slots_[kNumberOfElements]; 402 ObjectSlot slots_[kNumberOfElements];
432 }; 403 };
433 404
434 405
406 // -------------------------------------------------------------------------
407 // Marker shared between incremental and non-incremental marking
408 template<class BaseMarker> class Marker {
409 public:
410 Marker(BaseMarker* base_marker, MarkCompactCollector* mark_compact_collector)
411 : base_marker_(base_marker),
412 mark_compact_collector_(mark_compact_collector) {}
413
414 // Mark pointers in a Map and its DescriptorArray together, possibly
415 // treating transitions or back pointers weak.
416 void MarkMapContents(Map* map);
417 void MarkTransitionArray(TransitionArray* transitions);
418
419 private:
420 BaseMarker* base_marker() {
421 return base_marker_;
422 }
423
424 MarkCompactCollector* mark_compact_collector() {
425 return mark_compact_collector_;
426 }
427
428 BaseMarker* base_marker_;
429 MarkCompactCollector* mark_compact_collector_;
430 };
431
432
435 // Defined in isolate.h. 433 // Defined in isolate.h.
436 class ThreadLocalTop; 434 class ThreadLocalTop;
437 435
438 436
439 // ------------------------------------------------------------------------- 437 // -------------------------------------------------------------------------
440 // Mark-Compact collector 438 // Mark-Compact collector
441 class MarkCompactCollector { 439 class MarkCompactCollector {
442 public: 440 public:
443 // Type of functions to compute forwarding addresses of objects in 441 // Type of functions to compute forwarding addresses of objects in
444 // compacted spaces. Given an object and its size, return a (non-failure) 442 // compacted spaces. Given an object and its size, return a (non-failure)
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
588 inline void set_encountered_weak_maps(Object* weak_map) { 586 inline void set_encountered_weak_maps(Object* weak_map) {
589 encountered_weak_maps_ = weak_map; 587 encountered_weak_maps_ = weak_map;
590 } 588 }
591 589
592 void InvalidateCode(Code* code); 590 void InvalidateCode(Code* code);
593 591
594 void ClearMarkbits(); 592 void ClearMarkbits();
595 593
596 bool is_compacting() const { return compacting_; } 594 bool is_compacting() const { return compacting_; }
597 595
598 // Find the large objects that are not completely scanned, but have been
599 // postponed to later.
600 static void ProcessLargePostponedArrays(Heap* heap, MarkingDeque* deque);
601
602 private: 596 private:
603 MarkCompactCollector(); 597 MarkCompactCollector();
604 ~MarkCompactCollector(); 598 ~MarkCompactCollector();
605 599
606 bool MarkInvalidatedCode(); 600 bool MarkInvalidatedCode();
607 void RemoveDeadInvalidatedCode(); 601 void RemoveDeadInvalidatedCode();
608 void ProcessInvalidatedCode(ObjectVisitor* visitor); 602 void ProcessInvalidatedCode(ObjectVisitor* visitor);
609 603
610 604
611 #ifdef DEBUG 605 #ifdef DEBUG
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
655 // MarkCompactCollector::Prepare() and is otherwise in its 649 // MarkCompactCollector::Prepare() and is otherwise in its
656 // normal state. 650 // normal state.
657 // 651 //
658 // After: Live objects are marked and non-live objects are unmarked. 652 // After: Live objects are marked and non-live objects are unmarked.
659 653
660 friend class RootMarkingVisitor; 654 friend class RootMarkingVisitor;
661 friend class MarkingVisitor; 655 friend class MarkingVisitor;
662 friend class MarkCompactMarkingVisitor; 656 friend class MarkCompactMarkingVisitor;
663 friend class CodeMarkingVisitor; 657 friend class CodeMarkingVisitor;
664 friend class SharedFunctionInfoMarkingVisitor; 658 friend class SharedFunctionInfoMarkingVisitor;
659 friend class Marker<IncrementalMarking>;
660 friend class Marker<MarkCompactCollector>;
665 661
666 // Mark non-optimize code for functions inlined into the given optimized 662 // Mark non-optimize code for functions inlined into the given optimized
667 // code. This will prevent it from being flushed. 663 // code. This will prevent it from being flushed.
668 void MarkInlinedFunctionsCode(Code* code); 664 void MarkInlinedFunctionsCode(Code* code);
669 665
670 // Mark code objects that are active on the stack to prevent them 666 // Mark code objects that are active on the stack to prevent them
671 // from being flushed. 667 // from being flushed.
672 void PrepareThreadForCodeFlushing(Isolate* isolate, ThreadLocalTop* top); 668 void PrepareThreadForCodeFlushing(Isolate* isolate, ThreadLocalTop* top);
673 669
674 void PrepareForCodeFlushing(); 670 void PrepareForCodeFlushing();
675 671
676 // Marking operations for objects reachable from roots. 672 // Marking operations for objects reachable from roots.
677 void MarkLiveObjects(); 673 void MarkLiveObjects();
678 674
679 void AfterMarking(); 675 void AfterMarking();
680 676
681 // Marks the object black and pushes it on the marking stack. 677 // Marks the object black and pushes it on the marking stack.
678 // Returns true if object needed marking and false otherwise.
679 // This is for non-incremental marking only.
680 INLINE(bool MarkObjectAndPush(HeapObject* obj));
681
682 // Marks the object black and pushes it on the marking stack.
682 // This is for non-incremental marking only. 683 // This is for non-incremental marking only.
683 INLINE(void MarkObject(HeapObject* obj, MarkBit mark_bit)); 684 INLINE(void MarkObject(HeapObject* obj, MarkBit mark_bit));
684 685
686 // Marks the object black without pushing it on the marking stack.
687 // Returns true if object needed marking and false otherwise.
688 // This is for non-incremental marking only.
689 INLINE(bool MarkObjectWithoutPush(HeapObject* obj));
690
685 // Marks the object black assuming that it is not yet marked. 691 // Marks the object black assuming that it is not yet marked.
686 // This is for non-incremental marking only. 692 // This is for non-incremental marking only.
687 INLINE(void SetMark(HeapObject* obj, MarkBit mark_bit)); 693 INLINE(void SetMark(HeapObject* obj, MarkBit mark_bit));
688 694
695 void ProcessNewlyMarkedObject(HeapObject* obj);
696
689 // Mark the heap roots and all objects reachable from them. 697 // Mark the heap roots and all objects reachable from them.
690 void MarkRoots(RootMarkingVisitor* visitor); 698 void MarkRoots(RootMarkingVisitor* visitor);
691 699
692 // Mark the symbol table specially. References to symbols from the 700 // Mark the symbol table specially. References to symbols from the
693 // symbol table are weak. 701 // symbol table are weak.
694 void MarkSymbolTable(); 702 void MarkSymbolTable();
695 703
696 // Mark objects in object groups that have at least one object in the 704 // Mark objects in object groups that have at least one object in the
697 // group marked. 705 // group marked.
698 void MarkObjectGroups(); 706 void MarkObjectGroups();
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
781 static void VisitObject(HeapObject* obj); 789 static void VisitObject(HeapObject* obj);
782 790
783 friend class UnmarkObjectVisitor; 791 friend class UnmarkObjectVisitor;
784 static void UnmarkObject(HeapObject* obj); 792 static void UnmarkObject(HeapObject* obj);
785 #endif 793 #endif
786 794
787 Heap* heap_; 795 Heap* heap_;
788 MarkingDeque marking_deque_; 796 MarkingDeque marking_deque_;
789 CodeFlusher* code_flusher_; 797 CodeFlusher* code_flusher_;
790 Object* encountered_weak_maps_; 798 Object* encountered_weak_maps_;
799 Marker<MarkCompactCollector> marker_;
791 800
792 List<Page*> evacuation_candidates_; 801 List<Page*> evacuation_candidates_;
793 List<Code*> invalidated_code_; 802 List<Code*> invalidated_code_;
794 803
795 friend class Heap; 804 friend class Heap;
796 }; 805 };
797 806
798 807
799 const char* AllocationSpaceName(AllocationSpace space); 808 const char* AllocationSpaceName(AllocationSpace space);
800 809
801 } } // namespace v8::internal 810 } } // namespace v8::internal
802 811
803 #endif // V8_MARK_COMPACT_H_ 812 #endif // V8_MARK_COMPACT_H_
OLDNEW
« no previous file with comments | « src/liveedit.cc ('k') | src/mark-compact.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698