Skip to content

Commit 2783551

Browse files
committed
Fix x86
Signed-off-by: Heinz N. Gies <heinz@licenser.net>
1 parent 3b663a6 commit 2783551

File tree

7 files changed

+28
-27
lines changed

7 files changed

+28
-27
lines changed

src/impls/avx2/stage1.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#![allow(dead_code)]
22
use crate::{
3-
Stage1Parse,
3+
SIMDINPUT_LENGTH, Stage1Parse,
44
macros::{static_cast_i32, static_cast_i64, static_cast_u32},
55
};
66
#[cfg(target_arch = "x86")]
@@ -11,9 +11,9 @@ use std::arch::x86_64 as arch;
1111

1212
use arch::{
1313
__m256i, _mm_clmulepi64_si128, _mm_set_epi64x, _mm_set1_epi8, _mm256_add_epi32,
14-
_mm256_and_si256, _mm256_cmpeq_epi8, _mm256_loadu_si256, _mm256_max_epu8, _mm256_movemask_epi8,
15-
_mm256_set_epi32, _mm256_set1_epi8, _mm256_setr_epi8, _mm256_setzero_si256,
16-
_mm256_shuffle_epi8, _mm256_srli_epi32, _mm256_storeu_si256,
14+
_mm256_and_si256, _mm256_cmpeq_epi8, _mm256_load_si256, _mm256_loadu_si256, _mm256_max_epu8,
15+
_mm256_movemask_epi8, _mm256_set_epi32, _mm256_set1_epi8, _mm256_setr_epi8,
16+
_mm256_setzero_si256, _mm256_shuffle_epi8, _mm256_srli_epi32, _mm256_storeu_si256,
1717
};
1818

