| 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 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 358 | 358 |
| 359 // Checks whether addr can be a limit of addresses in this page. | 359 // Checks whether addr can be a limit of addresses in this page. |
| 360 // It's a limit if it's in the page, or if it's just after the | 360 // It's a limit if it's in the page, or if it's just after the |
| 361 // last byte of the page. | 361 // last byte of the page. |
| 362 bool ContainsLimit(Address addr) { | 362 bool ContainsLimit(Address addr) { |
| 363 return addr >= body() && addr <= address() + size(); | 363 return addr >= body() && addr <= address() + size(); |
| 364 } | 364 } |
| 365 | 365 |
| 366 enum MemoryChunkFlags { | 366 enum MemoryChunkFlags { |
| 367 IS_EXECUTABLE, | 367 IS_EXECUTABLE, |
| 368 WAS_SWEPT_CONSERVATIVELY, | |
| 369 ABOUT_TO_BE_FREED, | 368 ABOUT_TO_BE_FREED, |
| 370 POINTERS_TO_HERE_ARE_INTERESTING, | 369 POINTERS_TO_HERE_ARE_INTERESTING, |
| 371 POINTERS_FROM_HERE_ARE_INTERESTING, | 370 POINTERS_FROM_HERE_ARE_INTERESTING, |
| 372 SCAN_ON_SCAVENGE, | 371 SCAN_ON_SCAVENGE, |
| 373 IN_FROM_SPACE, // Mutually exclusive with IN_TO_SPACE. | 372 IN_FROM_SPACE, // Mutually exclusive with IN_TO_SPACE. |
| 374 IN_TO_SPACE, // All pages in new space has one of these two set. | 373 IN_TO_SPACE, // All pages in new space has one of these two set. |
| 375 NEW_SPACE_BELOW_AGE_MARK, | 374 NEW_SPACE_BELOW_AGE_MARK, |
| 376 CONTAINS_ONLY_DATA, | 375 CONTAINS_ONLY_DATA, |
| 377 EVACUATION_CANDIDATE, | 376 EVACUATION_CANDIDATE, |
| 378 RESCAN_ON_EVACUATION, | 377 RESCAN_ON_EVACUATION, |
| 379 WAS_SWEPT, | 378 |
| 379 // Pages swept precisely can be iterated, hitting only the live objects. |
| 380 // Whereas those swept conservatively cannot be iterated over. Both flags |
| 381 // indicate that marking bits have been cleared by the sweeper, otherwise |
| 382 // marking bits are still intact. |
| 383 WAS_SWEPT_PRECISELY, |
| 384 WAS_SWEPT_CONSERVATIVELY, |
| 385 |
| 386 // Last flag, keep at bottom. |
| 380 NUM_MEMORY_CHUNK_FLAGS | 387 NUM_MEMORY_CHUNK_FLAGS |
| 381 }; | 388 }; |
| 382 | 389 |
| 383 | 390 |
| 384 static const int kPointersToHereAreInterestingMask = | 391 static const int kPointersToHereAreInterestingMask = |
| 385 1 << POINTERS_TO_HERE_ARE_INTERESTING; | 392 1 << POINTERS_TO_HERE_ARE_INTERESTING; |
| 386 | 393 |
| 387 static const int kPointersFromHereAreInterestingMask = | 394 static const int kPointersFromHereAreInterestingMask = |
| 388 1 << POINTERS_FROM_HERE_ARE_INTERESTING; | 395 1 << POINTERS_FROM_HERE_ARE_INTERESTING; |
| 389 | 396 |
| (...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 648 | 655 |
| 649 inline void ClearGCFields(); | 656 inline void ClearGCFields(); |
| 650 | 657 |
| 651 static inline Page* Initialize(Heap* heap, | 658 static inline Page* Initialize(Heap* heap, |
| 652 MemoryChunk* chunk, | 659 MemoryChunk* chunk, |
| 653 Executability executable, | 660 Executability executable, |
| 654 PagedSpace* owner); | 661 PagedSpace* owner); |
| 655 | 662 |
| 656 void InitializeAsAnchor(PagedSpace* owner); | 663 void InitializeAsAnchor(PagedSpace* owner); |
| 657 | 664 |
| 658 bool WasSwept() { return IsFlagSet(WAS_SWEPT); } | 665 bool WasSweptPrecisely() { return IsFlagSet(WAS_SWEPT_PRECISELY); } |
| 666 bool WasSweptConservatively() { return IsFlagSet(WAS_SWEPT_CONSERVATIVELY); } |
| 667 bool WasSwept() { return WasSweptPrecisely() || WasSweptConservatively(); } |
| 659 | 668 |
| 660 void MarkSwept() { SetFlag(WAS_SWEPT); } | 669 void MarkSweptPrecisely() { SetFlag(WAS_SWEPT_PRECISELY); } |
| 670 void MarkSweptConservatively() { SetFlag(WAS_SWEPT_CONSERVATIVELY); } |
| 661 | 671 |
| 662 void ClearSwept() { ClearFlag(WAS_SWEPT); } | 672 void ClearSweptPrecisely() { ClearFlag(WAS_SWEPT_PRECISELY); } |
| 673 void ClearSweptConservatively() { ClearFlag(WAS_SWEPT_CONSERVATIVELY); } |
| 663 | 674 |
| 664 friend class MemoryAllocator; | 675 friend class MemoryAllocator; |
| 665 }; | 676 }; |
| 666 | 677 |
| 667 | 678 |
| 668 STATIC_CHECK(sizeof(Page) <= MemoryChunk::kHeaderSize); | 679 STATIC_CHECK(sizeof(Page) <= MemoryChunk::kHeaderSize); |
| 669 | 680 |
| 670 | 681 |
| 671 class LargePage : public MemoryChunk { | 682 class LargePage : public MemoryChunk { |
| 672 public: | 683 public: |
| (...skipping 744 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1417 | 1428 |
| 1418 // Report code object related statistics | 1429 // Report code object related statistics |
| 1419 void CollectCodeStatistics(); | 1430 void CollectCodeStatistics(); |
| 1420 static void ReportCodeStatistics(); | 1431 static void ReportCodeStatistics(); |
| 1421 static void ResetCodeStatistics(); | 1432 static void ResetCodeStatistics(); |
| 1422 #endif | 1433 #endif |
| 1423 | 1434 |
| 1424 bool was_swept_conservatively() { return was_swept_conservatively_; } | 1435 bool was_swept_conservatively() { return was_swept_conservatively_; } |
| 1425 void set_was_swept_conservatively(bool b) { was_swept_conservatively_ = b; } | 1436 void set_was_swept_conservatively(bool b) { was_swept_conservatively_ = b; } |
| 1426 | 1437 |
| 1438 // Evacuation candidates are swept by evacuator. Needs to return a valid |
| 1439 // result before _and_ after evacuation has finished. |
| 1440 static bool ShouldBeSweptLazily(Page* p) { |
| 1441 return !p->IsEvacuationCandidate() && |
| 1442 !p->IsFlagSet(Page::RESCAN_ON_EVACUATION) && |
| 1443 !p->WasSweptPrecisely(); |
| 1444 } |
| 1445 |
| 1427 void SetPagesToSweep(Page* first, Page* last) { | 1446 void SetPagesToSweep(Page* first, Page* last) { |
| 1428 first_unswept_page_ = first; | 1447 first_unswept_page_ = first; |
| 1429 last_unswept_page_ = last; | 1448 last_unswept_page_ = last; |
| 1430 int unswept_pages = 0; | |
| 1431 | |
| 1432 Page* p = first; | |
| 1433 do { | |
| 1434 // The WAS_SWEPT_CONSERVATIVELY flag means that we can't iterate over the | |
| 1435 // page. We have to set this flag on the pages to indicate this. | |
| 1436 p->SetFlag(MemoryChunk::WAS_SWEPT_CONSERVATIVELY); | |
| 1437 p = p->next_page(); | |
| 1438 unswept_pages++; | |
| 1439 } while (p != last); | |
| 1440 | |
| 1441 if (FLAG_trace_gc_verbose) { | |
| 1442 PrintF("Postponing sweep for %d pages\n", unswept_pages); | |
| 1443 } | |
| 1444 } | 1449 } |
| 1445 | 1450 |
| 1446 bool AdvanceSweeper(intptr_t bytes_to_sweep); | 1451 bool AdvanceSweeper(intptr_t bytes_to_sweep); |
| 1447 | 1452 |
| 1448 bool IsSweepingComplete() { | 1453 bool IsSweepingComplete() { |
| 1449 return !first_unswept_page_->is_valid(); | 1454 return !first_unswept_page_->is_valid(); |
| 1450 } | 1455 } |
| 1451 | 1456 |
| 1452 Page* FirstPage() { return anchor_.next_page(); } | 1457 Page* FirstPage() { return anchor_.next_page(); } |
| 1453 Page* LastPage() { return anchor_.prev_page(); } | 1458 Page* LastPage() { return anchor_.prev_page(); } |
| (...skipping 1047 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2501 } | 2506 } |
| 2502 // Must be small, since an iteration is used for lookup. | 2507 // Must be small, since an iteration is used for lookup. |
| 2503 static const int kMaxComments = 64; | 2508 static const int kMaxComments = 64; |
| 2504 }; | 2509 }; |
| 2505 #endif | 2510 #endif |
| 2506 | 2511 |
| 2507 | 2512 |
| 2508 } } // namespace v8::internal | 2513 } } // namespace v8::internal |
| 2509 | 2514 |
| 2510 #endif // V8_SPACES_H_ | 2515 #endif // V8_SPACES_H_ |
| OLD | NEW |