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

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: Used Clear/Set macros more in SemiSpace::Flip 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 376 matching lines...) Expand 10 before | Expand all | Expand 10 after
387 } 387 }
388 388
389 389
390 void Page::InitializeAsAnchor(PagedSpace* owner) { 390 void Page::InitializeAsAnchor(PagedSpace* owner) {
391 set_owner(owner); 391 set_owner(owner);
392 set_prev_page(this); 392 set_prev_page(this);
393 set_next_page(this); 393 set_next_page(this);
394 } 394 }
395 395
396 396
397 NewSpacePage* NewSpacePage::Initialize(Heap* heap, Address start) { 397 NewSpacePage* NewSpacePage::Initialize(Heap* heap,
398 Address start,
399 SemiSpaceId semispace_id) {
398 MemoryChunk* chunk = MemoryChunk::Initialize(heap, 400 MemoryChunk* chunk = MemoryChunk::Initialize(heap,
399 start, 401 start,
400 Page::kPageSize, 402 Page::kPageSize,
401 NOT_EXECUTABLE, 403 NOT_EXECUTABLE,
402 heap->new_space()); 404 heap->new_space());
405 chunk->set_next_chunk(NULL);
406 chunk->set_prev_chunk(NULL);
403 chunk->initialize_scan_on_scavenge(true); 407 chunk->initialize_scan_on_scavenge(true);
404 chunk->SetFlag(MemoryChunk::IN_NEW_SPACE); 408 bool in_to_space = (semispace_id != kFromSpace);
409 chunk->SetFlag(in_to_space ? MemoryChunk::IN_TO_SPACE
410 : MemoryChunk::IN_FROM_SPACE);
411 ASSERT(!chunk->IsFlagSet(in_to_space ? MemoryChunk::IN_FROM_SPACE
412 : MemoryChunk::IN_TO_SPACE));
405 heap->incremental_marking()->SetNewSpacePageFlags(chunk); 413 heap->incremental_marking()->SetNewSpacePageFlags(chunk);
406 return static_cast<NewSpacePage*>(chunk); 414 return static_cast<NewSpacePage*>(chunk);
407 } 415 }
408 416
409 417
410 MemoryChunk* MemoryChunk::Initialize(Heap* heap, 418 MemoryChunk* MemoryChunk::Initialize(Heap* heap,
411 Address base, 419 Address base,
412 size_t size, 420 size_t size,
413 Executability executable, 421 Executability executable,
414 Space* owner) { 422 Space* owner) {
(...skipping 513 matching lines...) Expand 10 before | Expand all | Expand 10 after
928 } 936 }
929 937
930 #endif 938 #endif
931 939
932 940
933 void NewSpace::Flip() { 941 void NewSpace::Flip() {
934 SemiSpace tmp = from_space_; 942 SemiSpace tmp = from_space_;
935 from_space_ = to_space_; 943 from_space_ = to_space_;
936 to_space_ = tmp; 944 to_space_ = tmp;
937 945
938 NewSpacePage* old_active_page = from_space_.current_page(); 946 // Copy GC flags from old active space (from-space) to new (to-space).
939 NewSpacePage* new_active_page = to_space_.current_page(); 947 intptr_t flags = from_space_.current_page()->GetFlags();
940 new_active_page->CopyFlagsFrom(old_active_page); 948 to_space_.Flip(flags, NewSpacePage::kCopyOnFlipFlagsMask);
949
950 from_space_.Flip(0, 0);
941 } 951 }
942 952
943 953
944 void NewSpace::Grow() { 954 void NewSpace::Grow() {
945 ASSERT(Capacity() < MaximumCapacity()); 955 ASSERT(Capacity() < MaximumCapacity());
946 if (to_space_.Grow()) { 956 if (to_space_.Grow()) {
947 // Only grow from space if we managed to grow to space. 957 // Only grow from space if we managed to grow to space.
948 if (!from_space_.Grow()) { 958 if (!from_space_.Grow()) {
949 // If we managed to grow to space but couldn't grow from space, 959 // If we managed to grow to space but couldn't grow from space,
950 // attempt to shrink to space. 960 // attempt to shrink to space.
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
1031 1041
1032 bool SemiSpace::Commit() { 1042 bool SemiSpace::Commit() {
1033 ASSERT(!is_committed()); 1043 ASSERT(!is_committed());
1034 if (!heap()->isolate()->memory_allocator()->CommitBlock( 1044 if (!heap()->isolate()->memory_allocator()->CommitBlock(
1035 start_, capacity_, executable())) { 1045 start_, capacity_, executable())) {
1036 return false; 1046 return false;
1037 } 1047 }
1038 committed_ = true; 1048 committed_ = true;
1039 // TODO(gc): When more than one page is present, initialize and 1049 // TODO(gc): When more than one page is present, initialize and
1040 // chain them all. 1050 // chain them all.
1041 current_page_ = NewSpacePage::Initialize(heap(), start_); 1051 current_page_ = NewSpacePage::Initialize(heap(), start_, id_);
1042 return true; 1052 return true;
1043 } 1053 }
1044 1054
1045 1055
1046 bool SemiSpace::Uncommit() { 1056 bool SemiSpace::Uncommit() {
1047 ASSERT(is_committed()); 1057 ASSERT(is_committed());
1048 if (!heap()->isolate()->memory_allocator()->UncommitBlock( 1058 if (!heap()->isolate()->memory_allocator()->UncommitBlock(
1049 start_, capacity_)) { 1059 start_, capacity_)) {
1050 return false; 1060 return false;
1051 } 1061 }
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
1130 ASSERT(IsAligned(delta, OS::AllocateAlignment())); 1140 ASSERT(IsAligned(delta, OS::AllocateAlignment()));
1131 if (!heap()->isolate()->memory_allocator()->UncommitBlock( 1141 if (!heap()->isolate()->memory_allocator()->UncommitBlock(
1132 high() - delta, delta)) { 1142 high() - delta, delta)) {
1133 return false; 1143 return false;
1134 } 1144 }
1135 capacity_ = new_capacity; 1145 capacity_ = new_capacity;
1136 return true; 1146 return true;
1137 } 1147 }
1138 1148
1139 1149
1150 void SemiSpace::Flip(intptr_t flags, intptr_t mask) {
1151 bool becomes_to_space = (id_ == kFromSpace);
1152 id_ = becomes_to_space ? kToSpace : kFromSpace;
1153 NewSpacePage* page = NewSpacePage::FromAddress(start_);
1154 while (page != NULL) {
1155 page->SetFlags(flags, mask);
1156 if (becomes_to_space) {
1157 page->ClearFlag(MemoryChunk::IN_FROM_SPACE);
1158 page->SetFlag(MemoryChunk::IN_TO_SPACE);
1159 } else {
1160 page->SetFlag(MemoryChunk::IN_FROM_SPACE);
1161 page->ClearFlag(MemoryChunk::IN_TO_SPACE);
1162 }
1163 page = page->next_page();
1164 }
1165 }
1166
1140 #ifdef DEBUG 1167 #ifdef DEBUG
1141 void SemiSpace::Print() { } 1168 void SemiSpace::Print() { }
1142 1169
1143 1170
1144 void SemiSpace::Verify() { } 1171 void SemiSpace::Verify() { }
1145 #endif 1172 #endif
1146 1173
1147 1174
1148 // ----------------------------------------------------------------------------- 1175 // -----------------------------------------------------------------------------
1149 // SemiSpaceIterator implementation. 1176 // SemiSpaceIterator implementation.
(...skipping 1116 matching lines...) Expand 10 before | Expand all | Expand 10 after
2266 for (HeapObject* obj = obj_it.Next(); obj != NULL; obj = obj_it.Next()) { 2293 for (HeapObject* obj = obj_it.Next(); obj != NULL; obj = obj_it.Next()) {
2267 if (obj->IsCode()) { 2294 if (obj->IsCode()) {
2268 Code* code = Code::cast(obj); 2295 Code* code = Code::cast(obj);
2269 isolate->code_kind_statistics()[code->kind()] += code->Size(); 2296 isolate->code_kind_statistics()[code->kind()] += code->Size();
2270 } 2297 }
2271 } 2298 }
2272 } 2299 }
2273 #endif // DEBUG 2300 #endif // DEBUG
2274 2301
2275 } } // namespace v8::internal 2302 } } // 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