Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 chunk->SetFlag(MemoryChunk::IN_NEW_SPACE); |
| 406 bool in_to_space = (semispace_id != kFromSpace); | |
| 407 chunk->SetFlagTo(MemoryChunk::IN_TO_SPACE, in_to_space); | |
| 402 heap->incremental_marking()->SetNewSpacePageFlags(chunk); | 408 heap->incremental_marking()->SetNewSpacePageFlags(chunk); |
| 403 return static_cast<NewSpacePage*>(chunk); | 409 return static_cast<NewSpacePage*>(chunk); |
| 404 } | 410 } |
| 405 | 411 |
| 406 | 412 |
| 407 MemoryChunk* MemoryChunk::Initialize(Heap* heap, | 413 MemoryChunk* MemoryChunk::Initialize(Heap* heap, |
| 408 Address base, | 414 Address base, |
| 409 size_t size, | 415 size_t size, |
| 410 Executability executable, | 416 Executability executable, |
| 411 Space* owner) { | 417 Space* owner) { |
| (...skipping 513 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 925 } | 931 } |
| 926 | 932 |
| 927 #endif | 933 #endif |
| 928 | 934 |
| 929 | 935 |
| 930 void NewSpace::Flip() { | 936 void NewSpace::Flip() { |
| 931 SemiSpace tmp = from_space_; | 937 SemiSpace tmp = from_space_; |
| 932 from_space_ = to_space_; | 938 from_space_ = to_space_; |
| 933 to_space_ = tmp; | 939 to_space_ = tmp; |
| 934 | 940 |
| 935 NewSpacePage* old_active_page = from_space_.current_page(); | 941 // Copy GC flags from old active space (from-space) to new (to-space). |
| 936 NewSpacePage* new_active_page = to_space_.current_page(); | 942 intptr_t flags = from_space_.current_page()->GetFlags(); |
| 937 new_active_page->CopyFlagsFrom(old_active_page); | 943 // GC related flags. |
| 944 intptr_t mask = | |
| 945 (1 << MemoryChunk::WAS_SWEPT_CONSERVATIVELY) | | |
| 946 (1 << MemoryChunk::CONTAINS_ONLY_DATA) | | |
| 947 (1 << MemoryChunk::POINTERS_TO_HERE_ARE_INTERESTING) | | |
| 948 (1 << MemoryChunk::POINTERS_FROM_HERE_ARE_INTERESTING) | | |
| 949 (1 << MemoryChunk::SCAN_ON_SCAVENGE); | |
|
Lasse Reichstein
2011/05/24 10:54:57
Vyacheslav, is this the correct flags to move? Or
Vyacheslav Egorov (Chromium)
2011/05/24 10:58:47
I think POINTERS_FROM_HERE_ARE_INTERESTING POINTE
Lasse Reichstein
2011/05/24 12:29:03
Reduced and added as constant in NewSpacePage.
| |
| 950 to_space_.Flip(flags, mask); | |
| 951 | |
| 952 from_space_.Flip(0, 0); | |
| 938 } | 953 } |
| 939 | 954 |
| 940 | 955 |
| 941 void NewSpace::Grow() { | 956 void NewSpace::Grow() { |
| 942 ASSERT(Capacity() < MaximumCapacity()); | 957 ASSERT(Capacity() < MaximumCapacity()); |
| 943 if (to_space_.Grow()) { | 958 if (to_space_.Grow()) { |
| 944 // Only grow from space if we managed to grow to space. | 959 // Only grow from space if we managed to grow to space. |
| 945 if (!from_space_.Grow()) { | 960 if (!from_space_.Grow()) { |
| 946 // If we managed to grow to space but couldn't grow from space, | 961 // If we managed to grow to space but couldn't grow from space, |
| 947 // attempt to shrink to space. | 962 // attempt to shrink to space. |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1028 | 1043 |
| 1029 bool SemiSpace::Commit() { | 1044 bool SemiSpace::Commit() { |
| 1030 ASSERT(!is_committed()); | 1045 ASSERT(!is_committed()); |
| 1031 if (!heap()->isolate()->memory_allocator()->CommitBlock( | 1046 if (!heap()->isolate()->memory_allocator()->CommitBlock( |
| 1032 start_, capacity_, executable())) { | 1047 start_, capacity_, executable())) { |
| 1033 return false; | 1048 return false; |
| 1034 } | 1049 } |
| 1035 committed_ = true; | 1050 committed_ = true; |
| 1036 // TODO(gc): When more than one page is present, initialize and | 1051 // TODO(gc): When more than one page is present, initialize and |
| 1037 // chain them all. | 1052 // chain them all. |
| 1038 current_page_ = NewSpacePage::Initialize(heap(), start_); | 1053 SemiSpaceId semispace = is_to_space_ ? kToSpace : kFromSpace; |
| 1054 current_page_ = NewSpacePage::Initialize(heap(), start_, semispace); | |
| 1039 return true; | 1055 return true; |
| 1040 } | 1056 } |
| 1041 | 1057 |
| 1042 | 1058 |
| 1043 bool SemiSpace::Uncommit() { | 1059 bool SemiSpace::Uncommit() { |
| 1044 ASSERT(is_committed()); | 1060 ASSERT(is_committed()); |
| 1045 if (!heap()->isolate()->memory_allocator()->UncommitBlock( | 1061 if (!heap()->isolate()->memory_allocator()->UncommitBlock( |
| 1046 start_, capacity_)) { | 1062 start_, capacity_)) { |
| 1047 return false; | 1063 return false; |
| 1048 } | 1064 } |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1127 ASSERT(IsAligned(delta, OS::AllocateAlignment())); | 1143 ASSERT(IsAligned(delta, OS::AllocateAlignment())); |
| 1128 if (!heap()->isolate()->memory_allocator()->UncommitBlock( | 1144 if (!heap()->isolate()->memory_allocator()->UncommitBlock( |
| 1129 high() - delta, delta)) { | 1145 high() - delta, delta)) { |
| 1130 return false; | 1146 return false; |
| 1131 } | 1147 } |
| 1132 capacity_ = new_capacity; | 1148 capacity_ = new_capacity; |
| 1133 return true; | 1149 return true; |
| 1134 } | 1150 } |
| 1135 | 1151 |
| 1136 | 1152 |
| 1153 void SemiSpace::Flip(intptr_t flags, intptr_t mask) { | |
| 1154 is_to_space_ = !is_to_space_; | |
|
Erik Corry
2011/05/24 11:25:50
This can be written in terms of GetFlag and SetFla
Lasse Reichstein
2011/05/24 12:29:03
No, it works on the "flags" argument, not the "fla
| |
| 1155 intptr_t in_to_space_mask = (1 << MemoryChunk::IN_TO_SPACE); | |
| 1156 if (is_to_space_) { | |
| 1157 flags |= in_to_space_mask; | |
| 1158 } else { | |
| 1159 flags &= ~in_to_space_mask; | |
| 1160 } | |
| 1161 mask |= in_to_space_mask; | |
| 1162 NewSpacePage* page = NewSpacePage::FromAddress(start_); | |
| 1163 while (page != NULL) { | |
| 1164 page->SetFlags(flags, mask); | |
| 1165 page = page->next_page(); | |
| 1166 } | |
| 1167 } | |
| 1168 | |
| 1137 #ifdef DEBUG | 1169 #ifdef DEBUG |
| 1138 void SemiSpace::Print() { } | 1170 void SemiSpace::Print() { } |
| 1139 | 1171 |
| 1140 | 1172 |
| 1141 void SemiSpace::Verify() { } | 1173 void SemiSpace::Verify() { } |
| 1142 #endif | 1174 #endif |
| 1143 | 1175 |
| 1144 | 1176 |
| 1145 // ----------------------------------------------------------------------------- | 1177 // ----------------------------------------------------------------------------- |
| 1146 // SemiSpaceIterator implementation. | 1178 // SemiSpaceIterator implementation. |
| (...skipping 1118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2265 for (HeapObject* obj = obj_it.Next(); obj != NULL; obj = obj_it.Next()) { | 2297 for (HeapObject* obj = obj_it.Next(); obj != NULL; obj = obj_it.Next()) { |
| 2266 if (obj->IsCode()) { | 2298 if (obj->IsCode()) { |
| 2267 Code* code = Code::cast(obj); | 2299 Code* code = Code::cast(obj); |
| 2268 isolate->code_kind_statistics()[code->kind()] += code->Size(); | 2300 isolate->code_kind_statistics()[code->kind()] += code->Size(); |
| 2269 } | 2301 } |
| 2270 } | 2302 } |
| 2271 } | 2303 } |
| 2272 #endif // DEBUG | 2304 #endif // DEBUG |
| 2273 | 2305 |
| 2274 } } // namespace v8::internal | 2306 } } // namespace v8::internal |
| OLD | NEW |