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

Side by Side Diff: src/incremental-marking.cc

Issue 10386046: Implement map collection for incremental marking. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Major cleanup of prototype. Created 8 years, 7 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 2011 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
11 // with the distribution. 11 // with the distribution.
(...skipping 23 matching lines...) Expand all
35 35
36 namespace v8 { 36 namespace v8 {
37 namespace internal { 37 namespace internal {
38 38
39 39
40 IncrementalMarking::IncrementalMarking(Heap* heap) 40 IncrementalMarking::IncrementalMarking(Heap* heap)
41 : heap_(heap), 41 : heap_(heap),
42 state_(STOPPED), 42 state_(STOPPED),
43 marking_deque_memory_(NULL), 43 marking_deque_memory_(NULL),
44 marking_deque_memory_committed_(false), 44 marking_deque_memory_committed_(false),
45 marker_(this, heap->mark_compact_collector()),
45 steps_count_(0), 46 steps_count_(0),
46 steps_took_(0), 47 steps_took_(0),
47 longest_step_(0.0), 48 longest_step_(0.0),
48 old_generation_space_available_at_start_of_incremental_(0), 49 old_generation_space_available_at_start_of_incremental_(0),
49 old_generation_space_used_at_start_of_incremental_(0), 50 old_generation_space_used_at_start_of_incremental_(0),
50 steps_count_since_last_gc_(0), 51 steps_count_since_last_gc_(0),
51 steps_took_since_last_gc_(0), 52 steps_took_since_last_gc_(0),
52 should_hurry_(false), 53 should_hurry_(false),
53 allocation_marking_factor_(0), 54 allocation_marking_factor_(0),
54 allocated_(0), 55 allocated_(0),
(...skipping 745 matching lines...) Expand 10 before | Expand all | Expand 10 after
800 Map* global_context_map = heap_->global_context_map(); 801 Map* global_context_map = heap_->global_context_map();
801 IncrementalMarkingMarkingVisitor marking_visitor(heap_, this); 802 IncrementalMarkingMarkingVisitor marking_visitor(heap_, this);
802 while (!marking_deque_.IsEmpty() && bytes_to_process > 0) { 803 while (!marking_deque_.IsEmpty() && bytes_to_process > 0) {
803 HeapObject* obj = marking_deque_.Pop(); 804 HeapObject* obj = marking_deque_.Pop();
804 805
805 // Explicitly skip one word fillers. Incremental markbit patterns are 806 // Explicitly skip one word fillers. Incremental markbit patterns are
806 // correct only for objects that occupy at least two words. 807 // correct only for objects that occupy at least two words.
807 Map* map = obj->map(); 808 Map* map = obj->map();
808 if (map == filler_map) continue; 809 if (map == filler_map) continue;
809 810
810 if (obj->IsMap()) {
811 Map* map = Map::cast(obj);
812 heap_->ClearCacheOnMap(map);
813 }
814
815
816 int size = obj->SizeFromMap(map); 811 int size = obj->SizeFromMap(map);
817 bytes_to_process -= size; 812 bytes_to_process -= size;
818 MarkBit map_mark_bit = Marking::MarkBitFrom(map); 813 MarkBit map_mark_bit = Marking::MarkBitFrom(map);
819 if (Marking::IsWhite(map_mark_bit)) { 814 if (Marking::IsWhite(map_mark_bit)) {
820 WhiteToGreyAndPush(map, map_mark_bit); 815 WhiteToGreyAndPush(map, map_mark_bit);
821 } 816 }
822 817
823 // TODO(gc) switch to static visitor instead of normal visitor. 818 // TODO(gc) switch to static visitor instead of normal visitor.
824 if (map == global_context_map) { 819 if (map == global_context_map) {
825 // Global contexts have weak fields. 820 // Global contexts have weak fields.
826 Context* ctx = Context::cast(obj); 821 Context* ctx = Context::cast(obj);
827 822
828 // We will mark cache black with a separate pass 823 // We will mark cache black with a separate pass
829 // when we finish marking. 824 // when we finish marking.
830 MarkObjectGreyDoNotEnqueue(ctx->normalized_map_cache()); 825 MarkObjectGreyDoNotEnqueue(ctx->normalized_map_cache());
831 826
832 VisitGlobalContext(ctx, &marking_visitor); 827 VisitGlobalContext(ctx, &marking_visitor);
828 } else if (map->instance_type() == MAP_TYPE) {
829 Map* map = Map::cast(obj);
830 heap_->ClearCacheOnMap(map);
831
832 // When map collection is enabled we have to mark through map's
833 // transitions and back pointers in a special way to make these links
834 // weak. Only maps for subclasses of JSReceiver can have transitions.
835 STATIC_ASSERT(LAST_TYPE == LAST_JS_RECEIVER_TYPE);
836 if (FLAG_collect_maps && map->instance_type() >= FIRST_JS_RECEIVER_TYPE) {
Vyacheslav Egorov (Chromium) 2012/05/11 12:58:35 long line
Michael Starzinger 2012/05/11 14:51:53 Done.
837 marker_.MarkMapContents(map);
838
839 // Mark the Object* fields of the Map. Since the descriptor array has
840 // been marked already, it is fine that one of these fields contains a
841 // pointer to it. But make sure to skip back pointer and prototype
842 // transitions.
843 STATIC_ASSERT(Map::kPointerFieldsEndOffset ==
844 Map::kPrototypeTransitionsOrBackPointerOffset + kPointerSize);
845 marking_visitor.VisitPointers(
846 HeapObject::RawField(map, Map::kPointerFieldsBeginOffset),
847 HeapObject::RawField(
848 map, Map::kPrototypeTransitionsOrBackPointerOffset));
849 } else {
850 marking_visitor.VisitPointers(
851 HeapObject::RawField(map, Map::kPointerFieldsBeginOffset),
852 HeapObject::RawField(map, Map::kPointerFieldsEndOffset));
853 }
833 } else if (map->instance_type() == JS_FUNCTION_TYPE) { 854 } else if (map->instance_type() == JS_FUNCTION_TYPE) {
834 marking_visitor.VisitPointers( 855 marking_visitor.VisitPointers(
835 HeapObject::RawField(obj, JSFunction::kPropertiesOffset), 856 HeapObject::RawField(obj, JSFunction::kPropertiesOffset),
836 HeapObject::RawField(obj, JSFunction::kCodeEntryOffset)); 857 HeapObject::RawField(obj, JSFunction::kCodeEntryOffset));
837 858
838 marking_visitor.VisitCodeEntry( 859 marking_visitor.VisitCodeEntry(
839 obj->address() + JSFunction::kCodeEntryOffset); 860 obj->address() + JSFunction::kCodeEntryOffset);
840 861
841 marking_visitor.VisitPointers( 862 marking_visitor.VisitPointers(
842 HeapObject::RawField(obj, 863 HeapObject::RawField(obj,
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
948 allocation_marking_factor_ = kInitialAllocationMarkingFactor; 969 allocation_marking_factor_ = kInitialAllocationMarkingFactor;
949 bytes_scanned_ = 0; 970 bytes_scanned_ = 0;
950 } 971 }
951 972
952 973
953 int64_t IncrementalMarking::SpaceLeftInOldSpace() { 974 int64_t IncrementalMarking::SpaceLeftInOldSpace() {
954 return heap_->MaxOldGenerationSize() - heap_->PromotedSpaceSizeOfObjects(); 975 return heap_->MaxOldGenerationSize() - heap_->PromotedSpaceSizeOfObjects();
955 } 976 }
956 977
957 } } // namespace v8::internal 978 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698