debase-ruby_core_source 0.10.12 → 0.10.13

Sign up to get free protection for your applications and to get access to all the features.
Files changed (116) hide show
  1. checksums.yaml +4 -4
  2. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/addr2line.h +20 -0
  3. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/builtin.h +83 -0
  4. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/ccan/build_assert/build_assert.h +40 -0
  5. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/ccan/check_type/check_type.h +63 -0
  6. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/ccan/container_of/container_of.h +142 -0
  7. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/ccan/list/list.h +788 -0
  8. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/ccan/str/str.h +16 -0
  9. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/constant.h +55 -0
  10. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/darray.h +198 -0
  11. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/debug_counter.h +467 -0
  12. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/dln.h +31 -0
  13. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/encindex.h +70 -0
  14. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/eval_intern.h +304 -0
  15. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/gc.h +142 -0
  16. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/hrtime.h +168 -0
  17. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/id.h +293 -0
  18. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/id_table.h +36 -0
  19. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/insns.inc +247 -0
  20. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/insns_info.inc +8978 -0
  21. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/internal/array.h +113 -0
  22. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/internal/bignum.h +246 -0
  23. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/internal/bits.h +565 -0
  24. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/internal/class.h +188 -0
  25. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/internal/compar.h +49 -0
  26. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/internal/compile.h +35 -0
  27. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/internal/compilers.h +107 -0
  28. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/internal/complex.h +29 -0
  29. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/internal/cont.h +24 -0
  30. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/internal/dir.h +16 -0
  31. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/internal/enc.h +19 -0
  32. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/internal/encoding.h +30 -0
  33. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/internal/enum.h +18 -0
  34. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/internal/enumerator.h +21 -0
  35. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/internal/error.h +191 -0
  36. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/internal/eval.h +32 -0
  37. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/internal/file.h +38 -0
  38. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/internal/fixnum.h +184 -0
  39. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/internal/gc.h +175 -0
  40. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/internal/hash.h +243 -0
  41. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/internal/imemo.h +243 -0
  42. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/internal/inits.h +50 -0
  43. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/internal/io.h +38 -0
  44. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/internal/load.h +18 -0
  45. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/internal/loadpath.h +16 -0
  46. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/internal/math.h +23 -0
  47. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/internal/missing.h +18 -0
  48. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/internal/numeric.h +271 -0
  49. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/internal/object.h +83 -0
  50. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/internal/parse.h +23 -0
  51. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/internal/proc.h +32 -0
  52. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/internal/process.h +137 -0
  53. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/internal/random.h +16 -0
  54. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/internal/range.h +40 -0
  55. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/internal/rational.h +72 -0
  56. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/internal/re.h +30 -0
  57. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/internal/sanitizers.h +190 -0
  58. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/internal/serial.h +23 -0
  59. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/internal/signal.h +21 -0
  60. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/internal/static_assert.h +16 -0
  61. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/internal/string.h +141 -0
  62. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/internal/struct.h +153 -0
  63. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/internal/symbol.h +40 -0
  64. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/internal/thread.h +53 -0
  65. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/internal/time.h +34 -0
  66. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/internal/transcode.h +20 -0
  67. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/internal/util.h +27 -0
  68. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/internal/variable.h +83 -0
  69. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/internal/vm.h +132 -0
  70. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/internal/warnings.h +16 -0
  71. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/internal.h +109 -0
  72. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/iseq.h +320 -0
  73. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/known_errors.inc +791 -0
  74. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/method.h +245 -0
  75. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/mjit.h +231 -0
  76. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/mjit_compile.inc +8265 -0
  77. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/node.h +499 -0
  78. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/node_name.inc +210 -0
  79. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/opt_sc.inc +107 -0
  80. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/optinsn.inc +128 -0
  81. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/optunifs.inc +43 -0
  82. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/parse.h +214 -0
  83. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/probes_helper.h +44 -0
  84. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/ractor_core.h +346 -0
  85. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/regenc.h +254 -0
  86. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/regint.h +942 -0
  87. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/regparse.h +370 -0
  88. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/revision.h +2 -0
  89. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/ruby_assert.h +14 -0
  90. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/ruby_atomic.h +23 -0
  91. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/siphash.h +48 -0
  92. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/symbol.h +119 -0
  93. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/thread_pthread.h +115 -0
  94. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/thread_win32.h +61 -0
  95. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/timev.h +57 -0
  96. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/transcode_data.h +138 -0
  97. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/transient_heap.h +65 -0
  98. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/variable.h +21 -0
  99. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/version.h +88 -0
  100. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/vm.inc +5415 -0
  101. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/vm_call_iseq_optimized.inc +244 -0
  102. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/vm_callinfo.h +454 -0
  103. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/vm_core.h +2103 -0
  104. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/vm_debug.h +119 -0
  105. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/vm_exec.h +197 -0
  106. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/vm_insnhelper.h +265 -0
  107. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/vm_opts.h +73 -0
  108. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/vm_sync.h +137 -0
  109. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/vmtc.inc +241 -0
  110. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/yjit.h +63 -0
  111. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/yjit_asm.h +392 -0
  112. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/yjit_codegen.h +19 -0
  113. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/yjit_core.h +302 -0
  114. data/lib/debase/ruby_core_source/ruby-3.1.0-preview1/yjit_iface.h +38 -0
  115. data/lib/debase/ruby_core_source/version.rb +1 -1
  116. metadata +116 -3
