From b8919b1d23403358c265e2d82d6c760446b2f72b Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Sun, 19 Jun 2016 10:44:22 +0200 Subject: [PATCH] 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 Reviewed-By: Colin Ihrig --- src/node.cc | 9 ++++++++- src/node_internals.h | 4 +--- src/util.h | 14 ++++++++------ 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/src/node.cc b/src/node.cc index bc328ad88a..fe53b9629e 100644 --- a/src/node.cc +++ b/src/node.cc @@ -1788,8 +1788,15 @@ void GetActiveHandles(const FunctionCallbackInfo& args) { } +NO_RETURN void Abort() { + DumpBacktrace(stderr); + fflush(stderr); + ABORT_NO_BACKTRACE(); +} + + static void Abort(const FunctionCallbackInfo& args) { - ABORT(); + Abort(); } diff --git a/src/node_internals.h b/src/node_internals.h index f9370c0a29..7d0a37e5d0 100644 --- a/src/node_internals.h +++ b/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 er); diff --git a/src/util.h b/src/util.h index f3f123c6d1..a02639affb 100644 --- a/src/util.h +++ b/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 using remove_reference = std::remove_reference; #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)