Skip to content

Commit b8919b1

Browse files
bnoordhuisFishrock123
authored andcommitted
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: #6734 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
1 parent 517e715 commit b8919b1

File tree

3 files changed

+17
-10
lines changed

3 files changed

+17
-10
lines changed

src/node.cc

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1788,8 +1788,15 @@ void GetActiveHandles(const FunctionCallbackInfo<Value>& args) {
17881788
}
17891789

17901790

1791+
NO_RETURN void Abort() {
1792+
DumpBacktrace(stderr);
1793+
fflush(stderr);
1794+
ABORT_NO_BACKTRACE();
1795+
}
1796+
1797+
17911798
static void Abort(const FunctionCallbackInfo<Value>& args) {
1792-
ABORT();
1799+
Abort();
17931800
}
17941801

17951802

src/node_internals.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,12 +134,10 @@ constexpr size_t arraysize(const T(&)[N]) { return N; }
134134
# define ROUND_UP(a, b) ((a) % (b) ? ((a) + (b)) - ((a) % (b)) : (a))
135135
#endif
136136

137-
#if defined(__GNUC__) && __GNUC__ >= 4
137+
#ifdef __GNUC__
138138
# define MUST_USE_RESULT __attribute__((warn_unused_result))
139-
# define NO_RETURN __attribute__((noreturn))
140139
#else
141140
# define MUST_USE_RESULT
142-
# define NO_RETURN
143141
#endif
144142

145143
bool IsExceptionDecorated(Environment* env, v8::Local<v8::Value> er);

src/util.h

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,13 @@
1919

2020
namespace node {
2121

22+
#ifdef __GNUC__
23+
#define NO_RETURN __attribute__((noreturn))
24+
#else
25+
#define NO_RETURN
26+
#endif
27+
28+
NO_RETURN void Abort();
2229
void DumpBacktrace(FILE* fp);
2330

2431
#ifdef __APPLE__
@@ -43,12 +50,7 @@ template <typename T> using remove_reference = std::remove_reference<T>;
4350
#define ABORT_NO_BACKTRACE() abort()
4451
#endif
4552

46-
#define ABORT() \
47-
do { \
48-
node::DumpBacktrace(stderr); \
49-
fflush(stderr); \
50-
ABORT_NO_BACKTRACE(); \
51-
} while (0)
53+
#define ABORT() node::Abort()
5254

5355
#if defined(NDEBUG)
5456
# define ASSERT(expression)

0 commit comments

Comments
 (0)