mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 719776 - Part 2: Inline MOZ_Assert and MOZ_Crash. r=waldo
This commit is contained in:
parent
509b99c841
commit
4458bdfe56
@ -332,22 +332,6 @@ __BitScanReverse64(unsigned __int64 val)
|
||||
JS_END_MACRO
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Internal function.
|
||||
* Compute the log of the least power of 2 greater than or equal to n. This is
|
||||
* a version of JS_CeilingLog2 that operates on unsigned integers with
|
||||
* CPU-dependant size.
|
||||
*/
|
||||
#define JS_CEILING_LOG2W(n) ((n) <= 1 ? 0 : 1 + JS_FLOOR_LOG2W((n) - 1))
|
||||
|
||||
/*
|
||||
* Internal function.
|
||||
* Compute the log of the greatest power of 2 less than or equal to n.
|
||||
* This is a version of JS_FloorLog2 that operates on unsigned integers with
|
||||
* CPU-dependant size and requires that n != 0.
|
||||
*/
|
||||
#define JS_FLOOR_LOG2W(n) (JS_ASSERT((n) != 0), js_FloorLog2wImpl(n))
|
||||
|
||||
#if JS_BYTES_PER_WORD == 4
|
||||
# ifdef JS_HAS_BUILTIN_BITSCAN32
|
||||
# define js_FloorLog2wImpl(n) \
|
||||
@ -366,6 +350,27 @@ JS_PUBLIC_API(size_t) js_FloorLog2wImpl(size_t n);
|
||||
# error "NOT SUPPORTED"
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Internal function.
|
||||
* Compute the log of the least power of 2 greater than or equal to n. This is
|
||||
* a version of JS_CeilingLog2 that operates on unsigned integers with
|
||||
* CPU-dependant size.
|
||||
*/
|
||||
#define JS_CEILING_LOG2W(n) ((n) <= 1 ? 0 : 1 + JS_FLOOR_LOG2W((n) - 1))
|
||||
|
||||
/*
|
||||
* Internal function.
|
||||
* Compute the log of the greatest power of 2 less than or equal to n.
|
||||
* This is a version of JS_FloorLog2 that operates on unsigned integers with
|
||||
* CPU-dependant size and requires that n != 0.
|
||||
*/
|
||||
static MOZ_ALWAYS_INLINE size_t
|
||||
JS_FLOOR_LOG2W(size_t n)
|
||||
{
|
||||
JS_ASSERT(n != 0);
|
||||
return js_FloorLog2wImpl(n);
|
||||
}
|
||||
|
||||
JS_END_EXTERN_C
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@ -40,7 +40,7 @@
|
||||
#define ASSERT(assertion) MOZ_ASSERT(assertion)
|
||||
#define ASSERT_UNUSED(variable, assertion) (((void)variable), ASSERT(assertion))
|
||||
#define ASSERT_NOT_REACHED() MOZ_NOT_REACHED("")
|
||||
#define CRASH() MOZ_Crash()
|
||||
#define CRASH() MOZ_CRASH()
|
||||
#define COMPILE_ASSERT(exp, name) MOZ_STATIC_ASSERT(exp, #name)
|
||||
|
||||
#endif
|
||||
|
@ -1535,15 +1535,6 @@ extern JSErrorFormatString js_ErrorFormatString[JSErr_Limit];
|
||||
# define JS_ASSERT_REQUEST_DEPTH(cx) ((void) 0)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* If the operation callback flag was set, call the operation callback.
|
||||
* This macro can run the full GC. Return true if it is OK to continue and
|
||||
* false otherwise.
|
||||
*/
|
||||
#define JS_CHECK_OPERATION_LIMIT(cx) \
|
||||
(JS_ASSERT_REQUEST_DEPTH(cx), \
|
||||
(!cx->runtime->interrupt || js_InvokeOperationCallback(cx)))
|
||||
|
||||
/*
|
||||
* Invoke the operation callback and return false if the current execution
|
||||
* is to be terminated.
|
||||
@ -1560,6 +1551,18 @@ js_GetCurrentBytecodePC(JSContext* cx);
|
||||
extern JSScript *
|
||||
js_GetCurrentScript(JSContext* cx);
|
||||
|
||||
/*
|
||||
* If the operation callback flag was set, call the operation callback.
|
||||
* This macro can run the full GC. Return true if it is OK to continue and
|
||||
* false otherwise.
|
||||
*/
|
||||
static MOZ_ALWAYS_INLINE bool
|
||||
JS_CHECK_OPERATION_LIMIT(JSContext *cx)
|
||||
{
|
||||
JS_ASSERT_REQUEST_DEPTH(cx);
|
||||
return !cx->runtime->interrupt || js_InvokeOperationCallback(cx);
|
||||
}
|
||||
|
||||
namespace js {
|
||||
|
||||
#ifdef JS_METHODJIT
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
* vim: set ts=8 sw=4 et tw=99 ft=cpp:
|
||||
*
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
@ -46,6 +46,15 @@
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "mozilla/Types.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#ifndef WIN32
|
||||
# include <signal.h>
|
||||
#endif
|
||||
#ifdef ANDROID
|
||||
# include <android/log.h>
|
||||
#endif
|
||||
|
||||
/*
|
||||
* MOZ_STATIC_ASSERT may be used to assert a condition *at compile time*. This
|
||||
* can be useful when you make certain assumptions about what must hold for
|
||||
@ -131,12 +140,59 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern MFBT_API(void)
|
||||
MOZ_Crash(void);
|
||||
#if defined(WIN32)
|
||||
/*
|
||||
* We used to call DebugBreak() on Windows, but amazingly, it causes
|
||||
* the MSVS 2010 debugger not to be able to recover a call stack.
|
||||
*/
|
||||
# define MOZ_CRASH() \
|
||||
do { \
|
||||
*((volatile int *) NULL) = 123; \
|
||||
exit(3); \
|
||||
} while (0)
|
||||
#elif defined(ANDROID)
|
||||
/*
|
||||
* On Android, raise(SIGABRT) is handled asynchronously. Seg fault now
|
||||
* so we crash immediately and capture the current call stack.
|
||||
*/
|
||||
# define MOZ_CRASH() \
|
||||
do { \
|
||||
*((volatile int *) NULL) = 123; \
|
||||
abort(); \
|
||||
} while (0)
|
||||
#elif defined(__APPLE__)
|
||||
/*
|
||||
* On Mac OS X, Breakpad ignores signals. Only real Mach exceptions are
|
||||
* trapped.
|
||||
*/
|
||||
# define MOZ_CRASH() \
|
||||
do { \
|
||||
*((volatile int *) NULL) = 123; \
|
||||
raise(SIGABRT); /* In case above statement gets nixed by the optimizer. */ \
|
||||
} while (0)
|
||||
#else
|
||||
# define MOZ_CRASH() \
|
||||
do { \
|
||||
raise(SIGABRT); /* To continue from here in GDB: "signal 0". */ \
|
||||
} while (0)
|
||||
#endif
|
||||
|
||||
|
||||
extern MFBT_API(void)
|
||||
MOZ_Assert(const char* s, const char* file, int ln);
|
||||
|
||||
static MOZ_ALWAYS_INLINE void
|
||||
MOZ_OutputAssertMessage(const char* s, const char *file, int ln)
|
||||
{
|
||||
#ifdef ANDROID
|
||||
__android_log_print(ANDROID_LOG_FATAL, "MOZ_Assert",
|
||||
"Assertion failure: %s, at %s:%d\n", s, file, ln);
|
||||
#else
|
||||
fprintf(stderr, "Assertion failure: %s, at %s:%d\n", s, file, ln);
|
||||
fflush(stderr);
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
@ -176,10 +232,20 @@ MOZ_Assert(const char* s, const char* file, int ln);
|
||||
#ifdef DEBUG
|
||||
/* First the single-argument form. */
|
||||
# define MOZ_ASSERT_HELPER1(expr) \
|
||||
((expr) ? ((void)0) : MOZ_Assert(#expr, __FILE__, __LINE__))
|
||||
do { \
|
||||
if (expr) { \
|
||||
MOZ_OutputAssertMessage(#expr, __FILE__, __LINE__); \
|
||||
MOZ_CRASH(); \
|
||||
} \
|
||||
} while (0)
|
||||
/* Now the two-argument form. */
|
||||
# define MOZ_ASSERT_HELPER2(expr, explain) \
|
||||
((expr) ? ((void)0) : MOZ_Assert(#expr " (" explain ")", __FILE__, __LINE__))
|
||||
do { \
|
||||
if (expr) { \
|
||||
MOZ_OutputAssertMessage(#expr " (" explain ")", __FILE__, __LINE__); \
|
||||
MOZ_CRASH(); \
|
||||
} \
|
||||
} while (0)
|
||||
/* And now, helper macrology up the wazoo. */
|
||||
/*
|
||||
* Count the number of arguments passed to MOZ_ASSERT, very carefully
|
||||
@ -205,7 +271,7 @@ MOZ_Assert(const char* s, const char* file, int ln);
|
||||
MOZ_ASSERT_GLUE(MOZ_ASSERT_CHOOSE_HELPER(MOZ_COUNT_ASSERT_ARGS(__VA_ARGS__)), \
|
||||
(__VA_ARGS__))
|
||||
#else
|
||||
# define MOZ_ASSERT(...) ((void)0)
|
||||
# define MOZ_ASSERT(...) do { } while(0)
|
||||
#endif /* DEBUG */
|
||||
|
||||
/*
|
||||
@ -218,9 +284,13 @@ MOZ_Assert(const char* s, const char* file, int ln);
|
||||
* designed to catch bugs during debugging, not "in the field".
|
||||
*/
|
||||
#ifdef DEBUG
|
||||
# define MOZ_ASSERT_IF(cond, expr) ((cond) ? MOZ_ASSERT(expr) : ((void)0))
|
||||
# define MOZ_ASSERT_IF(cond, expr) \
|
||||
do { \
|
||||
if ((cond)) \
|
||||
MOZ_ASSERT(expr); \
|
||||
} while (0)
|
||||
#else
|
||||
# define MOZ_ASSERT_IF(cond, expr) ((void)0)
|
||||
# define MOZ_ASSERT_IF(cond, expr) do { } while (0)
|
||||
#endif
|
||||
|
||||
/* MOZ_NOT_REACHED_MARKER() expands (in compilers which support it) to an
|
||||
|
Loading…
Reference in New Issue
Block a user