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

3 files changed

Lines changed: 17 additions & 10 deletions

File tree

‎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_RETURNvoidAbort() {
1792+
DumpBacktrace(stderr);
1793+
fflush(stderr);
1794+
ABORT_NO_BACKTRACE();
1795+
}
1796+
1797+
17911798
staticvoidAbort(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
# defineROUND_UP(a, b) ((a) % (b) ? ((a) + (b)) - ((a) % (b)) : (a))
135135
#endif
136136

137-
#if defined(__GNUC__) && __GNUC__ >= 4
137+
#ifdef__GNUC__
138138
# defineMUST_USE_RESULT__attribute__((warn_unused_result))
139-
# defineNO_RETURN__attribute__((noreturn))
140139
#else
141140
# defineMUST_USE_RESULT
142-
# defineNO_RETURN
143141
#endif
144142

145143
boolIsExceptionDecorated(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
namespacenode {
2121

22+
#ifdef __GNUC__
23+
#defineNO_RETURN__attribute__((noreturn))
24+
#else
25+
#defineNO_RETURN
26+
#endif
27+
28+
NO_RETURNvoidAbort();
2229
voidDumpBacktrace(FILE* fp);
2330

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

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

5355
#if defined(NDEBUG)
5456
# defineASSERT(expression)

0 commit comments

Comments
 (0)