Changeset 38665 in webkit for trunk/JavaScriptCore
- Timestamp:
- Nov 21, 2008, 10:49:03 AM (17 years ago)
- Location:
- trunk/JavaScriptCore
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/ChangeLog
r38662 r38665 1 2008-11-21 Alexey Proskuryakov <[email protected]> 2 3 Reviewed by Sam Weinig. 4 5 https://bugs.webkit.org/show_bug.cgi?id=22402 6 Replace abort() with CRASH() 7 8 * wtf/Assertions.h: Added abort() after an attempt to crash for extra safety. 9 10 * runtime/Collector.cpp: 11 * wtf/FastMalloc.cpp: 12 * wtf/FastMalloc.h: 13 * wtf/TCSpinLock.h: 14 Replace abort() with CRASH(). 15 1 16 2008-11-21 Geoffrey Garen <[email protected]> 2 17 -
trunk/JavaScriptCore/runtime/Collector.cpp
r38622 r38665 284 284 ASSERT(heapType == PrimaryHeap || heap.extraCost == 0); 285 285 // FIXME: If another global variable access here doesn't hurt performance 286 // too much, we could abort() in NDEBUG builds, which could help ensure we286 // too much, we could CRASH() in NDEBUG builds, which could help ensure we 287 287 // don't spend any time debugging cases where we allocate inside an object's 288 288 // deallocation code. … … 975 975 ASSERT((primaryHeap.operationInProgress == NoOperation) | (numberHeap.operationInProgress == NoOperation)); 976 976 if ((primaryHeap.operationInProgress != NoOperation) | (numberHeap.operationInProgress != NoOperation)) 977 abort();977 CRASH(); 978 978 979 979 JAVASCRIPTCORE_GC_BEGIN(); -
trunk/JavaScriptCore/wtf/Assertions.h
r35900 r38665 51 51 #endif 52 52 53 #include <stdlib.h> 54 53 55 #ifdef NDEBUG 54 56 #define ASSERTIONS_DISABLED_DEFAULT 1 … … 121 123 122 124 #ifndef CRASH 123 #define CRASH() *(int *)(uintptr_t)0xbbadbeef = 0 125 #define CRASH() do { \ 126 *(int *)(uintptr_t)0xbbadbeef = 0; \ 127 abort(); \ 128 } while (false) 124 129 #endif 125 130 -
trunk/JavaScriptCore/wtf/FastMalloc.cpp
r37804 r38665 192 192 void* result = malloc(n); 193 193 if (!result) 194 abort();194 CRASH(); 195 195 return result; 196 196 } … … 207 207 void* result = calloc(n_elements, element_size); 208 208 if (!result) 209 abort();209 CRASH(); 210 210 return result; 211 211 } … … 228 228 void* result = realloc(p, n); 229 229 if (!result) 230 abort();230 CRASH(); 231 231 return result; 232 232 } … … 687 687 if (ClassIndex(0) < 0) { 688 688 MESSAGE("Invalid class index %d for size 0\n", ClassIndex(0)); 689 abort();689 CRASH(); 690 690 } 691 691 if (static_cast<size_t>(ClassIndex(kMaxSize)) >= sizeof(class_array)) { 692 692 MESSAGE("Invalid class index %d for kMaxSize\n", ClassIndex(kMaxSize)); 693 abort();693 CRASH(); 694 694 } 695 695 … … 743 743 MESSAGE("wrong number of size classes: found %" PRIuS " instead of %d\n", 744 744 sc, int(kNumClasses)); 745 abort();745 CRASH(); 746 746 } 747 747 … … 761 761 if (sc == 0) { 762 762 MESSAGE("Bad size class %" PRIuS " for %" PRIuS "\n", sc, size); 763 abort();763 CRASH(); 764 764 } 765 765 if (sc > 1 && size <= class_to_size[sc-1]) { 766 766 MESSAGE("Allocating unnecessarily large class %" PRIuS " for %" PRIuS 767 767 "\n", sc, size); 768 abort();768 CRASH(); 769 769 } 770 770 if (sc >= kNumClasses) { 771 771 MESSAGE("Bad size class %" PRIuS " for %" PRIuS "\n", sc, size); 772 abort();772 CRASH(); 773 773 } 774 774 const size_t s = class_to_size[sc]; 775 775 if (size > s) { 776 776 MESSAGE("Bad size %" PRIuS " for %" PRIuS " (sc = %" PRIuS ")\n", s, size, sc); 777 abort();777 CRASH(); 778 778 } 779 779 if (s == 0) { 780 780 MESSAGE("Bad size %" PRIuS " for %" PRIuS " (sc = %" PRIuS ")\n", s, size, sc); 781 abort();781 CRASH(); 782 782 } 783 783 } … … 862 862 // Need more room 863 863 free_area_ = reinterpret_cast<char*>(MetaDataAlloc(kAllocIncrement)); 864 if (free_area_ == NULL) abort();864 if (free_area_ == NULL) CRASH(); 865 865 free_avail_ = kAllocIncrement; 866 866 } … … 3024 3024 3025 3025 #ifdef WTF_CHANGES 3026 template <bool abortOnFailure>3026 template <bool crashOnFailure> 3027 3027 #endif 3028 3028 static ALWAYS_INLINE void* do_malloc(size_t size) { … … 3057 3057 if (!ret) { 3058 3058 #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(); 3061 3061 #else 3062 3062 errno = ENOMEM; … … 3227 3227 extern "C" 3228 3228 #else 3229 #define do_malloc do_malloc< abortOnFailure>3230 3231 template <bool abortOnFailure>3229 #define do_malloc do_malloc<crashOnFailure> 3230 3231 template <bool crashOnFailure> 3232 3232 void* malloc(size_t); 3233 3233 … … 3242 3242 } 3243 3243 3244 template <bool abortOnFailure>3244 template <bool crashOnFailure> 3245 3245 ALWAYS_INLINE 3246 3246 #endif … … 3266 3266 extern "C" 3267 3267 #else 3268 template <bool abortOnFailure>3268 template <bool crashOnFailure> 3269 3269 void* calloc(size_t, size_t); 3270 3270 … … 3279 3279 } 3280 3280 3281 template <bool abortOnFailure>3281 template <bool crashOnFailure> 3282 3282 ALWAYS_INLINE 3283 3283 #endif … … 3312 3312 extern "C" 3313 3313 #else 3314 template <bool abortOnFailure>3314 template <bool crashOnFailure> 3315 3315 void* realloc(void*, size_t); 3316 3316 … … 3325 3325 } 3326 3326 3327 template <bool abortOnFailure>3327 template <bool crashOnFailure> 3328 3328 ALWAYS_INLINE 3329 3329 #endif -
trunk/JavaScriptCore/wtf/FastMalloc.h
r37804 r38665 28 28 namespace WTF { 29 29 30 // These functions call abort() if an allocation fails.30 // These functions call CRASH() if an allocation fails. 31 31 void* fastMalloc(size_t n); 32 32 void* fastZeroedMalloc(size_t n); -
trunk/JavaScriptCore/wtf/TCSpinLock.h
r34111 r38665 47 47 #include <sys/types.h> 48 48 #endif 49 #include <stdlib.h> /* for abort() */50 49 51 50 #if PLATFORM(WIN_OS) … … 200 199 201 200 inline void Init() { 202 if (pthread_mutex_init(&private_lock_, NULL) != 0) abort();201 if (pthread_mutex_init(&private_lock_, NULL) != 0) CRASH(); 203 202 } 204 203 inline void Finalize() { 205 if (pthread_mutex_destroy(&private_lock_) != 0) abort();204 if (pthread_mutex_destroy(&private_lock_) != 0) CRASH(); 206 205 } 207 206 inline void Lock() { 208 if (pthread_mutex_lock(&private_lock_) != 0) abort();207 if (pthread_mutex_lock(&private_lock_) != 0) CRASH(); 209 208 } 210 209 inline void Unlock() { 211 if (pthread_mutex_unlock(&private_lock_) != 0) abort();210 if (pthread_mutex_unlock(&private_lock_) != 0) CRASH(); 212 211 } 213 212 };
Note:
See TracChangeset
for help on using the changeset viewer.