News for hackers. Stuff that matters.
Re:QuickJS, the Next Generation: a mighty JavaScript engine by lionkor on Monday July 08, 2024 @04:04AM (#40903485)
I would be careful to use this in production. I'm a diehard C and C++ fan, but: Having a mutex unlock inside an if statement that performs an early return, on line 52000 something, does not inspire confidence.

Excellent job on building this, and it's very readable and nice, otherwise!

Re:QuickJS, the Next Generation: a mighty JavaScript engine by not_a_dane on Monday July 08, 2024 @04:26AM (#40903604)
when I see C/C++ code, I prefer do not run it.
Re:QuickJS, the Next Generation: a mighty JavaScript engine by bun_terminator on Monday July 08, 2024 @05:01AM (#40903797)
This is C, not C++ - very different languages.
Re:QuickJS, the Next Generation: a mighty JavaScript engine by lionkor on Monday July 08, 2024 @09:43AM (#40905371)
Yes, you should be using a goto for this in C
Re:QuickJS, the Next Generation: a mighty JavaScript engine by metadat on Monday July 08, 2024 @10:32PM (#40911999)
Line 52,000 and x of what file?

I didn't find any file with that many line's yet, still searching but I doubt it exists unless it's in a different repository.

Re:QuickJS, the Next Generation: a mighty JavaScript engine by lionkor on Tuesday July 09, 2024 @07:24PM (#40922321)
Re:QuickJS, the Next Generation: a mighty JavaScript engine by metadat on Tuesday July 09, 2024 @07:58PM (#40922543)
Thanks for digging that up.

It looks like the mutex is theoretically sound.. unlocked before all returns, as long as there isn't an exception raised in between.

Re:QuickJS, the Next Generation: a mighty JavaScript engine by lionkor on Wednesday July 10, 2024 @11:29AM (#40928024)
Oh yeah of course its sound, but this is not how you write C code, because all it takes is for someone else in 10 years to, somewhere between 51000 and 53000 introduce an early return statement and forget to unlock that mutex, or other little things.

This is solved in C usually with a goto to a cleanup routine, and avoiding early returns.