Skip to content

Commit 612be14

Browse files
committed
Jsonifier Release v0.9.7
-Removed a bunch of superfluous "inline" calls. -Updated a few types. -Updated the Vector, StringBase and StringViewBase classes to fill their implementations out. -Updated the Iterator and ConstIterator implementations as well as the iterator-related members of the String, StringView and Vector classes.
1 parent c0ceec8 commit 612be14

Some content is hidden

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

43 files changed

+3306
-2572
lines changed

.clang-format

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
# Format Style Options - Created with Clang Power Tools
21
---
32
AlignAfterOpenBracket: DontAlign
4-
AlignConsecutiveAssignments: false
3+
AlignConsecutiveAssignments: true
54
AlignConsecutiveDeclarations: false
65
AlignConsecutiveMacros: false
76
AlignEscapedNewlines: DontAlign
@@ -19,9 +18,9 @@ AllowShortLoopsOnASingleLine: false
1918
AlwaysBreakAfterDefinitionReturnType: None
2019
AlwaysBreakAfterReturnType: None
2120
AlwaysBreakTemplateDeclarations: No
22-
ColumnLimit: 150
21+
ColumnLimit: 180
2322
CompactNamespaces: false
24-
ConstructorInitializerIndentWidth : 4
23+
ConstructorInitializerIndentWidth: 4
2524
ContinuationIndentWidth: 4
2625
Cpp11BracedListStyle: false
2726
FixNamespaceComments: false
@@ -60,4 +59,3 @@ SpacesInSquareBrackets: false
6059
Standard: Cpp11
6160
TabWidth: 4
6261
UseTab: Always
63-
...

.github/workflows/CLANG_17 - MacOS.yml renamed to .github/workflows/CLANG_16-MacOS.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Build-and-Test-CLANG
1+
name: Build-and-Test-CLANG-MacOS
22

33
on:
44
push:
@@ -24,6 +24,8 @@ jobs:
2424
run: |
2525
brew install llvm
2626
echo 'export PATH="/usr/local/opt/llvm/bin:$PATH"' >> ~/.bash_profile
27+
export LDFLAGS="-L/usr/local/opt/llvm/lib"
28+
export CPPFLAGS="-I/usr/local/opt/llvm/include"
2729
2830
- name: Configure CMake
2931
working-directory: Tests
@@ -39,4 +41,5 @@ jobs:
3941
working-directory: Tests/Build
4042
run: |
4143
./Json-Performance
44+
continue-on-error: true
4245

.github/workflows/CLANG_17.yml

Lines changed: 0 additions & 44 deletions
This file was deleted.

.github/workflows/GCC_12.yml renamed to .github/workflows/GCC_12-Ubuntu.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Build-and-Test-GCC
1+
name: Build-and-Test-GCC-Ubuntu
22

33
on:
44
push:
@@ -36,4 +36,5 @@ jobs:
3636
- name: Run the Test
3737
working-directory: Tests/Build
3838
run: |
39-
./Json-Performance
39+
./Json-Performance
40+
continue-on-error: true

.github/workflows/MSVC_2022.yml renamed to .github/workflows/MSVC_2022-Windows.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Build-and-Test-MSVC
1+
name: Build-and-Test-MSVC-Windows
22

33
on:
44
push:
@@ -40,4 +40,5 @@ jobs:
4040
working-directory: Tests/Build/${{matrix.build_type}}/
4141
run: |
4242
./Json-Performance.exe
43+
continue-on-error: true
4344

CMake/DetectArchitecture.cmake

