debase-ruby_core_source 0.9.0 → 0.9.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +5 -0
  3. data/lib/debase/ruby_core_source.rb +1 -1
  4. data/lib/debase/ruby_core_source/{ruby-2.3.0-preview2 → ruby-2.4.0-preview1}/addr2line.h +0 -0
  5. data/lib/debase/ruby_core_source/{ruby-2.3.0-preview2 → ruby-2.4.0-preview1}/ccan/build_assert/build_assert.h +0 -0
  6. data/lib/debase/ruby_core_source/{ruby-2.3.0-preview2 → ruby-2.4.0-preview1}/ccan/check_type/check_type.h +0 -0
  7. data/lib/debase/ruby_core_source/{ruby-2.3.0-preview2 → ruby-2.4.0-preview1}/ccan/container_of/container_of.h +0 -0
  8. data/lib/debase/ruby_core_source/{ruby-2.3.0-preview2 → ruby-2.4.0-preview1}/ccan/list/list.h +0 -0
  9. data/lib/debase/ruby_core_source/{ruby-2.3.0-preview2 → ruby-2.4.0-preview1}/ccan/str/str.h +0 -0
  10. data/lib/debase/ruby_core_source/{ruby-2.3.0-preview2 → ruby-2.4.0-preview1}/constant.h +1 -1
  11. data/lib/debase/ruby_core_source/{ruby-2.3.0-preview2 → ruby-2.4.0-preview1}/dln.h +0 -0
  12. data/lib/debase/ruby_core_source/{ruby-2.3.0-preview2 → ruby-2.4.0-preview1}/encindex.h +0 -0
  13. data/lib/debase/ruby_core_source/{ruby-2.3.0-preview2 → ruby-2.4.0-preview1}/eval_intern.h +3 -2
  14. data/lib/debase/ruby_core_source/{ruby-2.3.0-preview2 → ruby-2.4.0-preview1}/gc.h +0 -0
  15. data/lib/debase/ruby_core_source/{ruby-2.3.0-preview2 → ruby-2.4.0-preview1}/id.h +9 -0
  16. data/lib/debase/ruby_core_source/{ruby-2.3.0-preview2 → ruby-2.4.0-preview1}/id_table.h +0 -0
  17. data/lib/debase/ruby_core_source/{ruby-2.3.0-preview2 → ruby-2.4.0-preview1}/insns.inc +48 -46
  18. data/lib/debase/ruby_core_source/{ruby-2.3.0-preview2 → ruby-2.4.0-preview1}/insns_info.inc +20 -0
  19. data/lib/debase/ruby_core_source/{ruby-2.3.0-preview2 → ruby-2.4.0-preview1}/internal.h +292 -52
  20. data/lib/debase/ruby_core_source/{ruby-2.3.0-preview2 → ruby-2.4.0-preview1}/iseq.h +18 -15
  21. data/lib/debase/ruby_core_source/{ruby-2.3.0-preview2 → ruby-2.4.0-preview1}/known_errors.inc +0 -0
  22. data/lib/debase/ruby_core_source/{ruby-2.3.0-preview2 → ruby-2.4.0-preview1}/method.h +0 -0
  23. data/lib/debase/ruby_core_source/{ruby-2.3.0-preview2 → ruby-2.4.0-preview1}/node.h +3 -2
  24. data/lib/debase/ruby_core_source/{ruby-2.3.0-preview2 → ruby-2.4.0-preview1}/node_name.inc +0 -0
  25. data/lib/debase/ruby_core_source/{ruby-2.3.0-preview2 → ruby-2.4.0-preview1}/opt_sc.inc +16 -0
  26. data/lib/debase/ruby_core_source/{ruby-2.3.0-preview2 → ruby-2.4.0-preview1}/optinsn.inc +0 -0
  27. data/lib/debase/ruby_core_source/{ruby-2.3.0-preview2 → ruby-2.4.0-preview1}/optunifs.inc +2 -0
  28. data/lib/debase/ruby_core_source/{ruby-2.3.0-preview2 → ruby-2.4.0-preview1}/parse.h +0 -0
  29. data/lib/debase/ruby_core_source/{ruby-2.3.0-preview2 → ruby-2.4.0-preview1}/probes_helper.h +0 -0
  30. data/lib/debase/ruby_core_source/{ruby-2.3.0-preview2 → ruby-2.4.0-preview1}/regenc.h +19 -11
  31. data/lib/debase/ruby_core_source/{ruby-2.3.0-preview2 → ruby-2.4.0-preview1}/regint.h +8 -0
  32. data/lib/debase/ruby_core_source/{ruby-2.3.0-preview2 → ruby-2.4.0-preview1}/regparse.h +0 -0
  33. data/lib/debase/ruby_core_source/ruby-2.4.0-preview1/revision.h +1 -0
  34. data/lib/debase/ruby_core_source/ruby-2.4.0-preview1/ruby_assert.h +54 -0
  35. data/lib/debase/ruby_core_source/{ruby-2.3.0-preview2 → ruby-2.4.0-preview1}/ruby_atomic.h +0 -0
  36. data/lib/debase/ruby_core_source/{ruby-2.3.0-preview2 → ruby-2.4.0-preview1}/siphash.h +0 -0
  37. data/lib/debase/ruby_core_source/{ruby-2.3.0-preview2 → ruby-2.4.0-preview1}/symbol.h +4 -4
  38. data/lib/debase/ruby_core_source/{ruby-2.3.0-preview2 → ruby-2.4.0-preview1}/thread_pthread.h +0 -0
  39. data/lib/debase/ruby_core_source/{ruby-2.3.0-preview2 → ruby-2.4.0-preview1}/thread_win32.h +0 -0
  40. data/lib/debase/ruby_core_source/{ruby-2.3.0-preview2 → ruby-2.4.0-preview1}/timev.h +0 -0
  41. data/lib/debase/ruby_core_source/{ruby-2.3.0-preview2 → ruby-2.4.0-preview1}/transcode_data.h +0 -0
  42. data/lib/debase/ruby_core_source/{ruby-2.3.0-preview2 → ruby-2.4.0-preview1}/version.h +26 -8
  43. data/lib/debase/ruby_core_source/{ruby-2.3.0-preview2 → ruby-2.4.0-preview1}/vm.inc +265 -254
  44. data/lib/debase/ruby_core_source/{ruby-2.3.0-preview2 → ruby-2.4.0-preview1}/vm_call_iseq_optimized.inc +5 -5
  45. data/lib/debase/ruby_core_source/{ruby-2.3.0-preview2 → ruby-2.4.0-preview1}/vm_core.h +35 -42
  46. data/lib/debase/ruby_core_source/{ruby-2.3.0-preview2 → ruby-2.4.0-preview1}/vm_debug.h +0 -0
  47. data/lib/debase/ruby_core_source/{ruby-2.3.0-preview2 → ruby-2.4.0-preview1}/vm_exec.h +0 -0
  48. data/lib/debase/ruby_core_source/{ruby-2.3.0-preview2 → ruby-2.4.0-preview1}/vm_insnhelper.h +3 -3
  49. data/lib/debase/ruby_core_source/{ruby-2.3.0-preview2 → ruby-2.4.0-preview1}/vm_opts.h +0 -0
  50. data/lib/debase/ruby_core_source/{ruby-2.3.0-preview2 → ruby-2.4.0-preview1}/vmtc.inc +2 -0
  51. data/lib/debase/ruby_core_source/version.rb +1 -1
  52. metadata +49 -48
  53. data/lib/debase/ruby_core_source/ruby-2.3.0-preview2/revision.h +0 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4fb397724bcafb189cbb0b9cc33aaed9c342b9c9