@@ -0,0 +1,392 @@
1
+ #ifndef YJIT_ASM_H
2
+ #define YJIT_ASM_H 1
3
+
4
+ #include <stdint.h>
5
+ #include <stddef.h>
6
+ #include <stdbool.h>
7
+
8
+ // Maximum number of labels to link
9
+ #define MAX_LABELS 32
10
+
11
+ // Maximum number of label references
12
+ #define MAX_LABEL_REFS 32
13
+
14
+ // Reference to an ASM label
15
+ typedef struct LabelRef
16
+ {
17
+ // Position in the code block where the label reference exists
18
+ uint32_t pos;
19
+
20
+ // Label which this refers to
21
+ uint32_t label_idx;
22
+
23
+ } labelref_t;
24
+
25
+ // Block of executable memory into which instructions can be written
26
+ typedef struct CodeBlock
27
+ {
28
+ // Memory block
29
+ uint8_t *mem_block;
30
+
31
+ // Memory block size
32
+ uint32_t mem_size;
33
+
34
+ /// Current writing position
35
+ uint32_t write_pos;
36
+
37
+ // Table of registered label addresses
38
+ uint32_t label_addrs[MAX_LABELS];
39
+
40
+ // Table of registered label names
41
+ // Note that these should be constant strings only
42
+ const char *label_names[MAX_LABELS];
43
+
44
+ // References to labels
45
+ labelref_t label_refs[MAX_LABEL_REFS];
46
+
47
+ // Number of labels registeered
48
+ uint32_t num_labels;
49
+
50
+ // Number of references to labels
51
+ uint32_t num_refs;
52
+
53
+ // TODO: system for disassembly/comment strings, indexed by position
54
+
55
+ // Flag to enable or disable comments
56
+ bool has_asm;
57
+
58
+ } codeblock_t;
59
+
60
+ enum OpndType
61
+ {
62
+ OPND_NONE,
63
+ OPND_REG,
64
+ OPND_IMM,
65
+ OPND_MEM
66
+ };
67
+
68
+ enum RegType
69
+ {
70
+ REG_GP,
71
+ REG_FP,
72
+ REG_XMM,
73
+ REG_IP
74
+ };
75
+
76
+ typedef struct X86Reg
77
+ {
78
+ // Register type
79
+ uint8_t reg_type;
80
+
81
+ // Register index number
82
+ uint8_t reg_no;
83
+
84
+ } x86reg_t;
85
+
86
+ typedef struct X86Mem
87
+ {
88
+ /// Base register number
89
+ uint8_t base_reg_no;
90
+
91
+ /// Index register number
92
+ uint8_t idx_reg_no;
93
+
94
+ /// SIB scale exponent value (power of two, two bits)
95
+ uint8_t scale_exp;
96
+
97
+ /// Has index register flag
98
+ bool has_idx;
99
+
100
+ // TODO: should this be here, or should we have an extra operand type?
101
+ /// IP-relative addressing flag
102
+ bool is_iprel;
103
+
104
+ /// Constant displacement from the base, not scaled
105
+ int32_t disp;
106
+
107
+ } x86mem_t;
108
+
109
+ typedef struct X86Opnd
110
+ {
111
+ // Operand type
112
+ uint8_t type;
113
+
114
+ // Size in bits
115
+ uint16_t num_bits;
116
+
117
+ union
118
+ {
119
+ // Register operand
120
+ x86reg_t reg;
121
+
122
+ // Memory operand
123
+ x86mem_t mem;
124
+
125
+ // Signed immediate value
126
+ int64_t imm;
127
+
128
+ // Unsigned immediate value
129
+ uint64_t unsig_imm;
130
+ } as;
131
+
132
+ } x86opnd_t;
133
+
134
+ // Dummy none/null operand
135
+ static const x86opnd_t NO_OPND = { OPND_NONE, 0, .as.imm = 0 };
136
+
137
+ // Instruction pointer
138
+ static const x86opnd_t RIP = { OPND_REG, 64, .as.reg = { REG_IP, 5 }};
139
+
140
+ // 64-bit GP registers
141
+ static const x86opnd_t RAX = { OPND_REG, 64, .as.reg = { REG_GP, 0 }};
142
+ static const x86opnd_t RCX = { OPND_REG, 64, .as.reg = { REG_GP, 1 }};
143
+ static const x86opnd_t RDX = { OPND_REG, 64, .as.reg = { REG_GP, 2 }};
144
+ static const x86opnd_t RBX = { OPND_REG, 64, .as.reg = { REG_GP, 3 }};
145
+ static const x86opnd_t RSP = { OPND_REG, 64, .as.reg = { REG_GP, 4 }};
146
+ static const x86opnd_t RBP = { OPND_REG, 64, .as.reg = { REG_GP, 5 }};
147
+ static const x86opnd_t RSI = { OPND_REG, 64, .as.reg = { REG_GP, 6 }};
148
+ static const x86opnd_t RDI = { OPND_REG, 64, .as.reg = { REG_GP, 7 }};
149
+ static const x86opnd_t R8 = { OPND_REG, 64, .as.reg = { REG_GP, 8 }};
150
+ static const x86opnd_t R9 = { OPND_REG, 64, .as.reg = { REG_GP, 9 }};
151
+ static const x86opnd_t R10 = { OPND_REG, 64, .as.reg = { REG_GP, 10 }};
152
+ static const x86opnd_t R11 = { OPND_REG, 64, .as.reg = { REG_GP, 11 }};
153
+ static const x86opnd_t R12 = { OPND_REG, 64, .as.reg = { REG_GP, 12 }};
154
+ static const x86opnd_t R13 = { OPND_REG, 64, .as.reg = { REG_GP, 13 }};
155
+ static const x86opnd_t R14 = { OPND_REG, 64, .as.reg = { REG_GP, 14 }};
156
+ static const x86opnd_t R15 = { OPND_REG, 64, .as.reg = { REG_GP, 15 }};
157
+
158
+ // 32-bit GP registers
159
+ static const x86opnd_t EAX = { OPND_REG, 32, .as.reg = { REG_GP, 0 }};
160
+ static const x86opnd_t ECX = { OPND_REG, 32, .as.reg = { REG_GP, 1 }};
161
+ static const x86opnd_t EDX = { OPND_REG, 32, .as.reg = { REG_GP, 2 }};
162
+ static const x86opnd_t EBX = { OPND_REG, 32, .as.reg = { REG_GP, 3 }};
163
+ static const x86opnd_t ESP = { OPND_REG, 32, .as.reg = { REG_GP, 4 }};
164
+ static const x86opnd_t EBP = { OPND_REG, 32, .as.reg = { REG_GP, 5 }};
165
+ static const x86opnd_t ESI = { OPND_REG, 32, .as.reg = { REG_GP, 6 }};
166
+ static const x86opnd_t EDI = { OPND_REG, 32, .as.reg = { REG_GP, 7 }};
167
+ static const x86opnd_t R8D = { OPND_REG, 32, .as.reg = { REG_GP, 8 }};
168
+ static const x86opnd_t R9D = { OPND_REG, 32, .as.reg = { REG_GP, 9 }};
169
+ static const x86opnd_t R10D = { OPND_REG, 32, .as.reg = { REG_GP, 10 }};
170
+ static const x86opnd_t R11D = { OPND_REG, 32, .as.reg = { REG_GP, 11 }};
171
+ static const x86opnd_t R12D = { OPND_REG, 32, .as.reg = { REG_GP, 12 }};
172
+ static const x86opnd_t R13D = { OPND_REG, 32, .as.reg = { REG_GP, 13 }};
173
+ static const x86opnd_t R14D = { OPND_REG, 32, .as.reg = { REG_GP, 14 }};
174
+ static const x86opnd_t R15D = { OPND_REG, 32, .as.reg = { REG_GP, 15 }};
175
+
176
+ // 16-bit GP registers
177
+ static const x86opnd_t AX = { OPND_REG, 16, .as.reg = { REG_GP, 0 }};
178
+ static const x86opnd_t CX = { OPND_REG, 16, .as.reg = { REG_GP, 1 }};
179
+ static const x86opnd_t DX = { OPND_REG, 16, .as.reg = { REG_GP, 2 }};
180
+ static const x86opnd_t BX = { OPND_REG, 16, .as.reg = { REG_GP, 3 }};
181
+ static const x86opnd_t SP = { OPND_REG, 16, .as.reg = { REG_GP, 4 }};
182
+ static const x86opnd_t BP = { OPND_REG, 16, .as.reg = { REG_GP, 5 }};
183
+ static const x86opnd_t SI = { OPND_REG, 16, .as.reg = { REG_GP, 6 }};
184
+ static const x86opnd_t DI = { OPND_REG, 16, .as.reg = { REG_GP, 7 }};
185
+ static const x86opnd_t R8W = { OPND_REG, 16, .as.reg = { REG_GP, 8 }};
186
+ static const x86opnd_t R9W = { OPND_REG, 16, .as.reg = { REG_GP, 9 }};
187
+ static const x86opnd_t R10W = { OPND_REG, 16, .as.reg = { REG_GP, 10 }};
188
+ static const x86opnd_t R11W = { OPND_REG, 16, .as.reg = { REG_GP, 11 }};
189
+ static const x86opnd_t R12W = { OPND_REG, 16, .as.reg = { REG_GP, 12 }};
190
+ static const x86opnd_t R13W = { OPND_REG, 16, .as.reg = { REG_GP, 13 }};
191
+ static const x86opnd_t R14W = { OPND_REG, 16, .as.reg = { REG_GP, 14 }};
192
+ static const x86opnd_t R15W = { OPND_REG, 16, .as.reg = { REG_GP, 15 }};
193
+
194
+ // 8-bit GP registers
195
+ static const x86opnd_t AL = { OPND_REG, 8, .as.reg = { REG_GP, 0 }};
196
+ static const x86opnd_t CL = { OPND_REG, 8, .as.reg = { REG_GP, 1 }};
197
+ static const x86opnd_t DL = { OPND_REG, 8, .as.reg = { REG_GP, 2 }};
198
+ static const x86opnd_t BL = { OPND_REG, 8, .as.reg = { REG_GP, 3 }};
199
+ static const x86opnd_t SPL = { OPND_REG, 8, .as.reg = { REG_GP, 4 }};
200
+ static const x86opnd_t BPL = { OPND_REG, 8, .as.reg = { REG_GP, 5 }};
201
+ static const x86opnd_t SIL = { OPND_REG, 8, .as.reg = { REG_GP, 6 }};
202
+ static const x86opnd_t DIL = { OPND_REG, 8, .as.reg = { REG_GP, 7 }};
203
+ static const x86opnd_t R8B = { OPND_REG, 8, .as.reg = { REG_GP, 8 }};
204
+ static const x86opnd_t R9B = { OPND_REG, 8, .as.reg = { REG_GP, 9 }};
205
+ static const x86opnd_t R10B = { OPND_REG, 8, .as.reg = { REG_GP, 10 }};
206
+ static const x86opnd_t R11B = { OPND_REG, 8, .as.reg = { REG_GP, 11 }};
207
+ static const x86opnd_t R12B = { OPND_REG, 8, .as.reg = { REG_GP, 12 }};
208
+ static const x86opnd_t R13B = { OPND_REG, 8, .as.reg = { REG_GP, 13 }};
209
+ static const x86opnd_t R14B = { OPND_REG, 8, .as.reg = { REG_GP, 14 }};
210
+ static const x86opnd_t R15B = { OPND_REG, 8, .as.reg = { REG_GP, 15 }};
211
+
212
+ // C argument registers
213
+ #define NUM_C_ARG_REGS 6
214
+ #define C_ARG_REGS ( (x86opnd_t[]){ RDI, RSI, RDX, RCX, R8, R9 } )
215
+
216
+ // Compute the number of bits needed to store a signed or unsigned value
217
+ static inline uint32_t sig_imm_size(int64_t imm);
218
+ static inline uint32_t unsig_imm_size(uint64_t imm);
219
+
220
+ // Memory operand with base register and displacement/offset
221
+ static inline x86opnd_t mem_opnd(uint32_t num_bits, x86opnd_t base_reg, int32_t disp);
222
+
223
+ // Scale-index-base memory operand
224
+ static inline x86opnd_t mem_opnd_sib(uint32_t num_bits, x86opnd_t base_reg, x86opnd_t index_reg, int32_t scale, int32_t disp);
225
+
226
+ // Immediate number operand
227
+ static inline x86opnd_t imm_opnd(int64_t val);
228
+
229
+ // Constant pointer operand
230
+ static inline x86opnd_t const_ptr_opnd(const void *ptr);
231
+
232
+ // Struct member operand
233
+ #define member_opnd(base_reg, struct_type, member_name) mem_opnd( \
234
+ 8 * sizeof(((struct_type*)0)->member_name), \
235
+ base_reg, \
236
+ offsetof(struct_type, member_name) \
237
+ )
238
+
239
+ // Struct member operand with an array index
240
+ #define member_opnd_idx(base_reg, struct_type, member_name, idx) mem_opnd( \
241
+ 8 * sizeof(((struct_type*)0)->member_name[0]), \
242
+ base_reg, \
243
+ (offsetof(struct_type, member_name) + \
244
+ sizeof(((struct_type*)0)->member_name[0]) * idx) \
245
+ )
246
+
247
+ // Allocate executable memory
248
+ static uint8_t *alloc_exec_mem(uint32_t mem_size);
249
+
250
+ // Code block functions
251
+ static inline void cb_init(codeblock_t *cb, uint8_t *mem_block, uint32_t mem_size);
252
+ static inline void cb_align_pos(codeblock_t *cb, uint32_t multiple);
253
+ static inline void cb_set_pos(codeblock_t *cb, uint32_t pos);
254
+ static inline void cb_set_write_ptr(codeblock_t *cb, uint8_t *code_ptr);
255
+ static inline uint8_t *cb_get_ptr(codeblock_t *cb, uint32_t index);
256
+ static inline uint8_t *cb_get_write_ptr(codeblock_t *cb);
257
+ static inline void cb_write_byte(codeblock_t *cb, uint8_t byte);
258
+ static inline void cb_write_bytes(codeblock_t *cb, uint32_t num_bytes, ...);
259
+ static inline void cb_write_int(codeblock_t *cb, uint64_t val, uint32_t num_bits);
260
+ static inline uint32_t cb_new_label(codeblock_t *cb, const char *name);
261
+ static inline void cb_write_label(codeblock_t *cb, uint32_t label_idx);
262
+ static inline void cb_label_ref(codeblock_t *cb, uint32_t label_idx);
263
+ static inline void cb_link_labels(codeblock_t *cb);
264
+
265
+ // Encode individual instructions into a code block
266
+ static inline void add(codeblock_t *cb, x86opnd_t opnd0, x86opnd_t opnd1);
267
+ static inline void and(codeblock_t *cb, x86opnd_t opnd0, x86opnd_t opnd1);
268
+ static inline void call_ptr(codeblock_t *cb, x86opnd_t scratch_reg, uint8_t *dst_ptr);
269
+ static inline void call_label(codeblock_t *cb, uint32_t label_idx);
270
+ static inline void call(codeblock_t *cb, x86opnd_t opnd);
271
+ static inline void cmova(codeblock_t *cb, x86opnd_t dst, x86opnd_t src);
272
+ static inline void cmovae(codeblock_t *cb, x86opnd_t dst, x86opnd_t src);
273
+ static inline void cmovb(codeblock_t *cb, x86opnd_t dst, x86opnd_t src);
274
+ static inline void cmovbe(codeblock_t *cb, x86opnd_t dst, x86opnd_t src);
275
+ static inline void cmovc(codeblock_t *cb, x86opnd_t dst, x86opnd_t src);
276
+ static inline void cmove(codeblock_t *cb, x86opnd_t dst, x86opnd_t src);
277
+ static inline void cmovg(codeblock_t *cb, x86opnd_t dst, x86opnd_t src);
278
+ static inline void cmovge(codeblock_t *cb, x86opnd_t dst, x86opnd_t src);
279
+ static inline void cmovl(codeblock_t *cb, x86opnd_t dst, x86opnd_t src);
280
+ static inline void cmovle(codeblock_t *cb, x86opnd_t dst, x86opnd_t src);
281
+ static inline void cmovna(codeblock_t *cb, x86opnd_t dst, x86opnd_t src);
282
+ static inline void cmovnae(codeblock_t *cb, x86opnd_t dst, x86opnd_t src);
283
+ static inline void cmovnb(codeblock_t *cb, x86opnd_t dst, x86opnd_t src);
284
+ static inline void cmovnbe(codeblock_t *cb, x86opnd_t dst, x86opnd_t src);
285
+ static inline void cmovnc(codeblock_t *cb, x86opnd_t dst, x86opnd_t src);
286
+ static inline void cmovne(codeblock_t *cb, x86opnd_t dst, x86opnd_t src);
287
+ static inline void cmovng(codeblock_t *cb, x86opnd_t dst, x86opnd_t src);
288
+ static inline void cmovnge(codeblock_t *cb, x86opnd_t dst, x86opnd_t src);
289
+ static inline void cmovnl(codeblock_t *cb, x86opnd_t dst, x86opnd_t src);
290
+ static inline void cmovnle(codeblock_t *cb, x86opnd_t dst, x86opnd_t src);
291
+ static inline void cmovno(codeblock_t *cb, x86opnd_t dst, x86opnd_t src);
292
+ static inline void cmovnp(codeblock_t *cb, x86opnd_t dst, x86opnd_t src);
293
+ static inline void cmovns(codeblock_t *cb, x86opnd_t dst, x86opnd_t src);
294
+ static inline void cmovnz(codeblock_t *cb, x86opnd_t dst, x86opnd_t src);
295
+ static inline void cmovo(codeblock_t *cb, x86opnd_t dst, x86opnd_t src);
296
+ static inline void cmovp(codeblock_t *cb, x86opnd_t dst, x86opnd_t src);
297
+ static inline void cmovpe(codeblock_t *cb, x86opnd_t dst, x86opnd_t src);
298
+ static inline void cmovpo(codeblock_t *cb, x86opnd_t dst, x86opnd_t src);
299
+ static inline void cmovs(codeblock_t *cb, x86opnd_t dst, x86opnd_t src);
300
+ static inline void cmovz(codeblock_t *cb, x86opnd_t dst, x86opnd_t src);
301
+ static inline void cmp(codeblock_t *cb, x86opnd_t opnd0, x86opnd_t opnd1);
302
+ static inline void cdq(codeblock_t *cb);
303
+ static inline void cqo(codeblock_t *cb);
304
+ static inline void int3(codeblock_t *cb);
305
+ static inline void ja_label(codeblock_t *cb, uint32_t label_idx);
306
+ static inline void jae_label(codeblock_t *cb, uint32_t label_idx);
307
+ static inline void jb_label(codeblock_t *cb, uint32_t label_idx);
308
+ static inline void jbe_label(codeblock_t *cb, uint32_t label_idx);
309
+ static inline void jc_label(codeblock_t *cb, uint32_t label_idx);
310
+ static inline void je_label(codeblock_t *cb, uint32_t label_idx);
311
+ static inline void jg_label(codeblock_t *cb, uint32_t label_idx);
312
+ static inline void jge_label(codeblock_t *cb, uint32_t label_idx);
313
+ static inline void jl_label(codeblock_t *cb, uint32_t label_idx);
314
+ static inline void jle_label(codeblock_t *cb, uint32_t label_idx);
315
+ static inline void jna_label(codeblock_t *cb, uint32_t label_idx);
316
+ static inline void jnae_label(codeblock_t *cb, uint32_t label_idx);
317
+ static inline void jnb_label(codeblock_t *cb, uint32_t label_idx);
318
+ static inline void jnbe_label(codeblock_t *cb, uint32_t label_idx);
319
+ static inline void jnc_label(codeblock_t *cb, uint32_t label_idx);
320
+ static inline void jne_label(codeblock_t *cb, uint32_t label_idx);
321
+ static inline void jng_label(codeblock_t *cb, uint32_t label_idx);
322
+ static inline void jnge_label(codeblock_t *cb, uint32_t label_idx);
323
+ static inline void jnl_label(codeblock_t *cb, uint32_t label_idx);
324
+ static inline void jnle_label(codeblock_t *cb, uint32_t label_idx);
325
+ static inline void jno_label(codeblock_t *cb, uint32_t label_idx);
326
+ static inline void jnp_label(codeblock_t *cb, uint32_t label_idx);
327
+ static inline void jns_label(codeblock_t *cb, uint32_t label_idx);
328
+ static inline void jnz_label(codeblock_t *cb, uint32_t label_idx);
329
+ static inline void jo_label(codeblock_t *cb, uint32_t label_idx);
330
+ static inline void jp_label(codeblock_t *cb, uint32_t label_idx);
331
+ static inline void jpe_label(codeblock_t *cb, uint32_t label_idx);
332
+ static inline void jpo_label(codeblock_t *cb, uint32_t label_idx);
333
+ static inline void js_label(codeblock_t *cb, uint32_t label_idx);
334
+ static inline void jz_label(codeblock_t *cb, uint32_t label_idx);
335
+ static inline void ja_ptr(codeblock_t *cb, uint8_t *ptr);
336
+ static inline void jae_ptr(codeblock_t *cb, uint8_t *ptr);
337
+ static inline void jb_ptr(codeblock_t *cb, uint8_t *ptr);
338
+ static inline void jbe_ptr(codeblock_t *cb, uint8_t *ptr);
339
+ static inline void jc_ptr(codeblock_t *cb, uint8_t *ptr);
340
+ static inline void je_ptr(codeblock_t *cb, uint8_t *ptr);
341
+ static inline void jg_ptr(codeblock_t *cb, uint8_t *ptr);
342
+ static inline void jge_ptr(codeblock_t *cb, uint8_t *ptr);
343
+ static inline void jl_ptr(codeblock_t *cb, uint8_t *ptr);
344
+ static inline void jle_ptr(codeblock_t *cb, uint8_t *ptr);
345
+ static inline void jna_ptr(codeblock_t *cb, uint8_t *ptr);
346
+ static inline void jnae_ptr(codeblock_t *cb, uint8_t *ptr);
347
+ static inline void jnb_ptr(codeblock_t *cb, uint8_t *ptr);
348
+ static inline void jnbe_ptr(codeblock_t *cb, uint8_t *ptr);
349
+ static inline void jnc_ptr(codeblock_t *cb, uint8_t *ptr);
350
+ static inline void jne_ptr(codeblock_t *cb, uint8_t *ptr);
351
+ static inline void jng_ptr(codeblock_t *cb, uint8_t *ptr);
352
+ static inline void jnge_ptr(codeblock_t *cb, uint8_t *ptr);
353
+ static inline void jnl_ptr(codeblock_t *cb, uint8_t *ptr);
354
+ static inline void jnle_ptr(codeblock_t *cb, uint8_t *ptr);
355
+ static inline void jno_ptr(codeblock_t *cb, uint8_t *ptr);
356
+ static inline void jnp_ptr(codeblock_t *cb, uint8_t *ptr);
357
+ static inline void jns_ptr(codeblock_t *cb, uint8_t *ptr);
358
+ static inline void jnz_ptr(codeblock_t *cb, uint8_t *ptr);
359
+ static inline void jo_ptr(codeblock_t *cb, uint8_t *ptr);
360
+ static inline void jp_ptr(codeblock_t *cb, uint8_t *ptr);
361
+ static inline void jpe_ptr(codeblock_t *cb, uint8_t *ptr);
362
+ static inline void jpo_ptr(codeblock_t *cb, uint8_t *ptr);
363
+ static inline void js_ptr(codeblock_t *cb, uint8_t *ptr);
364
+ static inline void jz_ptr(codeblock_t *cb, uint8_t *ptr);
365
+ static inline void jmp_label(codeblock_t *cb, uint32_t label_idx);
366
+ static inline void jmp_ptr(codeblock_t *cb, uint8_t *ptr);
367
+ static inline void jmp_rm(codeblock_t *cb, x86opnd_t opnd);
368
+ static inline void jmp32(codeblock_t *cb, int32_t offset);
369
+ static inline void lea(codeblock_t *cb, x86opnd_t dst, x86opnd_t src);
370
+ static inline void mov(codeblock_t *cb, x86opnd_t dst, x86opnd_t src);
371
+ static inline void movsx(codeblock_t *cb, x86opnd_t dst, x86opnd_t src);
372
+ static inline void neg(codeblock_t *cb, x86opnd_t opnd);
373
+ static inline void nop(codeblock_t *cb, uint32_t length);
374
+ static inline void not(codeblock_t *cb, x86opnd_t opnd);
375
+ static inline void or(codeblock_t *cb, x86opnd_t opnd0, x86opnd_t opnd1);
376
+ static inline void pop(codeblock_t *cb, x86opnd_t reg);
377
+ static inline void popfq(codeblock_t *cb);
378
+ static inline void push(codeblock_t *cb, x86opnd_t opnd);
379
+ static inline void pushfq(codeblock_t *cb);
380
+ static inline void ret(codeblock_t *cb);
381
+ static inline void sal(codeblock_t *cb, x86opnd_t opnd0, x86opnd_t opnd1);
382
+ static inline void sar(codeblock_t *cb, x86opnd_t opnd0, x86opnd_t opnd1);
383
+ static inline void shl(codeblock_t *cb, x86opnd_t opnd0, x86opnd_t opnd1);
384
+ static inline void shr(codeblock_t *cb, x86opnd_t opnd0, x86opnd_t opnd1);
385
+ static inline void sub(codeblock_t *cb, x86opnd_t opnd0, x86opnd_t opnd1);
386
+ static inline void test(codeblock_t *cb, x86opnd_t rm_opnd, x86opnd_t test_opnd);
387
+ static inline void ud2(codeblock_t *cb);
388
+ static inline void xchg(codeblock_t *cb, x86opnd_t rm_opnd, x86opnd_t r_opnd);
389
+ static inline void xor(codeblock_t *cb, x86opnd_t opnd0, x86opnd_t opnd1);
390
+ static inline void cb_write_lock_prefix(codeblock_t *cb);
391
+
392
+ #endif
@@ -0,0 +1,19 @@
1
+ #ifndef YJIT_CODEGEN_H
2
+ #define YJIT_CODEGEN_H 1
3
+
4
+ typedef enum codegen_status {
5
+ YJIT_END_BLOCK,
6
+ YJIT_KEEP_COMPILING,
7
+ YJIT_CANT_COMPILE
8
+ } codegen_status_t;
9
+
10
+ // Code generation function signature
11
+ typedef codegen_status_t (*codegen_fn)(jitstate_t *jit, ctx_t *ctx, codeblock_t *cb);
12
+
13
+ static uint8_t *yjit_entry_prologue(codeblock_t *cb, const rb_iseq_t *iseq);
14
+
15
+ static void yjit_gen_block(block_t *block, rb_execution_context_t *ec);
16
+
17
+ static void yjit_init_codegen(void);
18
+
19
+ #endif // #ifndef YJIT_CODEGEN_H