Lines changed: 31 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,8 @@ function(check_instruction_set INSTRUCTION_SET_NAME INSTRUCTION_SET_FLAG INSTRUC
1515
set(CMAKE_REQUIRED_FLAGS "${INSTRUCTION_SET_FLAG}")
1616
CHECK_CXX_SOURCE_RUNS("${INSTRUCTION_SET_CODE}" "${INSTRUCTION_SET_NAME}")
1717
if(${INSTRUCTION_SET_NAME})
18-
set(AVX_TYPE "${INSTRUCTION_SET_NAME}" PARENT_SCOPE)
1918
set(AVX_FLAG "${INSTRUCTION_SET_FLAG}" PARENT_SCOPE)
20-
set(AVX_NAME "${INSTRUCTION_SET_NAME}" PARENT_SCOPE)
19+
set(AVX_TYPE "${INSTRUCTION_SET_NAME}" PARENT_SCOPE)
2120
else()
2221
message(STATUS "Instruction set ${INSTRUCTION_SET_NAME} not supported. Falling back to the previous instruction set.")
2322
return()
@@ -27,30 +26,43 @@ endfunction()
2726
if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
2827
set(INSTRUCTION_SETS
2928
"T_AVX?/arch:AVX?auto result = _mm_testz_ps(__m128{}, __m128{})"
30-
"T_AVX2?/arch:AVX2?auto result = _mm256_extract_epi64(__m256i{}, 0)"
31-
"T_AVX512?/arch:AVX512?auto result = _mm512_add_ps(__m512i{}, __m512i{}).auto result2 = _mm512_cmplt_epu8_mask(__m512i{}, __m512i{}).char newArray[64]{}.auto result = _mm_loadu_epi64(newArray)"
29+
"T_AVX2?/arch:AVX2?auto result = _mm256_add_epi32(__m256i{}, __m256i{})"
30+
"T_AVX512?/arch:AVX512?auto result = _mm512_add_ps(__m512i{}, __m512i{}).auto result2 = _mm512_cmplt_epu8_mask(__m512i{}, __m512i{})"
31+
)
32+
elseif(APPLE)
33+
set(INSTRUCTION_SETS
34+
"T_AVX?-mavx.-mpclmul.-mbmi.-mlzcnt?auto result = _mm_testz_ps(__m128{}, __m128{}).auto result2 = _blsr_u64(std::uint64_t{})"
35+
"T_AVX2?-mavx2.-mavx.-mpclmul.-mbmi.-mlzcnt?auto result = _mm256_add_epi32(__m256i{}, __m256i{})"
36+
"T_AVX512?-mavx512bw.-mavx512f.-mavx2.-mavx.-mpclmul.-mbmi.-mlzcnt?auto result = _mm512_add_ps(__m512i{}, __m512i{}).auto result2 = _mm512_cmplt_epu8_mask(__m512i{}, __m512i{})"
3237
)
3338
else()
3439
set(INSTRUCTION_SETS
35-
"T_AVX?-mavx.-mpclmul.-mbmi?auto result = _mm_testz_ps(__m128{}, __m128{})"
36-
"T_AVX2?-mavx2.-mavx.-mpclmul.-mbmi?auto result = _mm256_extract_epi64(__m256i{}, 0)"
37-
"T_AVX512?-mavx512bw.-avx512vl.-mavx512f.-mavx2.-mavx.-mpclmul.-mbmi?auto result = _mm512_add_ps(__m512i{}, __m512i{}).auto result2 = _mm512_cmplt_epu8_mask(__m512i{}, __m512i{}).char newArray[64]{}.auto result = _mm_loadu_epi64(newArray)"
40+
"T_AVX?-mavx.-mpclmul.-mbmi.-mlzcnt?auto result = _mm_testz_ps(__m128{}, __m128{})"
41+
"T_AVX2?-mavx2.-mavx.-mpclmul.-mbmi.-mlzcnt?auto result = _mm256_add_epi32(__m256i{}, __m256i{})"
42+
"T_AVX512?-mavx512bw.-mavx512f.-mavx2.-mavx.-mpclmul.-mbmi.-mlzcnt?auto result = _mm512_add_ps(__m512i{}, __m512i{}).auto result2 = _mm512_cmplt_epu8_mask(__m512i{}, __m512i{})"
3843
)
3944
endif()
4045

4146
set(CMAKE_REQUIRED_FLAGS_SAVE "${CMAKE_REQUIRED_FLAGS}")
4247

43-
set(AVX_NAME "T_Fallback")
48+
set(AVX_TYPE "T_Fallback")
4449

45-
foreach(INSTRUCTION_SET IN LISTS INSTRUCTION_SETS)
46-
string(REPLACE "?" ";" CURRENT_LIST "${INSTRUCTION_SET}")
47-
list(GET CURRENT_LIST 0 INSTRUCTION_SET_NAME)
48-
list(GET CURRENT_LIST 1 INSTRUCTION_SET_FLAG)
49-
string(REPLACE "." ";" INSTRUCTION_SET_FLAG "${INSTRUCTION_SET_FLAG}")
50-
list(GET CURRENT_LIST 2 INSTRUCTION_SET_INTRINSIC)
51-
string(REPLACE "." ";" INSTRUCTION_SET_INTRINSIC "${INSTRUCTION_SET_INTRINSIC}")
52-
check_instruction_set("${INSTRUCTION_SET_NAME}" "${INSTRUCTION_SET_FLAG}" "${INSTRUCTION_SET_INTRINSIC}")
53-
endforeach()
50+
if ((${CMAKE_SYSTEM_PROCESSOR} MATCHES "x86_64") OR (${CMAKE_SYSTEM_PROCESSOR} MATCHES "i386") OR (${CMAKE_SYSTEM_PROCESSOR} MATCHES "AMD64"))
51+
52+
foreach(INSTRUCTION_SET IN LISTS INSTRUCTION_SETS)
53+
string(REPLACE "?" ";" CURRENT_LIST "${INSTRUCTION_SET}")
54+
list(GET CURRENT_LIST 0 INSTRUCTION_SET_NAME)
55+
list(GET CURRENT_LIST 1 INSTRUCTION_SET_FLAG)
56+
string(REPLACE "." ";" INSTRUCTION_SET_FLAG "${INSTRUCTION_SET_FLAG}")
57+
list(GET CURRENT_LIST 2 INSTRUCTION_SET_INTRINSIC)
58+
string(REPLACE "." ";" INSTRUCTION_SET_INTRINSIC "${INSTRUCTION_SET_INTRINSIC}")
59+
check_instruction_set("${INSTRUCTION_SET_NAME}" "${INSTRUCTION_SET_FLAG}" "${INSTRUCTION_SET_INTRINSIC}")
60+
endforeach()
61+
62+
string(REPLACE "T_" "" AVX_DISPLAY ${AVX_TYPE})
63+
message(STATUS "Detected CPU Architecture: ${AVX_DISPLAY}")
64+
else()
65+
message(STATUS "SSE not supported by architecture ${CMAKE_SYSTEM_PROCESSOR}")
66+
endif()
5467

55-
message(STATUS "Detected CPU Architecture: ${AVX_NAME}")
56-
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS_SAVE}")
68+
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS_SAVE}")