4
- data.tar.gz: bc4dc03bc40d4343f5845365bd658875eaa84fbc
3
+ metadata.gz: 0bd7b4848e5aca3cf90a335edf305fb5a1639c64
4
+ data.tar.gz: 13298f61686d9c5b513290e6e90e2318f7351d97
5
5
  SHA512:
6
- metadata.gz: cd6e0787310c013571c85acbc4784122fe3a6e6564bac8524c424b6609d2277b8b0fa26c8134b10a94d6f32e141193fd79a30cb7e395981e8da1463402c8abce
7
- data.tar.gz: 9ae11681118e3290f53047e7ea7c2f0901dbab35cc38f74fcd225b4c3d2631c981024c3dff791a2a74bf8e19acccfdefb0ff87b2776e9b5854b106eed85d8b2b
6
+ metadata.gz: 60ed635326d09ecdf50a86a63b07fcb2a61584d5313a076984f4b6297a9788b086e1337a8e38a82f5cb368dee3ac0b450940490126be425dee82b7be556831f4
7
+ data.tar.gz: 8df684aef591f6854791896848ca6568f69ac678b50531cffb51502dedd15e7aac874b5bc15228e8e15c85d66983434d020785ae024d84fa3cc30bae1ae6531a
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ ## [0.9.1](https::/github.com/os97673/debase-ruby_core_source/compare/v0.9.0...v0.9.1)
2
+
3
+ * ruby 2.4.0-preview1 added
4
+ * ruby 2.3.0-preview2 removed
5
+
1
6
  ## [0.9.0](https::/github.com/os97673/debase-ruby_core_source/compare/v0.8.6...v0.9.0)
2
7
 
3
8
  * ruby 2.3.1 added
@@ -4,7 +4,7 @@ require 'rbconfig'
4
4
  module Debase
5
5
  module RubyCoreSource
6
6
  REVISION_MAP = {
7
- 53028 => 'ruby-2.3.0-preview2',
7
+ 55466 => 'ruby-2.4.0-preview1',
8
8
  }
9
9
 
10
10
  def self.create_makefile_with_core(hdrs, name)
