Repository navigation
fix(runtime): same error handling in Debug and Release #605
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
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
904ec71
fix(runtime): throw a TypeError for invalid method receivers in every…
edusperoni 6980001
fix(test): fail run_tests.sh on failing specs and add --configuration
edusperoni 63c947b
fix(runtime): log and abort from tns::Assert the same way in every build
edusperoni 946073b
refactor(runtime): remove the logRuntimeDetail write-value checks and…
edusperoni 2345cd2
fix(runtime): reject non-native receivers of native instance members
edusperoni a219942
feat(runtime): add tns::Fatal and NS_CHECK/NS_DCHECK/NS_UNREACHABLE
edusperoni 9f8f6fb
fix(runtime): throw instead of aborting for bad native constructor an…
edusperoni 882a5e6
fix(runtime): throw instead of aborting for invalid extend() and __ex…
edusperoni 9af3945
fix(runtime): accept a Proxy around a native class as a native access…
edusperoni a385b5b
fix(runtime): reject a non-extensible extend() implementation before …
edusperoni 9e358ae
ci: skip the Catalyst job's report extraction when run_tests.sh alrea…
edusperoni 312ebc1
fix(runtime): keep a Proxy implementation's prototype through the ext…
edusperoni File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,93 @@ | ||
| #ifndef Checks_h | ||
| #define Checks_h | ||
|
|
||
| #include <string> | ||
|
|
||
| // How runtime code handles a failed condition: | ||
| // | ||
| // - A condition JS can reach throws a JS error: a TypeError for a bad | ||
| // argument or receiver, or the exception a failed V8 call left pending. | ||
| // - A failed v8::Maybe / MaybeLocal call propagates its pending exception. | ||
| // - NS_CHECK(cond, message): an invariant whose violation makes continuing | ||
| // unsafe. On in every build. | ||
| // - NS_DCHECK(cond) / NS_DCHECK_MSG(cond, message): a cheap internal sanity | ||
| // check, on only while NS_DCHECK_IS_ON. It is the one intentional | ||
| // Debug/Release difference, so it never guards anything JS can reach. | ||
| // - NS_UNREACHABLE(message): a branch that cannot be taken. | ||
| // - tns::Assert is legacy: a call site moves to the above when its code is | ||
| // touched. | ||
| // | ||
| // All of them end in tns::Fatal, which logs the location, the message, the | ||
| // native backtrace and, when an isolate is entered on the calling thread, the | ||
| // JS stack, then aborts. | ||
| // | ||
| // The names are prefixed: the vendored V8 inspector headers and the Node-API | ||
| // shim define their own unprefixed CHECK/DCHECK. | ||
|
|
||
| namespace tns { | ||
|
|
||
| [[noreturn]] void Fatal(const char* location, const std::string& message); | ||
|
|
||
| } // namespace tns | ||
|
|
||
| #define NS_CHECKS_STRINGIFY_HELPER(x) #x | ||
| #define NS_CHECKS_STRINGIFY(x) NS_CHECKS_STRINGIFY_HELPER(x) | ||
| #define NS_CHECKS_LOCATION __FILE__ ":" NS_CHECKS_STRINGIFY(__LINE__) | ||
|
|
||
| #ifndef NS_DCHECK_IS_ON | ||
| #if defined(DEBUG) | ||
| #define NS_DCHECK_IS_ON 1 | ||
| #elif defined(__has_feature) | ||
| #if __has_feature(address_sanitizer) | ||
| #define NS_DCHECK_IS_ON 1 | ||
| #else | ||
| #define NS_DCHECK_IS_ON 0 | ||
| #endif | ||
| #else | ||
| #define NS_DCHECK_IS_ON 0 | ||
| #endif | ||
| #endif | ||
|
|
||
| #define NS_CHECK(cond, message) \ | ||
| do { \ | ||
| if (!(cond)) [[unlikely]] { \ | ||
| ::tns::Fatal(NS_CHECKS_LOCATION, \ | ||
| std::string("NS_CHECK(" #cond ") failed: ") + (message)); \ | ||
| } \ | ||
| } while (0) | ||
|
|
||
| #if NS_DCHECK_IS_ON | ||
| #define NS_DCHECK(cond) \ | ||
| do { \ | ||
| if (!(cond)) [[unlikely]] { \ | ||
| ::tns::Fatal(NS_CHECKS_LOCATION, "NS_DCHECK(" #cond ") failed"); \ | ||
| } \ | ||
| } while (0) | ||
| #define NS_DCHECK_MSG(cond, message) \ | ||
| do { \ | ||
| if (!(cond)) [[unlikely]] { \ | ||
| ::tns::Fatal(NS_CHECKS_LOCATION, \ | ||
| std::string("NS_DCHECK(" #cond ") failed: ") + (message)); \ | ||
| } \ | ||
| } while (0) | ||
| #else | ||
| // Never evaluated, but still compiled, so names used only here stay used. | ||
| #define NS_DCHECK(cond) \ | ||
| do { \ | ||
| if (false) { \ | ||
| (void)(cond); \ | ||
| } \ | ||
| } while (0) | ||
| #define NS_DCHECK_MSG(cond, message) \ | ||
| do { \ | ||
| if (false) { \ | ||
| (void)(cond); \ | ||
| (void)(message); \ | ||
| } \ | ||
| } while (0) | ||
| #endif | ||
|
|
||
| #define NS_UNREACHABLE(message) \ | ||
| ::tns::Fatal(NS_CHECKS_LOCATION, std::string("NS_UNREACHABLE: ") + (message)) | ||
|
|
||
| #endif /* Checks_h */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.