Browse Source

src: move ABORT() logic into node::Abort()

Don't inline calls to node::DumpBacktrace() and fflush(), it makes the
generated code bigger.  A secondary benefit of moving it to a function
is that it gives you something to put a breakpoint on.

PR-URL: https://github.com/nodejs/node/pull/6734
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
v6.x
Ben Noordhuis 9 years ago
committed by Jeremiah Senkpiel
parent
commit
b8919b1d23
  1. 9
      src/node.cc
  2. 4
      src/node_internals.h
  3. 14
      src/util.h

9
src/node.cc

@ -1788,8 +1788,15 @@ void GetActiveHandles(const FunctionCallbackInfo<Value>& args) {
}
NO_RETURN void Abort() {
DumpBacktrace(stderr);
fflush(stderr);
ABORT_NO_BACKTRACE();
}
static void Abort(const FunctionCallbackInfo<Value>& args) {
ABORT();
Abort();
}

4
src/node_internals.h

@ -134,12 +134,10 @@ constexpr size_t arraysize(const T(&)[N]) { return N; }
# define ROUND_UP(a, b) ((a) % (b) ? ((a) + (b)) - ((a) % (b)) : (a))
#endif
#if defined(__GNUC__) && __GNUC__ >= 4
#ifdef __GNUC__
# define MUST_USE_RESULT __attribute__((warn_unused_result))
# define NO_RETURN __attribute__((noreturn))
#else
# define MUST_USE_RESULT
# define NO_RETURN
#endif
bool IsExceptionDecorated(Environment* env, v8::Local<v8::Value> er);

14
src/util.h

@ -19,6 +19,13 @@
namespace node {
#ifdef __GNUC__
#define NO_RETURN __attribute__((noreturn))
#else
#define NO_RETURN
#endif
NO_RETURN void Abort();
void DumpBacktrace(FILE* fp);
#ifdef __APPLE__
@ -43,12 +50,7 @@ template <typename T> using remove_reference = std::remove_reference<T>;
#define ABORT_NO_BACKTRACE() abort()
#endif
#define ABORT() \
do { \
node::DumpBacktrace(stderr); \
fflush(stderr); \
ABORT_NO_BACKTRACE(); \
} while (0)
#define ABORT() node::Abort()
#if defined(NDEBUG)
# define ASSERT(expression)

Loading…
Cancel
Save