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

Side by Side Diff: src/spaces.cc

Issue 7058009: Make InToSpace/InFromSpace use the page header. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/gc
Patch Set: Addressed review comments. Created 9 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
« no previous file with comments | « src/spaces.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 373 matching lines...) Expand 10 before | Expand all | Expand 10 after
384 } 384 }
385 385
386 386
387 void Page::InitializeAsAnchor(PagedSpace* owner) { 387 void Page::InitializeAsAnchor(PagedSpace* owner) {
388 set_owner(owner); 388 set_owner(owner);
389 set_prev_page(this); 389 set_prev_page(this);
390 set_next_page(this); 390 set_next_page(this);
391 } 391 }
392 392
393 393
394 NewSpacePage* NewSpacePage::Initialize(Heap* heap, Address start) { 394 NewSpacePage* NewSpacePage::Initialize(Heap* heap,
395 Address start,
396 SemiSpaceId semispace_id) {
395 MemoryChunk* chunk = MemoryChunk::Initialize(heap, 397 MemoryChunk* chunk = MemoryChunk::Initialize(heap,
396 start, 398 start,
397 Page::kPageSize, 399 Page::kPageSize,
398 NOT_EXECUTABLE, 400 NOT_EXECUTABLE,
399 heap->new_space()); 401 heap->new_space());
402 chunk->set_next_chunk(NULL);
403 chunk->set_prev_chunk(NULL);
400 chunk->initialize_scan_on_scavenge(true); 404 chunk->initialize_scan_on_scavenge(true);
401 chunk->SetFlag(MemoryChunk::IN_NEW_SPACE); 405 bool in_to_space = (semispace_id != kFromSpace);
406 chunk->SetFlag(in_to_space ? MemoryChunk::IN_TO_SPACE
407 : MemoryChunk::IN_FROM_SPACE);
408 ASSERT(!chunk->IsFlagSet(in_to_space ? MemoryChunk::IN_FROM_SPACE
409 : MemoryChunk::IN_TO_SPACE));
402 heap->incremental_marking()->SetNewSpacePageFlags(chunk); 410 heap->incremental_marking()->SetNewSpacePageFlags(chunk);
403 return static_cast<NewSpacePage*>(chunk); 411 return static_cast<NewSpacePage*>(chunk);
404 } 412 }
405 413
406 414
407 MemoryChunk* MemoryChunk::Initialize(Heap* heap, 415 MemoryChunk* MemoryChunk::Initialize(Heap* heap,
408 Address base, 416 Address base,
409 size_t size, 417 size_t size,
410 Executability executable, 418 Executability executable,
411 Space* owner) { 419 Space* owner) {
(...skipping 513 matching lines...) Expand 10 before | Expand all | Expand 10 after
925 } 933 }
926 934
927 #endif 935 #endif
928 936
929 937
930 void NewSpace::Flip() { 938 void NewSpace::Flip() {
931 SemiSpace tmp = from_space_; 939 SemiSpace tmp = from_space_;
932 from_space_ = to_space_; 940 from_space_ = to_space_;
933 to_space_ = tmp; 941 to_space_ = tmp;
934 942
935 NewSpacePage* old_active_page = from_space_.current_page(); 943 // Copy GC flags from old active space (from-space) to new (to-space).
936 NewSpacePage* new_active_page = to_space_.current_page(); 944 intptr_t flags = from_space_.current_page()->GetFlags();
937 new_active_page->CopyFlagsFrom(old_active_page); 945 to_space_.Flip(flags, NewSpacePage::kCopyOnFlipFlagsMask);
946
947 from_space_.Flip(0, 0);
938 } 948 }
939 949
940 950
941 void NewSpace::Grow() { 951 void NewSpace::Grow() {
942 ASSERT(Capacity() < MaximumCapacity()); 952 ASSERT(Capacity() < MaximumCapacity());
943 if (to_space_.Grow()) { 953 if (to_space_.Grow()) {
944 // Only grow from space if we managed to grow to space. 954 // Only grow from space if we managed to grow to space.
945 if (!from_space_.Grow()) { 955 if (!from_space_.Grow()) {
946 // If we managed to grow to space but couldn't grow from space, 956 // If we managed to grow to space but couldn't grow from space,
947 // attempt to shrink to space. 957 // attempt to shrink to space.
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
1028 1038
1029 bool SemiSpace::Commit() { 1039 bool SemiSpace::Commit() {
1030 ASSERT(!is_committed()); 1040 ASSERT(!is_committed());
1031 if (!heap()->isolate()->memory_allocator()->CommitBlock( 1041 if (!heap()->isolate()->memory_allocator()->CommitBlock(
1032 start_, capacity_, executable())) { 1042 start_, capacity_, executable())) {
1033 return false; 1043 return false;
1034 } 1044 }
1035 committed_ = true; 1045 committed_ = true;
1036 // TODO(gc): When more than one page is present, initialize and 1046 // TODO(gc): When more than one page is present, initialize and
1037 // chain them all. 1047 // chain them all.
1038 current_page_ = NewSpacePage::Initialize(heap(), start_); 1048 current_page_ = NewSpacePage::Initialize(heap(), start_, id_);
1039 return true; 1049 return true;
1040 } 1050 }
1041 1051
1042 1052
1043 bool SemiSpace::Uncommit() { 1053 bool SemiSpace::Uncommit() {
1044 ASSERT(is_committed()); 1054 ASSERT(is_committed());
1045 if (!heap()->isolate()->memory_allocator()->UncommitBlock( 1055 if (!heap()->isolate()->memory_allocator()->UncommitBlock(
1046 start_, capacity_)) { 1056 start_, capacity_)) {
1047 return false; 1057 return false;
1048 } 1058 }
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
1127 ASSERT(IsAligned(delta, OS::AllocateAlignment())); 1137 ASSERT(IsAligned(delta, OS::AllocateAlignment()));
1128 if (!heap()->isolate()->memory_allocator()->UncommitBlock( 1138 if (!heap()->isolate()->memory_allocator()->UncommitBlock(
1129 high() - delta, delta)) { 1139 high() - delta, delta)) {
1130 return false; 1140 return false;
1131 } 1141 }
1132 capacity_ = new_capacity; 1142 capacity_ = new_capacity;
1133 return true; 1143 return true;
1134 } 1144 }
1135 1145
1136 1146
1147 void SemiSpace::Flip(intptr_t flags, intptr_t mask) {
1148 bool becomes_to_space = (id_ == kFromSpace);
1149 id_ = becomes_to_space ? kToSpace : kFromSpace;
Erik Corry 2011/05/24 12:38:36 This can all be rewritten in terms of SetFlag and
1150 intptr_t semi_space_mask =
1151 (1 << MemoryChunk::IN_FROM_SPACE) | (1 << MemoryChunk::IN_TO_SPACE);
1152 flags &= ~semi_space_mask;
1153 if (becomes_to_space) {
1154 flags |= 1 << MemoryChunk::IN_TO_SPACE;
1155 } else {
1156 flags |= 1 << MemoryChunk::IN_FROM_SPACE;
1157 }
1158 mask |= semi_space_mask;
1159 NewSpacePage* page = NewSpacePage::FromAddress(start_);
1160 while (page != NULL) {
1161 page->SetFlags(flags, mask);
1162 page = page->next_page();
1163 }
1164 }
1165
1137 #ifdef DEBUG 1166 #ifdef DEBUG
1138 void SemiSpace::Print() { } 1167 void SemiSpace::Print() { }
1139 1168
1140 1169
1141 void SemiSpace::Verify() { } 1170 void SemiSpace::Verify() { }
1142 #endif 1171 #endif
1143 1172
1144 1173
1145 // ----------------------------------------------------------------------------- 1174 // -----------------------------------------------------------------------------
1146 // SemiSpaceIterator implementation. 1175 // SemiSpaceIterator implementation.
(...skipping 1118 matching lines...) Expand 10 before | Expand all | Expand 10 after
2265 for (HeapObject* obj = obj_it.Next(); obj != NULL; obj = obj_it.Next()) { 2294 for (HeapObject* obj = obj_it.Next(); obj != NULL; obj = obj_it.Next()) {
2266 if (obj->IsCode()) { 2295 if (obj->IsCode()) {
2267 Code* code = Code::cast(obj); 2296 Code* code = Code::cast(obj);
2268 isolate->code_kind_statistics()[code->kind()] += code->Size(); 2297 isolate->code_kind_statistics()[code->kind()] += code->Size();
2269 } 2298 }
2270 } 2299 }
2271 } 2300 }
2272 #endif // DEBUG 2301 #endif // DEBUG
2273 2302
2274 } } // namespace v8::internal 2303 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/spaces.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698