CMakeLists.txt

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,17 @@ target_compile_options(
6868
"${PROJECT_NAME}" INTERFACE
6969
"$<$<CXX_COMPILER_ID:MSVC>:$<$<STREQUAL:${ASAN_ENABLED},TRUE>:/fsanitize=address>>"
7070
"$<$<CXX_COMPILER_ID:MSVC>:$<$<STREQUAL:${ASAN_ENABLED},TRUE>:/EHsc>>"
71+
"$<$<CXX_COMPILER_ID:MSVC>:/Zc:preprocessor>"
72+
"$<$<CXX_COMPILER_ID:MSVC>:/permissive->"
73+
"$<$<CXX_COMPILER_ID:MSVC>:/Zc:lambda>"
7174
"$<$<CXX_COMPILER_ID:CLANG>:-Wextra>"
7275
"$<$<CXX_COMPILER_ID:CLANG>:-Wall>"
73-
"$<$<CXX_COMPILER_ID:GNU>:-Wextra>"
74-
"$<$<CXX_COMPILER_ID:GNU>:-Wall>"
76+
"$<$<CXX_COMPILER_ID:GNU>:-Wextra>"
7577
"$<$<CXX_COMPILER_ID:MSVC>:/W4>"
78+
"$<$<CXX_COMPILER_ID:GNU>:-Wall>"
79+
"$<$<CXX_COMPILER_ID:MSVC>:/GL>"
80+
"$<$<CXX_COMPILER_ID:GNU>:-pedantic>"
81+
"$<$<CXX_COMPILER_ID:CLANG>:-pedantic>"
7682
"${AVX_FLAG}"
7783
)
7884

Documentation/Doxyfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ STRIP_FROM_PATH =
190190
# header file to include in order to use a class. If left blank only the name of
191191
# the header file containing the class definition is used. Otherwise one should
192192
# specify the list of include paths that are normally passed to the compiler
193-
# using the -I flag.
193+
# using the -Index flag.
194194

195195
STRIP_FROM_INC_PATH =
196196

Include/jsonifier/Allocator.hpp

Lines changed: 44 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -3,29 +3,30 @@
33
44
Copyright (c) 2023 RealTimeChris
55
6-
Permission is hereby granted, free of charge, to any person obtaining a copy of this
7-
software and associated documentation files (the "Software"), to deal in the Software
8-
without restriction, including without limitation the rights to use, copy, modify, merge,
9-
publish, distribute, sublicense, and/or sell copies of the Software, and to permit
6+
Permission is hereby granted, free of charge, to any person obtaining a copy of this
7+
software and associated documentation files (the "Software"), to deal in the Software
8+
without restriction, including without limitation the rights to use, copy, modify, merge,
9+
publish, distribute, sublicense, and/or sell copies of the Software, and to permit
1010
persons to whom the Software is furnished to do so, subject to the following conditions:
1111
12-
The above copyright notice and this permission notice shall be included in all copies or
12+
The above copyright notice and this permission notice shall be included in all copies or
1313
substantial portions of the Software.
1414
15-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
16-
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
17-
PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
18-
FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
19-
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
16+
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
17+
PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
18+
FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
19+
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
2020
DEALINGS IN THE SOFTWARE.
2121
*/
2222
/// https://github.com/RealTimeChris/Jsonifier
2323
/// Feb 3, 2023
2424
#pragma once
2525

