OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
347 } | 347 } |
348 | 348 |
349 #if DCHECK_IS_ON() | 349 #if DCHECK_IS_ON() |
350 // Sanity check for a page header address: the address of the page | 350 // Sanity check for a page header address: the address of the page |
351 // header should be OS page size away from being Blink page size | 351 // header should be OS page size away from being Blink page size |
352 // aligned. | 352 // aligned. |
353 inline bool isPageHeaderAddress(Address address) { | 353 inline bool isPageHeaderAddress(Address address) { |
354 return !((reinterpret_cast<uintptr_t>(address) & blinkPageOffsetMask) - | 354 return !((reinterpret_cast<uintptr_t>(address) & blinkPageOffsetMask) - |
355 blinkGuardPageSize); | 355 blinkGuardPageSize); |
356 } | 356 } |
| 357 |
| 358 // Callback used for unit testing the marking of conservative pointers |
| 359 // (checkAndMarkPointer().) For each pointer that has been discovered |
| 360 // to point to a heap object, the callback is invoked with a pointer |
| 361 // to its header. If the callback returns |true|, the object will not |
| 362 // be marked. |
| 363 using MarkedPointerCallbackForTesting = bool (*)(HeapObjectHeader*); |
357 #endif | 364 #endif |
358 | 365 |
359 // BasePage is a base class for NormalPage and LargeObjectPage. | 366 // BasePage is a base class for NormalPage and LargeObjectPage. |
360 // | 367 // |
361 // - NormalPage is a page whose size is |blinkPageSize|. NormalPage can contain | 368 // - NormalPage is a page whose size is |blinkPageSize|. NormalPage can contain |
362 // multiple objects in the page. An object whose size is smaller than | 369 // multiple objects in the page. An object whose size is smaller than |
363 // |largeObjectSizeThreshold| is stored in NormalPage. | 370 // |largeObjectSizeThreshold| is stored in NormalPage. |
364 // | 371 // |
365 // - LargeObjectPage is a page that contains only one object. The object size | 372 // - LargeObjectPage is a page that contains only one object. The object size |
366 // is arbitrary. An object whose size is larger than |blinkPageSize| is stored | 373 // is arbitrary. An object whose size is larger than |blinkPageSize| is stored |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
401 #endif | 408 #endif |
402 // Check if the given address points to an object in this | 409 // Check if the given address points to an object in this |
403 // heap page. If so, find the start of that object and mark it | 410 // heap page. If so, find the start of that object and mark it |
404 // using the given Visitor. Otherwise do nothing. The pointer must | 411 // using the given Visitor. Otherwise do nothing. The pointer must |
405 // be within the same aligned blinkPageSize as the this-pointer. | 412 // be within the same aligned blinkPageSize as the this-pointer. |
406 // | 413 // |
407 // This is used during conservative stack scanning to | 414 // This is used during conservative stack scanning to |
408 // conservatively mark all objects that could be referenced from | 415 // conservatively mark all objects that could be referenced from |
409 // the stack. | 416 // the stack. |
410 virtual void checkAndMarkPointer(Visitor*, Address) = 0; | 417 virtual void checkAndMarkPointer(Visitor*, Address) = 0; |
| 418 #if DCHECK_IS_ON() |
| 419 virtual void checkAndMarkPointer(Visitor*, |
| 420 Address, |
| 421 MarkedPointerCallbackForTesting) = 0; |
| 422 #endif |
411 virtual void markOrphaned(); | 423 virtual void markOrphaned(); |
412 | 424 |
413 class HeapSnapshotInfo { | 425 class HeapSnapshotInfo { |
414 STACK_ALLOCATED(); | 426 STACK_ALLOCATED(); |
415 | 427 |
416 public: | 428 public: |
417 size_t freeCount = 0; | 429 size_t freeCount = 0; |
418 size_t freeSize = 0; | 430 size_t freeSize = 0; |
419 }; | 431 }; |
420 | 432 |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
482 void sweep() override; | 494 void sweep() override; |
483 void makeConsistentForGC() override; | 495 void makeConsistentForGC() override; |
484 void makeConsistentForMutator() override; | 496 void makeConsistentForMutator() override; |
485 void invalidateObjectStartBitmap() override { | 497 void invalidateObjectStartBitmap() override { |
486 m_objectStartBitMapComputed = false; | 498 m_objectStartBitMapComputed = false; |
487 } | 499 } |
488 #if defined(ADDRESS_SANITIZER) | 500 #if defined(ADDRESS_SANITIZER) |
489 void poisonUnmarkedObjects() override; | 501 void poisonUnmarkedObjects() override; |
490 #endif | 502 #endif |
491 void checkAndMarkPointer(Visitor*, Address) override; | 503 void checkAndMarkPointer(Visitor*, Address) override; |
| 504 #if DCHECK_IS_ON() |
| 505 void checkAndMarkPointer(Visitor*, |
| 506 Address, |
| 507 MarkedPointerCallbackForTesting) override; |
| 508 #endif |
492 void markOrphaned() override; | 509 void markOrphaned() override; |
493 | 510 |
494 void takeSnapshot(base::trace_event::MemoryAllocatorDump*, | 511 void takeSnapshot(base::trace_event::MemoryAllocatorDump*, |
495 ThreadState::GCSnapshotInfo&, | 512 ThreadState::GCSnapshotInfo&, |
496 HeapSnapshotInfo&) override; | 513 HeapSnapshotInfo&) override; |
497 #if DCHECK_IS_ON() | 514 #if DCHECK_IS_ON() |
498 // Returns true for the whole blinkPageSize page that the page is on, even | 515 // Returns true for the whole blinkPageSize page that the page is on, even |
499 // for the header, and the unmapped guard page at the start. That ensures | 516 // for the header, and the unmapped guard page at the start. That ensures |
500 // the result can be used to populate the negative page cache. | 517 // the result can be used to populate the negative page cache. |
501 bool contains(Address) override; | 518 bool contains(Address) override; |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
560 bool isEmpty() override; | 577 bool isEmpty() override; |
561 void removeFromHeap() override; | 578 void removeFromHeap() override; |
562 void sweep() override; | 579 void sweep() override; |
563 void makeConsistentForGC() override; | 580 void makeConsistentForGC() override; |
564 void makeConsistentForMutator() override; | 581 void makeConsistentForMutator() override; |
565 void invalidateObjectStartBitmap() override {} | 582 void invalidateObjectStartBitmap() override {} |
566 #if defined(ADDRESS_SANITIZER) | 583 #if defined(ADDRESS_SANITIZER) |
567 void poisonUnmarkedObjects() override; | 584 void poisonUnmarkedObjects() override; |
568 #endif | 585 #endif |
569 void checkAndMarkPointer(Visitor*, Address) override; | 586 void checkAndMarkPointer(Visitor*, Address) override; |
| 587 #if DCHECK_IS_ON() |
| 588 void checkAndMarkPointer(Visitor*, |
| 589 Address, |
| 590 MarkedPointerCallbackForTesting) override; |
| 591 #endif |
570 void markOrphaned() override; | 592 void markOrphaned() override; |
571 | 593 |
572 void takeSnapshot(base::trace_event::MemoryAllocatorDump*, | 594 void takeSnapshot(base::trace_event::MemoryAllocatorDump*, |
573 ThreadState::GCSnapshotInfo&, | 595 ThreadState::GCSnapshotInfo&, |
574 HeapSnapshotInfo&) override; | 596 HeapSnapshotInfo&) override; |
575 #if DCHECK_IS_ON() | 597 #if DCHECK_IS_ON() |
576 // Returns true for any address that is on one of the pages that this | 598 // Returns true for any address that is on one of the pages that this |
577 // large object uses. That ensures that we can use a negative result to | 599 // large object uses. That ensures that we can use a negative result to |
578 // populate the negative page cache. | 600 // populate the negative page cache. |
579 bool contains(Address) override; | 601 bool contains(Address) override; |
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
951 return outOfLineAllocate(allocationSize, gcInfoIndex); | 973 return outOfLineAllocate(allocationSize, gcInfoIndex); |
952 } | 974 } |
953 | 975 |
954 inline NormalPageArena* NormalPage::arenaForNormalPage() const { | 976 inline NormalPageArena* NormalPage::arenaForNormalPage() const { |
955 return static_cast<NormalPageArena*>(arena()); | 977 return static_cast<NormalPageArena*>(arena()); |
956 } | 978 } |
957 | 979 |
958 } // namespace blink | 980 } // namespace blink |
959 | 981 |
960 #endif // HeapPage_h | 982 #endif // HeapPage_h |
OLD | NEW |