Changeset 249221 in webkit
- Timestamp:
- Aug 28, 2019, 2:24:47 PM (7 years ago)
- Location:
- trunk/Source/JavaScriptCore
- Files:
-
- 4 edited
-
ChangeLog (modified) (1 diff)
-
wasm/WasmAirIRGenerator.cpp (modified) (1 diff)
-
wasm/WasmB3IRGenerator.cpp (modified) (1 diff)
-
wasm/WasmValidate.cpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r249208 r249221 1 2019-08-28 Mark Lam <mark.lam@apple.com> 2 3 Wasm's AirIRGenerator::addLocal() and B3IRGenerator::addLocal() are doing unnecessary overflow checks. 4 https://bugs.webkit.org/show_bug.cgi?id=201006 5 <rdar://problem/52053991> 6 7 Reviewed by Yusuke Suzuki. 8 9 We already ensured that it is not possible to overflow in Wasm::FunctionParser's 10 parse(). It is unnecessary and misleading to do those overflow checks in 11 AirIRGenerator and B3IRGenerator. The only check that is necessary is that 12 m_locals.tryReserveCapacity() is successful, otherwise, we have an out of memory 13 situation. 14 15 This patch changes these unnecessary checks to assertions instead. 16 17 * wasm/WasmAirIRGenerator.cpp: 18 (JSC::Wasm::AirIRGenerator::addLocal): 19 * wasm/WasmB3IRGenerator.cpp: 20 (JSC::Wasm::B3IRGenerator::addLocal): 21 * wasm/WasmValidate.cpp: 22 (JSC::Wasm::Validate::addLocal): 23 1 24 2019-08-28 Keith Rollin <krollin@apple.com> 2 25 -
trunk/Source/JavaScriptCore/wasm/WasmAirIRGenerator.cpp
r249159 r249221 915 915 auto AirIRGenerator::addLocal(Type type, uint32_t count) -> PartialResult 916 916 { 917 Checked<uint32_t, RecordOverflow> totalBytesChecked =count;918 totalBytesChecked += m_locals.size();919 uint32_t totalBytes;920 WASM_COMPILE_FAIL_IF( (totalBytesChecked.safeGet(totalBytes) == CheckedState::DidOverflow) || !m_locals.tryReserveCapacity(totalBytes), "can't allocate memory for ", totalBytes, " locals");917 size_t newSize = m_locals.size() + count; 918 ASSERT(!(CheckedUint32(count) + m_locals.size()).hasOverflowed()); 919 ASSERT(newSize <= maxFunctionLocals); 920 WASM_COMPILE_FAIL_IF(!m_locals.tryReserveCapacity(newSize), "can't allocate memory for ", newSize, " locals"); 921 921 922 922 for (uint32_t i = 0; i < count; ++i) { -
trunk/Source/JavaScriptCore/wasm/WasmB3IRGenerator.cpp
r248878 r249221 659 659 auto B3IRGenerator::addLocal(Type type, uint32_t count) -> PartialResult 660 660 { 661 Checked<uint32_t, RecordOverflow> totalBytesChecked =count;662 totalBytesChecked += m_locals.size();663 uint32_t totalBytes;664 WASM_COMPILE_FAIL_IF( (totalBytesChecked.safeGet(totalBytes) == CheckedState::DidOverflow) || !m_locals.tryReserveCapacity(totalBytes), "can't allocate memory for ", totalBytes, " locals");661 size_t newSize = m_locals.size() + count; 662 ASSERT(!(CheckedUint32(count) + m_locals.size()).hasOverflowed()); 663 ASSERT(newSize <= maxFunctionLocals); 664 WASM_COMPILE_FAIL_IF(!m_locals.tryReserveCapacity(newSize), "can't allocate memory for ", newSize, " locals"); 665 665 666 666 for (uint32_t i = 0; i < count; ++i) { -
trunk/Source/JavaScriptCore/wasm/WasmValidate.cpp
r248878 r249221 250 250 auto Validate::addLocal(Type type, uint32_t count) -> Result 251 251 { 252 size_t size = m_locals.size() + count; 253 WASM_VALIDATOR_FAIL_IF(!m_locals.tryReserveCapacity(size), "can't allocate memory for ", size, " locals"); 252 size_t newSize = m_locals.size() + count; 253 ASSERT(!(CheckedUint32(count) + m_locals.size()).hasOverflowed()); 254 ASSERT(newSize <= maxFunctionLocals); 255 WASM_VALIDATOR_FAIL_IF(!m_locals.tryReserveCapacity(newSize), "can't allocate memory for ", newSize, " locals"); 254 256 255 257 for (uint32_t i = 0; i < count; ++i)
Note:
See TracChangeset
for help on using the changeset viewer.