Conversation
saghul
commented
Feb 1, 2025
- Store the JS value, so the conversion happens when the backtrace is needed
- Prevent recursion in build_backtrace
- Simplify code for saving / restoring exception in build_backtrace
- Store the JS value, so the conversion happens when the backtrace is needed - Prevent recursion in build_backtrace - Simplify code for saving / restoring exception in build_backtrace
|
@bnoordhuis PTAL, let me know what you think. It ended up a bit more complex that I originally envisioned. Alternative: convert the value on the spot and store both the JS value and the converted value, and use the latter in build_backtrace. Thoughts? |
|
@bnoordhuis Updated, can you PTAL one more time? |
quickjs.c
Outdated
| JS_ToFloat64(ctx, &d, ctx->error_stack_trace_limit); | ||
| if (isnan(d) || d < 0.0 || (isinf(d) && d < 0.0)) | ||
| stack_trace_limit = 0; | ||
| else if (isinf(d) || d > (double)INT32_MAX) |
There was a problem hiding this comment.
You don't have to cast to double (but it doesn't hurt either, it's just a no-op)
The isinf(d) && d < 0.0 two lines up looks superfluous. You check d < 0.0 first and -Infinity < 0.0
There was a problem hiding this comment.
Right. Does the same apply to checking for positive infinity? It will be larger than INT32_MAX I guess.
There was a problem hiding this comment.
Right. Does the same apply to checking for positive infinity? It will be larger than INT32_MAX I guess.
Good point. By an infinite amount, according to mathematicians.
quickjs.c
Outdated
| JS_ToFloat64(ctx, &d, ctx->error_stack_trace_limit); | ||
| if (isnan(d) || d < 0.0 || (isinf(d) && d < 0.0)) | ||
| stack_trace_limit = 0; | ||
| else if (isinf(d) || d > (double)INT32_MAX) |
There was a problem hiding this comment.
Right. Does the same apply to checking for positive infinity? It will be larger than INT32_MAX I guess.
Good point. By an infinite amount, according to mathematicians.