Changeset 215525 in webkit
- Timestamp:
- Apr 19, 2017 12:38:52 PM (7 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JSTests/ChangeLog
r215517 r215525 1 2017-04-19 JF Bastien <jfbastien@apple.com> 2 3 WebAssembly: limit slow memories 4 https://bugs.webkit.org/show_bug.cgi?id=170825 5 6 Reviewed by Saam Barati. 7 8 * wasm.yaml: 9 * wasm/stress/oom.js: Added. 10 (try.true.WebAssemblyMemoryMode): 11 (catch): 12 1 13 2017-04-19 JF Bastien <jfbastien@apple.com> 2 14 -
trunk/JSTests/wasm.yaml
r215517 r215525 32 32 - path: wasm/fuzz 33 33 cmd: runWebAssembly unless parseRunCommands 34 - path: wasm/stress 35 cmd: runWebAssembly unless parseRunCommands 34 36 35 37 - path: wasm/spec-tests/address.wast.js -
trunk/Source/JavaScriptCore/ChangeLog
r215522 r215525 1 2017-04-19 JF Bastien <jfbastien@apple.com> 2 3 WebAssembly: limit slow memories 4 https://bugs.webkit.org/show_bug.cgi?id=170825 5 6 Reviewed by Saam Barati. 7 8 We limits the number of fast memories, partly because ASLR. The 9 code then falls back to slow memories. It first tries to virtually 10 allocated any declared maximum (and in there, physically the 11 initial), and if that fails it tries to physically allocate the 12 initial without any extra. 13 14 This can still be used to cause a bunch of virtual 15 allocation. This patch imposes soft limit on slow memories as 16 well. The total virtual maximum for slow memories is set at the 17 same (theoretical) value as that for fast memories. 18 19 Anything exceeding that limit causes allocation/grow to fail. 20 21 * wasm/WasmMemory.cpp: 22 1 23 2017-04-19 JF Bastien <jfbastien@apple.com> 2 24 -
trunk/Source/JavaScriptCore/wasm/WasmMemory.cpp
r215340 r215525 94 94 std::atomic<size_t> currentlyAllocatedFastMemories = ATOMIC_VAR_INIT(0); 95 95 std::atomic<size_t> observedMaximumFastMemory = ATOMIC_VAR_INIT(0); 96 std::atomic<size_t> currentSlowMemoryCapacity = ATOMIC_VAR_INIT(0); 97 98 size_t fastMemoryAllocatedBytesSoftLimit() 99 { 100 return fastMemoryAllocationSoftLimit * Memory::fastMappedBytes(); 101 } 96 102 97 103 void* tryGetCachedFastMemory() … … 195 201 } 196 202 203 bool slowMemoryCapacitySoftMaximumExceeded() 204 { 205 // The limit on slow memory capacity is arbitrary. Its purpose is to limit 206 // virtual memory allocation. We choose to set the limit at the same virtual 207 // memory limit imposed on fast memories. 208 size_t maximum = fastMemoryAllocatedBytesSoftLimit(); 209 size_t currentCapacity = currentSlowMemoryCapacity.load(std::memory_order_acquire); 210 if (UNLIKELY(currentCapacity > maximum)) { 211 dataLogLnIf(verbose, "Slow memory capacity limit reached"); 212 return true; 213 } 214 return false; 215 } 216 197 217 void* tryGetSlowMemory(size_t bytes) 198 218 { 219 if (slowMemoryCapacitySoftMaximumExceeded()) 220 return nullptr; 199 221 void* memory = mmapBytes(bytes); 222 if (memory) 223 currentSlowMemoryCapacity.fetch_add(bytes, std::memory_order_acq_rel); 200 224 dataLogLnIf(memory && verbose, "Obtained slow memory ", RawPointer(memory), " with capacity ", bytes); 201 225 dataLogLnIf(!memory && verbose, "Failed obtaining slow memory with capacity ", bytes); … … 229 253 dataLogLnIf(verbose, "relinquishFastMemory freeing slow memory ", RawPointer(memory)); 230 254 munmapBytes(memory, mappedCapacity); 255 currentSlowMemoryCapacity.fetch_sub(mappedCapacity, std::memory_order_acq_rel); 231 256 return; 232 257
Note: See TracChangeset
for help on using the changeset viewer.