Ignore:
Timestamp:
Jun 2, 2021, 12:02:15 PM (4 years ago)
Author:
Chris Dumez
Message:

Drop Checked::safeGet()
https://bugs.webkit.org/show_bug.cgi?id=226537

Reviewed by Geoffrey Garen.

Drop Checked::safeGet() and replace with uses of Checked::operator T() or Checked::value().
safeGet() is a bit akward, having both a return value and an out-parameter.

Source/JavaScriptCore:

  • dfg/DFGAbstractInterpreterInlines.h:

(JSC::DFG::AbstractInterpreter<AbstractStateType>::executeEffects):

  • runtime/JSArray.cpp:

(JSC::JSArray::appendMemcpy):
(JSC::JSArray::unshiftCountWithAnyIndexingType):

  • runtime/JSStringJoiner.cpp:

(JSC::JSStringJoiner::joinedLength const):

  • wasm/WasmFormat.cpp:

(JSC::Wasm::Segment::create):

  • wasm/WasmOperations.cpp:

(JSC::Wasm::JSC_DEFINE_JIT_OPERATION):

  • wasm/WasmTable.cpp:

(JSC::Wasm::Table::grow):

Source/WebKit:

  • UIProcess/mac/TextCheckerMac.mm:

(WebKit::TextChecker::updateSpellingUIWithGrammarString):

Source/WTF:

  • wtf/CheckedArithmetic.h:

(WTF::Checked::value const):
(WTF::operator+):
(WTF::operator-):
(WTF::operator*):
(WTF::operator/):

Tools:

  • TestWebKitAPI/Tests/WTF/CheckedArithmeticOperations.cpp:

(TestWebKitAPI::CheckedArithmeticTester::run):

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/wasm/WasmTable.cpp

    r278351 r278369  
    9090    CheckedUint32 newLengthChecked = length();
    9191    newLengthChecked += delta;
    92     uint32_t newLength;
    93     if (newLengthChecked.safeGet(newLength) == CheckedState::DidOverflow)
    94         return std::nullopt;
    95 
     92    if (newLengthChecked.hasOverflowed())
     93        return std::nullopt;
     94
     95    uint32_t newLength = newLengthChecked;
    9696    if (maximum() && newLength > *maximum())
    9797        return std::nullopt;
     
    103103            CheckedUint32 reallocSizeChecked = allocatedLength(newLengthChecked);
    104104            reallocSizeChecked *= sizeof(*container.get());
    105             uint32_t reallocSize;
    106             if (reallocSizeChecked.safeGet(reallocSize) == CheckedState::DidOverflow)
     105            if (reallocSizeChecked.hasOverflowed())
    107106                return false;
    108107            // FIXME this over-allocates and could be smarter about not committing all of that memory https://bugs.webkit.org/show_bug.cgi?id=181425
    109             container.realloc(reallocSize);
     108            container.realloc(reallocSizeChecked);
    110109        }
    111110        for (uint32_t i = m_length; i < allocatedLength(newLength); ++i) {
Note: See TracChangeset for help on using the changeset viewer.