Skip to content

Commit 454f5a8

Browse files
committed
Jsonifier Release v0.9.92
* Refactored the number-parsing functions to use lookup tables instead of subtraction operations. * Refactored the simd_string_reader class. * Refactored some functions with fold-expressions for manual loop unrolliing. * Refactored the toChars and parseNumber functions. * Removed some superfluous typedefs. * Testing new simd logic for string parsing. * Renamed some types to snake_case. * Refactored the jsonifier_core, parser, and serializer classes to utilize the CRTP. * Refactored the simd_structural_iterator and serialization_iterator classes to remain contained.
1 parent 5cb79df commit 454f5a8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+4743
-5682
lines changed

.github/workflows/CLANG_18-Ubuntu.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ on:
88

99
jobs:
1010
Build:
11-
runs-on: ubuntu-22.04
11+
runs-on: ubuntu-latest
1212

1313
strategy:
1414
fail-fast: false

.github/workflows/MSVC_2022-Windows.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ on:
88

99
jobs:
1010
Build:
11-
runs-on: windows-2022
11+
runs-on: windows-latest
1212

1313
strategy:
1414
fail-fast: false

BuildTools/Classes/Packager/Vcpkg.php

+8-8
Original file line numberDiff line numberDiff line change
@@ -137,22 +137,26 @@ function constructPortAndVersionFile(string $sha512 = "0"): string
137137
$portFileContent = 'vcpkg_from_github(
138138
OUT_SOURCE_PATH SOURCE_PATH
139139
REPO realtimechris/jsonifier
140-
REF "v${VERSION}"
140+
REF "v${VERSION}"
141141
SHA512 ' . $sha512 . '
142142
HEAD_REF main
143+
PATCHES
144+
uninstall-head.patch
143145
)
144146
147+
set(VCPKG_BUILD_TYPE release) # header-only
148+
145149
vcpkg_cmake_configure(
146150
SOURCE_PATH "${SOURCE_PATH}"
147151
)
148152
149153
vcpkg_cmake_install()
150154
151-
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug")
152-
153155
vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/License.md")
154156
';
155-
// ./Vcpkg/ports/jsonifier/vcpkg.json
157+
158+
159+
// ./Vcpkg/ports/jsonifier/vcpkg.json
156160
$versionFileContent = '{
157161
"name": "jsonifier",
158162
"version": ' . json_encode($this->getVersion()) . ',
@@ -164,10 +168,6 @@ function constructPortAndVersionFile(string $sha512 = "0"): string
164168
{
165169
"name": "vcpkg-cmake",
166170
"host": true
167-
},
168-
{
169-
"name": "vcpkg-cmake-config",
170-
"host": true
171171
}
172172
]
173173
}';

CMake/JsonifierDetectArchitecture.cmake