@@ -38,7 +38,7 @@ typedef struct rb_const_entry_struct {
38
38
  VALUE rb_mod_private_constant(int argc, const VALUE *argv, VALUE obj);
39
39
  VALUE rb_mod_public_constant(int argc, const VALUE *argv, VALUE obj);
40
40
  VALUE rb_mod_deprecate_constant(int argc, const VALUE *argv, VALUE obj);
41
- void rb_free_const_table(st_table *tbl);
41
+ void rb_free_const_table(struct rb_id_table *tbl);
42
42
  VALUE rb_public_const_get(VALUE klass, ID id);
43
43
  VALUE rb_public_const_get_at(VALUE klass, ID id);
44
44
  VALUE rb_public_const_get_from(VALUE klass, ID id);
@@ -139,9 +139,11 @@ LONG WINAPI rb_w32_stack_overflow_handler(struct _EXCEPTION_POINTERS *);
139
139
  #if defined __GNUC__ && __GNUC__ == 4 && (__GNUC_MINOR__ >= 6 && __GNUC_MINOR__ <= 8)
140
140
  # define VAR_FROM_MEMORY(var) __extension__(*(__typeof__(var) volatile *)&(var))
141
141
  # define VAR_INITIALIZED(var) ((var) = VAR_FROM_MEMORY(var))
142
+ # define VAR_NOCLOBBERED(var) volatile var
142
143
  #else
143
144
  # define VAR_FROM_MEMORY(var) (var)
144
145
  # define VAR_INITIALIZED(var) ((void)&(var))
146
+ # define VAR_NOCLOBBERED(var) var
145
147
  #endif
146
148
 
147
149
  /* clear th->state, and return the value */
@@ -264,7 +266,7 @@ NORETURN(void rb_method_name_error(VALUE, VALUE));
264
266
 
265
267
  NORETURN(void rb_fiber_start(void));
266
268
 
267
- NORETURN(void rb_print_undef(VALUE, ID, int));
269
+ NORETURN(void rb_print_undef(VALUE, ID, rb_method_visibility_t));
268
270
  NORETURN(void rb_print_undef_str(VALUE, VALUE));
269
271
  NORETURN(void rb_print_inaccessible(VALUE, ID, rb_method_visibility_t));
270
272
  NORETURN(void rb_vm_localjump_error(const char *,VALUE, int));
@@ -278,7 +280,6 @@ rb_cref_t *rb_vm_cref_replace_with_duplicated_cref(void);
278
280
  VALUE rb_vm_call_cfunc(VALUE recv, VALUE (*func)(VALUE), VALUE arg, const rb_block_t *blockptr, VALUE filename);
279
281
  void rb_vm_set_progname(VALUE filename);
280
282
  void rb_thread_terminate_all(void);
281
- VALUE rb_vm_top_self();
282
283
  VALUE rb_vm_cbase(void);
283
284
 
284
285
  #ifndef CharNext /* defined as CharNext[AW] on Windows. */
@@ -118,6 +118,8 @@ enum ruby_method_ids {
118
118
  id_core_hash_merge_kwd,
119
119
  id_debug_created_info,
120
120
  tPRESERVED_ID_END,
121
+ tMax,
122
+ tMin,
121
123
  tFreeze,
122
124
  tInspect,
123
125
  tIntern,
@@ -160,8 +162,12 @@ enum ruby_method_ids {
160
162
  tMesg,
161
163
  tException,
162
164
  tUScore,
165
+ tLASTLINE,
166
+ tBACKREF,
163
167
  tNEXT_ID,
164
168
  #define TOKEN2LOCALID(n) id##n = ((t##n<<ID_SCOPE_SHIFT)|ID_LOCAL|ID_STATIC_SYM)
169
+ TOKEN2LOCALID(Max),
170
+ TOKEN2LOCALID(Min),
165
171
  TOKEN2LOCALID(Freeze),
166
172
  TOKEN2LOCALID(Inspect),
167
173
  TOKEN2LOCALID(Intern),
@@ -204,6 +210,9 @@ enum ruby_method_ids {
204
210
  TOKEN2LOCALID(Mesg),
205
211
  TOKEN2LOCALID(Exception),
206
212
  TOKEN2LOCALID(UScore),
213
+ #define TOKEN2GLOBALID(n) id##n = ((t##n<<ID_SCOPE_SHIFT)|ID_GLOBAL|ID_STATIC_SYM)
214
+ TOKEN2GLOBALID(LASTLINE),
215
+ TOKEN2GLOBALID(BACKREF),
207
216
  tLAST_OP_ID = tPRESERVED_ID_END-1,
208
217
  idLAST_OP_ID = tLAST_OP_ID >> ID_SCOPE_SHIFT
209
218
  };
@@ -60,51 +60,53 @@ enum ruby_vminsn_type {
60
60
  BIN(defineclass) = 43,
61
61
  BIN(send) = 44,
62
62
  BIN(opt_str_freeze) = 45,
63
- BIN(opt_send_without_block) = 46,
64
- BIN(invokesuper) = 47,
65
- BIN(invokeblock) = 48,
66
- BIN(leave) = 49,
67
- BIN(throw) = 50,
68
- BIN(jump) = 51,
69
- BIN(branchif) = 52,
70
- BIN(branchunless) = 53,
71
- BIN(branchnil) = 54,
72
- BIN(getinlinecache) = 55,
73
- BIN(setinlinecache) = 56,
74
- BIN(once) = 57,
75
- BIN(opt_case_dispatch) = 58,
76
- BIN(opt_plus) = 59,
77
- BIN(opt_minus) = 60,
78
- BIN(opt_mult) = 61,
79
- BIN(opt_div) = 62,
80
- BIN(opt_mod) = 63,
81
- BIN(opt_eq) = 64,
82
- BIN(opt_neq) = 65,
83
- BIN(opt_lt) = 66,
84
- BIN(opt_le) = 67,
85
- BIN(opt_gt) = 68,
86
- BIN(opt_ge) = 69,
87
- BIN(opt_ltlt) = 70,
88
- BIN(opt_aref) = 71,
89
- BIN(opt_aset) = 72,
90
- BIN(opt_aset_with) = 73,
91
- BIN(opt_aref_with) = 74,
92
- BIN(opt_length) = 75,
93
- BIN(opt_size) = 76,
94
- BIN(opt_empty_p) = 77,
95
- BIN(opt_succ) = 78,
96
- BIN(opt_not) = 79,
97
- BIN(opt_regexpmatch1) = 80,
98
- BIN(opt_regexpmatch2) = 81,
99
- BIN(opt_call_c_function) = 82,
100
- BIN(bitblt) = 83,
101
- BIN(answer) = 84,
102
- BIN(getlocal_OP__WC__0) = 85,
103
- BIN(getlocal_OP__WC__1) = 86,
104
- BIN(setlocal_OP__WC__0) = 87,
105
- BIN(setlocal_OP__WC__1) = 88,
106
- BIN(putobject_OP_INT2FIX_O_0_C_) = 89,
107
- BIN(putobject_OP_INT2FIX_O_1_C_) = 90,
108
- VM_INSTRUCTION_SIZE = 91
63
+ BIN(opt_newarray_max) = 46,
64
+ BIN(opt_newarray_min) = 47,
65
+ BIN(opt_send_without_block) = 48,
66
+ BIN(invokesuper) = 49,
67
+ BIN(invokeblock) = 50,
68
+ BIN(leave) = 51,
69
+ BIN(throw) = 52,
70
+ BIN(jump) = 53,
71
+ BIN(branchif) = 54,
72
+ BIN(branchunless) = 55,
73
+ BIN(branchnil) = 56,
74
+ BIN(getinlinecache) = 57,
75
+ BIN(setinlinecache) = 58,
76
+ BIN(once) = 59,
77
+ BIN(opt_case_dispatch) = 60,
78
+ BIN(opt_plus) = 61,
79
+ BIN(opt_minus) = 62,
80
+ BIN(opt_mult) = 63,
81
+ BIN(opt_div) = 64,
82
+ BIN(opt_mod) = 65,
83
+ BIN(opt_eq) = 66,
84
+ BIN(opt_neq) = 67,
85
+ BIN(opt_lt) = 68,
86
+ BIN(opt_le) = 69,
87
+ BIN(opt_gt) = 70,
88
+ BIN(opt_ge) = 71,
89
+ BIN(opt_ltlt) = 72,
90
+ BIN(opt_aref) = 73,
91
+ BIN(opt_aset) = 74,
92
+ BIN(opt_aset_with) = 75,
93
+ BIN(opt_aref_with) = 76,
94
+ BIN(opt_length) = 77,
95
+ BIN(opt_size) = 78,
96
+ BIN(opt_empty_p) = 79,
97
+ BIN(opt_succ) = 80,
98
+ BIN(opt_not) = 81,
99
+ BIN(opt_regexpmatch1) = 82,
100
+ BIN(opt_regexpmatch2) = 83,
101
+ BIN(opt_call_c_function) = 84,
102
+ BIN(bitblt) = 85,
103
+ BIN(answer) = 86,
104
+ BIN(getlocal_OP__WC__0) = 87,
105
+ BIN(getlocal_OP__WC__1) = 88,
106
+ BIN(setlocal_OP__WC__0) = 89,
107
+ BIN(setlocal_OP__WC__1) = 90,
108
+ BIN(putobject_OP_INT2FIX_O_0_C_) = 91,
109
+ BIN(putobject_OP_INT2FIX_O_1_C_) = 92,
110
+ VM_INSTRUCTION_SIZE = 93
109
111
  };
110
112
 
@@ -70,6 +70,8 @@ static const char *const insn_name_info[] = {
70
70
  "defineclass",
71
71
  "send",
72
72
  "opt_str_freeze",
73
+ "opt_newarray_max",
74
+ "opt_newarray_min",
73
75
  "opt_send_without_block",
74
76
  "invokesuper",
75
77
  "invokeblock",
@@ -165,6 +167,8 @@ static const char *const insn_operand_info[] = {
165
167
  "ISN",
166
168
  "CES",
167
169
  "V",
170
+ "N",
171
+ "N",
168
172
  "CE",
169
173
  "CES",
170
174
  "C",
@@ -260,6 +264,8 @@ static const int insn_len_info[] = {
260
264
  4,
261
265
  4,
262
266
  2,
267
+ 2,
268
+ 2,
263
269
  3,
264
270
  4,
265
271
  2,
@@ -361,6 +367,8 @@ static const int insn_stack_push_num_info[] = {
361
367
  1,
362
368
  1,
363
369
  1,
370
+ 1,
371
+ 1,
364
372
  0,
365
373
  0,
366
374
  0,
@@ -581,6 +589,18 @@ insn_stack_increase(int depth, int insn, VALUE *opes)
581
589
  case BIN(opt_str_freeze):{
582
590
  return depth + 1;
583
591
  }
592
+ case BIN(opt_newarray_max):{
593
+ int inc = 0;
594
+ int num = FIX2INT(opes[0]);
595
+ inc += 1 - num;;
596
+ return depth + inc;
597
+ }
598
+ case BIN(opt_newarray_min):{
599
+ int inc = 0;
600
+ int num = FIX2INT(opes[0]);
601
+ inc += 1 - num;;
602
+ return depth + inc;
603
+ }
584
604
  case BIN(opt_send_without_block):{
585
605
  int inc = 0;
586
606
  CALL_INFO ci = (CALL_INFO)(opes[0]);
@@ -23,31 +23,25 @@ extern "C" {
23
23
  #endif
24
24
  #endif
25
25
 
26
- /* likely */
27
- #if __GNUC__ >= 3
28
- #define LIKELY(x) (__builtin_expect(!!(x), 1))
29
- #define UNLIKELY(x) (__builtin_expect(!!(x), 0))
30
- #else /* __GNUC__ >= 3 */
31
- #define LIKELY(x) (x)
32
- #define UNLIKELY(x) (x)
33
- #endif /* __GNUC__ >= 3 */
26
+ #define LIKELY(x) RB_LIKELY(x)
27
+ #define UNLIKELY(x) RB_UNLIKELY(x)
34
28
 
35
29
  #ifndef __has_attribute
36
30
  # define __has_attribute(x) 0
37
31
  #endif
38
32
 
39
- #if __has_attribute(unused)
40
- #define UNINITIALIZED_VAR(x) x __attribute__((unused))
33
+ #if __has_attribute(__unused__)
34
+ #define UNINITIALIZED_VAR(x) x __attribute__((__unused__))
41
35
  #elif defined(__GNUC__) && __GNUC__ >= 3
42
36
  #define UNINITIALIZED_VAR(x) x = x
43
37
  #else
44
38
  #define UNINITIALIZED_VAR(x) x
45
39
  #endif
46
40
 
47
- #if __has_attribute(warn_unused_result)
48
- #define WARN_UNUSED_RESULT(x) x __attribute__((warn_unused_result))
49
- #elif defined(__GNUC__) && (__GNUC__ * 1000 + __GNUC_MINOR__) >= 3004
50
- #define WARN_UNUSED_RESULT(x) x __attribute__((warn_unused_result))
41
+ #if __has_attribute(__warn_unused_result__)
42
+ #define WARN_UNUSED_RESULT(x) x __attribute__((__warn_unused_result__))
43
+ #elif GCC_VERSION_SINCE(3,4,0)
44
+ #define WARN_UNUSED_RESULT(x) x __attribute__((__warn_unused_result__))
51
45
  #else
52
46
  #define WARN_UNUSED_RESULT(x) x
53
47
  #endif
@@ -67,12 +61,6 @@ extern "C" {
67
61
 
68
62
  #define numberof(array) ((int)(sizeof(array) / sizeof((array)[0])))
69
63
 
70
- #define GCC_VERSION_SINCE(major, minor, patchlevel) \
71
- (defined(__GNUC__) && !defined(__INTEL_COMPILER) && \
72
- ((__GNUC__ > (major)) || \
73
- (__GNUC__ == (major) && __GNUC_MINOR__ > (minor)) || \
74
- (__GNUC__ == (major) && __GNUC_MINOR__ == (minor) && __GNUC_PATCHLEVEL__ >= (patchlevel))))
75
-
76
64
  #ifndef __has_feature
77
65
  # define __has_feature(x) 0
78
66
  #endif
@@ -266,6 +254,156 @@ nlz_int128(uint128_t x)
266
254
  }
267
255
  #endif
268
256
 
257
+ static inline int
258
+ nlz_intptr(uintptr_t x) {
259
+ #if SIZEOF_VOIDP == 8
260
+ return nlz_long_long(x);
261
+ #elif SIZEOF_VOIDP == 4
262
+ return nlz_int(x);
263
+ #endif
264
+ }
265
+
266
+ static inline int
267
+ rb_popcount32(uint32_t x) {
268
+ #ifdef HAVE_BUILTIN___BUILTIN_POPCOUNT
269
+ return __builtin_popcount(x);
270
+ #else
271
+ x = (x & 0x55555555) + (x >> 1 & 0x55555555);
272
+ x = (x & 0x33333333) + (x >> 2 & 0x33333333);
273
+ x = (x & 0x0f0f0f0f) + (x >> 4 & 0x0f0f0f0f);
274
+ x = (x & 0x001f001f) + (x >> 8 & 0x001f001f);
275
+ return (x & 0x0000003f) + (x >>16 & 0x0000003f);
276
+ #endif
277
+ }
278
+
279
+ static inline int
280
+ rb_popcount64(uint64_t x) {
281
+ #ifdef HAVE_BUILTIN___BUILTIN_POPCOUNT
282
+ return __builtin_popcountll(x);
283
+ #else
284
+ x = (x & 0x5555555555555555) + (x >> 1 & 0x5555555555555555);
285
+ x = (x & 0x3333333333333333) + (x >> 2 & 0x3333333333333333);
286
+ x = (x & 0x0707070707070707) + (x >> 4 & 0x0707070707070707);
287
+ x = (x & 0x001f001f001f001f) + (x >> 8 & 0x001f001f001f001f);
288
+ x = (x & 0x0000003f0000003f) + (x >>16 & 0x0000003f0000003f);
289
+ return (x & 0x7f) + (x >>32 & 0x7f);
290
+ #endif
291
+ }
292
+
293
+ static inline int
294
+ rb_popcount_intptr(uintptr_t x) {
295
+ #if SIZEOF_VOIDP == 8
296
+ return rb_popcount64(x);
297
+ #elif SIZEOF_VOIDP == 4
298
+ return rb_popcount32(x);
299
+ #endif
300
+ }
301
+
302
+ static inline int
303
+ ntz_int32(uint32_t x) {
304
+ #ifdef HAVE_BUILTIN___BUILTIN_CTZ
305
+ return __builtin_ctz(x);
306
+ #else
307
+ return rb_popcount32((~x) & (x-1));
308
+ #endif
309
+ }
310
+
311
+ static inline int
312
+ ntz_int64(uint64_t x) {
313
+ #ifdef HAVE_BUILTIN___BUILTIN_CTZLL
314
+ return __builtin_ctzll(x);
315
+ #else
316
+ return rb_popcount64((~x) & (x-1));
317
+ #endif
318
+ }
319
+
320
+ static inline int
321
+ ntz_intptr(uintptr_t x) {
322
+ #if SIZEOF_VOIDP == 8
323
+ return ntz_int64(x);
324
+ #elif SIZEOF_VOIDP == 4
325
+ return ntz_int32(x);
326
+ #endif
327
+ }
328
+
329
+ #if HAVE_LONG_LONG && SIZEOF_LONG * 2 <= SIZEOF_LONG_LONG
330
+ # define DLONG LONG_LONG
331
+ # define DL2NUM(x) LL2NUM(x)
332
+ #elif defined(HAVE_INT128_T)
333
+ # define DLONG int128_t
334
+ # define DL2NUM(x) (RB_FIXABLE(x) ? LONG2FIX(x) : rb_int128t2big(x))
335
+ VALUE rb_int128t2big(int128_t n);
336
+ #endif
337
+
338
+ /* arguments must be Fixnum */
339
+ static inline VALUE
340
+ rb_fix_mul_fix(VALUE x, VALUE y)
341
+ {
342
+ long lx = FIX2LONG(x);
343
+ long ly = FIX2LONG(y);
344
+ #ifdef DLONG
345
+ return DL2NUM((DLONG)lx * (DLONG)ly);
346
+ #else
347
+ if (MUL_OVERFLOW_FIXNUM_P(lx, ly)) {
348
+ return rb_big_mul(rb_int2big(lx), rb_int2big(ly));
349
+ }
350
+ else {
351
+ return LONG2FIX(lx * ly);
352
+ }
353
+ #endif
354
+ }
355
+
356
+ /*
357
+ * This behaves different from C99 for negative arguments.
358
+ * Note that div may overflow fixnum.
359
+ */
360
+ static inline void
361
+ rb_fix_divmod_fix(VALUE a, VALUE b, VALUE *divp, VALUE *modp)
362
+ {
363
+ /* assume / and % comply C99.
364
+ * ldiv(3) won't be inlined by GCC and clang.
365
+ * I expect / and % are compiled as single idiv.
366
+ */
367
+ long x = FIX2LONG(a);
368
+ long y = FIX2LONG(b);
369
+ long div, mod;
370
+ if (x == FIXNUM_MIN && y == -1) {
371
+ if (divp) *divp = LONG2NUM(-FIXNUM_MIN);
372
+ if (modp) *modp = LONG2FIX(0);
373
+ return;
374
+ }
375
+ div = x / y;
376
+ mod = x % y;
377
+ if (y > 0 ? mod < 0 : mod > 0) {
378
+ mod += y;
379
+ div -= 1;
380
+ }
381
+ if (divp) *divp = LONG2FIX(div);
382
+ if (modp) *modp = LONG2FIX(mod);
383
+ }
384
+
385
+ /* div() for Ruby
386
+ * This behaves different from C99 for negative arguments.
387
+ */
388
+ static inline VALUE
389
+ rb_fix_div_fix(VALUE x, VALUE y)
390
+ {
391
+ VALUE div;
392
+ rb_fix_divmod_fix(x, y, &div, NULL);
393
+ return div;
394
+ }
395
+
396
+ /* mod() for Ruby
397
+ * This behaves different from C99 for negative arguments.
398
+ */
399
+ static inline VALUE
400
+ rb_fix_mod_fix(VALUE x, VALUE y)
401
+ {
402
+ VALUE mod;
403
+ rb_fix_divmod_fix(x, y, NULL, &mod);
404
+ return mod;
405
+ }
406
+
269
407
  #if defined(HAVE_UINT128_T)
270
408
  # define bit_length(x) \
271
409
  (sizeof(x) <= SIZEOF_INT ? SIZEOF_INT * CHAR_BIT - nlz_int((unsigned int)(x)) : \
@@ -364,6 +502,7 @@ struct RBignum {
364
502
  : (RBASIC(b)->flags &= ~BIGNUM_SIGN_BIT))
365
503
  #define BIGNUM_POSITIVE_P(b) BIGNUM_SIGN(b)
366
504
  #define BIGNUM_NEGATIVE_P(b) (!BIGNUM_SIGN(b))
505
+ #define BIGNUM_NEGATE(b) (RBASIC(b)->flags ^= BIGNUM_SIGN_BIT)
367
506
 
368
507
  #define BIGNUM_EMBED_FLAG FL_USER2
369
508
  #define BIGNUM_EMBED_LEN_MASK (FL_USER5|FL_USER4|FL_USER3)
@@ -389,6 +528,8 @@ struct RRational {
389
528
  };
390
529
 
391
530
  #define RRATIONAL(obj) (R_CAST(RRational)(obj))
531
+ #define RRATIONAL_SET_NUM(rat, n) RB_OBJ_WRITE((rat), &((struct RRational *)(rat))->num,(n))
532
+ #define RRATIONAL_SET_DEN(rat, d) RB_OBJ_WRITE((rat), &((struct RRational *)(rat))->den,(d))
392
533
 
393
534
  struct RFloat {
394
535
  struct RBasic basic;
@@ -407,7 +548,7 @@ struct RComplex {
407
548
 
408
549
  #ifdef RCOMPLEX_SET_REAL /* shortcut macro for internal only */
409
550
  #undef RCOMPLEX_SET_REAL
410
- #undef RCOMPLEX_SET_REAL
551
+ #undef RCOMPLEX_SET_IMAG
411
552
  #define RCOMPLEX_SET_REAL(cmp, r) RB_OBJ_WRITE((cmp), &((struct RComplex *)(cmp))->real,(r))
412
553
  #define RCOMPLEX_SET_IMAG(cmp, i) RB_OBJ_WRITE((cmp), &((struct RComplex *)(cmp))->imag,(i))
413
554
  #endif
@@ -463,7 +604,7 @@ typedef unsigned long rb_serial_t;
463
604
  struct rb_classext_struct {
464
605
  struct st_table *iv_index_tbl;
465
606
  struct st_table *iv_tbl;
466
- struct st_table *const_tbl;
607
+ struct rb_id_table *const_tbl;
467
608
  struct rb_id_table *callable_m_tbl;
468
609
  rb_subclass_entry_t *subclasses;
469
610
  rb_subclass_entry_t **parent_subclasses;
@@ -491,6 +632,7 @@ struct RClass {
491
632
 
492
633
  void rb_class_subclass_add(VALUE super, VALUE klass);
493
634
  void rb_class_remove_from_super_subclasses(VALUE);
635
+ int rb_singleton_class_internal_p(VALUE sklass);
494
636
 
495
637
  #define RCLASS_EXT(c) (RCLASS(c)->ptr)
496
638
  #define RCLASS_IV_TBL(c) (RCLASS_EXT(c)->iv_tbl)
@@ -631,6 +773,45 @@ struct MEMO {
631
773
  #define MEMO_FOR(type, value) ((type *)RARRAY_PTR(value))
632
774
  #define NEW_MEMO_FOR(type, value) \
633
775
  ((value) = rb_ary_tmp_new_fill(type_roomof(type, VALUE)), MEMO_FOR(type, value))
776
+ #define NEW_PARTIAL_MEMO_FOR(type, value, member) \
777
+ ((value) = rb_ary_tmp_new_fill(type_roomof(type, VALUE)), \
778
+ rb_ary_set_len((value), offsetof(type, member) / sizeof(VALUE)), \
779
+ MEMO_FOR(type, value))
780
+
781
+ #define STRING_P(s) (RB_TYPE_P((s), T_STRING) && CLASS_OF(s) == rb_cString)
782
+
783
+ #ifdef RUBY_INTEGER_UNIFICATION
784
+ # define rb_cFixnum rb_cInteger
785
+ # define rb_cBignum rb_cInteger
786
+ #endif
787
+
788
+ enum {
789
+ cmp_opt_Fixnum,
790
+ cmp_opt_String,
791
+ cmp_optimizable_count
792
+ };
793
+
794
+ struct cmp_opt_data {
795
+ int opt_methods;
796
+ int opt_inited;
797
+ };
798
+
799
+ #define NEW_CMP_OPT_MEMO(type, value) \
800
+ NEW_PARTIAL_MEMO_FOR(type, value, cmp_opt)
801
+ #define CMP_OPTIMIZABLE_BIT(type) (1U << TOKEN_PASTE(cmp_opt_,type))
802
+ #define CMP_OPTIMIZABLE(data, type) \
803
+ (((data).opt_inited & CMP_OPTIMIZABLE_BIT(type)) ? \
804
+ ((data).opt_methods & CMP_OPTIMIZABLE_BIT(type)) : \
805
+ (((data).opt_inited |= CMP_OPTIMIZABLE_BIT(type)), \
806
+ rb_method_basic_definition_p(TOKEN_PASTE(rb_c,type), id_cmp) && \
807
+ ((data).opt_methods |= CMP_OPTIMIZABLE_BIT(type))))
808
+
809
+ #define OPTIMIZED_CMP(a, b, data) \
810
+ ((FIXNUM_P(a) && FIXNUM_P(b) && CMP_OPTIMIZABLE(data, Fixnum)) ? \
811
+ (((long)a > (long)b) ? 1 : ((long)a < (long)b) ? -1 : 0) : \
812
+ (STRING_P(a) && STRING_P(b) && CMP_OPTIMIZABLE(data, String)) ? \
813
+ rb_str_cmp(a, b) : \
814
+ rb_cmpint(rb_funcallv(a, id_cmp, 1, &b), a, b))
634
815
 
635
816
  /* ment is in method.h */
636
817
 
@@ -670,10 +851,29 @@ size_t rb_ary_memsize(VALUE);
670
851
  extern const char ruby_digitmap[];
671
852
  VALUE rb_big_fdiv(VALUE x, VALUE y);
672
853
  VALUE rb_big_uminus(VALUE x);
854
+ VALUE rb_big_hash(VALUE);
855
+ VALUE rb_big_odd_p(VALUE);
856
+ VALUE rb_big_even_p(VALUE);
857
+ size_t rb_big_size(VALUE);
673
858
  VALUE rb_integer_float_cmp(VALUE x, VALUE y);
674
859
  VALUE rb_integer_float_eq(VALUE x, VALUE y);
860
+ VALUE rb_cstr_parse_inum(const char *str, ssize_t len, char **endp, int base);
861
+ VALUE rb_big_comp(VALUE x);
862
+ VALUE rb_big_aref(VALUE x, VALUE y);
863
+ VALUE rb_big_abs(VALUE x);
864
+ VALUE rb_big_size_m(VALUE big);
865
+ VALUE rb_big_bit_length(VALUE big);
866
+ VALUE rb_big_remainder(VALUE x, VALUE y);
867
+ VALUE rb_big_gt(VALUE x, VALUE y);
868
+ VALUE rb_big_ge(VALUE x, VALUE y);
869
+ VALUE rb_big_lt(VALUE x, VALUE y);
870
+ VALUE rb_big_le(VALUE x, VALUE y);
675
871
 
676
872
  /* class.c */
873
+ VALUE rb_class_boot(VALUE);
874
+ VALUE rb_class_inherited(VALUE, VALUE);
875
+ VALUE rb_make_metaclass(VALUE, VALUE);
876
+ VALUE rb_include_class_new(VALUE, VALUE);
677
877
  void rb_class_foreach_subclass(VALUE klass, void (*f)(VALUE, VALUE), VALUE);
678
878
  void rb_class_detach_subclasses(VALUE);
679
879
  void rb_class_detach_module_subclasses(VALUE);
@@ -694,13 +894,16 @@ int rb_class_has_methods(VALUE c);
694
894
  VALUE rb_invcmp(VALUE, VALUE);
695
895
 
696
896
  /* compile.c */
697
- int rb_dvar_defined(ID);
698
- int rb_local_defined(ID);
699
- int rb_parse_in_eval(void);
700
- int rb_parse_in_main(void);
701
- const char * rb_insns_name(int i);
897
+ struct rb_block_struct;
898
+ int rb_dvar_defined(ID, const struct rb_block_struct *);
899
+ int rb_local_defined(ID, const struct rb_block_struct *);
900
+ CONSTFUNC(const char * rb_insns_name(int i));
702
901
  VALUE rb_insns_name_array(void);
703
902
 
903
+ /* complex.c */
904
+ VALUE rb_nucomp_add(VALUE, VALUE);
905
+ VALUE rb_nucomp_mul(VALUE, VALUE);
906
+
704
907
  /* cont.c */
705
908
  VALUE rb_obj_is_fiber(VALUE);
706
909
  void rb_fiber_reset_root_local_storage(VALUE);
@@ -715,7 +918,7 @@ void Init_ext(void);
715
918
 
716
919
  /* encoding.c */
717
920
  ID rb_id_encoding(void);
718
- void rb_gc_mark_encodings(void);
921
+ CONSTFUNC(void rb_gc_mark_encodings(void));
719
922
  rb_encoding *rb_enc_get_from_index(int index);
720
923
  rb_encoding *rb_enc_check_str(VALUE str1, VALUE str2);
721
924
  int rb_encdb_replicate(const char *alias, const char *orig);
@@ -725,16 +928,19 @@ void rb_encdb_declare(const char *name);
725
928
  void rb_enc_set_base(const char *name, const char *orig);
726
929
  int rb_enc_set_dummy(int index);
727
930
  void rb_encdb_set_unicode(int index);
728
- int rb_data_is_encoding(VALUE obj);
931
+ PUREFUNC(int rb_data_is_encoding(VALUE obj));
729
932
 
730
933
  /* enum.c */
731
934
  VALUE rb_f_send(int argc, VALUE *argv, VALUE recv);
935
+ VALUE rb_nmin_run(VALUE obj, VALUE num, int by, int rev, int ary);
732
936
 
733
937
  /* error.c */
734
938
  extern VALUE rb_eEAGAIN;
735
939
  extern VALUE rb_eEWOULDBLOCK;
736
940
  extern VALUE rb_eEINPROGRESS;
737
- NORETURN(PRINTF_ARGS(void rb_compile_bug(const char*, int, const char*, ...), 3, 4));
941
+ void rb_report_bug_valist(VALUE file, int line, const char *fmt, va_list args);
942
+ PRINTF_ARGS(void rb_compile_error_str(VALUE file, int line, void *enc, const char *fmt, ...), 4, 5);
943
+ VALUE rb_syntax_error_append(VALUE, VALUE, int, int, rb_encoding*, const char*, va_list);
738
944
  VALUE rb_check_backtrace(VALUE);
739
945
  NORETURN(void rb_async_bug_errno(const char *,int));
740
946
  const char *rb_builtin_type_name(int t);
@@ -747,6 +953,8 @@ VALUE rb_name_err_new(VALUE mesg, VALUE recv, VALUE method);
747
953
  rb_exc_raise(rb_name_err_new(mesg, recv, name))
748
954
  #define rb_name_err_raise(mesg, recv, name) \
749
955
  rb_name_err_raise_str(rb_fstring_cstr(mesg), (recv), (name))
956
+ NORETURN(void ruby_only_for_internal_use(const char *));
957
+ #define ONLY_FOR_INTERNAL_USE(func) ruby_only_for_internal_use(func)
750
958
 
751
959
  /* eval.c */
752
960
  VALUE rb_refinement_module_get_refined_class(VALUE module);
@@ -838,6 +1046,7 @@ st_table *rb_init_identtable_with_size(st_index_t size);
838
1046
  #define RHASH_TBL_RAW(h) rb_hash_tbl_raw(h)
839
1047
  VALUE rb_hash_keys(VALUE hash);
840
1048
  VALUE rb_hash_values(VALUE hash);
1049
+ VALUE rb_hash_rehash(VALUE hash);
841
1050
  #define HASH_DELETED FL_USER1
842
1051
  #define HASH_PROC_DEFAULT FL_USER2
843
1052
 
@@ -849,7 +1058,6 @@ const char *ruby_get_inplace_mode(void);
849
1058
  void ruby_set_inplace_mode(const char *);
850
1059
  ssize_t rb_io_bufread(VALUE io, void *buf, size_t size);
851
1060
  void rb_stdio_set_default_encoding(void);
852
- void rb_write_error_str(VALUE mesg);
853
1061
  VALUE rb_io_flush_raw(VALUE, int);
854
1062
  size_t rb_io_memsize(const rb_io_t *);
855
1063
 
@@ -890,7 +1098,17 @@ double ruby_float_mod(double x, double y);
890
1098
  int rb_num_negative_p(VALUE);
891
1099
  VALUE rb_int_succ(VALUE num);
892
1100
  VALUE rb_int_pred(VALUE num);
1101
+ VALUE rb_int_uminus(VALUE num);
1102
+ VALUE rb_int_plus(VALUE x, VALUE y);
1103
+ VALUE rb_int_minus(VALUE x, VALUE y);
1104
+ VALUE rb_int_mul(VALUE x, VALUE y);
1105
+ VALUE rb_int_idiv(VALUE x, VALUE y);
1106
+ VALUE rb_int_modulo(VALUE x, VALUE y);
1107
+ VALUE rb_int_round(VALUE num, int ndigits);
1108
+ VALUE rb_int2str(VALUE num, int base);
893
1109
  VALUE rb_dbl_hash(double d);
1110
+ VALUE rb_fix_plus(VALUE x, VALUE y);
1111
+ VALUE rb_int_ge(VALUE x, VALUE y);
894
1112
 
895
1113
  #if USE_FLONUM
896
1114
  #define RUBY_BIT_ROTL(v, n) (((v) << (n)) | ((v) >> ((sizeof(v) * 8) - n)))
@@ -968,7 +1186,8 @@ rb_float_new_inline(double d)
968
1186
 
969
1187
  /* object.c */
970
1188
  void rb_obj_copy_ivar(VALUE dest, VALUE obj);
971
- VALUE rb_obj_equal(VALUE obj1, VALUE obj2);
1189
+ CONSTFUNC(VALUE rb_obj_equal(VALUE obj1, VALUE obj2));
1190
+ CONSTFUNC(VALUE rb_obj_not(VALUE obj));
972
1191
  VALUE rb_class_search_ancestor(VALUE klass, VALUE super);
973
1192
  NORETURN(void rb_undefined_alloc(VALUE klass));
974
1193
  double rb_num_to_dbl(VALUE val);
@@ -992,6 +1211,8 @@ struct RBasicRaw {
992
1211
  #endif
993
1212
  VALUE rb_parser_get_yydebug(VALUE);
994
1213
  VALUE rb_parser_set_yydebug(VALUE, VALUE);
1214
+ VALUE rb_parser_set_context(VALUE, const struct rb_block_struct *, int);
1215
+ void *rb_parser_load_file(VALUE parser, VALUE name);
995
1216
  int rb_is_const_name(VALUE name);
996
1217
  int rb_is_class_name(VALUE name);
997
1218
  int rb_is_global_name(VALUE name);
@@ -1000,14 +1221,14 @@ int rb_is_attrset_name(VALUE name);
1000
1221
  int rb_is_local_name(VALUE name);
1001
1222
  int rb_is_method_name(VALUE name);
1002
1223
  int rb_is_junk_name(VALUE name);
1003
- int rb_is_const_sym(VALUE sym);
1004
- int rb_is_class_sym(VALUE sym);
1005
- int rb_is_global_sym(VALUE sym);
1006
- int rb_is_instance_sym(VALUE sym);
1007
- int rb_is_attrset_sym(VALUE sym);
1008
- int rb_is_local_sym(VALUE sym);
1009
- int rb_is_method_sym(VALUE sym);
1010
- int rb_is_junk_sym(VALUE sym);
1224
+ PUREFUNC(int rb_is_const_sym(VALUE sym));
1225
+ PUREFUNC(int rb_is_class_sym(VALUE sym));
1226
+ PUREFUNC(int rb_is_global_sym(VALUE sym));
1227
+ PUREFUNC(int rb_is_instance_sym(VALUE sym));
1228
+ PUREFUNC(int rb_is_attrset_sym(VALUE sym));
1229
+ PUREFUNC(int rb_is_local_sym(VALUE sym));
1230
+ PUREFUNC(int rb_is_method_sym(VALUE sym));
1231
+ PUREFUNC(int rb_is_junk_sym(VALUE sym));
1011
1232
  ID rb_make_internal_id(void);
1012
1233
  void rb_gc_free_dsymbol(VALUE);
1013
1234
  ID rb_id_attrget(ID id);
@@ -1075,6 +1296,7 @@ rb_pid_t rb_fork_ruby(int *status);
1075
1296
  void rb_last_status_clear(void);
1076
1297
 
1077
1298
  /* rational.c */
1299
+ VALUE rb_rational_plus(VALUE self, VALUE other);
1078
1300
  VALUE rb_lcm(VALUE x, VALUE y);
1079
1301
  VALUE rb_rational_reciprocal(VALUE x);
1080
1302
  VALUE rb_cstr_to_rat(const char *, int);
@@ -1084,6 +1306,8 @@ VALUE rb_reg_compile(VALUE str, int options, const char *sourcefile, int sourcel
1084
1306
  VALUE rb_reg_check_preprocess(VALUE);
1085
1307
  long rb_reg_search0(VALUE, VALUE, long, int, int);
1086
1308
  void rb_backref_set_string(VALUE string, long pos, long len);
1309
+ int rb_match_count(VALUE match);
1310
+ int rb_match_nth_defined(int nth, VALUE match);
1087
1311
 
1088
1312
  /* signal.c */
1089
1313
  extern int ruby_enable_coredump;
@@ -1092,10 +1316,10 @@ int rb_sigaltstack_size(void);
1092
1316
 
1093
1317
  /* strftime.c */
1094
1318
  #ifdef RUBY_ENCODING_H
1095
- size_t rb_strftime_timespec(char *s, size_t maxsize, const char *format, rb_encoding *enc,
1096
- const struct vtm *vtm, struct timespec *ts, int gmt);
1097
- size_t rb_strftime(char *s, size_t maxsize, const char *format, rb_encoding *enc,
1098
- const struct vtm *vtm, VALUE timev, int gmt);
1319
+ VALUE rb_strftime_timespec(const char *format, size_t format_len, rb_encoding *enc,
1320
+ const struct vtm *vtm, struct timespec *ts, int gmt);
1321
+ VALUE rb_strftime(const char *format, size_t format_len, rb_encoding *enc,
1322
+ const struct vtm *vtm, VALUE timev, int gmt);
1099
1323
  #endif
1100
1324
 
1101
1325
  /* string.c */
@@ -1105,13 +1329,25 @@ VALUE rb_fstring_new(const char *ptr, long len);
1105
1329
  #define rb_fstring_lit(str) rb_fstring_new((str), rb_strlen_lit(str))
1106
1330
  #define rb_fstring_literal(str) rb_fstring_lit(str)
1107
1331
  VALUE rb_fstring_cstr(const char *str);
1108
- #if defined(__GNUC__) && !defined(__PCC__)
1109
- #define rb_fstring_cstr(str) __extension__ ( \
1110
- { \
1332
+ #ifdef HAVE_BUILTIN___BUILTIN_CONSTANT_P
1333
+ # define rb_fstring_cstr(str) RB_GNUC_EXTENSION_BLOCK( \
1111
1334
  (__builtin_constant_p(str)) ? \
1112
1335
  rb_fstring_new((str), (long)strlen(str)) : \
1113
- rb_fstring_cstr(str); \
1114
- })
1336
+ rb_fstring_cstr(str) \
1337
+ )
1338
+ #endif
1339
+ #ifdef RUBY_ENCODING_H
1340
+ VALUE rb_fstring_enc_new(const char *ptr, long len, rb_encoding *enc);
1341
+ #define rb_fstring_enc_lit(str, enc) rb_fstring_enc_new((str), rb_strlen_lit(str), (enc))
1342
+ #define rb_fstring_enc_literal(str, enc) rb_fstring_enc_lit(str, enc)
1343
+ VALUE rb_fstring_enc_cstr(const char *ptr, rb_encoding *enc);
1344
+ # ifdef HAVE_BUILTIN___BUILTIN_CONSTANT_P
1345
+ # define rb_fstring_enc_cstr(str, enc) RB_GNUC_EXTENSION_BLOCK( \
1346
+ (__builtin_constant_p(str)) ? \
1347
+ rb_fstring_enc_new((str), (long)strlen(str), (enc)) : \
1348
+ rb_fstring_enc_cstr(str, enc) \
1349
+ )
1350
+ # endif
1115
1351
  #endif
1116
1352
  int rb_str_buf_cat_escaped_char(VALUE result, unsigned int c, int unicode_p);
1117
1353
  int rb_str_symname_p(VALUE);
@@ -1119,12 +1355,13 @@ VALUE rb_str_quote_unprintable(VALUE);
1119
1355
  VALUE rb_id_quote_unprintable(ID);
1120
1356
  #define QUOTE(str) rb_str_quote_unprintable(str)
1121
1357
  #define QUOTE_ID(id) rb_id_quote_unprintable(id)
1122
- void rb_str_fill_terminator(VALUE str, const int termlen);
1358
+ char *rb_str_fill_terminator(VALUE str, const int termlen);
1123
1359
  VALUE rb_str_locktmp_ensure(VALUE str, VALUE (*func)(VALUE), VALUE arg);
1124
1360
  #ifdef RUBY_ENCODING_H
1125
1361
  VALUE rb_external_str_with_enc(VALUE str, rb_encoding *eenc);
1126
1362
  VALUE rb_str_cat_conv_enc_opts(VALUE newstr, long ofs, const char *ptr, long len,
1127
1363
  rb_encoding *from, int ecflags, VALUE ecopts);
1364
+ VALUE rb_enc_str_scrub(rb_encoding *enc, VALUE str, VALUE repl);
1128
1365
  #endif
1129
1366
  #define STR_NOEMBED FL_USER1
1130
1367
  #define STR_SHARED FL_USER2 /* = ELTS_SHARED */
@@ -1202,6 +1439,7 @@ char *ruby_hdtoa(double d, const char *xdigs, int ndigits, int *decpt, int *sign
1202
1439
  extern rb_encoding OnigEncodingUTF_8;
1203
1440
 
1204
1441
  /* variable.c */
1442
+ void rb_gc_mark_global_tbl(void);
1205
1443
  size_t rb_generic_ivar_memsize(VALUE);
1206
1444
  VALUE rb_search_class_path(VALUE);
1207
1445
  VALUE rb_attr_delete(VALUE, ID);
@@ -1219,7 +1457,7 @@ VALUE rb_obj_is_thread(VALUE obj);
1219
1457
  void rb_vm_mark(void *ptr);
1220
1458
  void Init_BareVM(void);
1221
1459
  void Init_vm_objects(void);
1222
- VALUE rb_vm_top_self(void);
1460
+ PUREFUNC(VALUE rb_vm_top_self(void));
1223
1461
  void rb_thread_recycle_stack_release(VALUE *);
1224
1462
  void rb_vm_change_state(void);
1225
1463
  void rb_vm_inc_const_missing_count(void);
@@ -1233,6 +1471,8 @@ int rb_vm_add_root_module(ID id, VALUE module);
1233
1471
  void rb_vm_check_redefinition_by_prepend(VALUE klass);
1234
1472
  VALUE rb_yield_refine_block(VALUE refinement, VALUE refinements);
1235
1473
  VALUE ruby_vm_sysstack_error_copy(void);
1474
+ PUREFUNC(st_table *rb_vm_fstring_table(void));
1475
+
1236
1476
 
1237
1477
  /* vm_dump.c */
1238
1478
  void rb_print_backtrace(void);
@@ -1314,6 +1554,7 @@ VALUE rb_ident_hash_new(void);
1314
1554
  /* io.c (export) */
1315
1555
  void rb_maygvl_fd_fix_cloexec(int fd);
1316
1556
  int rb_gc_for_fd(int err);
1557
+ void rb_write_error_str(VALUE mesg);
1317
1558
 
1318
1559
  /* numeric.c (export) */
1319
1560
  VALUE rb_int_positive_pow(long x, unsigned long y);
@@ -1352,7 +1593,6 @@ extern const char ruby_hexdigits[];
1352
1593
  extern unsigned long ruby_scan_digits(const char *str, ssize_t len, int base, size_t *retlen, int *overflow);
1353
1594
 
1354
1595
  /* variable.c (export) */
1355
- void rb_gc_mark_global_tbl(void);
1356
1596
  void rb_mark_generic_ivar(VALUE);
1357
1597
  VALUE rb_const_missing(VALUE klass, VALUE name);
1358
1598
  int rb_class_ivar_set(VALUE klass, ID vid, VALUE value);