parent
e8ad728209
commit
de6e59e5ba
Notes:
git
2025-05-01 08:06:19 +00:00
@ -18,7 +18,7 @@ else
|
||||
return 0;
|
||||
}
|
||||
SRC
|
||||
$defs.push("-DENABLE_SIMD")
|
||||
$defs.push("-DJSON_ENABLE_SIMD")
|
||||
end
|
||||
end
|
||||
|
||||
@ -29,7 +29,7 @@ else
|
||||
return 0;
|
||||
}
|
||||
SRC
|
||||
$defs.push("-DENABLE_SIMD")
|
||||
$defs.push("-DJSON_ENABLE_SIMD")
|
||||
end
|
||||
|
||||
have_header('cpuid.h')
|
||||
|
@ -112,7 +112,7 @@ typedef struct _search_state {
|
||||
const char *cursor;
|
||||
FBuffer *buffer;
|
||||
|
||||
#ifdef ENABLE_SIMD
|
||||
#ifdef HAVE_SIMD
|
||||
const char *chunk_base;
|
||||
const char *chunk_end;
|
||||
bool has_matches;
|
||||
@ -124,7 +124,7 @@ typedef struct _search_state {
|
||||
#else
|
||||
#error "Unknown SIMD Implementation."
|
||||
#endif /* HAVE_SIMD_NEON */
|
||||
#endif /* ENABLE_SIMD */
|
||||
#endif /* HAVE_SIMD */
|
||||
} search_state;
|
||||
|
||||
#if (defined(__GNUC__ ) || defined(__clang__))
|
||||
@ -189,15 +189,11 @@ static inline FORCE_INLINE void escape_UTF8_char_basic(search_state *search)
|
||||
case '\r': fbuffer_append(search->buffer, "\\r", 2); break;
|
||||
case '\t': fbuffer_append(search->buffer, "\\t", 2); break;
|
||||
default: {
|
||||
if (ch < ' ') {
|
||||
const char *hexdig = "0123456789abcdef";
|
||||
char scratch[6] = { '\\', 'u', '0', '0', 0, 0 };
|
||||
scratch[4] = hexdig[(ch >> 4) & 0xf];
|
||||
scratch[5] = hexdig[ch & 0xf];
|
||||
fbuffer_append(search->buffer, scratch, 6);
|
||||
} else {
|
||||
fbuffer_append_char(search->buffer, ch);
|
||||
}
|
||||
const char *hexdig = "0123456789abcdef";
|
||||
char scratch[6] = { '\\', 'u', '0', '0', 0, 0 };
|
||||
scratch[4] = hexdig[(ch >> 4) & 0xf];
|
||||
scratch[5] = hexdig[ch & 0xf];
|
||||
fbuffer_append(search->buffer, scratch, 6);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -265,7 +261,7 @@ static inline void escape_UTF8_char(search_state *search, unsigned char ch_len)
|
||||
search->cursor = (search->ptr += ch_len);
|
||||
}
|
||||
|
||||
#ifdef ENABLE_SIMD
|
||||
#ifdef HAVE_SIMD
|
||||
|
||||
static inline FORCE_INLINE char *copy_remaining_bytes(search_state *search, unsigned long vec_len, unsigned long len)
|
||||
{
|
||||
@ -537,7 +533,7 @@ static inline TARGET_SSE2 FORCE_INLINE unsigned char search_escape_basic_sse2(se
|
||||
|
||||
#endif /* HAVE_SIMD_SSE2 */
|
||||
|
||||
#endif /* ENABLE_SIMD */
|
||||
#endif /* HAVE_SIMD */
|
||||
|
||||
static const unsigned char script_safe_escape_table[256] = {
|
||||
// ASCII Control Characters
|
||||
@ -1302,11 +1298,11 @@ static void generate_json_string(FBuffer *buffer, struct generate_json_data *dat
|
||||
search.cursor = search.ptr;
|
||||
search.end = search.ptr + len;
|
||||
|
||||
#ifdef ENABLE_SIMD
|
||||
#ifdef HAVE_SIMD
|
||||
search.matches_mask = 0;
|
||||
search.has_matches = false;
|
||||
search.chunk_base = NULL;
|
||||
#endif /* ENABLE_SIMD */
|
||||
#endif /* HAVE_SIMD */
|
||||
|
||||
switch(rb_enc_str_coderange(obj)) {
|
||||
case ENC_CODERANGE_7BIT:
|
||||
@ -2174,7 +2170,7 @@ void Init_generator(void)
|
||||
|
||||
|
||||
switch(find_simd_implementation()) {
|
||||
#ifdef ENABLE_SIMD
|
||||
#ifdef HAVE_SIMD
|
||||
#ifdef HAVE_SIMD_NEON
|
||||
case SIMD_NEON:
|
||||
search_escape_basic_impl = search_escape_basic_neon;
|
||||
@ -2185,7 +2181,7 @@ void Init_generator(void)
|
||||
search_escape_basic_impl = search_escape_basic_sse2;
|
||||
break;
|
||||
#endif /* HAVE_SIMD_SSE2 */
|
||||
#endif /* ENABLE_SIMD */
|
||||
#endif /* HAVE_SIMD */
|
||||
default:
|
||||
search_escape_basic_impl = search_escape_basic;
|
||||
break;
|
||||
|
@ -4,7 +4,7 @@ typedef enum {
|
||||
SIMD_SSE2
|
||||
} SIMD_Implementation;
|
||||
|
||||
#ifdef ENABLE_SIMD
|
||||
#ifdef JSON_ENABLE_SIMD
|
||||
|
||||
#ifdef __clang__
|
||||
#if __has_builtin(__builtin_ctzll)
|
||||
@ -56,6 +56,7 @@ static SIMD_Implementation find_simd_implementation(void) {
|
||||
return SIMD_NEON;
|
||||
}
|
||||
|
||||
#define HAVE_SIMD 1
|
||||
#define HAVE_SIMD_NEON 1
|
||||
|
||||
uint8x16x4_t load_uint8x16_4(const unsigned char *table) {
|
||||
@ -74,6 +75,7 @@ uint8x16x4_t load_uint8x16_4(const unsigned char *table) {
|
||||
#ifdef HAVE_X86INTRIN_H
|
||||
#include <x86intrin.h>
|
||||
|
||||
#define HAVE_SIMD 1
|
||||
#define HAVE_SIMD_SSE2 1
|
||||
|
||||
#ifdef HAVE_CPUID_H
|
||||
@ -101,7 +103,7 @@ static SIMD_Implementation find_simd_implementation(void) {
|
||||
#endif /* HAVE_X86INTRIN_H */
|
||||
#endif /* X86_64 Support */
|
||||
|
||||
#endif /* ENABLE_SIMD */
|
||||
#endif /* JSON_ENABLE_SIMD */
|
||||
|
||||
#ifndef FIND_SIMD_IMPLEMENTATION_DEFINED
|
||||
static SIMD_Implementation find_simd_implementation(void) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user