Chromium Code Reviews| 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 MarkedPointerCallback = bool (*)(HeapObjectHeader*); | |
|
haraken
2017/01/25 06:14:08
MarkedPointerCallbackForTesting ?
sof
2017/01/25 06:25:24
Done.
| |
| 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 MarkedPointerCallback) = 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*, Address, MarkedPointerCallback) override; | |
| 506 #endif | |
| 492 void markOrphaned() override; | 507 void markOrphaned() override; |
| 493 | 508 |
| 494 void takeSnapshot(base::trace_event::MemoryAllocatorDump*, | 509 void takeSnapshot(base::trace_event::MemoryAllocatorDump*, |
| 495 ThreadState::GCSnapshotInfo&, | 510 ThreadState::GCSnapshotInfo&, |
| 496 HeapSnapshotInfo&) override; | 511 HeapSnapshotInfo&) override; |
| 497 #if DCHECK_IS_ON() | 512 #if DCHECK_IS_ON() |
| 498 // Returns true for the whole blinkPageSize page that the page is on, even | 513 // 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 | 514 // 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. | 515 // the result can be used to populate the negative page cache. |
| 501 bool contains(Address) override; | 516 bool contains(Address) override; |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 560 bool isEmpty() override; | 575 bool isEmpty() override; |
| 561 void removeFromHeap() override; | 576 void removeFromHeap() override; |
| 562 void sweep() override; | 577 void sweep() override; |
| 563 void makeConsistentForGC() override; | 578 void makeConsistentForGC() override; |
| 564 void makeConsistentForMutator() override; | 579 void makeConsistentForMutator() override; |
| 565 void invalidateObjectStartBitmap() override {} | 580 void invalidateObjectStartBitmap() override {} |
| 566 #if defined(ADDRESS_SANITIZER) | 581 #if defined(ADDRESS_SANITIZER) |
| 567 void poisonUnmarkedObjects() override; | 582 void poisonUnmarkedObjects() override; |
| 568 #endif | 583 #endif |
| 569 void checkAndMarkPointer(Visitor*, Address) override; | 584 void checkAndMarkPointer(Visitor*, Address) override; |
| 585 #if DCHECK_IS_ON() | |
| 586 void checkAndMarkPointer(Visitor*, Address, MarkedPointerCallback) override; | |
| 587 #endif | |
| 570 void markOrphaned() override; | 588 void markOrphaned() override; |
| 571 | 589 |
| 572 void takeSnapshot(base::trace_event::MemoryAllocatorDump*, | 590 void takeSnapshot(base::trace_event::MemoryAllocatorDump*, |
| 573 ThreadState::GCSnapshotInfo&, | 591 ThreadState::GCSnapshotInfo&, |
| 574 HeapSnapshotInfo&) override; | 592 HeapSnapshotInfo&) override; |
| 575 #if DCHECK_IS_ON() | 593 #if DCHECK_IS_ON() |
| 576 // Returns true for any address that is on one of the pages that this | 594 // 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 | 595 // large object uses. That ensures that we can use a negative result to |
| 578 // populate the negative page cache. | 596 // populate the negative page cache. |
| 579 bool contains(Address) override; | 597 bool contains(Address) override; |
| (...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 951 return outOfLineAllocate(allocationSize, gcInfoIndex); | 969 return outOfLineAllocate(allocationSize, gcInfoIndex); |
| 952 } | 970 } |
| 953 | 971 |
| 954 inline NormalPageArena* NormalPage::arenaForNormalPage() const { | 972 inline NormalPageArena* NormalPage::arenaForNormalPage() const { |
| 955 return static_cast<NormalPageArena*>(arena()); | 973 return static_cast<NormalPageArena*>(arena()); |
| 956 } | 974 } |
| 957 | 975 |
| 958 } // namespace blink | 976 } // namespace blink |
| 959 | 977 |
| 960 #endif // HeapPage_h | 978 #endif // HeapPage_h |
| OLD | NEW |