Changeset 140584 in webkit


Ignore:
Timestamp:
Jan 23, 2013 1:44:29 PM (11 years ago)
Author:
oliver@apple.com
Message:

Replace numerous manual CRASH's in JSC with RELEASE_ASSERT
https://bugs.webkit.org/show_bug.cgi?id=107726

Reviewed by Filip Pizlo.

Fairly manual change from if (foo) CRASH(); to RELEASE_ASSERT(!foo);

  • assembler/MacroAssembler.h:

(JSC::MacroAssembler::branchAdd32):
(JSC::MacroAssembler::branchMul32):

  • bytecode/CodeBlockHash.cpp:

(JSC::CodeBlockHash::CodeBlockHash):

  • heap/BlockAllocator.h:

(JSC::Region::create):
(JSC::Region::createCustomSize):

  • heap/GCAssertions.h:
  • heap/HandleSet.cpp:

(JSC::HandleSet::visitStrongHandles):
(JSC::HandleSet::writeBarrier):

  • heap/HandleSet.h:

(JSC::HandleSet::allocate):

  • heap/Heap.cpp:

(JSC::Heap::collect):

  • heap/SlotVisitor.cpp:

(JSC::SlotVisitor::validate):

  • interpreter/Interpreter.cpp:

(JSC::Interpreter::execute):

  • jit/ExecutableAllocator.cpp:

(JSC::DemandExecutableAllocator::allocateNewSpace):
(JSC::ExecutableAllocator::allocate):

  • jit/ExecutableAllocator.h:

(JSC::roundUpAllocationSize):

  • jit/ExecutableAllocatorFixedVMPool.cpp:

(JSC::FixedVMPoolExecutableAllocator::FixedVMPoolExecutableAllocator):
(JSC::ExecutableAllocator::allocate):

  • runtime/ButterflyInlines.h:

(JSC::Butterfly::createUninitialized):

  • runtime/Completion.cpp:

(JSC::evaluate):

  • runtime/JSArray.h:

(JSC::constructArray):

  • runtime/JSGlobalObject.cpp:

(JSC::slowValidateCell):

  • runtime/JSObject.cpp:

(JSC::JSObject::enterDictionaryIndexingModeWhenArrayStorageAlreadyExists):
(JSC::JSObject::createArrayStorage):

  • tools/TieredMMapArray.h:

(JSC::TieredMMapArray::append):

  • yarr/YarrInterpreter.cpp:

(JSC::Yarr::Interpreter::allocDisjunctionContext):
(JSC::Yarr::Interpreter::allocParenthesesDisjunctionContext):
(JSC::Yarr::Interpreter::InputStream::readChecked):
(JSC::Yarr::Interpreter::InputStream::uncheckInput):
(JSC::Yarr::Interpreter::InputStream::atEnd):
(JSC::Yarr::Interpreter::interpret):

