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

Side by Side Diff: src/heap.cc

Issue 3382007: [Isolates] ScavengeVisitor gets member Heap*. (Closed)
Patch Set: fixed per review comments Created 10 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 unified diff | Download patch
« no previous file with comments | « src/ast.cc ('k') | src/isolate.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 2009 the V8 project authors. All rights reserved. 1 // Copyright 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 798 matching lines...) Expand 10 before | Expand all | Expand 10 after
809 obj = lo_space_->FindObject(a); 809 obj = lo_space_->FindObject(a);
810 } 810 }
811 ASSERT(!obj->IsFailure()); 811 ASSERT(!obj->IsFailure());
812 return obj; 812 return obj;
813 } 813 }
814 814
815 815
816 // Helper class for copying HeapObjects 816 // Helper class for copying HeapObjects
817 class ScavengeVisitor: public ObjectVisitor { 817 class ScavengeVisitor: public ObjectVisitor {
818 public: 818 public:
819 explicit ScavengeVisitor(Heap* heap) : heap_(heap) {}
820
819 void VisitPointer(Object** p) { ScavengePointer(p); } 821 void VisitPointer(Object** p) { ScavengePointer(p); }
820 822
821 void VisitPointers(Object** start, Object** end) { 823 void VisitPointers(Object** start, Object** end) {
822 // Copy all HeapObject pointers in [start, end) 824 // Copy all HeapObject pointers in [start, end)
823 for (Object** p = start; p < end; p++) ScavengePointer(p); 825 for (Object** p = start; p < end; p++) ScavengePointer(p);
824 } 826 }
825 827
826 private: 828 private:
827 void ScavengePointer(Object** p) { 829 void ScavengePointer(Object** p) {
828 Object* object = *p; 830 Object* object = *p;
829 if (!HEAP->InNewSpace(object)) return; 831 if (!heap_->InNewSpace(object)) return;
830 Heap::ScavengeObject(reinterpret_cast<HeapObject**>(p), 832 Heap::ScavengeObject(reinterpret_cast<HeapObject**>(p),
831 reinterpret_cast<HeapObject*>(object)); 833 reinterpret_cast<HeapObject*>(object));
832 } 834 }
835
836 Heap* heap_;
833 }; 837 };
834 838
835 839
836 #ifdef DEBUG 840 #ifdef DEBUG
837 // Visitor class to verify pointers in code or data space do not point into 841 // Visitor class to verify pointers in code or data space do not point into
838 // new space. 842 // new space.
839 class VerifyNonPointerSpacePointersVisitor: public ObjectVisitor { 843 class VerifyNonPointerSpacePointersVisitor: public ObjectVisitor {
840 public: 844 public:
841 void VisitPointers(Object** start, Object**end) { 845 void VisitPointers(Object** start, Object**end) {
842 for (Object** current = start; current < end; current++) { 846 for (Object** current = start; current < end; current++) {
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
876 } 880 }
877 881
878 882
879 void Heap::Scavenge() { 883 void Heap::Scavenge() {
880 #ifdef DEBUG 884 #ifdef DEBUG
881 if (FLAG_enable_slow_asserts) VerifyNonPointerSpacePointers(); 885 if (FLAG_enable_slow_asserts) VerifyNonPointerSpacePointers();
882 #endif 886 #endif
883 887
884 gc_state_ = SCAVENGE; 888 gc_state_ = SCAVENGE;
885 889
886 Page::FlipMeaningOfInvalidatedWatermarkFlag(); 890 Page::FlipMeaningOfInvalidatedWatermarkFlag(this);
887 #ifdef DEBUG 891 #ifdef DEBUG
888 VerifyPageWatermarkValidity(old_pointer_space_, ALL_VALID); 892 VerifyPageWatermarkValidity(old_pointer_space_, ALL_VALID);
889 VerifyPageWatermarkValidity(map_space_, ALL_VALID); 893 VerifyPageWatermarkValidity(map_space_, ALL_VALID);
890 #endif 894 #endif
891 895
892 // We do not update an allocation watermark of the top page during linear 896 // We do not update an allocation watermark of the top page during linear
893 // allocation to avoid overhead. So to maintain the watermark invariant 897 // allocation to avoid overhead. So to maintain the watermark invariant
894 // we have to manually cache the watermark and mark the top page as having an 898 // we have to manually cache the watermark and mark the top page as having an
895 // invalid watermark. This guarantees that dirty regions iteration will use a 899 // invalid watermark. This guarantees that dirty regions iteration will use a
896 // correct watermark even if a linear allocation happens. 900 // correct watermark even if a linear allocation happens.
(...skipping 30 matching lines...) Expand all
927 // updated as a side effect of promoting an object. 931 // updated as a side effect of promoting an object.
928 // 932 //
929 // There is guaranteed to be enough room at the top of the to space 933 // There is guaranteed to be enough room at the top of the to space
930 // for the addresses of promoted objects: every object promoted 934 // for the addresses of promoted objects: every object promoted
931 // frees up its size in bytes from the top of the new space, and 935 // frees up its size in bytes from the top of the new space, and
932 // objects are at least one pointer in size. 936 // objects are at least one pointer in size.
933 Address new_space_front = new_space_.ToSpaceLow(); 937 Address new_space_front = new_space_.ToSpaceLow();
934 promotion_queue_.Initialize(new_space_.ToSpaceHigh()); 938 promotion_queue_.Initialize(new_space_.ToSpaceHigh());
935 939
936 is_safe_to_read_maps_ = false; 940 is_safe_to_read_maps_ = false;
937 ScavengeVisitor scavenge_visitor; 941 ScavengeVisitor scavenge_visitor(this);
938 // Copy roots. 942 // Copy roots.
939 IterateRoots(&scavenge_visitor, VISIT_ALL_IN_SCAVENGE); 943 IterateRoots(&scavenge_visitor, VISIT_ALL_IN_SCAVENGE);
940 944
941 // Copy objects reachable from the old generation. By definition, 945 // Copy objects reachable from the old generation. By definition,
942 // there are no intergenerational pointers in code or data spaces. 946 // there are no intergenerational pointers in code or data spaces.
943 IterateDirtyRegions(old_pointer_space_, 947 IterateDirtyRegions(old_pointer_space_,
944 &Heap::IteratePointersInDirtyRegion, 948 &Heap::IteratePointersInDirtyRegion,
945 &ScavengePointer, 949 &ScavengePointer,
946 WATERMARK_CAN_BE_INVALID); 950 WATERMARK_CAN_BE_INVALID);
947 951
(...skipping 3997 matching lines...) Expand 10 before | Expand all | Expand 10 after
4945 } 4949 }
4946 4950
4947 4951
4948 void ExternalStringTable::TearDown() { 4952 void ExternalStringTable::TearDown() {
4949 new_space_strings_.Free(); 4953 new_space_strings_.Free();
4950 old_space_strings_.Free(); 4954 old_space_strings_.Free();
4951 } 4955 }
4952 4956
4953 4957
4954 } } // namespace v8::internal 4958 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/ast.cc ('k') | src/isolate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698