Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

sincos and thread safety#382

Answeredbykgryte
ghalimi asked this question inQ&A
Feb 21, 2021· 1 comments· 3 replies
Discussion options

What does the commentWARNING: not thread safe mean on thisline in relation to thesincos 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?

You must be logged in to vote

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

Comment options

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.

You must be logged in to vote
3 replies
@trusktr
Comment options

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.

@kgryte
Comment options

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.

@kgryte
Comment options

New discovery today: JavaScript code which isnot 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.

Answer selected bykgryte
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Category
Q&A
Labels
QuestionGeneral question.MathIssue or pull request specific to math functionality.
3 participants
@ghalimi@trusktr@kgryte

[8]ページ先頭

©2009-2025 Movatter.jp