-
-
Notifications
You must be signed in to change notification settings - Fork 35.4k
src: use struct as arguments to node::Assert #25869
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
This just makes the code a bit more obvious (subjectively).
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -85,10 +85,16 @@ 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* filename; | ||
| unsigned int linenum; | ||
| 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 +126,10 @@ void DumpBacktrace(FILE* fp); | |
| #define CHECK(expr) \ | ||
| do { \ | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you're here, would you consider de-crufting this? i.e.: if (!(expr)) { \
node::Assert({ __FILE__, __LINE__, #expr, PRETTY_FUNCTION_NAME }); \
} \
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @refack At least locally (gcc-7 on Ubuntu 18.04), that would undo the purpose of this (what the comment is referring to): It would put the object construction in-line into the code instead of ending up as a simple pointer load from the read-only data section.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So how about: if (!(expr)) { \
static constexpr args{ __FILE__, __LINE__, #expr, PRETTY_FUNCTION_NAME } \
node::Assert(args); \
}
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @refack You are talking about I’ll make the comment more explicit about what the idea here is. |
||
| if (UNLIKELY(!(expr))) { \ | ||
| static const char* const args[] = { __FILE__, STRINGIFY(__LINE__), \ | ||
| #expr, PRETTY_FUNCTION_NAME }; \ | ||
| node::Assert(&args); \ | ||
| static const node::AssertionInfo args = { \ | ||
| __FILE__, __LINE__, #expr, PRETTY_FUNCTION_NAME \ | ||
| }; \ | ||
| node::Assert(args); \ | ||
| } \ | ||
| } while (0) | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.