Ignore:
Timestamp:
Nov 21, 2008, 1:20:41 PM (17 years ago)
Author:
[email protected]
Message:

Reviewed by Dan Bernstein.

https://bugs.webkit.org/show_bug.cgi?id=22402
Replace abort() with CRASH()

  • wtf/Assertions.h: Added a different method to crash, which should work even is 0xbbadbeef is a valid memory address.
  • runtime/Collector.cpp:
  • wtf/FastMalloc.cpp:
  • wtf/FastMalloc.h:
  • wtf/TCSpinLock.h: Replace abort() with CRASH().
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/wtf/FastMalloc.cpp

    r38672 r38673  
    192192    void* result = malloc(n);
    193193    if (!result)
    194         abort();
     194        CRASH();
    195195    return result;
    196196}
     
    207207    void* result = calloc(n_elements, element_size);
    208208    if (!result)
    209         abort();
     209        CRASH();
    210210    return result;
    211211}
     
    228228    void* result = realloc(p, n);
    229229    if (!result)
    230         abort();
     230        CRASH();
    231231    return result;
    232232}
     
    687687  if (ClassIndex(0) < 0) {
    688688    MESSAGE("Invalid class index %d for size 0\n", ClassIndex(0));
    689     abort();
     689    CRASH();
    690690  }
    691691  if (static_cast<size_t>(ClassIndex(kMaxSize)) >= sizeof(class_array)) {
    692692    MESSAGE("Invalid class index %d for kMaxSize\n", ClassIndex(kMaxSize));
    693     abort();
     693    CRASH();
    694694  }
    695695
     
    743743    MESSAGE("wrong number of size classes: found %" PRIuS " instead of %d\n",
    744744            sc, int(kNumClasses));
    745     abort();
     745    CRASH();
    746746  }
    747747
     
    761761    if (sc == 0) {
    762762      MESSAGE("Bad size class %" PRIuS " for %" PRIuS "\n", sc, size);
    763       abort();
     763      CRASH();
    764764    }
    765765    if (sc > 1 && size <= class_to_size[sc-1]) {
    766766      MESSAGE("Allocating unnecessarily large class %" PRIuS " for %" PRIuS
    767767              "\n", sc, size);
    768       abort();
     768      CRASH();
    769769    }
    770770    if (sc >= kNumClasses) {
    771771      MESSAGE("Bad size class %" PRIuS " for %" PRIuS "\n", sc, size);
    772       abort();
     772      CRASH();
    773773    }
    774774    const size_t s = class_to_size[sc];
    775775    if (size > s) {
    776776     MESSAGE("Bad size %" PRIuS " for %" PRIuS " (sc = %" PRIuS ")\n", s, size, sc);
    777       abort();
     777      CRASH();
    778778    }
    779779    if (s == 0) {
    780780      MESSAGE("Bad size %" PRIuS " for %" PRIuS " (sc = %" PRIuS ")\n", s, size, sc);
    781       abort();
     781      CRASH();
    782782    }
    783783  }
     
    862862        // Need more room
    863863        free_area_ = reinterpret_cast<char*>(MetaDataAlloc(kAllocIncrement));
    864         if (free_area_ == NULL) abort();
     864        if (free_area_ == NULL) CRASH();
    865865        free_avail_ = kAllocIncrement;
    866866      }
     
    30243024
    30253025#ifdef WTF_CHANGES
    3026 template <bool abortOnFailure>
     3026template <bool crashOnFailure>
    30273027#endif
    30283028static ALWAYS_INLINE void* do_malloc(size_t size) {
     
    30573057  if (!ret) {
    30583058#ifdef WTF_CHANGES
    3059     if (abortOnFailure) // This branch should be optimized out by the compiler.
    3060         abort();
     3059    if (crashOnFailure) // This branch should be optimized out by the compiler.
     3060        CRASH();
    30613061#else
    30623062    errno = ENOMEM;
     
    32273227extern "C"
    32283228#else
    3229 #define do_malloc do_malloc<abortOnFailure>
    3230 
    3231 template <bool abortOnFailure>
     3229#define do_malloc do_malloc<crashOnFailure>
     3230
     3231template <bool crashOnFailure>
    32323232void* malloc(size_t);
    32333233
     
    32423242}
    32433243
    3244 template <bool abortOnFailure>
     3244template <bool crashOnFailure>
    32453245ALWAYS_INLINE
    32463246#endif
     
    32663266extern "C"
    32673267#else
    3268 template <bool abortOnFailure>
     3268template <bool crashOnFailure>
    32693269void* calloc(size_t, size_t);
    32703270
     
    32793279}
    32803280
    3281 template <bool abortOnFailure>
     3281template <bool crashOnFailure>
    32823282ALWAYS_INLINE
    32833283#endif
     
    33123312extern "C"
    33133313#else
    3314 template <bool abortOnFailure>
     3314template <bool crashOnFailure>
    33153315void* realloc(void*, size_t);
    33163316
     
    33253325}
    33263326
    3327 template <bool abortOnFailure>
     3327template <bool crashOnFailure>
    33283328ALWAYS_INLINE
    33293329#endif
Note: See TracChangeset for help on using the changeset viewer.