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 798 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
809 | 809 |
810 virtual PassOwnPtr<BaseHeap> split(int numberOfNormalPages) override; | 810 virtual PassOwnPtr<BaseHeap> split(int numberOfNormalPages) override; |
811 virtual void merge(PassOwnPtr<BaseHeap> splitOffBase) override; | 811 virtual void merge(PassOwnPtr<BaseHeap> splitOffBase) override; |
812 | 812 |
813 void removePageFromHeap(HeapPage<Header>*); | 813 void removePageFromHeap(HeapPage<Header>*); |
814 | 814 |
815 PLATFORM_EXPORT void promptlyFreeObject(Header*); | 815 PLATFORM_EXPORT void promptlyFreeObject(Header*); |
816 | 816 |
817 private: | 817 private: |
818 void addPageToHeap(const GCInfo*); | 818 void addPageToHeap(const GCInfo*); |
819 PLATFORM_EXPORT Address outOfLineAllocate(size_t, const GCInfo*); | 819 PLATFORM_EXPORT Address outOfLineAllocate(size_t payloadSize, size_t allocat
ionSize, const GCInfo*); |
820 static size_t allocationSizeFromSize(size_t); | 820 static size_t allocationSizeFromSize(size_t); |
821 PLATFORM_EXPORT Address allocateLargeObject(size_t, const GCInfo*); | 821 PLATFORM_EXPORT Address allocateLargeObject(size_t, const GCInfo*); |
822 Address currentAllocationPoint() const { return m_currentAllocationPoint; } | 822 Address currentAllocationPoint() const { return m_currentAllocationPoint; } |
823 size_t remainingAllocationSize() const { return m_remainingAllocationSize; } | 823 size_t remainingAllocationSize() const { return m_remainingAllocationSize; } |
824 bool ownsNonEmptyAllocationArea() const { return currentAllocationPoint() &&
remainingAllocationSize(); } | 824 bool ownsNonEmptyAllocationArea() const { return currentAllocationPoint() &&
remainingAllocationSize(); } |
825 void setAllocationPoint(Address point, size_t size) | 825 void setAllocationPoint(Address point, size_t size) |
826 { | 826 { |
827 ASSERT(!point || heapPageFromAddress(point)); | 827 ASSERT(!point || heapPageFromAddress(point)); |
828 ASSERT(size <= HeapPage<Header>::payloadSize()); | 828 ASSERT(size <= HeapPage<Header>::payloadSize()); |
829 updateRemainingAllocationSize(); | 829 updateRemainingAllocationSize(); |
(...skipping 565 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1395 ASSERT(!(reinterpret_cast<uintptr_t>(result) & allocationMask)); | 1395 ASSERT(!(reinterpret_cast<uintptr_t>(result) & allocationMask)); |
1396 | 1396 |
1397 // Unpoison the memory used for the object (payload). | 1397 // Unpoison the memory used for the object (payload). |
1398 ASAN_UNPOISON_MEMORY_REGION(result, allocationSize - sizeof(Header)); | 1398 ASAN_UNPOISON_MEMORY_REGION(result, allocationSize - sizeof(Header)); |
1399 #if ENABLE(ASSERT) || defined(LEAK_SANITIZER) || defined(ADDRESS_SANITIZER) | 1399 #if ENABLE(ASSERT) || defined(LEAK_SANITIZER) || defined(ADDRESS_SANITIZER) |
1400 memset(result, 0, allocationSize - sizeof(Header)); | 1400 memset(result, 0, allocationSize - sizeof(Header)); |
1401 #endif | 1401 #endif |
1402 ASSERT(heapPageFromAddress(headerAddress + allocationSize - 1)); | 1402 ASSERT(heapPageFromAddress(headerAddress + allocationSize - 1)); |
1403 return result; | 1403 return result; |
1404 } | 1404 } |
1405 return outOfLineAllocate(size, gcInfo); | 1405 return outOfLineAllocate(size, allocationSize, gcInfo); |
1406 } | 1406 } |
1407 | 1407 |
1408 template<typename T, typename HeapTraits> | 1408 template<typename T, typename HeapTraits> |
1409 Address Heap::allocate(size_t size) | 1409 Address Heap::allocate(size_t size) |
1410 { | 1410 { |
1411 ThreadState* state = ThreadStateFor<ThreadingTrait<T>::Affinity>::state(); | 1411 ThreadState* state = ThreadStateFor<ThreadingTrait<T>::Affinity>::state(); |
1412 ASSERT(state->isAllocationAllowed()); | 1412 ASSERT(state->isAllocationAllowed()); |
1413 const GCInfo* gcInfo = GCInfoTrait<T>::get(); | 1413 const GCInfo* gcInfo = GCInfoTrait<T>::get(); |
1414 int heapIndex = HeapTraits::index(gcInfo->hasFinalizer(), size); | 1414 int heapIndex = HeapTraits::index(gcInfo->hasFinalizer(), size); |
1415 BaseHeap* heap = state->heap(heapIndex); | 1415 BaseHeap* heap = state->heap(heapIndex); |
(...skipping 1002 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2418 }; | 2418 }; |
2419 | 2419 |
2420 template<typename T> | 2420 template<typename T> |
2421 struct IfWeakMember<WeakMember<T> > { | 2421 struct IfWeakMember<WeakMember<T> > { |
2422 static bool isDead(Visitor* visitor, const WeakMember<T>& t) { return !visit
or->isAlive(t.get()); } | 2422 static bool isDead(Visitor* visitor, const WeakMember<T>& t) { return !visit
or->isAlive(t.get()); } |
2423 }; | 2423 }; |
2424 | 2424 |
2425 } // namespace blink | 2425 } // namespace blink |
2426 | 2426 |
2427 #endif // Heap_h | 2427 #endif // Heap_h |
OLD | NEW |