+12-12
Original file line numberDiff line numberDiff line change
@@ -48,19 +48,19 @@ function(jsonifier_check_instruction_set INSTRUCTION_SET_NAME INSTRUCTION_SET_IN
4848
endfunction()
4949

5050
set(INSTRUCTION_SET_NAMES "POPCNT" "LZCNT" "BMI" "BMI2" "AVX" "AVX2" "AVX512")
51-
set (INSTRUCTION_SET_CODE
51+
set(INSTRUCTION_SET_CODE
5252
"auto result = _mm_popcnt_u64(uint64_t{})"
5353
"auto result = _lzcnt_u64(int64_t{})"
5454
"auto result = _blsr_u64(uint64_t{}).result = _tzcnt_u32(uint16_t{})"
5555
"auto result = _pdep_u64(uint64_t{}, uint64_t{})"
56-
"auto result = _mm_castsi128_pd(__m128i{}).auto result02 = _mm_setzero_si128()"
56+
"auto result = _mm_castsi128_pd(__m128i{}).auto result01 = _mm_setzero_si128()"
5757
"auto result = _mm256_add_epi32(__m256i{}, __m256i{})"
58-
"auto result = _mm512_add_ps(__m512i{}, __m512i{}).auto result2 = _mm512_cmplt_epu8_mask(__m512i{}, __m512i{}).auto result03 = _mm_abs_epi64 (__m128i{})"
58+
"auto result = _mm_abs_epi64 (__m128i{}).auto result01 = _mm512_abs_epi16(__m512i{})"
5959
)
6060

6161
set(INDEX_SET "0" "1" "2" "3" "4" "5" "6")
6262

63-
if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
63+
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
6464
set(INSTRUCTION_SET_IN_FLAGS "/arch:AVX" "/arch:AVX" "/arch:AVX" "/arch:AVX" "/arch:AVX" "/arch:AVX2" "/arch:AVX512")
6565
set(INSTRUCTION_SET_OUT_FLAGS "/arch:AVX" "/arch:AVX" "/arch:AVX" "/arch:AVX" "/arch:AVX" "/arch:AVX2" "/arch:AVX512")
6666
else()
@@ -70,7 +70,7 @@ endif()
7070

7171
set(CMAKE_REQUIRED_FLAGS_SAVE "${CMAKE_REQUIRED_FLAGS}")
7272

73-
if ((${CMAKE_SYSTEM_PROCESSOR} MATCHES "x86_64") OR (${CMAKE_SYSTEM_PROCESSOR} MATCHES "i386") OR (${CMAKE_SYSTEM_PROCESSOR} MATCHES "AMD64"))
73+
if((${CMAKE_SYSTEM_PROCESSOR} MATCHES "x86_64") OR (${CMAKE_SYSTEM_PROCESSOR} MATCHES "i386") OR (${CMAKE_SYSTEM_PROCESSOR} MATCHES "AMD64"))
7474

7575
foreach(CURRENT_INDEX IN LISTS INDEX_SET)
7676
list(GET INSTRUCTION_SET_NAMES "${CURRENT_INDEX}" INSTRUCTION_SET_NAME)
@@ -90,29 +90,29 @@ endif()
9090
set(AVX_FLAG)
9191
set(JSONIFIER_CPU_INSTRUCTIONS 0)
9292

93-
if (NOT "${POPCNT}" STREQUAL "")
93+
if(NOT "${POPCNT}" STREQUAL "")
9494
list(APPEND AVX_FLAG "${POPCNT}")
9595
math(EXPR JSONIFIER_CPU_INSTRUCTIONS "${JSONIFIER_CPU_INSTRUCTIONS} | 1 << 0" OUTPUT_FORMAT DECIMAL)
9696
endif()
97-
if (NOT "${LZCNT}" STREQUAL "")
97+
if(NOT "${LZCNT}" STREQUAL "")
9898
list(APPEND AVX_FLAG "${LZCNT}")
9999
math(EXPR JSONIFIER_CPU_INSTRUCTIONS "${JSONIFIER_CPU_INSTRUCTIONS} | 1 << 1" OUTPUT_FORMAT DECIMAL)
100100
endif()
101-
if (NOT "${BMI}" STREQUAL "")
101+
if(NOT "${BMI}" STREQUAL "")
102102
list(APPEND AVX_FLAG "${BMI}")
103103
math(EXPR JSONIFIER_CPU_INSTRUCTIONS "${JSONIFIER_CPU_INSTRUCTIONS} | 1 << 2" OUTPUT_FORMAT DECIMAL)
104104
endif()
105-
if (NOT "${BMI2}" STREQUAL "")
105+
if(NOT "${BMI2}" STREQUAL "")
106106
list(APPEND AVX_FLAG "${BMI2}")
107107
math(EXPR JSONIFIER_CPU_INSTRUCTIONS "${JSONIFIER_CPU_INSTRUCTIONS} | 1 << 3" OUTPUT_FORMAT DECIMAL)
108108
endif()
109-
if (NOT "${AVX512}" STREQUAL "")
109+
if(NOT "${AVX512}" STREQUAL "")
110110
list(APPEND AVX_FLAG "${AVX512}")
111111
math(EXPR JSONIFIER_CPU_INSTRUCTIONS "${JSONIFIER_CPU_INSTRUCTIONS} | 1 << 6" OUTPUT_FORMAT DECIMAL)
112-
elseif (NOT "${AVX2}" STREQUAL "")
112+
elseif(NOT "${AVX2}" STREQUAL "")
113113
list(APPEND AVX_FLAG "${AVX2}")
114114
math(EXPR JSONIFIER_CPU_INSTRUCTIONS "${JSONIFIER_CPU_INSTRUCTIONS} | 1 << 5" OUTPUT_FORMAT DECIMAL)
115-
elseif (NOT "${AVX}" STREQUAL "")
115+
elseif(NOT "${AVX}" STREQUAL "")
116116
list(APPEND AVX_FLAG "${AVX}")
117117
math(EXPR JSONIFIER_CPU_INSTRUCTIONS "${JSONIFIER_CPU_INSTRUCTIONS} | 1 << 4" OUTPUT_FORMAT DECIMAL)
118118
endif()

Documentation/Custom/doxygen-awesome.css

+5-5
Original file line numberDiff line numberDiff line change
@@ -942,7 +942,7 @@ code, div.fragment, pre.fragment {
942942
}
943943

944944
code {
945-
display: jsonifier_inline;
945+
display: inline;
946946
background: var(--code-background);
947947
color: var(--code-foreground);
948948
padding: 2px 6px;
@@ -1026,7 +1026,7 @@ div.fragment span.preprocessor {
10261026
}
10271027

10281028
div.fragment span.lineno {
1029-
display: jsonifier_inline-block;
1029+
display: inline-block;
10301030
width: 27px;
10311031
border-right: none;
10321032
background: var(--fragment-linenumber-background);
@@ -1100,7 +1100,7 @@ dl.deprecated dt a {
11001100
}
11011101

11021102
dl.section dd, dl.bug dd, dl.deprecated dd {
1103-
margin-jsonifier_inline-start: 0px;
1103+
margin-inline-start: 0px;
11041104
}
11051105

11061106
dl.invariant, dl.pre {
@@ -1429,7 +1429,7 @@ address.footer {
14291429

14301430
.navpath li.navelem a {
14311431
text-shadow: none;
1432-
display: jsonifier_inline-block;
1432+
display: inline-block;
14331433
color: var(--primary-color) !important;
14341434
}
14351435

@@ -1481,7 +1481,7 @@ li.navelem:first-child:before {
14811481
*/
14821482

14831483
doxygen-awesome-dark-mode-toggle {
1484-
display: jsonifier_inline-block;
1484+
display: inline-block;
14851485
margin: 0 0 0 var(--spacing-small);
14861486
padding: 0;
14871487
width: var(--searchbar-height);

Documentation/Doxyfile

+3-3
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,7 @@ SUBGROUPING = NO
440440
INLINE_GROUPED_CLASSES = NO
441441

442442
# When the INLINE_SIMPLE_STRUCTS tag is set to YES, structs, classes, and unions
443-
# with only public data fields or simple typedef fields will be shown jsonifier_inline in
443+
# with only public data fields or simple typedef fields will be shown inline in
444444
# the documentation of the scope in which they are defined (i.e. file,
445445
# namespace, or group documentation), provided this scope is documented. If set
446446
# to NO, structs, classes, and unions are shown on a separate page (for HTML and
@@ -648,8 +648,8 @@ SHOW_GROUPED_MEMB_INC = NO
648648

649649
FORCE_LOCAL_INCLUDES = NO
650650

651-
# If the INLINE_INFO tag is set to YES then a tag [jsonifier_inline] is inserted in the
652-
# documentation for jsonifier_inline members.
651+
# If the INLINE_INFO tag is set to YES then a tag [inline] is inserted in the
652+
# documentation for inline members.
653653
# The default value is: YES.
654654

655655
INLINE_INFO = YES

Include/jsonifier/Allocator.hpp

+39-18
Original file line numberDiff line numberDiff line change
@@ -28,40 +28,61 @@
2828

2929
namespace jsonifier_internal {
3030

31-
template<uint64_t multiple> jsonifier_inline uint64_t roundUpToMultiple(uint64_t num) {
31+
template<uint64_t multiple> JSONIFIER_INLINE uint64_t roundUpToMultiple(uint64_t num) {
3232
uint64_t remainder = num % multiple;
3333
return remainder == 0 ? num : num + (multiple - remainder);
3434
}
3535

36-
template<int64_t multiple> jsonifier_inline uint64_t roundDownToMultiple(int64_t value) {
36+
template<int64_t multiple> JSONIFIER_INLINE uint64_t roundDownToMultiple(int64_t value) {
3737
return static_cast<uint64_t>(value >= 0 ? (value / multiple) * multiple : ((value - multiple + 1) / multiple) * multiple);
3838
}
3939

40-
template<typename value_type_new> class aligned_allocator : public std::pmr::polymorphic_allocator<value_type_new> {
40+
#if defined(_MSC_VER)
41+
42+
template<typename value_type> JSONIFIER_INLINE value_type* jsonifierAlignedAlloc(uint64_t size) {
43+
return static_cast<value_type*>(_aligned_malloc(roundUpToMultiple<BytesPerStep>(size * sizeof(value_type)), BytesPerStep));
44+
}
45+
46+
JSONIFIER_INLINE void jsonifierFree(void* ptr) {
47+
_aligned_free(ptr);
48+
}
49+
50+
#else
51+
52+
template<typename value_type> JSONIFIER_INLINE value_type* jsonifierAlignedAlloc(uint64_t size) {
53+
return static_cast<value_type*>(std::aligned_alloc(BytesPerStep, roundUpToMultiple<BytesPerStep>(size * sizeof(value_type))));
54+
}
55+
56+
JSONIFIER_INLINE void jsonifierFree(void* ptr) {
57+
free(ptr);
58+
}
59+
60+
#endif
61+
62+
template<typename value_type_new> class aligned_allocator {
4163
public:
4264
using value_type = value_type_new;
4365
using pointer = value_type*;
4466
using size_type = uint64_t;
45-
using allocator = std::pmr::polymorphic_allocator<value_type_new>;
4667

47-
jsonifier_inline pointer allocate(size_type n) {
68+
JSONIFIER_INLINE pointer allocate(size_type n) {
4869
if (n == 0) {
4970
return nullptr;
5071
}
51-
return static_cast<pointer>(allocator::allocate_bytes(roundUpToMultiple<BytesPerStep>(n * sizeof(value_type)), BytesPerStep));
72+
return jsonifierAlignedAlloc<value_type>(n);
5273
}
5374

54-
jsonifier_inline void deallocate(pointer ptr, size_type n) {
75+
JSONIFIER_INLINE void deallocate(pointer ptr, size_type) {
5576
if (ptr) {
56-
allocator::deallocate_bytes(ptr, roundUpToMultiple<BytesPerStep>(n * sizeof(value_type)), BytesPerStep);
77+
jsonifierFree(ptr);
5778
}
5879
}
5980

60-
template<typename... Args> jsonifier_inline void construct(pointer p, Args&&... args) {
61-
new (p) value_type(std::forward<Args>(args)...);
81+
template<typename... arg_types> JSONIFIER_INLINE void construct(pointer p, arg_types&&... args) {
82+
new (p) value_type(std::forward<arg_types>(args)...);
6283
}
6384

64-
jsonifier_inline void destroy(pointer p) {
85+
JSONIFIER_INLINE void destroy(pointer p) {
6586
p->~value_type();
6687
}
6788
};
@@ -74,23 +95,23 @@ namespace jsonifier_internal {
7495
using allocator = aligned_allocator<value_type>;
7596
using allocator_traits = std::allocator_traits<allocator>;
7697

77-
jsonifier_inline pointer allocate(size_type count) {
98+
JSONIFIER_INLINE pointer allocate(size_type count) {
7899
return allocator_traits::allocate(*this, count);
79100
}
80101

81-
jsonifier_inline void deallocate(pointer ptr, size_type count) {
102+
JSONIFIER_INLINE void deallocate(pointer ptr, size_type count) {
82103
allocator_traits::deallocate(*this, ptr, count);
83104
}
84105

85-
template<typename... Args> jsonifier_inline void construct(pointer ptr, Args&&... args) {
86-
allocator_traits::construct(*this, ptr, std::forward<Args>(args)...);
106+
template<typename... arg_types> JSONIFIER_INLINE void construct(pointer ptr, arg_types&&... args) {
107+
allocator_traits::construct(*this, ptr, std::forward<arg_types>(args)...);
87108
}
88109

89-
jsonifier_inline static size_type maxSize() {
90-
return allocator_traits::max_size(allocator{});
110+
JSONIFIER_INLINE size_type maxSize() {
111+
return allocator_traits::max_size(*this);
91112
}
92113

93-
jsonifier_inline void destroy(pointer ptr) {
114+
JSONIFIER_INLINE void destroy(pointer ptr) {
94115
allocator_traits::destroy(*this, ptr);
95116
}
96117
};

0 commit comments

Comments
 (0)