asmjit 0.2.0 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/Rakefile +5 -3
- data/asmjit.gemspec +1 -3
- data/ext/asmjit/asmjit/.editorconfig +10 -0
- data/ext/asmjit/asmjit/.github/FUNDING.yml +1 -0
- data/ext/asmjit/asmjit/.github/workflows/build-config.json +47 -0
- data/ext/asmjit/asmjit/.github/workflows/build.yml +156 -0
- data/ext/asmjit/asmjit/.gitignore +6 -0
- data/ext/asmjit/asmjit/CMakeLists.txt +611 -0
- data/ext/asmjit/asmjit/LICENSE.md +17 -0
- data/ext/asmjit/asmjit/README.md +69 -0
- data/ext/asmjit/asmjit/src/asmjit/a64.h +62 -0
- data/ext/asmjit/asmjit/src/asmjit/arm/a64archtraits_p.h +81 -0
- data/ext/asmjit/asmjit/src/asmjit/arm/a64assembler.cpp +5115 -0
- data/ext/asmjit/asmjit/src/asmjit/arm/a64assembler.h +72 -0
- data/ext/asmjit/asmjit/src/asmjit/arm/a64builder.cpp +51 -0
- data/ext/asmjit/asmjit/src/asmjit/arm/a64builder.h +57 -0
- data/ext/asmjit/asmjit/src/asmjit/arm/a64compiler.cpp +60 -0
- data/ext/asmjit/asmjit/src/asmjit/arm/a64compiler.h +247 -0
- data/ext/asmjit/asmjit/src/asmjit/arm/a64emithelper.cpp +464 -0
- data/ext/asmjit/asmjit/src/asmjit/arm/a64emithelper_p.h +50 -0
- data/ext/asmjit/asmjit/src/asmjit/arm/a64emitter.h +1228 -0
- data/ext/asmjit/asmjit/src/asmjit/arm/a64formatter.cpp +298 -0
- data/ext/asmjit/asmjit/src/asmjit/arm/a64formatter_p.h +59 -0
- data/ext/asmjit/asmjit/src/asmjit/arm/a64func.cpp +189 -0
- data/ext/asmjit/asmjit/src/asmjit/arm/a64func_p.h +33 -0
- data/ext/asmjit/asmjit/src/asmjit/arm/a64globals.h +1894 -0
- data/ext/asmjit/asmjit/src/asmjit/arm/a64instapi.cpp +278 -0
- data/ext/asmjit/asmjit/src/asmjit/arm/a64instapi_p.h +41 -0
- data/ext/asmjit/asmjit/src/asmjit/arm/a64instdb.cpp +1957 -0
- data/ext/asmjit/asmjit/src/asmjit/arm/a64instdb.h +74 -0
- data/ext/asmjit/asmjit/src/asmjit/arm/a64instdb_p.h +876 -0
- data/ext/asmjit/asmjit/src/asmjit/arm/a64operand.cpp +85 -0
- data/ext/asmjit/asmjit/src/asmjit/arm/a64operand.h +312 -0
- data/ext/asmjit/asmjit/src/asmjit/arm/a64rapass.cpp +852 -0
- data/ext/asmjit/asmjit/src/asmjit/arm/a64rapass_p.h +105 -0
- data/ext/asmjit/asmjit/src/asmjit/arm/a64utils.h +179 -0
- data/ext/asmjit/asmjit/src/asmjit/arm/armformatter.cpp +143 -0
- data/ext/asmjit/asmjit/src/asmjit/arm/armformatter_p.h +44 -0
- data/ext/asmjit/asmjit/src/asmjit/arm/armglobals.h +21 -0
- data/ext/asmjit/asmjit/src/asmjit/arm/armoperand.h +621 -0
- data/ext/asmjit/asmjit/src/asmjit/arm.h +62 -0
- data/ext/asmjit/asmjit/src/asmjit/asmjit-scope-begin.h +17 -0
- data/ext/asmjit/asmjit/src/asmjit/asmjit-scope-end.h +9 -0
- data/ext/asmjit/asmjit/src/asmjit/asmjit.h +33 -0
- data/ext/asmjit/asmjit/src/asmjit/core/api-build_p.h +55 -0
- data/ext/asmjit/asmjit/src/asmjit/core/api-config.h +613 -0
- data/ext/asmjit/asmjit/src/asmjit/core/archcommons.h +229 -0
- data/ext/asmjit/asmjit/src/asmjit/core/archtraits.cpp +160 -0
- data/ext/asmjit/asmjit/src/asmjit/core/archtraits.h +290 -0
- data/ext/asmjit/asmjit/src/asmjit/core/assembler.cpp +406 -0
- data/ext/asmjit/asmjit/src/asmjit/core/assembler.h +129 -0
- data/ext/asmjit/asmjit/src/asmjit/core/builder.cpp +889 -0
- data/ext/asmjit/asmjit/src/asmjit/core/builder.h +1391 -0
- data/ext/asmjit/asmjit/src/asmjit/core/codebuffer.h +113 -0
- data/ext/asmjit/asmjit/src/asmjit/core/codeholder.cpp +1149 -0
- data/ext/asmjit/asmjit/src/asmjit/core/codeholder.h +1035 -0
- data/ext/asmjit/asmjit/src/asmjit/core/codewriter.cpp +175 -0
- data/ext/asmjit/asmjit/src/asmjit/core/codewriter_p.h +179 -0
- data/ext/asmjit/asmjit/src/asmjit/core/compiler.cpp +582 -0
- data/ext/asmjit/asmjit/src/asmjit/core/compiler.h +737 -0
- data/ext/asmjit/asmjit/src/asmjit/core/compilerdefs.h +173 -0
- data/ext/asmjit/asmjit/src/asmjit/core/constpool.cpp +363 -0
- data/ext/asmjit/asmjit/src/asmjit/core/constpool.h +250 -0
- data/ext/asmjit/asmjit/src/asmjit/core/cpuinfo.cpp +1162 -0
- data/ext/asmjit/asmjit/src/asmjit/core/cpuinfo.h +813 -0
- data/ext/asmjit/asmjit/src/asmjit/core/emithelper.cpp +323 -0
- data/ext/asmjit/asmjit/src/asmjit/core/emithelper_p.h +58 -0
- data/ext/asmjit/asmjit/src/asmjit/core/emitter.cpp +333 -0
- data/ext/asmjit/asmjit/src/asmjit/core/emitter.h +741 -0
- data/ext/asmjit/asmjit/src/asmjit/core/emitterutils.cpp +129 -0
- data/ext/asmjit/asmjit/src/asmjit/core/emitterutils_p.h +89 -0
- data/ext/asmjit/asmjit/src/asmjit/core/environment.cpp +46 -0
- data/ext/asmjit/asmjit/src/asmjit/core/environment.h +508 -0
- data/ext/asmjit/asmjit/src/asmjit/core/errorhandler.cpp +14 -0
- data/ext/asmjit/asmjit/src/asmjit/core/errorhandler.h +228 -0
- data/ext/asmjit/asmjit/src/asmjit/core/formatter.cpp +584 -0
- data/ext/asmjit/asmjit/src/asmjit/core/formatter.h +247 -0
- data/ext/asmjit/asmjit/src/asmjit/core/formatter_p.h +34 -0
- data/ext/asmjit/asmjit/src/asmjit/core/func.cpp +286 -0
- data/ext/asmjit/asmjit/src/asmjit/core/func.h +1445 -0
- data/ext/asmjit/asmjit/src/asmjit/core/funcargscontext.cpp +293 -0
- data/ext/asmjit/asmjit/src/asmjit/core/funcargscontext_p.h +199 -0
- data/ext/asmjit/asmjit/src/asmjit/core/globals.cpp +133 -0
- data/ext/asmjit/asmjit/src/asmjit/core/globals.h +393 -0
- data/ext/asmjit/asmjit/src/asmjit/core/inst.cpp +113 -0
- data/ext/asmjit/asmjit/src/asmjit/core/inst.h +772 -0
- data/ext/asmjit/asmjit/src/asmjit/core/jitallocator.cpp +1242 -0
- data/ext/asmjit/asmjit/src/asmjit/core/jitallocator.h +261 -0
- data/ext/asmjit/asmjit/src/asmjit/core/jitruntime.cpp +80 -0
- data/ext/asmjit/asmjit/src/asmjit/core/jitruntime.h +89 -0
- data/ext/asmjit/asmjit/src/asmjit/core/logger.cpp +69 -0
- data/ext/asmjit/asmjit/src/asmjit/core/logger.h +198 -0
- data/ext/asmjit/asmjit/src/asmjit/core/misc_p.h +33 -0
- data/ext/asmjit/asmjit/src/asmjit/core/operand.cpp +132 -0
- data/ext/asmjit/asmjit/src/asmjit/core/operand.h +1611 -0
- data/ext/asmjit/asmjit/src/asmjit/core/osutils.cpp +84 -0
- data/ext/asmjit/asmjit/src/asmjit/core/osutils.h +61 -0
- data/ext/asmjit/asmjit/src/asmjit/core/osutils_p.h +68 -0
- data/ext/asmjit/asmjit/src/asmjit/core/raassignment_p.h +418 -0
- data/ext/asmjit/asmjit/src/asmjit/core/rabuilders_p.h +612 -0
- data/ext/asmjit/asmjit/src/asmjit/core/radefs_p.h +1204 -0
- data/ext/asmjit/asmjit/src/asmjit/core/ralocal.cpp +1166 -0
- data/ext/asmjit/asmjit/src/asmjit/core/ralocal_p.h +254 -0
- data/ext/asmjit/asmjit/src/asmjit/core/rapass.cpp +1969 -0
- data/ext/asmjit/asmjit/src/asmjit/core/rapass_p.h +1183 -0
- data/ext/asmjit/asmjit/src/asmjit/core/rastack.cpp +184 -0
- data/ext/asmjit/asmjit/src/asmjit/core/rastack_p.h +171 -0
- data/ext/asmjit/asmjit/src/asmjit/core/string.cpp +559 -0
- data/ext/asmjit/asmjit/src/asmjit/core/string.h +372 -0
- data/ext/asmjit/asmjit/src/asmjit/core/support.cpp +494 -0
- data/ext/asmjit/asmjit/src/asmjit/core/support.h +1773 -0
- data/ext/asmjit/asmjit/src/asmjit/core/target.cpp +14 -0
- data/ext/asmjit/asmjit/src/asmjit/core/target.h +53 -0
- data/ext/asmjit/asmjit/src/asmjit/core/type.cpp +74 -0
- data/ext/asmjit/asmjit/src/asmjit/core/type.h +419 -0
- data/ext/asmjit/asmjit/src/asmjit/core/virtmem.cpp +722 -0
- data/ext/asmjit/asmjit/src/asmjit/core/virtmem.h +242 -0
- data/ext/asmjit/asmjit/src/asmjit/core/zone.cpp +353 -0
- data/ext/asmjit/asmjit/src/asmjit/core/zone.h +615 -0
- data/ext/asmjit/asmjit/src/asmjit/core/zonehash.cpp +309 -0
- data/ext/asmjit/asmjit/src/asmjit/core/zonehash.h +186 -0
- data/ext/asmjit/asmjit/src/asmjit/core/zonelist.cpp +163 -0
- data/ext/asmjit/asmjit/src/asmjit/core/zonelist.h +209 -0
- data/ext/asmjit/asmjit/src/asmjit/core/zonestack.cpp +176 -0
- data/ext/asmjit/asmjit/src/asmjit/core/zonestack.h +239 -0
- data/ext/asmjit/asmjit/src/asmjit/core/zonestring.h +120 -0
- data/ext/asmjit/asmjit/src/asmjit/core/zonetree.cpp +99 -0
- data/ext/asmjit/asmjit/src/asmjit/core/zonetree.h +380 -0
- data/ext/asmjit/asmjit/src/asmjit/core/zonevector.cpp +356 -0
- data/ext/asmjit/asmjit/src/asmjit/core/zonevector.h +690 -0
- data/ext/asmjit/asmjit/src/asmjit/core.h +1861 -0
- data/ext/asmjit/asmjit/src/asmjit/x86/x86archtraits_p.h +148 -0
- data/ext/asmjit/asmjit/src/asmjit/x86/x86assembler.cpp +5110 -0
- data/ext/asmjit/asmjit/src/asmjit/x86/x86assembler.h +685 -0
- data/ext/asmjit/asmjit/src/asmjit/x86/x86builder.cpp +52 -0
- data/ext/asmjit/asmjit/src/asmjit/x86/x86builder.h +351 -0
- data/ext/asmjit/asmjit/src/asmjit/x86/x86compiler.cpp +61 -0
- data/ext/asmjit/asmjit/src/asmjit/x86/x86compiler.h +721 -0
- data/ext/asmjit/asmjit/src/asmjit/x86/x86emithelper.cpp +619 -0
- data/ext/asmjit/asmjit/src/asmjit/x86/x86emithelper_p.h +60 -0
- data/ext/asmjit/asmjit/src/asmjit/x86/x86emitter.h +4315 -0
- data/ext/asmjit/asmjit/src/asmjit/x86/x86formatter.cpp +944 -0
- data/ext/asmjit/asmjit/src/asmjit/x86/x86formatter_p.h +58 -0
- data/ext/asmjit/asmjit/src/asmjit/x86/x86func.cpp +503 -0
- data/ext/asmjit/asmjit/src/asmjit/x86/x86func_p.h +33 -0
- data/ext/asmjit/asmjit/src/asmjit/x86/x86globals.h +2169 -0
- data/ext/asmjit/asmjit/src/asmjit/x86/x86instapi.cpp +1732 -0
- data/ext/asmjit/asmjit/src/asmjit/x86/x86instapi_p.h +41 -0
- data/ext/asmjit/asmjit/src/asmjit/x86/x86instdb.cpp +4427 -0
- data/ext/asmjit/asmjit/src/asmjit/x86/x86instdb.h +563 -0
- data/ext/asmjit/asmjit/src/asmjit/x86/x86instdb_p.h +311 -0
- data/ext/asmjit/asmjit/src/asmjit/x86/x86opcode_p.h +436 -0
- data/ext/asmjit/asmjit/src/asmjit/x86/x86operand.cpp +231 -0
- data/ext/asmjit/asmjit/src/asmjit/x86/x86operand.h +1085 -0
- data/ext/asmjit/asmjit/src/asmjit/x86/x86rapass.cpp +1509 -0
- data/ext/asmjit/asmjit/src/asmjit/x86/x86rapass_p.h +94 -0
- data/ext/asmjit/asmjit/src/asmjit/x86.h +93 -0
- data/ext/asmjit/asmjit/src/asmjit.natvis +245 -0
- data/ext/asmjit/asmjit/test/asmjit_test_assembler.cpp +84 -0
- data/ext/asmjit/asmjit/test/asmjit_test_assembler.h +85 -0
- data/ext/asmjit/asmjit/test/asmjit_test_assembler_a64.cpp +4006 -0
- data/ext/asmjit/asmjit/test/asmjit_test_assembler_x64.cpp +17833 -0
- data/ext/asmjit/asmjit/test/asmjit_test_assembler_x86.cpp +8300 -0
- data/ext/asmjit/asmjit/test/asmjit_test_compiler.cpp +253 -0
- data/ext/asmjit/asmjit/test/asmjit_test_compiler.h +73 -0
- data/ext/asmjit/asmjit/test/asmjit_test_compiler_a64.cpp +690 -0
- data/ext/asmjit/asmjit/test/asmjit_test_compiler_x86.cpp +4317 -0
- data/ext/asmjit/asmjit/test/asmjit_test_emitters.cpp +197 -0
- data/ext/asmjit/asmjit/test/asmjit_test_instinfo.cpp +181 -0
- data/ext/asmjit/asmjit/test/asmjit_test_misc.h +257 -0
- data/ext/asmjit/asmjit/test/asmjit_test_perf.cpp +62 -0
- data/ext/asmjit/asmjit/test/asmjit_test_perf.h +61 -0
- data/ext/asmjit/asmjit/test/asmjit_test_perf_a64.cpp +699 -0
- data/ext/asmjit/asmjit/test/asmjit_test_perf_x86.cpp +5032 -0
- data/ext/asmjit/asmjit/test/asmjit_test_unit.cpp +172 -0
- data/ext/asmjit/asmjit/test/asmjit_test_x86_sections.cpp +172 -0
- data/ext/asmjit/asmjit/test/asmjitutils.h +38 -0
- data/ext/asmjit/asmjit/test/broken.cpp +312 -0
- data/ext/asmjit/asmjit/test/broken.h +148 -0
- data/ext/asmjit/asmjit/test/cmdline.h +61 -0
- data/ext/asmjit/asmjit/test/performancetimer.h +41 -0
- data/ext/asmjit/asmjit/tools/configure-makefiles.sh +13 -0
- data/ext/asmjit/asmjit/tools/configure-ninja.sh +13 -0
- data/ext/asmjit/asmjit/tools/configure-sanitizers.sh +13 -0
- data/ext/asmjit/asmjit/tools/configure-vs2019-x64.bat +2 -0
- data/ext/asmjit/asmjit/tools/configure-vs2019-x86.bat +2 -0
- data/ext/asmjit/asmjit/tools/configure-vs2022-x64.bat +2 -0
- data/ext/asmjit/asmjit/tools/configure-vs2022-x86.bat +2 -0
- data/ext/asmjit/asmjit/tools/configure-xcode.sh +8 -0
- data/ext/asmjit/asmjit/tools/enumgen.js +417 -0
- data/ext/asmjit/asmjit/tools/enumgen.sh +3 -0
- data/ext/asmjit/asmjit/tools/tablegen-arm.js +365 -0
- data/ext/asmjit/asmjit/tools/tablegen-arm.sh +3 -0
- data/ext/asmjit/asmjit/tools/tablegen-x86.js +2638 -0
- data/ext/asmjit/asmjit/tools/tablegen-x86.sh +3 -0
- data/ext/asmjit/asmjit/tools/tablegen.js +947 -0
- data/ext/asmjit/asmjit/tools/tablegen.sh +4 -0
- data/ext/asmjit/asmjit.cc +167 -30
- data/ext/asmjit/extconf.rb +9 -9
- data/lib/asmjit/version.rb +1 -1
- data/lib/asmjit.rb +14 -4
- metadata +198 -17
@@ -0,0 +1,250 @@
|
|
1
|
+
// This file is part of AsmJit project <https://asmjit.com>
|
2
|
+
//
|
3
|
+
// See asmjit.h or LICENSE.md for license and copyright information
|
4
|
+
// SPDX-License-Identifier: Zlib
|
5
|
+
|
6
|
+
#ifndef ASMJIT_CORE_CONSTPOOL_H_INCLUDED
|
7
|
+
#define ASMJIT_CORE_CONSTPOOL_H_INCLUDED
|
8
|
+
|
9
|
+
#include "../core/support.h"
|
10
|
+
#include "../core/zone.h"
|
11
|
+
#include "../core/zonetree.h"
|
12
|
+
|
13
|
+
ASMJIT_BEGIN_NAMESPACE
|
14
|
+
|
15
|
+
//! \addtogroup asmjit_utilities
|
16
|
+
//! \{
|
17
|
+
|
18
|
+
//! Constant pool scope.
|
19
|
+
enum class ConstPoolScope : uint32_t {
|
20
|
+
//! Local constant, always embedded right after the current function.
|
21
|
+
kLocal = 0,
|
22
|
+
//! Global constant, embedded at the end of the currently compiled code.
|
23
|
+
kGlobal = 1,
|
24
|
+
|
25
|
+
//! Maximum value of `ConstPoolScope`.
|
26
|
+
kMaxValue = kGlobal
|
27
|
+
};
|
28
|
+
|
29
|
+
//! Constant pool.
|
30
|
+
class ConstPool {
|
31
|
+
public:
|
32
|
+
ASMJIT_NONCOPYABLE(ConstPool)
|
33
|
+
|
34
|
+
//! \cond INTERNAL
|
35
|
+
|
36
|
+
//! Index of a given size in const-pool table.
|
37
|
+
enum Index : uint32_t {
|
38
|
+
kIndex1 = 0,
|
39
|
+
kIndex2 = 1,
|
40
|
+
kIndex4 = 2,
|
41
|
+
kIndex8 = 3,
|
42
|
+
kIndex16 = 4,
|
43
|
+
kIndex32 = 5,
|
44
|
+
kIndex64 = 6,
|
45
|
+
kIndexCount = 7
|
46
|
+
};
|
47
|
+
|
48
|
+
//! Zone-allocated const-pool gap created by two differently aligned constants.
|
49
|
+
struct Gap {
|
50
|
+
//! Pointer to the next gap
|
51
|
+
Gap* _next;
|
52
|
+
//! Offset of the gap.
|
53
|
+
size_t _offset;
|
54
|
+
//! Remaining bytes of the gap (basically a gap size).
|
55
|
+
size_t _size;
|
56
|
+
};
|
57
|
+
|
58
|
+
//! Zone-allocated const-pool node.
|
59
|
+
class Node : public ZoneTreeNodeT<Node> {
|
60
|
+
public:
|
61
|
+
ASMJIT_NONCOPYABLE(Node)
|
62
|
+
|
63
|
+
//! If this constant is shared with another.
|
64
|
+
uint32_t _shared : 1;
|
65
|
+
//! Data offset from the beginning of the pool.
|
66
|
+
uint32_t _offset;
|
67
|
+
|
68
|
+
inline Node(size_t offset, bool shared) noexcept
|
69
|
+
: ZoneTreeNodeT<Node>(),
|
70
|
+
_shared(shared),
|
71
|
+
_offset(uint32_t(offset)) {}
|
72
|
+
|
73
|
+
inline void* data() const noexcept {
|
74
|
+
return static_cast<void*>(const_cast<ConstPool::Node*>(this) + 1);
|
75
|
+
}
|
76
|
+
};
|
77
|
+
|
78
|
+
//! Data comparer used internally.
|
79
|
+
class Compare {
|
80
|
+
public:
|
81
|
+
size_t _dataSize;
|
82
|
+
|
83
|
+
inline Compare(size_t dataSize) noexcept
|
84
|
+
: _dataSize(dataSize) {}
|
85
|
+
|
86
|
+
inline int operator()(const Node& a, const Node& b) const noexcept {
|
87
|
+
return ::memcmp(a.data(), b.data(), _dataSize);
|
88
|
+
}
|
89
|
+
|
90
|
+
inline int operator()(const Node& a, const void* data) const noexcept {
|
91
|
+
return ::memcmp(a.data(), data, _dataSize);
|
92
|
+
}
|
93
|
+
};
|
94
|
+
|
95
|
+
//! Zone-allocated const-pool tree.
|
96
|
+
struct Tree {
|
97
|
+
//! RB tree.
|
98
|
+
ZoneTree<Node> _tree;
|
99
|
+
//! Size of the tree (number of nodes).
|
100
|
+
size_t _size;
|
101
|
+
//! Size of the data.
|
102
|
+
size_t _dataSize;
|
103
|
+
|
104
|
+
inline explicit Tree(size_t dataSize = 0) noexcept
|
105
|
+
: _tree(),
|
106
|
+
_size(0),
|
107
|
+
_dataSize(dataSize) {}
|
108
|
+
|
109
|
+
inline void reset() noexcept {
|
110
|
+
_tree.reset();
|
111
|
+
_size = 0;
|
112
|
+
}
|
113
|
+
|
114
|
+
inline bool empty() const noexcept { return _size == 0; }
|
115
|
+
inline size_t size() const noexcept { return _size; }
|
116
|
+
|
117
|
+
inline void setDataSize(size_t dataSize) noexcept {
|
118
|
+
ASMJIT_ASSERT(empty());
|
119
|
+
_dataSize = dataSize;
|
120
|
+
}
|
121
|
+
|
122
|
+
inline Node* get(const void* data) noexcept {
|
123
|
+
Compare cmp(_dataSize);
|
124
|
+
return _tree.get(data, cmp);
|
125
|
+
}
|
126
|
+
|
127
|
+
inline void insert(Node* node) noexcept {
|
128
|
+
Compare cmp(_dataSize);
|
129
|
+
_tree.insert(node, cmp);
|
130
|
+
_size++;
|
131
|
+
}
|
132
|
+
|
133
|
+
template<typename Visitor>
|
134
|
+
inline void forEach(Visitor& visitor) const noexcept {
|
135
|
+
Node* node = _tree.root();
|
136
|
+
if (!node) return;
|
137
|
+
|
138
|
+
Node* stack[Globals::kMaxTreeHeight];
|
139
|
+
size_t top = 0;
|
140
|
+
|
141
|
+
for (;;) {
|
142
|
+
Node* left = node->left();
|
143
|
+
if (left != nullptr) {
|
144
|
+
ASMJIT_ASSERT(top != Globals::kMaxTreeHeight);
|
145
|
+
stack[top++] = node;
|
146
|
+
|
147
|
+
node = left;
|
148
|
+
continue;
|
149
|
+
}
|
150
|
+
|
151
|
+
for (;;) {
|
152
|
+
visitor(node);
|
153
|
+
node = node->right();
|
154
|
+
|
155
|
+
if (node != nullptr)
|
156
|
+
break;
|
157
|
+
|
158
|
+
if (top == 0)
|
159
|
+
return;
|
160
|
+
|
161
|
+
node = stack[--top];
|
162
|
+
}
|
163
|
+
}
|
164
|
+
}
|
165
|
+
|
166
|
+
static inline Node* _newNode(Zone* zone, const void* data, size_t size, size_t offset, bool shared) noexcept {
|
167
|
+
Node* node = zone->allocT<Node>(sizeof(Node) + size);
|
168
|
+
if (ASMJIT_UNLIKELY(!node)) return nullptr;
|
169
|
+
|
170
|
+
node = new(node) Node(offset, shared);
|
171
|
+
memcpy(node->data(), data, size);
|
172
|
+
return node;
|
173
|
+
}
|
174
|
+
};
|
175
|
+
|
176
|
+
//! \endcond
|
177
|
+
|
178
|
+
//! \name Members
|
179
|
+
//! \{
|
180
|
+
|
181
|
+
//! Zone allocator.
|
182
|
+
Zone* _zone;
|
183
|
+
//! Tree per size.
|
184
|
+
Tree _tree[kIndexCount];
|
185
|
+
//! Gaps per size.
|
186
|
+
Gap* _gaps[kIndexCount];
|
187
|
+
//! Gaps pool
|
188
|
+
Gap* _gapPool;
|
189
|
+
|
190
|
+
//! Size of the pool (in bytes).
|
191
|
+
size_t _size;
|
192
|
+
//! Required pool alignment.
|
193
|
+
size_t _alignment;
|
194
|
+
//! Minimum item size in the pool.
|
195
|
+
size_t _minItemSize;
|
196
|
+
|
197
|
+
//! \}
|
198
|
+
|
199
|
+
//! \name Construction & Destruction
|
200
|
+
//! \{
|
201
|
+
|
202
|
+
ASMJIT_API ConstPool(Zone* zone) noexcept;
|
203
|
+
ASMJIT_API ~ConstPool() noexcept;
|
204
|
+
|
205
|
+
ASMJIT_API void reset(Zone* zone) noexcept;
|
206
|
+
|
207
|
+
//! \}
|
208
|
+
|
209
|
+
//! \name Accessors
|
210
|
+
//! \{
|
211
|
+
|
212
|
+
//! Tests whether the constant-pool is empty.
|
213
|
+
inline bool empty() const noexcept { return _size == 0; }
|
214
|
+
//! Returns the size of the constant-pool in bytes.
|
215
|
+
inline size_t size() const noexcept { return _size; }
|
216
|
+
//! Returns minimum alignment.
|
217
|
+
inline size_t alignment() const noexcept { return _alignment; }
|
218
|
+
//! Returns the minimum size of all items added to the constant pool.
|
219
|
+
inline size_t minItemSize() const noexcept { return _minItemSize; }
|
220
|
+
|
221
|
+
//! \}
|
222
|
+
|
223
|
+
//! \name Utilities
|
224
|
+
//! \{
|
225
|
+
|
226
|
+
//! Adds a constant to the constant pool.
|
227
|
+
//!
|
228
|
+
//! The constant must have known size, which is 1, 2, 4, 8, 16 or 32 bytes. The constant is added to the pool only
|
229
|
+
//! if it doesn't not exist, otherwise cached value is returned.
|
230
|
+
//!
|
231
|
+
//! AsmJit is able to subdivide added constants, so for example if you add 8-byte constant 0x1122334455667788 it
|
232
|
+
//! will create the following slots:
|
233
|
+
//!
|
234
|
+
//! 8-byte: 0x1122334455667788
|
235
|
+
//! 4-byte: 0x11223344, 0x55667788
|
236
|
+
//!
|
237
|
+
//! The reason is that when combining MMX/SSE/AVX code some patterns are used frequently. However, AsmJit is not
|
238
|
+
//! able to reallocate a constant that has been already added. For example if you try to add 4-byte constant and
|
239
|
+
//! then 8-byte constant having the same 4-byte pattern as the previous one, two independent slots will be used.
|
240
|
+
ASMJIT_API Error add(const void* data, size_t size, size_t& dstOffset) noexcept;
|
241
|
+
|
242
|
+
//! Fills the destination with the content of this constant pool.
|
243
|
+
ASMJIT_API void fill(void* dst) const noexcept;
|
244
|
+
};
|
245
|
+
|
246
|
+
//! \}
|
247
|
+
|
248
|
+
ASMJIT_END_NAMESPACE
|
249
|
+
|
250
|
+
#endif // ASMJIT_CORE_CONSTPOOL_H_INCLUDED
|