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 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
336 RELEASE_ASSERT(getThreadState()->isSweepingInProgress()); | 336 RELEASE_ASSERT(getThreadState()->isSweepingInProgress()); |
337 ASSERT(getThreadState()->sweepForbidden()); | 337 ASSERT(getThreadState()->sweepForbidden()); |
338 ASSERT(!getThreadState()->isMainThread() || ScriptForbiddenScope::isScriptFo
rbidden()); | 338 ASSERT(!getThreadState()->isMainThread() || ScriptForbiddenScope::isScriptFo
rbidden()); |
339 | 339 |
340 while (m_firstUnsweptPage) { | 340 while (m_firstUnsweptPage) { |
341 sweepUnsweptPage(); | 341 sweepUnsweptPage(); |
342 } | 342 } |
343 ThreadHeap::reportMemoryUsageForTracing(); | 343 ThreadHeap::reportMemoryUsageForTracing(); |
344 } | 344 } |
345 | 345 |
| 346 Address BaseArena::allocateLargeObject(size_t allocationSize, size_t gcInfoIndex
) |
| 347 { |
| 348 // TODO(sof): should need arise, support eagerly finalized large objects. |
| 349 CHECK(arenaIndex() != BlinkGC::EagerSweepArenaIndex); |
| 350 LargeObjectArena* largeObjectArena = static_cast<LargeObjectArena*>(getThrea
dState()->arena(BlinkGC::LargeObjectArenaIndex)); |
| 351 Address largeObject = largeObjectArena -> allocateLargeObjectPage(allocation
Size, gcInfoIndex); |
| 352 ASAN_MARK_LARGE_VECTOR_CONTAINER(this, largeObject); |
| 353 return largeObject; |
| 354 } |
| 355 |
346 NormalPageArena::NormalPageArena(ThreadState* state, int index) | 356 NormalPageArena::NormalPageArena(ThreadState* state, int index) |
347 : BaseArena(state, index) | 357 : BaseArena(state, index) |
348 , m_currentAllocationPoint(nullptr) | 358 , m_currentAllocationPoint(nullptr) |
349 , m_remainingAllocationSize(0) | 359 , m_remainingAllocationSize(0) |
350 , m_lastRemainingAllocationSize(0) | 360 , m_lastRemainingAllocationSize(0) |
351 , m_promptlyFreedSize(0) | 361 , m_promptlyFreedSize(0) |
352 { | 362 { |
353 clearFreeLists(); | 363 clearFreeLists(); |
354 } | 364 } |
355 | 365 |
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
675 m_currentAllocationPoint = point; | 685 m_currentAllocationPoint = point; |
676 m_lastRemainingAllocationSize = m_remainingAllocationSize = size; | 686 m_lastRemainingAllocationSize = m_remainingAllocationSize = size; |
677 } | 687 } |
678 | 688 |
679 Address NormalPageArena::outOfLineAllocate(size_t allocationSize, size_t gcInfoI
ndex) | 689 Address NormalPageArena::outOfLineAllocate(size_t allocationSize, size_t gcInfoI
ndex) |
680 { | 690 { |
681 ASSERT(allocationSize > remainingAllocationSize()); | 691 ASSERT(allocationSize > remainingAllocationSize()); |
682 ASSERT(allocationSize >= allocationGranularity); | 692 ASSERT(allocationSize >= allocationGranularity); |
683 | 693 |
684 // 1. If this allocation is big enough, allocate a large object. | 694 // 1. If this allocation is big enough, allocate a large object. |
685 if (allocationSize >= largeObjectSizeThreshold) { | 695 if (allocationSize >= largeObjectSizeThreshold) |
686 // TODO(sof): support eagerly finalized large objects, if ever needed. | 696 return allocateLargeObject(allocationSize, gcInfoIndex); |
687 RELEASE_ASSERT(arenaIndex() != BlinkGC::EagerSweepArenaIndex); | |
688 LargeObjectArena* largeObjectArena = static_cast<LargeObjectArena*>(getT
hreadState()->arena(BlinkGC::LargeObjectArenaIndex)); | |
689 Address largeObject = largeObjectArena->allocateLargeObjectPage(allocati
onSize, gcInfoIndex); | |
690 ASAN_MARK_LARGE_VECTOR_CONTAINER(this, largeObject); | |
691 return largeObject; | |
692 } | |
693 | 697 |
694 // 2. Try to allocate from a free list. | 698 // 2. Try to allocate from a free list. |
695 updateRemainingAllocationSize(); | 699 updateRemainingAllocationSize(); |
696 Address result = allocateFromFreeList(allocationSize, gcInfoIndex); | 700 Address result = allocateFromFreeList(allocationSize, gcInfoIndex); |
697 if (result) | 701 if (result) |
698 return result; | 702 return result; |
699 | 703 |
700 // 3. Reset the allocation point. | 704 // 3. Reset the allocation point. |
701 setAllocationPoint(nullptr, 0); | 705 setAllocationPoint(nullptr, 0); |
702 | 706 |
(...skipping 859 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1562 | 1566 |
1563 m_hasEntries = true; | 1567 m_hasEntries = true; |
1564 size_t index = hash(address); | 1568 size_t index = hash(address); |
1565 ASSERT(!(index & 1)); | 1569 ASSERT(!(index & 1)); |
1566 Address cachePage = roundToBlinkPageStart(address); | 1570 Address cachePage = roundToBlinkPageStart(address); |
1567 m_entries[index + 1] = m_entries[index]; | 1571 m_entries[index + 1] = m_entries[index]; |
1568 m_entries[index] = cachePage; | 1572 m_entries[index] = cachePage; |
1569 } | 1573 } |
1570 | 1574 |
1571 } // namespace blink | 1575 } // namespace blink |
OLD | NEW |