2626
#include <cstdint>
27-
#include <utility>
2827
#include <memory>
28+
#include <memory_resource>
29+
#include <utility>
2930

3031
#if defined(_MSC_VER)
3132
#define ALIGNED_ALLOC(size, alignment) _aligned_malloc(size, alignment)
@@ -35,60 +36,73 @@
3536
#define ALIGNED_FREE(ptr) free(ptr)
3637
#endif
3738

39+
#if defined T_AVX512
40+
#define ALIGNMENT 64
41+
#elif defined T_AVX2
42+
#define ALIGNMENT 32
43+
#elif defined T_AVX
44+
#define ALIGNMENT 16
45+
#else
46+
#define ALIGNMENT 8
47+
#endif
48+
3849
namespace JsonifierInternal {
3950

40-
template<typename ValueType, uint64_t Alignment = alignof(ValueType)> class AlignedAllocator {
51+
template<typename ValueType> class AlignedAllocator {
4152
public:
4253
using value_type = ValueType;
43-
using pointer = value_type*;
44-
using size_type = uint64_t;
54+
using pointer = value_type*;
55+
using size_type = uint64_t;
4556

46-
inline pointer allocate(size_type n) {
57+
inline pointer allocate(size_type n) const {
4758
if (n == 0) {
4859
return nullptr;
4960
}
50-
51-
return static_cast<pointer>(ALIGNED_ALLOC(n * sizeof(ValueType), Alignment < 32 ? 32 : Alignment));
61+
return static_cast<pointer>(ALIGNED_ALLOC(n * sizeof(ValueType), ALIGNMENT));
5262
}
5363

54-
inline void deallocate(pointer p, size_type) {
64+
inline void deallocate(pointer p, size_type) const {
5565
if (p) {
5666
ALIGNED_FREE(p);
5767
}
5868
}
5969

60-
template<typename... Args> inline void construct(pointer p, Args&&... args) {
70+
template<typename... Args> inline void construct(pointer p, Args&&... args) const {
6171
new (p) value_type(std::forward<Args>(args)...);
6272
}
6373

64-
inline void destroy(pointer p) {
74+
inline void destroy(pointer p) const {
6575
p->~value_type();
6676
}
6777
};
6878

6979
template<typename ValueType> class AllocWrapper : public AlignedAllocator<ValueType> {
7080
public:
71-
using value_type = ValueType;
72-
using pointer = value_type*;
73-
using size_type = uint64_t;
74-
using allocator = AlignedAllocator<value_type>;
75-
using allocator_traits = std::allocator_traits<allocator>;
81+
using value_type = ValueType;
82+
using pointer = value_type*;
83+
using size_type = uint64_t;
84+
using allocator = const AlignedAllocator<value_type>;
85+
using allocator_traits = const std::allocator_traits<allocator>;
7686

77-
inline pointer allocate(size_type count) noexcept {
87+
inline AllocWrapper(){};
88+
89+
inline pointer allocate(size_type count) const {
7890
return allocator_traits::allocate(*this, count);
7991
}
8092

81-
inline void deallocate(pointer ptr, size_type count) noexcept {
93+
inline void deallocate(pointer ptr, size_type count) const {
8294
allocator_traits::deallocate(*this, ptr, count);
8395
}
8496

85-
template<typename... Args> inline void construct(pointer ptr, Args&&... args) noexcept {
97+
template<typename... Args> inline void construct(pointer ptr, Args&&... args) const {
8698
allocator_traits::construct(*this, ptr, std::forward<Args>(args)...);
8799
}
88100

89-
inline void destroy(pointer ptr) noexcept {
101+
inline void destroy(pointer ptr) const {
90102
allocator_traits::destroy(*this, ptr);
91103
}
104+
105+
inline ~AllocWrapper(){};
92106
};
93107

94-
}
108+
}// namespace JsonifierInternal

0 commit comments

Comments
 (0)