Changeset 259646 in webkit
- Timestamp:
- Apr 7, 2020, 11:04:57 AM (6 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 8 edited
-
JSTests/ChangeLog (modified) (1 diff)
-
JSTests/stress/scoped-arguments-table-should-be-tolerant-for-oom.js (added)
-
Source/JavaScriptCore/ChangeLog (modified) (1 diff)
-
Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp (modified) (1 diff)
-
Source/JavaScriptCore/runtime/CachedTypes.cpp (modified) (1 diff)
-
Source/JavaScriptCore/runtime/ScopedArguments.cpp (modified) (1 diff)
-
Source/JavaScriptCore/runtime/ScopedArgumentsTable.cpp (modified) (5 diffs)
-
Source/JavaScriptCore/runtime/ScopedArgumentsTable.h (modified) (3 diffs)
-
Source/JavaScriptCore/runtime/SymbolTable.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/JSTests/ChangeLog
r259638 r259646 1 2020-04-07 Yusuke Suzuki <ysuzuki@apple.com> 2 3 [JSC] ScopedArgumentsTable should handle OOM in tolerant manner 4 https://bugs.webkit.org/show_bug.cgi?id=210126 5 6 Reviewed by Mark Lam. 7 8 * stress/scoped-arguments-table-should-be-tolerant-for-oom.js: Added. 9 (canThrow): 10 (bar): 11 (get bar): 12 (foo): 13 (i.canThrow): 14 1 15 2020-04-07 Yusuke Suzuki <ysuzuki@apple.com> 2 16 -
trunk/Source/JavaScriptCore/ChangeLog
r259645 r259646 1 2020-04-07 Yusuke Suzuki <ysuzuki@apple.com> 2 3 [JSC] ScopedArgumentsTable should handle OOM in tolerant manner 4 https://bugs.webkit.org/show_bug.cgi?id=210126 5 6 Reviewed by Mark Lam. 7 8 This patch makes ScopedArgumentsTable allocations OOM tolerant to throw OOM error when allocation fails. 9 10 * bytecompiler/BytecodeGenerator.cpp: 11 (JSC::BytecodeGenerator::BytecodeGenerator): 12 * runtime/CachedTypes.cpp: 13 (JSC::CachedScopedArgumentsTable::decode const): 14 * runtime/ScopedArguments.cpp: 15 (JSC::ScopedArguments::unmapArgument): 16 * runtime/ScopedArgumentsTable.cpp: 17 (JSC::ScopedArgumentsTable::tryClone): 18 (JSC::ScopedArgumentsTable::trySetLength): 19 (JSC::ScopedArgumentsTable::trySet): 20 (JSC::ScopedArgumentsTable::clone): Deleted. 21 (JSC::ScopedArgumentsTable::setLength): Deleted. 22 (JSC::ScopedArgumentsTable::set): Deleted. 23 * runtime/ScopedArgumentsTable.h: 24 * runtime/SymbolTable.h: 25 1 26 2020-04-07 Yusuke Suzuki <ysuzuki@apple.com> 2 27 -
trunk/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp
r258071 r259646 506 506 for (unsigned i = 0; i < parameters.size(); ++i) { 507 507 ScopeOffset offset = functionSymbolTable->takeNextScopeOffset(NoLockingNecessary); 508 functionSymbolTable->setArgumentOffset(vm, i, offset); 508 bool success = functionSymbolTable->trySetArgumentOffset(vm, i, offset); 509 if (UNLIKELY(!success)) { 510 m_outOfMemoryDuringConstruction = true; 511 return; 512 } 509 513 if (UniquedStringImpl* name = visibleNameForParameter(parameters.at(i).first)) { 510 514 VarOffset varOffset(offset); -
trunk/Source/JavaScriptCore/runtime/CachedTypes.cpp
r257719 r259646 1122 1122 ScopedArgumentsTable* decode(Decoder& decoder) const 1123 1123 { 1124 ScopedArgumentsTable* scopedArgumentsTable = ScopedArgumentsTable::create(decoder.vm(), m_length); 1124 ScopedArgumentsTable* scopedArgumentsTable = ScopedArgumentsTable::tryCreate(decoder.vm(), m_length); 1125 RELEASE_ASSERT(scopedArgumentsTable); // We crash here. This is unlikely to continue execution if we hit this condition when decoding UnlinkedCodeBlock. 1125 1126 m_arguments.decode(decoder, scopedArgumentsTable->m_arguments.get(m_length), m_length); 1126 1127 return scopedArgumentsTable; -
trunk/Source/JavaScriptCore/runtime/ScopedArguments.cpp
r256087 r259646 144 144 { 145 145 VM& vm = globalObject->vm(); 146 auto scope = DECLARE_THROW_SCOPE(vm); 146 147 ASSERT_WITH_SECURITY_IMPLICATION(i < m_totalLength); 147 148 unsigned namedLength = m_table->length(); 148 if (i < namedLength) 149 m_table.set(vm, this, m_table->set(vm, i, ScopeOffset())); 150 else 149 if (i < namedLength) { 150 auto* maybeCloned = m_table->trySet(vm, i, ScopeOffset()); 151 if (UNLIKELY(!maybeCloned)) { 152 throwOutOfMemoryError(globalObject, scope); 153 return; 154 } 155 m_table.set(vm, this, maybeCloned); 156 } else 151 157 storage()[i - namedLength].clear(); 152 158 } -
trunk/Source/JavaScriptCore/runtime/ScopedArgumentsTable.cpp
r257907 r259646 57 57 } 58 58 59 ScopedArgumentsTable* ScopedArgumentsTable::create(VM& vm, uint32_t length)60 {61 ScopedArgumentsTable* result = create(vm);62 result->m_length = length;63 result->m_arguments = ArgumentsPtr::create(length);64 return result;65 }66 67 59 ScopedArgumentsTable* ScopedArgumentsTable::tryCreate(VM& vm, uint32_t length) 68 60 { … … 80 72 } 81 73 82 ScopedArgumentsTable* ScopedArgumentsTable:: clone(VM& vm)74 ScopedArgumentsTable* ScopedArgumentsTable::tryClone(VM& vm) 83 75 { 84 ScopedArgumentsTable* result = create(vm, m_length); 76 ScopedArgumentsTable* result = tryCreate(vm, m_length); 77 if (UNLIKELY(!result)) 78 return nullptr; 85 79 for (unsigned i = m_length; i--;) 86 80 result->at(i) = this->at(i); … … 88 82 } 89 83 90 ScopedArgumentsTable* ScopedArgumentsTable:: setLength(VM& vm, uint32_t newLength)84 ScopedArgumentsTable* ScopedArgumentsTable::trySetLength(VM& vm, uint32_t newLength) 91 85 { 92 86 if (LIKELY(!m_locked)) { 93 ArgumentsPtr newArguments = ArgumentsPtr::create(newLength, newLength); 87 ArgumentsPtr newArguments = ArgumentsPtr::tryCreate(newLength, newLength); 88 if (UNLIKELY(!newArguments)) 89 return nullptr; 94 90 for (unsigned i = std::min(m_length, newLength); i--;) 95 91 newArguments.at(i, newLength) = this->at(i); … … 99 95 } 100 96 101 ScopedArgumentsTable* result = create(vm, newLength); 97 ScopedArgumentsTable* result = tryCreate(vm, newLength); 98 if (UNLIKELY(!result)) 99 return nullptr; 102 100 for (unsigned i = std::min(m_length, newLength); i--;) 103 101 result->at(i) = this->at(i); … … 107 105 static_assert(std::is_trivially_destructible<ScopeOffset>::value, ""); 108 106 109 ScopedArgumentsTable* ScopedArgumentsTable:: set(VM& vm, uint32_t i, ScopeOffset value)107 ScopedArgumentsTable* ScopedArgumentsTable::trySet(VM& vm, uint32_t i, ScopeOffset value) 110 108 { 111 109 ScopedArgumentsTable* result; 112 if (UNLIKELY(m_locked)) 113 result = clone(vm); 114 else 110 if (UNLIKELY(m_locked)) { 111 result = tryClone(vm); 112 if (UNLIKELY(!result)) 113 return nullptr; 114 } else 115 115 result = this; 116 116 result->at(i) = value; -
trunk/Source/JavaScriptCore/runtime/ScopedArgumentsTable.h
r257907 r259646 60 60 public: 61 61 static ScopedArgumentsTable* create(VM&); 62 static ScopedArgumentsTable* create(VM&, uint32_t length);63 62 static ScopedArgumentsTable* tryCreate(VM&, uint32_t length); 64 63 65 64 static void destroy(JSCell*); 66 65 67 ScopedArgumentsTable* clone(VM&);68 69 66 uint32_t length() const { return m_length; } 70 ScopedArgumentsTable* setLength(VM&, uint32_t newLength);67 ScopedArgumentsTable* trySetLength(VM&, uint32_t newLength); 71 68 72 69 ScopeOffset get(uint32_t i) const { return at(i); } … … 77 74 } 78 75 79 ScopedArgumentsTable* set(VM&, uint32_t index, ScopeOffset);76 ScopedArgumentsTable* trySet(VM&, uint32_t index, ScopeOffset); 80 77 81 78 DECLARE_INFO; … … 89 86 90 87 private: 88 ScopedArgumentsTable* tryClone(VM&); 89 91 90 ScopeOffset& at(uint32_t i) const 92 91 { -
trunk/Source/JavaScriptCore/runtime/SymbolTable.h
r257907 r259646 643 643 return false; 644 644 m_arguments.set(vm, this, table); 645 } else 646 m_arguments.set(vm, this, m_arguments->setLength(vm, length)); 645 } else { 646 ScopedArgumentsTable* table = m_arguments->trySetLength(vm, length); 647 if (UNLIKELY(!table)) 648 return false; 649 m_arguments.set(vm, this, table); 650 } 647 651 return true; 648 652 } … … 654 658 } 655 659 656 void setArgumentOffset(VM& vm, uint32_t i, ScopeOffset offset)660 bool trySetArgumentOffset(VM& vm, uint32_t i, ScopeOffset offset) 657 661 { 658 662 ASSERT_WITH_SECURITY_IMPLICATION(m_arguments); 659 m_arguments.set(vm, this, m_arguments->set(vm, i, offset)); 663 auto* maybeCloned = m_arguments->trySet(vm, i, offset); 664 if (!maybeCloned) 665 return false; 666 m_arguments.set(vm, this, maybeCloned); 667 return true; 660 668 } 661 669
Note:
See TracChangeset
for help on using the changeset viewer.