debase-ruby_core_source 3.4.1 → 4.0.0.preview2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/addr2line.h +22 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/builtin.h +125 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/ccan/build_assert/build_assert.h +40 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/ccan/check_type/check_type.h +63 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/ccan/container_of/container_of.h +142 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/ccan/list/list.h +791 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/ccan/str/str.h +17 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/constant.h +53 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/darray.h +278 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/debug_counter.h +425 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/dln.h +33 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/encindex.h +70 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/eval_intern.h +331 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/hrtime.h +237 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/id.h +354 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/id_table.h +54 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/insns.inc +302 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/insns_info.inc +11241 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/array.h +154 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/basic_operators.h +65 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/bignum.h +245 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/bits.h +650 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/box.h +81 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/class.h +805 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/cmdlineopt.h +64 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/compar.h +29 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/compile.h +34 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/compilers.h +107 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/complex.h +29 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/concurrent_set.h +21 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/cont.h +35 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/dir.h +16 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/enc.h +19 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/encoding.h +39 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/enum.h +18 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/enumerator.h +21 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/error.h +251 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/eval.h +41 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/file.h +38 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/fixnum.h +185 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/gc.h +358 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/hash.h +194 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/imemo.h +322 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/inits.h +51 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/io.h +163 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/load.h +20 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/loadpath.h +16 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/math.h +23 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/missing.h +19 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/numeric.h +275 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/object.h +63 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/parse.h +131 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/proc.h +30 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/process.h +124 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/ractor.h +10 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/random.h +17 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/range.h +40 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/rational.h +71 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/re.h +33 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/ruby_parser.h +102 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/sanitizers.h +346 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/serial.h +23 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/set_table.h +70 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/signal.h +25 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/st.h +11 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/static_assert.h +16 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/string.h +203 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/struct.h +160 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/symbol.h +46 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/thread.h +112 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/time.h +37 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/transcode.h +23 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/util.h +27 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/variable.h +74 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/vm.h +136 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/warnings.h +16 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal.h +105 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/iseq.h +357 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/known_errors.inc +1419 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/method.h +271 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/node.h +122 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/node_name.inc +224 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/optinsn.inc +128 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/optunifs.inc +41 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/parse.h +244 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/parser_bits.h +564 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/parser_node.h +32 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/parser_st.h +162 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/parser_value.h +106 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/prism/ast.h +8233 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/prism/defines.h +260 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/prism/diagnostic.h +458 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/prism/encoding.h +283 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/prism/extension.h +19 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/prism/node.h +129 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/prism/options.h +485 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/prism/pack.h +163 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/prism/parser.h +936 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/prism/prettyprint.h +34 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/prism/prism.h +408 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/prism/regexp.h +43 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/prism/static_literals.h +121 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/prism/util/pm_buffer.h +236 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/prism/util/pm_char.h +204 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/prism/util/pm_constant_pool.h +218 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/prism/util/pm_integer.h +130 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/prism/util/pm_list.h +103 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/prism/util/pm_memchr.h +29 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/prism/util/pm_newline_list.h +113 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/prism/util/pm_string.h +200 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/prism/util/pm_strncasecmp.h +32 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/prism/util/pm_strpbrk.h +46 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/prism/version.h +29 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/prism_compile.h +106 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/probes_helper.h +42 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/ractor_core.h +306 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/regenc.h +259 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/regint.h +1005 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/regparse.h +371 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/revision.h +5 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/ruby_assert.h +14 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/ruby_atomic.h +66 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/rubyparser.h +1394 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/shape.h +444 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/siphash.h +48 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/symbol.h +116 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/thread_none.h +21 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/thread_pthread.h +175 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/thread_win32.h +58 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/timev.h +58 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/transcode_data.h +138 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/variable.h +27 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/version.h +69 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/vm.inc +6183 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/vm_call_iseq_optimized.inc +244 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/vm_callinfo.h +640 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/vm_core.h +2350 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/vm_debug.h +124 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/vm_exec.h +210 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/vm_insnhelper.h +277 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/vm_opts.h +67 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/vm_sync.h +156 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/vmtc.inc +289 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/yjit.h +81 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/zjit.h +47 -0
- data/lib/debase/ruby_core_source/version.rb +1 -1
- metadata +148 -3
|
@@ -0,0 +1,444 @@
|
|
|
1
|
+
#ifndef RUBY_SHAPE_H
|
|
2
|
+
#define RUBY_SHAPE_H
|
|
3
|
+
|
|
4
|
+
#include "internal/gc.h"
|
|
5
|
+
|
|
6
|
+
typedef uint16_t attr_index_t;
|
|
7
|
+
typedef uint32_t shape_id_t;
|
|
8
|
+
#define SHAPE_ID_NUM_BITS 32
|
|
9
|
+
#define SHAPE_ID_OFFSET_NUM_BITS 19
|
|
10
|
+
|
|
11
|
+
STATIC_ASSERT(shape_id_num_bits, SHAPE_ID_NUM_BITS == sizeof(shape_id_t) * CHAR_BIT);
|
|
12
|
+
|
|
13
|
+
#define SHAPE_BUFFER_SIZE (1 << SHAPE_ID_OFFSET_NUM_BITS)
|
|
14
|
+
#define SHAPE_ID_OFFSET_MASK (SHAPE_BUFFER_SIZE - 1)
|
|
15
|
+
|
|
16
|
+
#define SHAPE_ID_HEAP_INDEX_BITS 3
|
|
17
|
+
#define SHAPE_ID_HEAP_INDEX_MAX ((1 << SHAPE_ID_HEAP_INDEX_BITS) - 1)
|
|
18
|
+
|
|
19
|
+
#define SHAPE_ID_FL_USHIFT (SHAPE_ID_OFFSET_NUM_BITS + SHAPE_ID_HEAP_INDEX_BITS)
|
|
20
|
+
#define SHAPE_ID_HEAP_INDEX_OFFSET SHAPE_ID_FL_USHIFT
|
|
21
|
+
|
|
22
|
+
// shape_id_t bits:
|
|
23
|
+
// 0-18 SHAPE_ID_OFFSET_MASK
|
|
24
|
+
// index in rb_shape_tree.shape_list. Allow to access `rb_shape_t *`.
|
|
25
|
+
// 19-21 SHAPE_ID_HEAP_INDEX_MASK
|
|
26
|
+
// index in rb_shape_tree.capacities. Allow to access slot size.
|
|
27
|
+
// Always 0 except for T_OBJECT.
|
|
28
|
+
// 22 SHAPE_ID_FL_FROZEN
|
|
29
|
+
// Whether the object is frozen or not.
|
|
30
|
+
// 23 SHAPE_ID_FL_HAS_OBJECT_ID
|
|
31
|
+
// Whether the object has an `SHAPE_OBJ_ID` transition.
|
|
32
|
+
// 24 SHAPE_ID_FL_TOO_COMPLEX
|
|
33
|
+
// The object is backed by a `st_table`.
|
|
34
|
+
|
|
35
|
+
enum shape_id_fl_type {
|
|
36
|
+
#define RBIMPL_SHAPE_ID_FL(n) (1<<(SHAPE_ID_FL_USHIFT+n))
|
|
37
|
+
|
|
38
|
+
SHAPE_ID_HEAP_INDEX_MASK = RBIMPL_SHAPE_ID_FL(0) | RBIMPL_SHAPE_ID_FL(1) | RBIMPL_SHAPE_ID_FL(2),
|
|
39
|
+
|
|
40
|
+
SHAPE_ID_FL_FROZEN = RBIMPL_SHAPE_ID_FL(3),
|
|
41
|
+
SHAPE_ID_FL_HAS_OBJECT_ID = RBIMPL_SHAPE_ID_FL(4),
|
|
42
|
+
SHAPE_ID_FL_TOO_COMPLEX = RBIMPL_SHAPE_ID_FL(5),
|
|
43
|
+
|
|
44
|
+
SHAPE_ID_FL_NON_CANONICAL_MASK = SHAPE_ID_FL_FROZEN | SHAPE_ID_FL_HAS_OBJECT_ID,
|
|
45
|
+
SHAPE_ID_FLAGS_MASK = SHAPE_ID_HEAP_INDEX_MASK | SHAPE_ID_FL_NON_CANONICAL_MASK | SHAPE_ID_FL_TOO_COMPLEX,
|
|
46
|
+
|
|
47
|
+
#undef RBIMPL_SHAPE_ID_FL
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
// This mask allows to check if a shape_id contains any ivar.
|
|
51
|
+
// It relies on ROOT_SHAPE_WITH_OBJ_ID==1.
|
|
52
|
+
enum shape_id_mask {
|
|
53
|
+
SHAPE_ID_HAS_IVAR_MASK = SHAPE_ID_FL_TOO_COMPLEX | (SHAPE_ID_OFFSET_MASK - 1),
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
// The interpreter doesn't care about frozen status or slot size when reading ivars.
|
|
57
|
+
// So we normalize shape_id by clearing these bits to improve cache hits.
|
|
58
|
+
// JITs however might care about it.
|
|
59
|
+
#define SHAPE_ID_READ_ONLY_MASK (~(SHAPE_ID_FL_FROZEN | SHAPE_ID_HEAP_INDEX_MASK))
|
|
60
|
+
|
|
61
|
+
typedef uint32_t redblack_id_t;
|
|
62
|
+
|
|
63
|
+
#define SHAPE_MAX_FIELDS (attr_index_t)(-1)
|
|
64
|
+
#define SHAPE_FLAG_SHIFT ((SIZEOF_VALUE * CHAR_BIT) - SHAPE_ID_NUM_BITS)
|
|
65
|
+
#define SHAPE_FLAG_MASK (((VALUE)-1) >> SHAPE_ID_NUM_BITS)
|
|
66
|
+
|
|
67
|
+
#define SHAPE_MAX_VARIATIONS 8
|
|
68
|
+
|
|
69
|
+
#define INVALID_SHAPE_ID ((shape_id_t)-1)
|
|
70
|
+
#define ATTR_INDEX_NOT_SET ((attr_index_t)-1)
|
|
71
|
+
|
|
72
|
+
#define ROOT_SHAPE_ID 0x0
|
|
73
|
+
#define ROOT_SHAPE_WITH_OBJ_ID 0x1
|
|
74
|
+
#define ROOT_TOO_COMPLEX_SHAPE_ID (ROOT_SHAPE_ID | SHAPE_ID_FL_TOO_COMPLEX)
|
|
75
|
+
#define ROOT_TOO_COMPLEX_WITH_OBJ_ID (ROOT_SHAPE_WITH_OBJ_ID | SHAPE_ID_FL_TOO_COMPLEX | SHAPE_ID_FL_HAS_OBJECT_ID)
|
|
76
|
+
|
|
77
|
+
typedef struct redblack_node redblack_node_t;
|
|
78
|
+
|
|
79
|
+
struct rb_shape {
|
|
80
|
+
VALUE edges; // id_table from ID (ivar) to next shape
|
|
81
|
+
ID edge_name; // ID (ivar) for transition from parent to rb_shape
|
|
82
|
+
redblack_node_t *ancestor_index;
|
|
83
|
+
shape_id_t parent_id;
|
|
84
|
+
attr_index_t next_field_index; // Fields are either ivars or internal properties like `object_id`
|
|
85
|
+
attr_index_t capacity; // Total capacity of the object with this shape
|
|
86
|
+
uint8_t type;
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
typedef struct rb_shape rb_shape_t;
|
|
90
|
+
|
|
91
|
+
struct redblack_node {
|
|
92
|
+
ID key;
|
|
93
|
+
rb_shape_t *value;
|
|
94
|
+
redblack_id_t l;
|
|
95
|
+
redblack_id_t r;
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
enum shape_type {
|
|
99
|
+
SHAPE_ROOT,
|
|
100
|
+
SHAPE_IVAR,
|
|
101
|
+
SHAPE_OBJ_ID,
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
enum shape_flags {
|
|
105
|
+
SHAPE_FL_FROZEN = 1 << 0,
|
|
106
|
+
SHAPE_FL_HAS_OBJECT_ID = 1 << 1,
|
|
107
|
+
SHAPE_FL_TOO_COMPLEX = 1 << 2,
|
|
108
|
+
|
|
109
|
+
SHAPE_FL_NON_CANONICAL_MASK = SHAPE_FL_FROZEN | SHAPE_FL_HAS_OBJECT_ID,
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
typedef struct {
|
|
113
|
+
/* object shapes */
|
|
114
|
+
rb_shape_t *shape_list;
|
|
115
|
+
rb_shape_t *root_shape;
|
|
116
|
+
const attr_index_t *capacities;
|
|
117
|
+
rb_atomic_t next_shape_id;
|
|
118
|
+
|
|
119
|
+
redblack_node_t *shape_cache;
|
|
120
|
+
unsigned int cache_size;
|
|
121
|
+
} rb_shape_tree_t;
|
|
122
|
+
|
|
123
|
+
RUBY_SYMBOL_EXPORT_BEGIN
|
|
124
|
+
RUBY_EXTERN rb_shape_tree_t rb_shape_tree;
|
|
125
|
+
RUBY_SYMBOL_EXPORT_END
|
|
126
|
+
|
|
127
|
+
static inline shape_id_t
|
|
128
|
+
rb_shapes_count(void)
|
|
129
|
+
{
|
|
130
|
+
return (shape_id_t)RUBY_ATOMIC_LOAD(rb_shape_tree.next_shape_id);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
union rb_attr_index_cache {
|
|
134
|
+
uint64_t pack;
|
|
135
|
+
struct {
|
|
136
|
+
shape_id_t shape_id;
|
|
137
|
+
attr_index_t index;
|
|
138
|
+
} unpack;
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
static inline shape_id_t
|
|
142
|
+
RBASIC_SHAPE_ID(VALUE obj)
|
|
143
|
+
{
|
|
144
|
+
RUBY_ASSERT(!RB_SPECIAL_CONST_P(obj));
|
|
145
|
+
RUBY_ASSERT(!RB_TYPE_P(obj, T_IMEMO) || IMEMO_TYPE_P(obj, imemo_fields));
|
|
146
|
+
#if RBASIC_SHAPE_ID_FIELD
|
|
147
|
+
return (shape_id_t)((RBASIC(obj)->shape_id));
|
|
148
|
+
#else
|
|
149
|
+
return (shape_id_t)((RBASIC(obj)->flags) >> SHAPE_FLAG_SHIFT);
|
|
150
|
+
#endif
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
// Same as RBASIC_SHAPE_ID but with flags that have no impact
|
|
154
|
+
// on reads removed. e.g. Remove FL_FROZEN.
|
|
155
|
+
static inline shape_id_t
|
|
156
|
+
RBASIC_SHAPE_ID_FOR_READ(VALUE obj)
|
|
157
|
+
{
|
|
158
|
+
return RBASIC_SHAPE_ID(obj) & SHAPE_ID_READ_ONLY_MASK;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
#if RUBY_DEBUG
|
|
162
|
+
bool rb_shape_verify_consistency(VALUE obj, shape_id_t shape_id);
|
|
163
|
+
#endif
|
|
164
|
+
|
|
165
|
+
static inline void
|
|
166
|
+
RBASIC_SET_SHAPE_ID(VALUE obj, shape_id_t shape_id)
|
|
167
|
+
{
|
|
168
|
+
RUBY_ASSERT(!RB_SPECIAL_CONST_P(obj));
|
|
169
|
+
RUBY_ASSERT(!RB_TYPE_P(obj, T_IMEMO) || IMEMO_TYPE_P(obj, imemo_fields));
|
|
170
|
+
#if RBASIC_SHAPE_ID_FIELD
|
|
171
|
+
RBASIC(obj)->shape_id = (VALUE)shape_id;
|
|
172
|
+
#else
|
|
173
|
+
// Object shapes are occupying top bits
|
|
174
|
+
RBASIC(obj)->flags &= SHAPE_FLAG_MASK;
|
|
175
|
+
RBASIC(obj)->flags |= ((VALUE)(shape_id) << SHAPE_FLAG_SHIFT);
|
|
176
|
+
#endif
|
|
177
|
+
RUBY_ASSERT(rb_shape_verify_consistency(obj, shape_id));
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
void rb_set_boxed_class_shape_id(VALUE obj, shape_id_t shape_id);
|
|
181
|
+
|
|
182
|
+
static inline void
|
|
183
|
+
RB_SET_SHAPE_ID(VALUE obj, shape_id_t shape_id)
|
|
184
|
+
{
|
|
185
|
+
switch (BUILTIN_TYPE(obj)) {
|
|
186
|
+
case T_CLASS:
|
|
187
|
+
case T_MODULE:
|
|
188
|
+
rb_set_boxed_class_shape_id(obj, shape_id);
|
|
189
|
+
break;
|
|
190
|
+
default:
|
|
191
|
+
RBASIC_SET_SHAPE_ID(obj, shape_id);
|
|
192
|
+
break;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
static inline rb_shape_t *
|
|
197
|
+
RSHAPE(shape_id_t shape_id)
|
|
198
|
+
{
|
|
199
|
+
uint32_t offset = (shape_id & SHAPE_ID_OFFSET_MASK);
|
|
200
|
+
RUBY_ASSERT(offset != INVALID_SHAPE_ID);
|
|
201
|
+
|
|
202
|
+
return &rb_shape_tree.shape_list[offset];
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
int32_t rb_shape_id_offset(void);
|
|
206
|
+
|
|
207
|
+
RUBY_FUNC_EXPORTED shape_id_t rb_obj_shape_id(VALUE obj);
|
|
208
|
+
shape_id_t rb_shape_get_next_iv_shape(shape_id_t shape_id, ID id);
|
|
209
|
+
bool rb_shape_get_iv_index(shape_id_t shape_id, ID id, attr_index_t *value);
|
|
210
|
+
bool rb_shape_get_iv_index_with_hint(shape_id_t shape_id, ID id, attr_index_t *value, shape_id_t *shape_id_hint);
|
|
211
|
+
bool rb_shape_find_ivar(shape_id_t shape_id, ID id, shape_id_t *ivar_shape);
|
|
212
|
+
|
|
213
|
+
typedef int rb_shape_foreach_transition_callback(shape_id_t shape_id, void *data);
|
|
214
|
+
bool rb_shape_foreach_field(shape_id_t shape_id, rb_shape_foreach_transition_callback func, void *data);
|
|
215
|
+
|
|
216
|
+
shape_id_t rb_shape_transition_frozen(VALUE obj);
|
|
217
|
+
shape_id_t rb_shape_transition_complex(VALUE obj);
|
|
218
|
+
shape_id_t rb_shape_transition_remove_ivar(VALUE obj, ID id, shape_id_t *removed_shape_id);
|
|
219
|
+
shape_id_t rb_shape_transition_add_ivar(VALUE obj, ID id);
|
|
220
|
+
shape_id_t rb_shape_transition_add_ivar_no_warnings(VALUE obj, ID id);
|
|
221
|
+
shape_id_t rb_shape_transition_object_id(VALUE obj);
|
|
222
|
+
shape_id_t rb_shape_transition_heap(VALUE obj, size_t heap_index);
|
|
223
|
+
shape_id_t rb_shape_object_id(shape_id_t original_shape_id);
|
|
224
|
+
|
|
225
|
+
void rb_shape_free_all(void);
|
|
226
|
+
|
|
227
|
+
shape_id_t rb_shape_rebuild(shape_id_t initial_shape_id, shape_id_t dest_shape_id);
|
|
228
|
+
void rb_shape_copy_fields(VALUE dest, VALUE *dest_buf, shape_id_t dest_shape_id, VALUE *src_buf, shape_id_t src_shape_id);
|
|
229
|
+
void rb_shape_copy_complex_ivars(VALUE dest, VALUE obj, shape_id_t src_shape_id, st_table *fields_table);
|
|
230
|
+
|
|
231
|
+
static inline bool
|
|
232
|
+
rb_shape_too_complex_p(shape_id_t shape_id)
|
|
233
|
+
{
|
|
234
|
+
return shape_id & SHAPE_ID_FL_TOO_COMPLEX;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
static inline bool
|
|
238
|
+
rb_shape_obj_too_complex_p(VALUE obj)
|
|
239
|
+
{
|
|
240
|
+
return !RB_SPECIAL_CONST_P(obj) && rb_shape_too_complex_p(RBASIC_SHAPE_ID(obj));
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
static inline bool
|
|
244
|
+
rb_shape_has_object_id(shape_id_t shape_id)
|
|
245
|
+
{
|
|
246
|
+
return shape_id & SHAPE_ID_FL_HAS_OBJECT_ID;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
static inline bool
|
|
250
|
+
rb_shape_canonical_p(shape_id_t shape_id)
|
|
251
|
+
{
|
|
252
|
+
return !(shape_id & SHAPE_ID_FL_NON_CANONICAL_MASK);
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
static inline uint8_t
|
|
256
|
+
rb_shape_heap_index(shape_id_t shape_id)
|
|
257
|
+
{
|
|
258
|
+
return (uint8_t)((shape_id & SHAPE_ID_HEAP_INDEX_MASK) >> SHAPE_ID_HEAP_INDEX_OFFSET);
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
static inline shape_id_t
|
|
262
|
+
rb_shape_root(size_t heap_id)
|
|
263
|
+
{
|
|
264
|
+
shape_id_t heap_index = (shape_id_t)(heap_id + 1);
|
|
265
|
+
shape_id_t heap_flags = heap_index << SHAPE_ID_HEAP_INDEX_OFFSET;
|
|
266
|
+
|
|
267
|
+
RUBY_ASSERT((heap_flags & SHAPE_ID_HEAP_INDEX_MASK) == heap_flags);
|
|
268
|
+
RUBY_ASSERT(rb_shape_heap_index(heap_flags) == heap_index);
|
|
269
|
+
|
|
270
|
+
return ROOT_SHAPE_ID | heap_flags;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
static inline shape_id_t
|
|
274
|
+
RSHAPE_PARENT_RAW_ID(shape_id_t shape_id)
|
|
275
|
+
{
|
|
276
|
+
return RSHAPE(shape_id)->parent_id;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
static inline bool
|
|
280
|
+
RSHAPE_DIRECT_CHILD_P(shape_id_t parent_id, shape_id_t child_id)
|
|
281
|
+
{
|
|
282
|
+
return (parent_id & SHAPE_ID_FLAGS_MASK) == (child_id & SHAPE_ID_FLAGS_MASK) &&
|
|
283
|
+
RSHAPE(child_id)->parent_id == (parent_id & SHAPE_ID_OFFSET_MASK);
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
static inline enum shape_type
|
|
287
|
+
RSHAPE_TYPE(shape_id_t shape_id)
|
|
288
|
+
{
|
|
289
|
+
return RSHAPE(shape_id)->type;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
static inline bool
|
|
293
|
+
RSHAPE_TYPE_P(shape_id_t shape_id, enum shape_type type)
|
|
294
|
+
{
|
|
295
|
+
return RSHAPE_TYPE(shape_id) == type;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
static inline attr_index_t
|
|
299
|
+
RSHAPE_EMBEDDED_CAPACITY(shape_id_t shape_id)
|
|
300
|
+
{
|
|
301
|
+
uint8_t heap_index = rb_shape_heap_index(shape_id);
|
|
302
|
+
if (heap_index) {
|
|
303
|
+
return rb_shape_tree.capacities[heap_index - 1];
|
|
304
|
+
}
|
|
305
|
+
return 0;
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
static inline attr_index_t
|
|
309
|
+
RSHAPE_CAPACITY(shape_id_t shape_id)
|
|
310
|
+
{
|
|
311
|
+
attr_index_t embedded_capacity = RSHAPE_EMBEDDED_CAPACITY(shape_id);
|
|
312
|
+
|
|
313
|
+
if (embedded_capacity > RSHAPE(shape_id)->capacity) {
|
|
314
|
+
return embedded_capacity;
|
|
315
|
+
}
|
|
316
|
+
else {
|
|
317
|
+
return RSHAPE(shape_id)->capacity;
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
static inline attr_index_t
|
|
322
|
+
RSHAPE_LEN(shape_id_t shape_id)
|
|
323
|
+
{
|
|
324
|
+
return RSHAPE(shape_id)->next_field_index;
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
static inline attr_index_t
|
|
328
|
+
RSHAPE_INDEX(shape_id_t shape_id)
|
|
329
|
+
{
|
|
330
|
+
RUBY_ASSERT(RSHAPE_LEN(shape_id) > 0);
|
|
331
|
+
return RSHAPE_LEN(shape_id) - 1;
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
static inline ID
|
|
335
|
+
RSHAPE_EDGE_NAME(shape_id_t shape_id)
|
|
336
|
+
{
|
|
337
|
+
return RSHAPE(shape_id)->edge_name;
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
static inline uint32_t
|
|
341
|
+
ROBJECT_FIELDS_CAPACITY(VALUE obj)
|
|
342
|
+
{
|
|
343
|
+
RBIMPL_ASSERT_TYPE(obj, RUBY_T_OBJECT);
|
|
344
|
+
// Asking for capacity doesn't make sense when the object is using
|
|
345
|
+
// a hash table for storing instance variables
|
|
346
|
+
RUBY_ASSERT(!rb_shape_obj_too_complex_p(obj));
|
|
347
|
+
return RSHAPE_CAPACITY(RBASIC_SHAPE_ID(obj));
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
static inline st_table *
|
|
351
|
+
ROBJECT_FIELDS_HASH(VALUE obj)
|
|
352
|
+
{
|
|
353
|
+
RBIMPL_ASSERT_TYPE(obj, RUBY_T_OBJECT);
|
|
354
|
+
RUBY_ASSERT(rb_shape_obj_too_complex_p(obj));
|
|
355
|
+
RUBY_ASSERT(FL_TEST_RAW(obj, ROBJECT_HEAP));
|
|
356
|
+
|
|
357
|
+
return (st_table *)ROBJECT(obj)->as.heap.fields;
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
static inline void
|
|
361
|
+
ROBJECT_SET_FIELDS_HASH(VALUE obj, const st_table *tbl)
|
|
362
|
+
{
|
|
363
|
+
RBIMPL_ASSERT_TYPE(obj, RUBY_T_OBJECT);
|
|
364
|
+
RUBY_ASSERT(rb_shape_obj_too_complex_p(obj));
|
|
365
|
+
RUBY_ASSERT(FL_TEST_RAW(obj, ROBJECT_HEAP));
|
|
366
|
+
|
|
367
|
+
ROBJECT(obj)->as.heap.fields = (VALUE *)tbl;
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
static inline uint32_t
|
|
371
|
+
ROBJECT_FIELDS_COUNT(VALUE obj)
|
|
372
|
+
{
|
|
373
|
+
if (rb_shape_obj_too_complex_p(obj)) {
|
|
374
|
+
return (uint32_t)rb_st_table_size(ROBJECT_FIELDS_HASH(obj));
|
|
375
|
+
}
|
|
376
|
+
else {
|
|
377
|
+
RBIMPL_ASSERT_TYPE(obj, RUBY_T_OBJECT);
|
|
378
|
+
RUBY_ASSERT(!rb_shape_obj_too_complex_p(obj));
|
|
379
|
+
return RSHAPE(RBASIC_SHAPE_ID(obj))->next_field_index;
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
static inline uint32_t
|
|
384
|
+
RBASIC_FIELDS_COUNT(VALUE obj)
|
|
385
|
+
{
|
|
386
|
+
return RSHAPE(rb_obj_shape_id(obj))->next_field_index;
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
static inline bool
|
|
390
|
+
rb_shape_obj_has_id(VALUE obj)
|
|
391
|
+
{
|
|
392
|
+
return rb_shape_has_object_id(RBASIC_SHAPE_ID(obj));
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
static inline bool
|
|
396
|
+
rb_shape_has_ivars(shape_id_t shape_id)
|
|
397
|
+
{
|
|
398
|
+
return shape_id & SHAPE_ID_HAS_IVAR_MASK;
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
static inline bool
|
|
402
|
+
rb_shape_obj_has_ivars(VALUE obj)
|
|
403
|
+
{
|
|
404
|
+
return rb_shape_has_ivars(RBASIC_SHAPE_ID(obj));
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
static inline bool
|
|
408
|
+
rb_shape_has_fields(shape_id_t shape_id)
|
|
409
|
+
{
|
|
410
|
+
return shape_id & (SHAPE_ID_OFFSET_MASK | SHAPE_ID_FL_TOO_COMPLEX);
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
static inline bool
|
|
414
|
+
rb_shape_obj_has_fields(VALUE obj)
|
|
415
|
+
{
|
|
416
|
+
return rb_shape_has_fields(RBASIC_SHAPE_ID(obj));
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
static inline bool
|
|
420
|
+
rb_obj_exivar_p(VALUE obj)
|
|
421
|
+
{
|
|
422
|
+
switch (TYPE(obj)) {
|
|
423
|
+
case T_NONE:
|
|
424
|
+
case T_OBJECT:
|
|
425
|
+
case T_CLASS:
|
|
426
|
+
case T_MODULE:
|
|
427
|
+
case T_IMEMO:
|
|
428
|
+
return false;
|
|
429
|
+
default:
|
|
430
|
+
break;
|
|
431
|
+
}
|
|
432
|
+
return rb_shape_obj_has_fields(obj);
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
// For ext/objspace
|
|
436
|
+
RUBY_SYMBOL_EXPORT_BEGIN
|
|
437
|
+
typedef void each_shape_callback(shape_id_t shape_id, void *data);
|
|
438
|
+
void rb_shape_each_shape_id(each_shape_callback callback, void *data);
|
|
439
|
+
size_t rb_shape_memsize(shape_id_t shape);
|
|
440
|
+
size_t rb_shape_edges_count(shape_id_t shape_id);
|
|
441
|
+
size_t rb_shape_depth(shape_id_t shape_id);
|
|
442
|
+
RUBY_SYMBOL_EXPORT_END
|
|
443
|
+
|
|
444
|
+
#endif
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
#ifndef SIPHASH_H
|
|
2
|
+
#define SIPHASH_H 1
|
|
3
|
+
#include <stdlib.h>
|
|
4
|
+
#ifdef HAVE_STDINT_H
|
|
5
|
+
#include <stdint.h>
|
|
6
|
+
#endif
|
|
7
|
+
#ifdef HAVE_INTTYPES_H
|
|
8
|
+
#include <inttypes.h>
|
|
9
|
+
#endif
|
|
10
|
+
|
|
11
|
+
#ifndef HAVE_UINT64_T
|
|
12
|
+
typedef struct {
|
|
13
|
+
uint32_t u32[2];
|
|
14
|
+
} sip_uint64_t;
|
|
15
|
+
#define uint64_t sip_uint64_t
|
|
16
|
+
#else
|
|
17
|
+
typedef uint64_t sip_uint64_t;
|
|
18
|
+
#endif
|
|
19
|
+
|
|
20
|
+
typedef struct {
|
|
21
|
+
int c;
|
|
22
|
+
int d;
|
|
23
|
+
uint64_t v[4];
|
|
24
|
+
uint8_t buf[sizeof(uint64_t)];
|
|
25
|
+
uint8_t buflen;
|
|
26
|
+
uint8_t msglen_byte;
|
|
27
|
+
} sip_state;
|
|
28
|
+
|
|
29
|
+
typedef struct sip_interface_st sip_interface;
|
|
30
|
+
|
|
31
|
+
typedef struct {
|
|
32
|
+
sip_state state[1];
|
|
33
|
+
const sip_interface *methods;
|
|
34
|
+
} sip_hash;
|
|
35
|
+
|
|
36
|
+
sip_hash *sip_hash_new(const uint8_t key[16], int c, int d);
|
|
37
|
+
sip_hash *sip_hash_init(sip_hash *h, const uint8_t key[16], int c, int d);
|
|
38
|
+
int sip_hash_update(sip_hash *h, const uint8_t *data, size_t len);
|
|
39
|
+
int sip_hash_final(sip_hash *h, uint8_t **digest, size_t *len);
|
|
40
|
+
int sip_hash_final_integer(sip_hash *h, uint64_t *digest);
|
|
41
|
+
int sip_hash_digest(sip_hash *h, const uint8_t *data, size_t data_len, uint8_t **digest, size_t *digest_len);
|
|
42
|
+
int sip_hash_digest_integer(sip_hash *h, const uint8_t *data, size_t data_len, uint64_t *digest);
|
|
43
|
+
void sip_hash_free(sip_hash *h);
|
|
44
|
+
void sip_hash_dump(sip_hash *h);
|
|
45
|
+
|
|
46
|
+
NO_SANITIZE("unsigned-integer-overflow", uint64_t sip_hash13(const uint8_t key[16], const uint8_t *data, size_t len));
|
|
47
|
+
|
|
48
|
+
#endif
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
#ifndef RUBY_SYMBOL_H
|
|
2
|
+
#define RUBY_SYMBOL_H 1
|
|
3
|
+
/**********************************************************************
|
|
4
|
+
|
|
5
|
+
symbol.h -
|
|
6
|
+
|
|
7
|
+
$Author$
|
|
8
|
+
created at: Tue Jul 8 15:49:54 JST 2014
|
|
9
|
+
|
|
10
|
+
Copyright (C) 2014 Yukihiro Matsumoto
|
|
11
|
+
|
|
12
|
+
**********************************************************************/
|
|
13
|
+
|
|
14
|
+
#include "id.h"
|
|
15
|
+
#include "ruby/encoding.h"
|
|
16
|
+
|
|
17
|
+
#define DYNAMIC_ID_P(id) (!(id&ID_STATIC_SYM)&&id>tLAST_OP_ID)
|
|
18
|
+
#define STATIC_ID2SYM(id) (((VALUE)(id)<<RUBY_SPECIAL_SHIFT)|SYMBOL_FLAG)
|
|
19
|
+
|
|
20
|
+
#ifdef HAVE_BUILTIN___BUILTIN_CONSTANT_P
|
|
21
|
+
#define rb_id2sym(id) \
|
|
22
|
+
RB_GNUC_EXTENSION_BLOCK(__builtin_constant_p(id) && !DYNAMIC_ID_P(id) ? \
|
|
23
|
+
STATIC_ID2SYM(id) : rb_id2sym(id))
|
|
24
|
+
#endif
|
|
25
|
+
|
|
26
|
+
struct RSymbol {
|
|
27
|
+
struct RBasic basic;
|
|
28
|
+
st_index_t hashval;
|
|
29
|
+
VALUE fstr;
|
|
30
|
+
ID id;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
#define RSYMBOL(obj) ((struct RSymbol *)(obj))
|
|
34
|
+
|
|
35
|
+
#define is_notop_id(id) ((id)>tLAST_OP_ID)
|
|
36
|
+
#define is_local_id(id) (id_type(id)==ID_LOCAL)
|
|
37
|
+
#define is_global_id(id) (id_type(id)==ID_GLOBAL)
|
|
38
|
+
#define is_instance_id(id) (id_type(id)==ID_INSTANCE)
|
|
39
|
+
#define is_attrset_id(id) ((id)==idASET||id_type(id)==ID_ATTRSET)
|
|
40
|
+
#define is_const_id(id) (id_type(id)==ID_CONST)
|
|
41
|
+
#define is_class_id(id) (id_type(id)==ID_CLASS)
|
|
42
|
+
#define is_internal_id(id) (id_type(id)==ID_INTERNAL)
|
|
43
|
+
|
|
44
|
+
static inline int
|
|
45
|
+
id_type(ID id)
|
|
46
|
+
{
|
|
47
|
+
if (is_notop_id(id)) {
|
|
48
|
+
return (int)(id&ID_SCOPE_MASK);
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
return -1;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
typedef uint32_t rb_id_serial_t;
|
|
56
|
+
static const uint32_t RB_ID_SERIAL_MAX = /* 256M on LP32 */
|
|
57
|
+
UINT32_MAX >>
|
|
58
|
+
((sizeof(ID)-sizeof(rb_id_serial_t))*CHAR_BIT < RUBY_ID_SCOPE_SHIFT ?
|
|
59
|
+
RUBY_ID_SCOPE_SHIFT : 0);
|
|
60
|
+
|
|
61
|
+
static inline rb_id_serial_t
|
|
62
|
+
rb_id_to_serial(ID id)
|
|
63
|
+
{
|
|
64
|
+
if (is_notop_id(id)) {
|
|
65
|
+
return (rb_id_serial_t)(id >> ID_SCOPE_SHIFT);
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
return (rb_id_serial_t)id;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
static inline int
|
|
73
|
+
sym_type(VALUE sym)
|
|
74
|
+
{
|
|
75
|
+
ID id;
|
|
76
|
+
if (STATIC_SYM_P(sym)) {
|
|
77
|
+
id = RSHIFT(sym, RUBY_SPECIAL_SHIFT);
|
|
78
|
+
if (id<=tLAST_OP_ID) {
|
|
79
|
+
return -1;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
id = RSYMBOL(sym)->id;
|
|
84
|
+
}
|
|
85
|
+
return (int)(id&ID_SCOPE_MASK);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
#define is_local_sym(sym) (sym_type(sym)==ID_LOCAL)
|
|
89
|
+
#define is_global_sym(sym) (sym_type(sym)==ID_GLOBAL)
|
|
90
|
+
#define is_instance_sym(sym) (sym_type(sym)==ID_INSTANCE)
|
|
91
|
+
#define is_attrset_sym(sym) (sym_type(sym)==ID_ATTRSET)
|
|
92
|
+
#define is_const_sym(sym) (sym_type(sym)==ID_CONST)
|
|
93
|
+
#define is_class_sym(sym) (sym_type(sym)==ID_CLASS)
|
|
94
|
+
#define is_internal_sym(sym) (sym_type(sym)==ID_INTERNAL)
|
|
95
|
+
|
|
96
|
+
#ifndef RIPPER
|
|
97
|
+
RUBY_FUNC_EXPORTED
|
|
98
|
+
#else
|
|
99
|
+
RUBY_EXTERN
|
|
100
|
+
#endif
|
|
101
|
+
const uint_least32_t ruby_global_name_punct_bits[(0x7e - 0x20 + 31) / 32];
|
|
102
|
+
|
|
103
|
+
static inline int
|
|
104
|
+
is_global_name_punct(const int c)
|
|
105
|
+
{
|
|
106
|
+
if (c <= 0x20 || 0x7e < c) return 0;
|
|
107
|
+
return (ruby_global_name_punct_bits[(c - 0x20) / 32] >> (c % 32)) & 1;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
RUBY_SYMBOL_EXPORT_BEGIN
|
|
111
|
+
|
|
112
|
+
int rb_enc_symname_type(const char *name, long len, rb_encoding *enc, unsigned int allowed_attrset);
|
|
113
|
+
size_t rb_sym_immortal_count(void);
|
|
114
|
+
|
|
115
|
+
RUBY_SYMBOL_EXPORT_END
|
|
116
|
+
#endif
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
#ifndef RUBY_THREAD_NONE_H
|
|
2
|
+
#define RUBY_THREAD_NONE_H
|
|
3
|
+
|
|
4
|
+
#define RB_NATIVETHREAD_LOCK_INIT (void)(0)
|
|
5
|
+
#define RB_NATIVETHREAD_COND_INIT (void)(0)
|
|
6
|
+
|
|
7
|
+
// no-thread impl doesn't use TLS but define this to avoid using tls key
|
|
8
|
+
// based implementation in vm.c
|
|
9
|
+
#define RB_THREAD_LOCAL_SPECIFIER
|
|
10
|
+
|
|
11
|
+
struct rb_native_thread {
|
|
12
|
+
void *thread_id; // NULL
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
struct rb_thread_sched_item {};
|
|
16
|
+
struct rb_thread_sched {};
|
|
17
|
+
|
|
18
|
+
RUBY_EXTERN struct rb_execution_context_struct *ruby_current_ec;
|
|
19
|
+
NOINLINE(struct rb_execution_context_struct *rb_current_ec_noinline(void)); // for assertions
|
|
20
|
+
|
|
21
|
+
#endif /* RUBY_THREAD_NONE_H */
|