1919
macro_rules! low_nibble_mask {

src/impls/native/stage1.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#![allow(clippy::cast_lossless, clippy::cast_sign_loss)]
22

3-
use crate::{Stage1Parse, macros::static_cast_i32};
3+
use crate::{SIMDINPUT_LENGTH, Stage1Parse, macros::static_cast_i32};
44

55
type V128 = [u8; 16];
66

src/impls/neon/stage1.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,6 @@ pub unsafe fn neon_movemask_bulk(
4242

4343
// /NEON-SPECIFIC
4444

45-
//pub const SIMDJSON_PADDING: usize = mem::size_of::<uint8x16_t>() * 4;
46-
//pub const SIMDINPUT_LENGTH: usize = 64;
47-
4845
#[derive(Debug)]
4946
pub(crate) struct SimdInput {
5047
v0: uint8x16_t,

src/impls/portable/stage1.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use std::simd::{ToBitMask, prelude::*};
22

3-
use crate::{Stage1Parse, macros::static_cast_i32};
3+
use crate::{SIMDINPUT_LENGTH, Stage1Parse, macros::static_cast_i32};
44
#[derive(Debug)]
55
pub(crate) struct SimdInput {
66
v: u8x64,

src/impls/simd128/stage1.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::Stage1Parse;
1+
use crate::{Stage1Parse, SIMDINPUT_LENGTH};
22
use std::arch::wasm32::{
33
i8x16_splat, u8x16, u8x16_bitmask, u8x16_eq, u8x16_le, u8x16_shr, u8x16_splat, u8x16_swizzle,
44
u32x4, u32x4_add, u32x4_splat, v128, v128_and, v128_load, v128_store,

src/impls/sse42/stage1.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use crate::{
2-
Stage1Parse,
2+
SIMDINPUT_LENGTH, Stage1Parse,
33
macros::{static_cast_i32, static_cast_i64, static_cast_u32},
44
};
55
#[cfg(target_arch = "x86")]
@@ -10,16 +10,17 @@ use std::arch::x86_64 as arch;
1010

1111
#[cfg(target_arch = "x86")]
1212
use arch::{
13-
__m128i, _mm_add_epi32, _mm_and_si128, _mm_cmpeq_epi8, _mm_cmpgt_epi8, _mm_loadu_si128,
14-
_mm_max_epu8, _mm_movemask_epi8, _mm_or_si128, _mm_set_epi32, _mm_set1_epi8, _mm_setr_epi8,
15-
_mm_setzero_si128, _mm_shuffle_epi8, _mm_srli_epi32, _mm_storeu_si128, _mm_testz_si128,
13+
__m128i, _mm_add_epi32, _mm_and_si128, _mm_cmpeq_epi8, _mm_cmpgt_epi8, _mm_load_si128,
14+
_mm_loadu_si128, _mm_max_epu8, _mm_movemask_epi8, _mm_or_si128, _mm_set_epi32, _mm_set1_epi8,
15+
_mm_setr_epi8, _mm_setzero_si128, _mm_shuffle_epi8, _mm_srli_epi32, _mm_storeu_si128,
16+
_mm_testz_si128,
1617
};
1718

1819
#[cfg(target_arch = "x86_64")]
1920
use arch::{
20-
__m128i, _mm_add_epi32, _mm_and_si128, _mm_cmpeq_epi8, _mm_loadu_si128, _mm_max_epu8,
21-
_mm_movemask_epi8, _mm_set_epi32, _mm_set1_epi8, _mm_setr_epi8, _mm_setzero_si128,
22-
_mm_shuffle_epi8, _mm_srli_epi32, _mm_storeu_si128,
21+
__m128i, _mm_add_epi32, _mm_and_si128, _mm_cmpeq_epi8, _mm_load_si128, _mm_loadu_si128,
22+
_mm_max_epu8, _mm_movemask_epi8, _mm_set_epi32, _mm_set1_epi8, _mm_setr_epi8,
23+
_mm_setzero_si128, _mm_shuffle_epi8, _mm_srli_epi32, _mm_storeu_si128,
2324
};
2425

2526
macro_rules! low_nibble_mask {

src/lib.rs

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,8 @@ type ParseStrFn = for<'invoke, 'de> unsafe fn(
335335
any(target_arch = "x86_64", target_arch = "x86"),
336336
))]
337337
type FindStructuralBitsFn = unsafe fn(
338-
input: &[u8],
338+
input: &AlignedBuf,
339+
len: usize,
339340
structural_indexes: &mut Vec<u32>,
340341
) -> std::result::Result<(), ErrorType>;
341342

@@ -611,7 +612,8 @@ impl Deserializer<'_> {
611612
any(target_arch = "x86_64", target_arch = "x86"),
612613
))]
613614
pub(crate) unsafe fn find_structural_bits(
614-
input: &[u8],
615+
input: &AlignedBuf,
616+
len: usize,
615617
structural_indexes: &mut Vec<u32>,
616618
) -> std::result::Result<(), ErrorType> {
617619
unsafe {
@@ -636,18 +638,19 @@ impl Deserializer<'_> {
636638

637639
#[cfg_attr(not(feature = "no-inline"), inline)]
638640
unsafe fn get_fastest(
639-
input: &[u8],
641+
input: &AlignedBuf,
642+
len: usize,
640643
structural_indexes: &mut Vec<u32>,
641644
) -> core::result::Result<(), error::ErrorType> {
642645
unsafe {
643646
let fun = get_fastest_available_implementation();
644647
FN.store(fun as FnRaw, Ordering::Relaxed);
645-
(fun)(input, structural_indexes)
648+
(fun)(input, len, structural_indexes)
646649
}
647650
}
648651

649652
let fun = FN.load(Ordering::Relaxed);
650-
mem::transmute::<FnRaw, FindStructuralBitsFn>(fun)(input, structural_indexes)
653+
mem::transmute::<FnRaw, FindStructuralBitsFn>(fun)(input, len, structural_indexes)
651654
}
652655
}
653656

@@ -664,7 +667,7 @@ impl Deserializer<'_> {
664667
)))]
665668
#[cfg_attr(not(feature = "no-inline"), inline)]
666669
pub(crate) unsafe fn find_structural_bits(
667-
input: &[u8],
670+
input: &AlignedBuf,
668671
len: usize,
669672
structural_indexes: &mut Vec<u32>,
670673
) -> std::result::Result<(), ErrorType> {
@@ -683,7 +686,7 @@ impl Deserializer<'_> {
683686
#[cfg(all(feature = "portable", not(feature = "runtime-detection")))]
684687
#[cfg_attr(not(feature = "no-inline"), inline)]
685688
pub(crate) unsafe fn find_structural_bits(
686-
input: &[u8],
689+
input: &AlignedBuf,
687690
len: usize,
688691
structural_indexes: &mut Vec<u32>,
689692
) -> std::result::Result<(), ErrorType> {
@@ -703,7 +706,7 @@ impl Deserializer<'_> {
703706
))]
704707
#[cfg_attr(not(feature = "no-inline"), inline)]
705708
pub(crate) unsafe fn find_structural_bits(
706-
input: &[u8],
709+
input: &AlignedBuf,
707710
len: usize,
708711
structural_indexes: &mut Vec<u32>,
709712
) -> std::result::Result<(), ErrorType> {
@@ -720,7 +723,7 @@ impl Deserializer<'_> {
720723
))]
721724
#[cfg_attr(not(feature = "no-inline"), inline)]
722725
pub(crate) unsafe fn find_structural_bits(
723-
input: &[u8],
726+
input: &AlignedBuf,
724727
len: usize,
725728
structural_indexes: &mut Vec<u32>,
726729
) -> std::result::Result<(), ErrorType> {
@@ -744,7 +747,7 @@ impl Deserializer<'_> {
744747
#[cfg(all(target_feature = "simd128", not(feature = "portable")))]
745748
#[cfg_attr(not(feature = "no-inline"), inline)]
746749
pub(crate) unsafe fn find_structural_bits(
747-
input: &[u8],
750+
input: &AlignedBuf,
748751
len: usize,
749752
structural_indexes: &mut Vec<u32>,
750753
) -> std::result::Result<(), ErrorType> {

0 commit comments

Comments
 (0)