| 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 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 } | 163 } |
| 164 | 164 |
| 165 Address base() const { return m_base; } | 165 Address base() const { return m_base; } |
| 166 size_t size() const { return m_size; } | 166 size_t size() const { return m_size; } |
| 167 | 167 |
| 168 private: | 168 private: |
| 169 Address m_base; | 169 Address m_base; |
| 170 size_t m_size; | 170 size_t m_size; |
| 171 }; | 171 }; |
| 172 | 172 |
| 173 // TODO(haraken): Like partitionOutOfMemoryWithLotsOfUncommitedPages(), |
| 174 // we should probably have a way to distinguish physical memory OOM from |
| 175 // virtual address space OOM. |
| 176 static NEVER_INLINE void blinkGCOutOfMemory() |
| 177 { |
| 178 #if OS(WIN) |
| 179 // Crash at a special address (0x9b) |
| 180 // to be easily distinguished on crash reports. |
| 181 // This is because crash stack traces are inaccurate on Windows and |
| 182 // blinkGCOutOfMemory might be not included in the stack traces. |
| 183 reinterpret_cast<void(*)()>(0x9b)(); |
| 184 #endif |
| 185 |
| 186 // On non-Windows environment, IMMEDIATE_CRASH is sufficient |
| 187 // because blinkGCOutOfMemory will appear in crash stack traces. |
| 188 IMMEDIATE_CRASH(); |
| 189 } |
| 190 |
| 173 // A PageMemoryRegion represents a chunk of reserved virtual address | 191 // A PageMemoryRegion represents a chunk of reserved virtual address |
| 174 // space containing a number of blink heap pages. On Windows, reserved | 192 // space containing a number of blink heap pages. On Windows, reserved |
| 175 // virtual address space can only be given back to the system as a | 193 // virtual address space can only be given back to the system as a |
| 176 // whole. The PageMemoryRegion allows us to do that by keeping track | 194 // whole. The PageMemoryRegion allows us to do that by keeping track |
| 177 // of the number of pages using it in order to be able to release all | 195 // of the number of pages using it in order to be able to release all |
| 178 // of the virtual address space when there are no more pages using it. | 196 // of the virtual address space when there are no more pages using it. |
| 179 class PageMemoryRegion : public MemoryRegion { | 197 class PageMemoryRegion : public MemoryRegion { |
| 180 public: | 198 public: |
| 181 ~PageMemoryRegion() | 199 ~PageMemoryRegion() |
| 182 { | 200 { |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 size_t offset = blinkPageAddress(address) - base(); | 259 size_t offset = blinkPageAddress(address) - base(); |
| 242 ASSERT(offset % blinkPageSize == 0); | 260 ASSERT(offset % blinkPageSize == 0); |
| 243 return offset / blinkPageSize; | 261 return offset / blinkPageSize; |
| 244 } | 262 } |
| 245 | 263 |
| 246 static PageMemoryRegion* allocate(size_t size, unsigned numPages) | 264 static PageMemoryRegion* allocate(size_t size, unsigned numPages) |
| 247 { | 265 { |
| 248 // Round size up to the allocation granularity. | 266 // Round size up to the allocation granularity. |
| 249 size = (size + WTF::kPageAllocationGranularityOffsetMask) & WTF::kPageAl
locationGranularityBaseMask; | 267 size = (size + WTF::kPageAllocationGranularityOffsetMask) & WTF::kPageAl
locationGranularityBaseMask; |
| 250 Address base = static_cast<Address>(WTF::allocPages(nullptr, size, blink
PageSize)); | 268 Address base = static_cast<Address>(WTF::allocPages(nullptr, size, blink
PageSize)); |
| 251 RELEASE_ASSERT(base); | 269 if (!base) |
| 270 blinkGCOutOfMemory(); |
| 252 WTF::setSystemPagesInaccessible(base, size); | 271 WTF::setSystemPagesInaccessible(base, size); |
| 253 return new PageMemoryRegion(base, size, numPages); | 272 return new PageMemoryRegion(base, size, numPages); |
| 254 } | 273 } |
| 255 | 274 |
| 256 bool m_isLargePage; | 275 bool m_isLargePage; |
| 257 bool m_inUse[blinkPagesPerRegion]; | 276 bool m_inUse[blinkPagesPerRegion]; |
| 258 unsigned m_numPages; | 277 unsigned m_numPages; |
| 259 }; | 278 }; |
| 260 | 279 |
| 261 // Representation of the memory used for a Blink heap page. | 280 // Representation of the memory used for a Blink heap page. |
| (...skipping 2565 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2827 size_t Heap::s_allocatedObjectSize = 0; | 2846 size_t Heap::s_allocatedObjectSize = 0; |
| 2828 size_t Heap::s_allocatedSpace = 0; | 2847 size_t Heap::s_allocatedSpace = 0; |
| 2829 size_t Heap::s_markedObjectSize = 0; | 2848 size_t Heap::s_markedObjectSize = 0; |
| 2830 | 2849 |
| 2831 size_t Heap::s_externallyAllocatedBytes = 0; | 2850 size_t Heap::s_externallyAllocatedBytes = 0; |
| 2832 size_t Heap::s_externallyAllocatedBytesAlive = 0; | 2851 size_t Heap::s_externallyAllocatedBytesAlive = 0; |
| 2833 unsigned Heap::s_requestedUrgentGC = false; | 2852 unsigned Heap::s_requestedUrgentGC = false; |
| 2834 double Heap::s_markingTimeInLastGC = 0.0; | 2853 double Heap::s_markingTimeInLastGC = 0.0; |
| 2835 | 2854 |
| 2836 } // namespace blink | 2855 } // namespace blink |
| OLD | NEW |