Location:
trunk/Source/JavaScriptCore
Files:
20 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r140504 r140584  
     12013-01-23  Oliver Hunt  <oliver@apple.com>
     2
     3        Replace numerous manual CRASH's in JSC with RELEASE_ASSERT
     4        https://bugs.webkit.org/show_bug.cgi?id=107726
     5
     6        Reviewed by Filip Pizlo.
     7
     8        Fairly manual change from if (foo) CRASH(); to RELEASE_ASSERT(!foo);
     9
     10        * assembler/MacroAssembler.h:
     11        (JSC::MacroAssembler::branchAdd32):
     12        (JSC::MacroAssembler::branchMul32):
     13        * bytecode/CodeBlockHash.cpp:
     14        (JSC::CodeBlockHash::CodeBlockHash):
     15        * heap/BlockAllocator.h:
     16        (JSC::Region::create):
     17        (JSC::Region::createCustomSize):
     18        * heap/GCAssertions.h:
     19        * heap/HandleSet.cpp:
     20        (JSC::HandleSet::visitStrongHandles):
     21        (JSC::HandleSet::writeBarrier):
     22        * heap/HandleSet.h:
     23        (JSC::HandleSet::allocate):
     24        * heap/Heap.cpp:
     25        (JSC::Heap::collect):
     26        * heap/SlotVisitor.cpp:
     27        (JSC::SlotVisitor::validate):
     28        * interpreter/Interpreter.cpp:
     29        (JSC::Interpreter::execute):
     30        * jit/ExecutableAllocator.cpp:
     31        (JSC::DemandExecutableAllocator::allocateNewSpace):
     32        (JSC::ExecutableAllocator::allocate):
     33        * jit/ExecutableAllocator.h:
     34        (JSC::roundUpAllocationSize):
     35        * jit/ExecutableAllocatorFixedVMPool.cpp:
     36        (JSC::FixedVMPoolExecutableAllocator::FixedVMPoolExecutableAllocator):
     37        (JSC::ExecutableAllocator::allocate):
     38        * runtime/ButterflyInlines.h:
     39        (JSC::Butterfly::createUninitialized):
     40        * runtime/Completion.cpp:
     41        (JSC::evaluate):
     42        * runtime/JSArray.h:
     43        (JSC::constructArray):
     44        * runtime/JSGlobalObject.cpp:
     45        (JSC::slowValidateCell):
     46        * runtime/JSObject.cpp:
     47        (JSC::JSObject::enterDictionaryIndexingModeWhenArrayStorageAlreadyExists):
     48        (JSC::JSObject::createArrayStorage):
     49        * tools/TieredMMapArray.h:
     50        (JSC::TieredMMapArray::append):
     51        * yarr/YarrInterpreter.cpp:
     52        (JSC::Yarr::Interpreter::allocDisjunctionContext):
     53        (JSC::Yarr::Interpreter::allocParenthesesDisjunctionContext):
     54        (JSC::Yarr::Interpreter::InputStream::readChecked):
     55        (JSC::Yarr::Interpreter::InputStream::uncheckInput):
     56        (JSC::Yarr::Interpreter::InputStream::atEnd):
     57        (JSC::Yarr::Interpreter::interpret):
     58
    1592013-01-22  Filip Pizlo  <fpizlo@apple.com>
    260
  • trunk/Source/JavaScriptCore/assembler/MacroAssembler.h

    r135759 r140584  
    13511351    Jump branchAdd32(ResultCondition cond, RegisterID src, Imm32 imm, RegisterID dest)
    13521352    {
    1353         if (src == dest) {
    1354             if (!scratchRegisterForBlinding()) {
    1355                 // Release mode ASSERT, if this fails we will perform incorrect codegen.
    1356                 CRASH();
    1357             }
    1358         }
     1353        if (src == dest)
     1354            RELEASE_ASSERT(scratchRegisterForBlinding());
     1355
    13591356        if (shouldBlind(imm)) {
    13601357            if (src == dest) {
     
    13721369    Jump branchMul32(ResultCondition cond, Imm32 imm, RegisterID src, RegisterID dest)
    13731370    {
    1374         if (src == dest) {
    1375             if (!scratchRegisterForBlinding()) {
    1376                 // Release mode ASSERT, if this fails we will perform incorrect codegen.
    1377                 CRASH();
    1378             }
    1379         }
     1371        if (src == dest)
     1372            RELEASE_ASSERT(scratchRegisterForBlinding());
     1373
    13801374        if (shouldBlind(imm)) {
    13811375            if (src == dest) {
  • trunk/Source/JavaScriptCore/bytecode/CodeBlockHash.cpp

    r136199 r140584  
    3737    : m_hash(0)
    3838{
    39     if (strlen(string) != 6)
    40         CRASH();
     39    RELEASE_ASSERT(strlen(string) == 6);
    4140   
    4241    for (unsigned i = 0; i < 6; ++i) {
  • trunk/Source/JavaScriptCore/heap/BlockAllocator.h

    r138067 r140584  
    9494    ASSERT(!(s_regionSize % blockSize));
    9595    PageAllocationAligned allocation = PageAllocationAligned::allocate(s_regionSize, s_regionSize, OSAllocator::JSGCHeapPages);
    96     if (!static_cast<bool>(allocation))
    97         CRASH();
     96    RELEASE_ASSERT(static_cast<bool>(allocation));
    9897    return new Region(allocation, blockSize, s_regionSize / blockSize);
    9998}
     
    102101{
    103102    PageAllocationAligned allocation = PageAllocationAligned::allocate(blockSize, blockAlignment, OSAllocator::JSGCHeapPages);
    104     if (!static_cast<bool>(allocation))
    105         CRASH();
     103    RELEASE_ASSERT(static_cast<bool>(allocation));
    106104    Region* region = new Region(allocation, blockSize, 1);
    107105    region->m_isCustomSize = true;
  • trunk/Source/JavaScriptCore/heap/GCAssertions.h

    r110033 r140584  
    3131#if ENABLE(GC_VALIDATION)
    3232#define ASSERT_GC_OBJECT_LOOKS_VALID(cell) do { \
    33     if (!(cell))\
    34         CRASH();\
    35     if (cell->unvalidatedStructure()->unvalidatedStructure() != cell->unvalidatedStructure()->unvalidatedStructure()->unvalidatedStructure())\
    36         CRASH();\
     33    RELEASE_ASSERT(cell);\
     34    RELEASE_ASSERT(cell->unvalidatedStructure()->unvalidatedStructure() == cell->unvalidatedStructure()->unvalidatedStructure()->unvalidatedStructure()); \
    3735} while (0)
    3836
    3937#define ASSERT_GC_OBJECT_INHERITS(object, classInfo) do {\
    4038    ASSERT_GC_OBJECT_LOOKS_VALID(object); \
    41     if (!object->inherits(classInfo)) \
    42         CRASH();\
     39    RELEASE_ASSERT(object->inherits(classInfo)); \
    4340} while (0)
    4441
  • trunk/Source/JavaScriptCore/heap/HandleSet.cpp

    r139541 r140584  
    5555    for (Node* node = m_strongList.begin(); node != end; node = node->next()) {
    5656#if ENABLE(GC_VALIDATION)
    57         if (!isLiveNode(node))
    58             CRASH();
     57        RELEASE_ASSERT(isLiveNode(node));
    5958#endif
    6059        heapRootVisitor.visit(node->slot());
     
    6665    // Forbid assignment to handles during the finalization phase, since it would violate many GC invariants.
    6766    // File a bug with stack trace if you hit this.
    68     if (m_nextToFinalize)
    69         CRASH();
     67    RELEASE_ASSERT(!m_nextToFinalize);
    7068
    7169    if (!value == !*slot && slot->isCell() == value.isCell())
     
    7472    Node* node = toNode(slot);
    7573#if ENABLE(GC_VALIDATION)
    76     if (!isLiveNode(node))
    77         CRASH();
     74    RELEASE_ASSERT(isLiveNode(node));
    7875#endif
    7976    SentinelLinkedList<Node>::remove(node);
     
    8582    m_strongList.push(node);
    8683#if ENABLE(GC_VALIDATION)
    87     if (!isLiveNode(node))
    88         CRASH();
     84    RELEASE_ASSERT(isLiveNode(node));
    8985#endif
    9086}
  • trunk/Source/JavaScriptCore/heap/HandleSet.h

    r113508 r140584  
    124124    // Forbid assignment to handles during the finalization phase, since it would violate many GC invariants.
    125125    // File a bug with stack trace if you hit this.
    126     if (m_nextToFinalize)
    127         CRASH();
     126    RELEASE_ASSERT(!m_nextToFinalize);
     127
    128128    if (m_freeList.isEmpty())
    129129        grow();
  • trunk/Source/JavaScriptCore/heap/Heap.cpp

    r139541 r140584  
    722722    ASSERT(m_isSafeToCollect);
    723723    JAVASCRIPTCORE_GC_BEGIN();
    724     if (m_operationInProgress != NoOperation)
    725         CRASH();
     724    RELEASE_ASSERT(m_operationInProgress == NoOperation);
    726725    m_operationInProgress = Collection;
    727726
     
    812811    if (Options::recordGCPauseTimes())
    813812        HeapStatistics::recordGCPauseTime(lastGCStartTime, lastGCEndTime);
    814     if (m_operationInProgress != Collection)
    815         CRASH();
     813    RELEASE_ASSERT(m_operationInProgress == Collection);
     814
    816815    m_operationInProgress = NoOperation;
    817816    JAVASCRIPTCORE_GC_END();
  • trunk/Source/JavaScriptCore/heap/SlotVisitor.cpp

    r139541 r140584  
    337337void SlotVisitor::validate(JSCell* cell)
    338338{
    339     if (!cell) {
    340         dataLogF("cell is NULL\n");
    341         CRASH();
    342     }
     339    RELEASE_ASSERT(cell);
    343340
    344341    if (!cell->structure()) {
  • trunk/Source/JavaScriptCore/interpreter/Interpreter.cpp

    r139510 r140584  
    836836    ASSERT(isValidThisObject(thisObj, callFrame));
    837837    ASSERT(!globalData.exception);
    838     ASSERT(!globalData.isCollectorBusy());
    839     if (globalData.isCollectorBusy())
    840         CRASH();
     838    RELEASE_ASSERT(!globalData.isCollectorBusy());
    841839
    842840    StackStats::CheckPoint stackCheckPoint;
  • trunk/Source/JavaScriptCore/jit/ExecutableAllocator.cpp

    r122166 r140584  
    115115       
    116116        PageReservation reservation = PageReservation::reserve(numPages * pageSize(), OSAllocator::JSJITCodePages, EXECUTABLE_POOL_WRITABLE, true);
    117         if (!reservation)
    118             CRASH();
     117        RELEASE_ASSERT(reservation);
    119118       
    120119        reservations.append(reservation);
     
    217216{
    218217    RefPtr<ExecutableMemoryHandle> result = allocator()->allocate(sizeInBytes, ownerUID);
    219     if (!result && effort == JITCompilationMustSucceed)
    220         CRASH();
     218    RELEASE_ASSERT(result || effort != JITCompilationMustSucceed);
    221219    return result.release();
    222220}
  • trunk/Source/JavaScriptCore/jit/ExecutableAllocator.h

    r122166 r140584  
    8282inline size_t roundUpAllocationSize(size_t request, size_t granularity)
    8383{
    84     if ((std::numeric_limits<size_t>::max() - granularity) <= request)
    85         CRASH(); // Allocation is too large
     84    RELEASE_ASSERT((std::numeric_limits<size_t>::max() - granularity) > request);
    8685   
    8786    // Round up to next page boundary
  • trunk/Source/JavaScriptCore/jit/ExecutableAllocatorFixedVMPool.cpp

    r139926 r140584  
    6464        m_reservation = PageReservation::reserveWithGuardPages(fixedExecutableMemoryPoolSize, OSAllocator::JSJITCodePages, EXECUTABLE_POOL_WRITABLE, true);
    6565#if !ENABLE(LLINT)
    66         if (!m_reservation)
    67             CRASH();
     66        RELEASE_ASSERT(m_reservation);
    6867#endif
    6968        if (m_reservation) {
     
    166165        releaseExecutableMemory(globalData);
    167166        result = allocator->allocate(sizeInBytes, ownerUID);
    168         if (!result)
    169             CRASH();
     167        RELEASE_ASSERT(result);
    170168    }
    171169    return result.release();
  • trunk/Source/JavaScriptCore/runtime/ButterflyInlines.h

    r137961 r140584  
    4040    void* temp;
    4141    size_t size = totalSize(preCapacity, propertyCapacity, hasIndexingHeader, indexingPayloadSizeInBytes);
    42     if (!globalData.heap.tryAllocateStorage(size, &temp))
    43         CRASH();
     42    RELEASE_ASSERT(globalData.heap.tryAllocateStorage(size, &temp));
    4443    Butterfly* result = fromBase(temp, preCapacity, propertyCapacity);
    4544    return result;
  • trunk/Source/JavaScriptCore/runtime/Completion.cpp

    r139541 r140584  
    5656{
    5757    JSLockHolder lock(exec);
    58     ASSERT(exec->globalData().identifierTable == wtfThreadData().currentIdentifierTable());
    59     if (exec->globalData().isCollectorBusy())
    60         CRASH();
     58    RELEASE_ASSERT(exec->globalData().identifierTable == wtfThreadData().currentIdentifierTable());
     59    RELEASE_ASSERT(!exec->globalData().isCollectorBusy());
    6160
    6261    CodeProfiling profile(source);
  • trunk/Source/JavaScriptCore/runtime/JSArray.h

    r139094 r140584  
    292292    // when making this change we should check that all clients of this
    293293    // function will correctly handle an exception being thrown from here.
    294     if (!array)
    295         CRASH();
     294    RELEASE_ASSERT(array);
    296295
    297296    for (unsigned i = 0; i < length; ++i)
     
    308307    // when making this change we should check that all clients of this
    309308    // function will correctly handle an exception being thrown from here.
    310     if (!array)
    311         CRASH();
     309    RELEASE_ASSERT(array);
    312310
    313311    for (unsigned i = 0; i < length; ++i)
  • trunk/Source/JavaScriptCore/runtime/JSGlobalObject.cpp

    r140259 r140584  
    594594void slowValidateCell(JSGlobalObject* globalObject)
    595595{
    596     if (!globalObject->isGlobalObject())
    597         CRASH();
     596    RELEASE_ASSERT(globalObject->isGlobalObject());
    598597    ASSERT_GC_OBJECT_INHERITS(globalObject, &JSGlobalObject::s_info);
    599598}
  • trunk/Source/JavaScriptCore/runtime/JSObject.cpp

    r140259 r140584  
    559559
    560560    Butterfly* newButterfly = storage->butterfly()->resizeArray(globalData, structure(), 0, ArrayStorage::sizeFor(0));
    561     if (!newButterfly)
    562         CRASH();
     561    RELEASE_ASSERT(newButterfly);
    563562   
    564563    m_butterfly = newButterfly;
     
    660659        globalData, structure(), structure()->outOfLineCapacity(), false, 0,
    661660        ArrayStorage::sizeFor(vectorLength));
    662     if (!newButterfly)
    663         CRASH();
     661    RELEASE_ASSERT(newButterfly);
     662
    664663    ArrayStorage* result = newButterfly->arrayStorage();
    665664    result->setLength(length);
  • trunk/Source/JavaScriptCore/tools/TieredMMapArray.h

    r110033 r140584  
    7979            size_t oldDirectorySize = m_directoryCount * sizeof(T*);
    8080            size_t newDirectorySize = oldDirectorySize * 2;
    81             if (newDirectorySize < oldDirectorySize)
    82                 CRASH();
     81            RELEASE_ASSERT(newDirectorySize < oldDirectorySize);
    8382            m_directory = OSAllocator::reallocateCommitted(m_directory, oldDirectorySize, newDirectorySize);
    8483
  • trunk/Source/JavaScriptCore/yarr/YarrInterpreter.cpp

    r135469 r140584  
    112112        size_t size = sizeof(DisjunctionContext) - sizeof(uintptr_t) + disjunction->m_frameSize * sizeof(uintptr_t);
    113113        allocatorPool = allocatorPool->ensureCapacity(size);
    114         if (!allocatorPool)
    115             CRASH();
     114        RELEASE_ASSERT(allocatorPool);
    116115        return new (allocatorPool->alloc(size)) DisjunctionContext();
    117116    }
     
    162161        size_t size = sizeof(ParenthesesDisjunctionContext) - sizeof(unsigned) + (term.atom.parenthesesDisjunction->m_numSubpatterns << 1) * sizeof(unsigned) + sizeof(DisjunctionContext) - sizeof(uintptr_t) + disjunction->m_frameSize * sizeof(uintptr_t);
    163162        allocatorPool = allocatorPool->ensureCapacity(size);
    164         if (!allocatorPool)
    165             CRASH();
     163        RELEASE_ASSERT(allocatorPool);
    166164        return new (allocatorPool->alloc(size)) ParenthesesDisjunctionContext(output, term);
    167165    }
     
    208206        int readChecked(unsigned negativePositionOffest)
    209207        {
    210             if (pos < negativePositionOffest)
    211                 CRASH();
     208            RELEASE_ASSERT(pos >= negativePositionOffest);
    212209            unsigned p = pos - negativePositionOffest;
    213210            ASSERT(p < length);
     
    265262        void uncheckInput(unsigned count)
    266263        {
    267             if (pos < count)
    268                 CRASH();
     264            RELEASE_ASSERT(pos >= count);
    269265            pos -= count;
    270266        }
     
    277273        bool atEnd(unsigned negativePositionOffest)
    278274        {
    279             if (pos < negativePositionOffest)
    280                 CRASH();
     275            RELEASE_ASSERT(pos >= negativePositionOffest);
    281276            return (pos - negativePositionOffest) == length;
    282277        }
     
    14261421
    14271422        allocatorPool = pattern->m_allocator->startAllocator();
    1428         if (!allocatorPool)
    1429             CRASH();
     1423        RELEASE_ASSERT(allocatorPool);
    14301424
    14311425        DisjunctionContext* context = allocDisjunctionContext(pattern->m_body.get());
Note: See TracChangeset for help on using the changeset viewer.