diff options
author | Anna Henningsen <anna@addaleax.net> | 2019-02-01 17:38:28 +0300 |
---|---|---|
committer | Anna Henningsen <anna@addaleax.net> | 2019-02-03 22:35:27 +0300 |
commit | 30545a5b21fecee1ff6c646ea49b3719644b200a (patch) | |
tree | b804868074a82a5fd4aafb1c735129e54aee357f /src/util.h | |
parent | d0bce9a82d820df9b297de58881fb00a57f6775c (diff) |
src: use struct as arguments to node::Assert
This just makes the code a bit more obvious (subjectively).
PR-URL: https://github.com/nodejs/node/pull/25869
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Diffstat (limited to 'src/util.h')
-rw-r--r-- | src/util.h | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/src/util.h b/src/util.h index fcb543fcacf..b199476aa24 100644 --- a/src/util.h +++ b/src/util.h @@ -85,10 +85,15 @@ extern bool v8_initialized; // whether V8 is initialized. void LowMemoryNotification(); -// The slightly odd function signature for Assert() is to ease -// instruction cache pressure in calls from CHECK. +// The reason that Assert() takes a struct argument instead of individual +// const char*s is to ease instruction cache pressure in calls from CHECK. +struct AssertionInfo { + const char* file_line; // filename:line + const char* message; + const char* function; +}; +[[noreturn]] void Assert(const AssertionInfo& info); [[noreturn]] void Abort(); -[[noreturn]] void Assert(const char* const (*args)[4]); void DumpBacktrace(FILE* fp); #define DISALLOW_COPY_AND_ASSIGN(TypeName) \ @@ -120,9 +125,12 @@ void DumpBacktrace(FILE* fp); #define CHECK(expr) \ do { \ if (UNLIKELY(!(expr))) { \ - static const char* const args[] = { __FILE__, STRINGIFY(__LINE__), \ - #expr, PRETTY_FUNCTION_NAME }; \ - node::Assert(&args); \ + /* Make sure that this struct does not end up in inline code, but */ \ + /* rather in a read-only data section when modifying this code. */ \ + static const node::AssertionInfo args = { \ + __FILE__ ":" STRINGIFY(__LINE__), #expr, PRETTY_FUNCTION_NAME \ + }; \ + node::Assert(args); \ } \ } while (0) |