-
-
Notifications
You must be signed in to change notification settings - Fork 878
-
What does the comment WARNING: not thread safe
mean on this line in relation to the sincos
function? Since JavaScript is single-threaded (taking web workers aside), how could thread safety be an issue? Is this a legacy of an anterior C implementation?
Beta Was this translation helpful? Give feedback.
All reactions
This means that, if someone was porting to a language supporting multiple threads (e.g., C), then porting as is would not be thread safe. In JavaScript, we can elevate memory allocations out of functions as code does not need be reentrant. In C, we would not be able to do so.
Replies: 1 comment 3 replies
-
This means that, if someone was porting to a language supporting multiple threads (e.g., C), then porting as is would not be thread safe. In JavaScript, we can elevate memory allocations out of functions as code does not need be reentrant. In C, we would not be able to do so.
Beta Was this translation helpful? Give feedback.
All reactions
-
If you fork a C program, then both programs have their own copy of the in-scope variables right? Wouldn't it still be thread safe then?
But in any case, I think the comments aren't needed. Someone porting to any other language should know what they're doing in their target language.
I believe the comments will cause more confusion there than benefit.
Beta Was this translation helpful? Give feedback.
All reactions
-
Re: fork. Yes, that is correct.
The source comments are useful for us--that's why they are there--serving as a reminder as to how our internal native C and JS implementations should differ.
Beta Was this translation helpful? Give feedback.
All reactions
-
New discovery today: JavaScript code which is not thread safe can affect whether V8 is able to perform certain optimizations. If a function is not thread safe, this can trigger de-optimizations. This was discovered on newer versions of V8 during profiling.
Beta Was this translation helpful? Give feedback.