-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Add emscripten_memset_js and use it from memset #21683
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,9 +9,16 @@ __attribute__((no_sanitize("address"))) void *__memset(void *str, int c, size_t | |
__attribute__((__weak__)) void *__musl_memset(void *str, int c, size_t n); | ||
__attribute__((__weak__)) void *__memset(void *str, int c, size_t n); | ||
|
||
#ifdef EMSCRIPTEN_OPTIMIZE_FOR_OZ | ||
#if defined(EMSCRIPTEN_OPTIMIZE_FOR_OZ) || __has_feature(address_sanitizer) | ||
|
||
void *__memset(void *str, int c, size_t n) { | ||
#if !defined(EMSCRIPTEN_STANDALONE_WASM) | ||
if (n >= 512) { | ||
_emscripten_memset_js(str, c, n); | ||
return str; | ||
} | ||
#endif | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It looks like There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We want good performance in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, for ASan I think we want to be able to instrument it as you said, and performance is less critical there. For |
||
|
||
unsigned char *s = (unsigned char *)str; | ||
#pragma clang loop unroll(disable) | ||
while(n--) *s++ = c; | ||
|
@@ -26,10 +33,21 @@ void *__memset(void *str, int c, size_t n) { | |
|
||
#else | ||
|
||
#define memset __memset | ||
#define memset __musl_memset | ||
#include "musl/src/string/memset.c" | ||
#undef memset | ||
|
||
void *__memset(void *str, int c, size_t n) { | ||
#if !defined(EMSCRIPTEN_STANDALONE_WASM) | ||
if (n >= 512) { | ||
_emscripten_memset_js(str, c, n); | ||
return str; | ||
} | ||
#endif | ||
|
||
return __musl_memset(str, c, n); | ||
} | ||
|
||
#endif | ||
|
||
weak_alias(__memset, emscripten_builtin_memset); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe revert these whitespace changes.