datadog-ruby_core_source 3.4.2 → 3.5.0

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.
Files changed (113) hide show
  1. checksums.yaml +4 -4
  2. data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/id.h +10 -5
  3. data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/id_table.h +15 -0
  4. data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/internal/array.h +2 -0
  5. data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/internal/basic_operators.h +1 -0
  6. data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/internal/bignum.h +22 -10
  7. data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/internal/bits.h +14 -17
  8. data/lib/datadog/ruby_core_source/ruby-4.0.0-p0/internal/box.h +83 -0
  9. data/lib/datadog/ruby_core_source/ruby-4.0.0-p0/internal/class.h +806 -0
  10. data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/internal/cmdlineopt.h +3 -0
  11. data/lib/datadog/ruby_core_source/ruby-4.0.0-p0/internal/concurrent_set.h +21 -0
  12. data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/internal/cont.h +0 -1
  13. data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/internal/encoding.h +2 -1
  14. data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/internal/error.h +7 -0
  15. data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/internal/eval.h +10 -0
  16. data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/internal/gc.h +32 -5
  17. data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/internal/hash.h +1 -0
  18. data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/internal/imemo.h +87 -22
  19. data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/internal/inits.h +4 -0
  20. data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/internal/io.h +25 -5
  21. data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/internal/load.h +2 -0
  22. data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/internal/numeric.h +49 -0
  23. data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/internal/object.h +1 -1
  24. data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/internal/re.h +5 -0
  25. data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/internal/sanitizers.h +16 -0
  26. data/lib/datadog/ruby_core_source/ruby-4.0.0-p0/internal/set_table.h +70 -0
  27. data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/internal/signal.h +1 -0
  28. data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/internal/st.h +1 -1
  29. data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/internal/string.h +4 -0
  30. data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/internal/struct.h +41 -0
  31. data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/internal/symbol.h +4 -5
  32. data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/internal/thread.h +15 -11
  33. data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/internal/time.h +2 -5
  34. data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/internal/variable.h +13 -9
  35. data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/internal/vm.h +5 -4
  36. data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/internal.h +0 -3
  37. data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/iseq.h +10 -2
  38. data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/method.h +21 -3
  39. data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/prism/ast.h +360 -70
  40. data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/prism/diagnostic.h +7 -0
  41. data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/prism/extension.h +1 -1
  42. data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/prism/options.h +49 -3
  43. data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/prism/parser.h +3 -0
  44. data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/prism/prism.h +40 -15
  45. data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/prism/regexp.h +2 -2
  46. data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/prism/util/pm_buffer.h +8 -0
  47. data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/prism/util/pm_integer.h +4 -0
  48. data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/prism/util/pm_list.h +6 -0
  49. data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/prism/util/pm_string.h +12 -2
  50. data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/prism/version.h +2 -2
  51. data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/prism_compile.h +1 -0
  52. data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/ractor_core.h +63 -114
  53. data/lib/datadog/ruby_core_source/ruby-4.0.0-p0/ruby_atomic.h +73 -0
  54. data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/rubyparser.h +15 -2
  55. data/lib/datadog/ruby_core_source/ruby-4.0.0-p0/shape.h +464 -0
  56. data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/thread_pthread.h +13 -3
  57. data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/vm_core.h +228 -57
  58. data/lib/datadog/ruby_core_source/version.rb +1 -1
  59. metadata +108 -106
  60. data/CHANGELOG.datadog.md +0 -19
  61. data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/internal/class.h +0 -283
  62. data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/ruby_atomic.h +0 -23
  63. data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/shape.h +0 -234
  64. data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/ccan/build_assert/build_assert.h +0 -0
  65. data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/ccan/check_type/check_type.h +0 -0
  66. data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/ccan/container_of/container_of.h +0 -0
  67. data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/ccan/list/list.h +0 -0
  68. data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/ccan/str/str.h +0 -0
  69. data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/internal/compar.h +0 -0
  70. data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/internal/compile.h +0 -0
  71. data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/internal/compilers.h +0 -0
  72. data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/internal/complex.h +0 -0
  73. data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/internal/dir.h +0 -0
  74. data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/internal/enc.h +0 -0
  75. data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/internal/enum.h +0 -0
  76. data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/internal/enumerator.h +0 -0
  77. data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/internal/file.h +0 -0
  78. data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/internal/fixnum.h +0 -0
  79. data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/internal/loadpath.h +0 -0
  80. data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/internal/math.h +0 -0
  81. data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/internal/missing.h +0 -0
  82. data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/internal/parse.h +0 -0
  83. data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/internal/proc.h +0 -0
  84. data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/internal/process.h +0 -0
  85. data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/internal/ractor.h +0 -0
  86. data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/internal/random.h +0 -0
  87. data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/internal/range.h +0 -0
  88. data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/internal/rational.h +0 -0
  89. data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/internal/ruby_parser.h +0 -0
  90. data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/internal/serial.h +0 -0
  91. data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/internal/static_assert.h +0 -0
  92. data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/internal/transcode.h +0 -0
  93. data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/internal/util.h +0 -0
  94. data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/internal/warnings.h +0 -0
  95. data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/node.h +0 -0
  96. data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/parser_st.h +0 -0
  97. data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/parser_value.h +0 -0
  98. data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/prism/defines.h +0 -0
  99. data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/prism/encoding.h +0 -0
  100. data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/prism/node.h +0 -0
  101. data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/prism/pack.h +0 -0
  102. data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/prism/prettyprint.h +0 -0
  103. data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/prism/static_literals.h +0 -0
  104. data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/prism/util/pm_char.h +0 -0
  105. data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/prism/util/pm_constant_pool.h +0 -0
  106. data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/prism/util/pm_memchr.h +0 -0
  107. data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/prism/util/pm_newline_list.h +0 -0
  108. data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/prism/util/pm_strncasecmp.h +0 -0
  109. data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/prism/util/pm_strpbrk.h +0 -0
  110. data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/ruby_assert.h +0 -0
  111. data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/thread_none.h +0 -0
  112. data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/vm_debug.h +4 -4
  113. /data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/vm_opts.h +0 -0
@@ -118,8 +118,10 @@ extern int ruby_assert_critical_section_entered;
118
118
  #include "internal.h"
119
119
  #include "internal/array.h"
120
120
  #include "internal/basic_operators.h"
121
+ #include "internal/box.h"
121
122
  #include "internal/sanitizers.h"
122
123
  #include "internal/serial.h"
124
+ #include "internal/set_table.h"
123
125
  #include "internal/vm.h"
124
126
  #include "method.h"
125
127
  #include "node.h"
@@ -259,10 +261,8 @@ union ic_serial_entry {
259
261
  struct iseq_inline_constant_cache_entry {
260
262
  VALUE flags;
261
263
 
262
- VALUE value; // v0
263
- VALUE _unused1; // v1
264
- VALUE _unused2; // v2
265
- const rb_cref_t *ic_cref; // v3
264
+ VALUE value;
265
+ const rb_cref_t *ic_cref;
266
266
  };
267
267
  STATIC_ASSERT(sizeof_iseq_inline_constant_cache_entry,
268
268
  (offsetof(struct iseq_inline_constant_cache_entry, ic_cref) +
@@ -286,7 +286,7 @@ struct iseq_inline_constant_cache {
286
286
  };
287
287
 
288
288
  struct iseq_inline_iv_cache_entry {
289
- uintptr_t value; // attr_index in lower bits, dest_shape_id in upper bits
289
+ uint64_t value; // dest_shape_id in former half, attr_index in latter half
290
290
  ID iv_set_name;
291
291
  };
292
292
 
@@ -317,6 +317,8 @@ struct rb_calling_info {
317
317
  #define VM_ARGC_STACK_MAX 128
318
318
  #endif
319
319
 
320
+ #define VM_KW_SPECIFIED_BITS_MAX (32-1) /* TODO: 32 -> Fixnum's max bits */
321
+
320
322
  # define CALLING_ARGC(calling) ((calling)->heap_argv ? RARRAY_LENINT((calling)->heap_argv) : (calling)->argc)
321
323
 
322
324
  struct rb_execution_context_struct;
@@ -398,6 +400,7 @@ enum rb_builtin_attr {
398
400
  };
399
401
 
400
402
  typedef VALUE (*rb_jit_func_t)(struct rb_execution_context_struct *, struct rb_control_frame_struct *);
403
+ typedef VALUE (*rb_zjit_func_t)(struct rb_execution_context_struct *, struct rb_control_frame_struct *, rb_jit_func_t);
401
404
 
402
405
  struct rb_iseq_constant_body {
403
406
  enum rb_iseq_type type;
@@ -428,7 +431,7 @@ struct rb_iseq_constant_body {
428
431
  * size = M+N+O+(*1)+K+(&1)+(**1) // parameter size.
429
432
  */
430
433
 
431
- struct {
434
+ struct rb_iseq_parameters {
432
435
  struct {
433
436
  unsigned int has_lead : 1;
434
437
  unsigned int has_opt : 1;
@@ -495,6 +498,12 @@ struct rb_iseq_constant_body {
495
498
 
496
499
  const ID *local_table; /* must free */
497
500
 
501
+ enum lvar_state {
502
+ lvar_uninitialized,
503
+ lvar_initialized,
504
+ lvar_reassigned,
505
+ } *lvar_states;
506
+
498
507
  /* catch table */
499
508
  struct iseq_catch_table *catch_table;
500
509
 
@@ -534,7 +543,7 @@ struct rb_iseq_constant_body {
534
543
 
535
544
  const rb_iseq_t *mandatory_only_iseq;
536
545
 
537
- #if USE_YJIT
546
+ #if USE_YJIT || USE_ZJIT
538
547
  // Function pointer for JIT code on jit_exec()
539
548
  rb_jit_func_t jit_entry;
540
549
  // Number of calls on jit_exec()
@@ -543,11 +552,19 @@ struct rb_iseq_constant_body {
543
552
  rb_jit_func_t jit_exception;
544
553
  // Number of calls on jit_exec_exception()
545
554
  long unsigned jit_exception_calls;
555
+ #endif
556
+
557
+ #if USE_YJIT
546
558
  // YJIT stores some data on each iseq.
547
559
  void *yjit_payload;
548
560
  // Used to estimate how frequently this ISEQ gets called
549
561
  uint64_t yjit_calls_at_interv;
550
562
  #endif
563
+
564
+ #if USE_ZJIT
565
+ // ZJIT stores some data on each iseq.
566
+ void *zjit_payload;
567
+ #endif
551
568
  };
552
569
 
553
570
  /* T_IMEMO/iseq */
@@ -567,7 +584,7 @@ struct rb_iseq_struct {
567
584
  } loader;
568
585
 
569
586
  struct {
570
- struct rb_hook_list_struct *local_hooks;
587
+ unsigned int local_hooks_cnt;
571
588
  rb_event_flag_t global_trace_events;
572
589
  } exec;
573
590
  } aux;
@@ -633,15 +650,21 @@ void *rb_objspace_alloc(void);
633
650
  void rb_objspace_free(void *objspace);
634
651
  void rb_objspace_call_finalizer(void);
635
652
 
653
+ enum rb_hook_list_type {
654
+ hook_list_type_ractor_local,
655
+ hook_list_type_targeted_iseq,
656
+ hook_list_type_targeted_def, // C function
657
+ hook_list_type_global
658
+ };
659
+
636
660
  typedef struct rb_hook_list_struct {
637
661
  struct rb_event_hook_struct *hooks;
638
662
  rb_event_flag_t events;
639
663
  unsigned int running;
664
+ enum rb_hook_list_type type;
640
665
  bool need_clean;
641
- bool is_local;
642
666
  } rb_hook_list_t;
643
667
 
644
-
645
668
  // see builtin.h for definition
646
669
  typedef const struct rb_builtin_function *RB_BUILTIN;
647
670
 
@@ -672,12 +695,15 @@ typedef struct rb_vm_struct {
672
695
  bool terminate_waiting;
673
696
 
674
697
  #ifndef RUBY_THREAD_PTHREAD_H
698
+ // win32
675
699
  bool barrier_waiting;
676
700
  unsigned int barrier_cnt;
677
- rb_nativethread_cond_t barrier_cond;
701
+ rb_nativethread_cond_t barrier_complete_cond;
702
+ rb_nativethread_cond_t barrier_release_cond;
678
703
  #endif
679
704
  } sync;
680
705
 
706
+ #ifdef RUBY_THREAD_PTHREAD_H
681
707
  // ractor scheduling
682
708
  struct {
683
709
  rb_nativethread_lock_t lock;
@@ -711,7 +737,10 @@ typedef struct rb_vm_struct {
711
737
  bool barrier_waiting;
712
738
  unsigned int barrier_waiting_cnt;
713
739
  unsigned int barrier_serial;
740
+ struct rb_ractor_struct *barrier_ractor;
741
+ unsigned int barrier_lock_rec;
714
742
  } sched;
743
+ #endif
715
744
  } ractor;
716
745
 
717
746
  #ifdef USE_SIGALTSTACK
@@ -719,7 +748,6 @@ typedef struct rb_vm_struct {
719
748
  #endif
720
749
 
721
750
  rb_serial_t fork_gen;
722
- struct ccan_list_head waiting_fds; /* <=> struct waiting_fd */
723
751
 
724
752
  /* set in single-threaded processes only: */
725
753
  volatile int ubf_async_safe;
@@ -734,18 +762,11 @@ typedef struct rb_vm_struct {
734
762
  struct global_object_list *global_object_list;
735
763
  const VALUE special_exceptions[ruby_special_error_count];
736
764
 
765
+ /* Ruby Box */
766
+ rb_box_t *root_box;
767
+ rb_box_t *main_box;
768
+
737
769
  /* load */
738
- VALUE top_self;
739
- VALUE load_path;
740
- VALUE load_path_snapshot;
741
- VALUE load_path_check_cache;
742
- VALUE expanded_load_path;
743
- VALUE loaded_features;
744
- VALUE loaded_features_snapshot;
745
- VALUE loaded_features_realpaths;
746
- VALUE loaded_features_realpath_map;
747
- struct st_table *loaded_features_index;
748
- struct st_table *loading_table;
749
770
  // For running the init function of statically linked
750
771
  // extensions when they are loaded
751
772
  struct st_table *static_ext_inits;
@@ -755,6 +776,9 @@ typedef struct rb_vm_struct {
755
776
  VALUE cmd[RUBY_NSIG];
756
777
  } trap_list;
757
778
 
779
+ /* hook (for internal events: NEWOBJ, FREEOBJ, GC events, etc.) */
780
+ rb_hook_list_t global_hooks;
781
+
758
782
  /* postponed_job (async-signal-safe, and thread-safe) */
759
783
  struct rb_postponed_job_queue *postponed_job_queue;
760
784
 
@@ -778,14 +802,13 @@ typedef struct rb_vm_struct {
778
802
 
779
803
  rb_at_exit_list *at_exit;
780
804
 
781
- st_table *frozen_strings;
782
-
783
805
  const struct rb_builtin_function *builtin_function_table;
784
806
 
785
807
  st_table *ci_table;
786
808
  struct rb_id_table *negative_cme_table;
787
809
  st_table *overloaded_cme_table; // cme -> overloaded_cme
788
- st_table *unused_block_warning_table;
810
+ set_table *unused_block_warning_table;
811
+ set_table *cc_refinement_table;
789
812
 
790
813
  // This id table contains a mapping from ID to ICs. It does this with ID
791
814
  // keys and nested st_tables as values. The nested tables have ICs as keys
@@ -810,9 +833,10 @@ typedef struct rb_vm_struct {
810
833
  size_t fiber_vm_stack_size;
811
834
  size_t fiber_machine_stack_size;
812
835
  } default_params;
813
-
814
836
  } rb_vm_t;
815
837
 
838
+ extern bool ruby_vm_during_cleanup;
839
+
816
840
  /* default values */
817
841
 
818
842
  #define RUBY_VM_SIZE_ALIGN 4096
@@ -831,7 +855,7 @@ typedef struct rb_vm_struct {
831
855
  #define RUBY_VM_FIBER_MACHINE_STACK_SIZE_MIN ( 16 * 1024 * sizeof(VALUE)) /* 64 KB or 128 KB */
832
856
  #endif
833
857
 
834
- #if __has_feature(memory_sanitizer) || __has_feature(address_sanitizer)
858
+ #if __has_feature(memory_sanitizer) || __has_feature(address_sanitizer) || __has_feature(leak_sanitizer)
835
859
  /* It seems sanitizers consume A LOT of machine stacks */
836
860
  #undef RUBY_VM_THREAD_MACHINE_STACK_SIZE
837
861
  #define RUBY_VM_THREAD_MACHINE_STACK_SIZE (1024 * 1024 * sizeof(VALUE))
@@ -1023,6 +1047,8 @@ struct rb_execution_context_struct {
1023
1047
 
1024
1048
  rb_fiber_t *fiber_ptr;
1025
1049
  struct rb_thread_struct *thread_ptr;
1050
+ rb_serial_t serial;
1051
+ rb_serial_t ractor_id;
1026
1052
 
1027
1053
  /* storage (ec (fiber) local) */
1028
1054
  struct rb_id_table *local_storage;
@@ -1050,6 +1076,11 @@ struct rb_execution_context_struct {
1050
1076
 
1051
1077
  VALUE private_const_reference;
1052
1078
 
1079
+ struct {
1080
+ VALUE obj;
1081
+ VALUE fields_obj;
1082
+ } gen_fields_cache;
1083
+
1053
1084
  /* for GC */
1054
1085
  struct {
1055
1086
  VALUE *stack_start;
@@ -1084,6 +1115,10 @@ void rb_ec_initialize_vm_stack(rb_execution_context_t *ec, VALUE *stack, size_t
1084
1115
  // @param ec the execution context to update.
1085
1116
  void rb_ec_clear_vm_stack(rb_execution_context_t *ec);
1086
1117
 
1118
+ // Close an execution context and free related resources that are no longer needed.
1119
+ // @param ec the execution context to close.
1120
+ void rb_ec_close(rb_execution_context_t *ec);
1121
+
1087
1122
  struct rb_ext_config {
1088
1123
  bool ractor_safe;
1089
1124
  };
@@ -1093,7 +1128,7 @@ typedef struct rb_ractor_struct rb_ractor_t;
1093
1128
  struct rb_native_thread;
1094
1129
 
1095
1130
  typedef struct rb_thread_struct {
1096
- struct ccan_list_node lt_node; // managed by a ractor
1131
+ struct ccan_list_node lt_node; // managed by a ractor (r->threads.set)
1097
1132
  VALUE self;
1098
1133
  rb_ractor_t *ractor;
1099
1134
  rb_vm_t *vm;
@@ -1258,8 +1293,8 @@ typedef struct {
1258
1293
 
1259
1294
  RUBY_SYMBOL_EXPORT_BEGIN
1260
1295
  VALUE rb_proc_isolate(VALUE self);
1261
- VALUE rb_proc_isolate_bang(VALUE self);
1262
- VALUE rb_proc_ractor_make_shareable(VALUE self);
1296
+ VALUE rb_proc_isolate_bang(VALUE self, VALUE replace_self);
1297
+ VALUE rb_proc_ractor_make_shareable(VALUE proc, VALUE replace_self);
1263
1298
  RUBY_SYMBOL_EXPORT_END
1264
1299
 
1265
1300
  typedef struct {
@@ -1342,11 +1377,11 @@ typedef rb_control_frame_t *
1342
1377
 
1343
1378
  enum vm_frame_env_flags {
1344
1379
  /* Frame/Environment flag bits:
1345
- * MMMM MMMM MMMM MMMM ____ FFFF FFFE EEEX (LSB)
1380
+ * MMMM MMMM MMMM MMMM ___F FFFF FFFE EEEX (LSB)
1346
1381
  *
1347
1382
  * X : tag for GC marking (It seems as Fixnum)
1348
1383
  * EEE : 4 bits Env flags
1349
- * FF..: 7 bits Frame flags
1384
+ * FF..: 8 bits Frame flags
1350
1385
  * MM..: 15 bits frame magic (to check frame corruption)
1351
1386
  */
1352
1387
 
@@ -1369,8 +1404,9 @@ enum vm_frame_env_flags {
1369
1404
  VM_FRAME_FLAG_CFRAME = 0x0080,
1370
1405
  VM_FRAME_FLAG_LAMBDA = 0x0100,
1371
1406
  VM_FRAME_FLAG_MODIFIED_BLOCK_PARAM = 0x0200,
1372
- VM_FRAME_FLAG_CFRAME_KW = 0x0400,
1373
- VM_FRAME_FLAG_PASSED = 0x0800,
1407
+ VM_FRAME_FLAG_CFRAME_KW = 0x0400,
1408
+ VM_FRAME_FLAG_PASSED = 0x0800,
1409
+ VM_FRAME_FLAG_BOX_REQUIRE = 0x1000,
1374
1410
 
1375
1411
  /* env flag */
1376
1412
  VM_ENV_FLAG_LOCAL = 0x0002,
@@ -1414,12 +1450,31 @@ VM_ENV_FLAGS(const VALUE *ep, long flag)
1414
1450
  return flags & flag;
1415
1451
  }
1416
1452
 
1453
+ static inline unsigned long
1454
+ VM_ENV_FLAGS_UNCHECKED(const VALUE *ep, long flag)
1455
+ {
1456
+ VALUE flags = ep[VM_ENV_DATA_INDEX_FLAGS];
1457
+ return flags & flag;
1458
+ }
1459
+
1460
+ static inline unsigned long
1461
+ VM_ENV_FRAME_TYPE_P(const VALUE *ep, unsigned long frame_type)
1462
+ {
1463
+ return VM_ENV_FLAGS(ep, VM_FRAME_MAGIC_MASK) == frame_type;
1464
+ }
1465
+
1417
1466
  static inline unsigned long
1418
1467
  VM_FRAME_TYPE(const rb_control_frame_t *cfp)
1419
1468
  {
1420
1469
  return VM_ENV_FLAGS(cfp->ep, VM_FRAME_MAGIC_MASK);
1421
1470
  }
1422
1471
 
1472
+ static inline unsigned long
1473
+ VM_FRAME_TYPE_UNCHECKED(const rb_control_frame_t *cfp)
1474
+ {
1475
+ return VM_ENV_FLAGS_UNCHECKED(cfp->ep, VM_FRAME_MAGIC_MASK);
1476
+ }
1477
+
1423
1478
  static inline int
1424
1479
  VM_FRAME_LAMBDA_P(const rb_control_frame_t *cfp)
1425
1480
  {
@@ -1438,6 +1493,12 @@ VM_FRAME_FINISHED_P(const rb_control_frame_t *cfp)
1438
1493
  return VM_ENV_FLAGS(cfp->ep, VM_FRAME_FLAG_FINISH) != 0;
1439
1494
  }
1440
1495
 
1496
+ static inline int
1497
+ VM_FRAME_FINISHED_P_UNCHECKED(const rb_control_frame_t *cfp)
1498
+ {
1499
+ return VM_ENV_FLAGS_UNCHECKED(cfp->ep, VM_FRAME_FLAG_FINISH) != 0;
1500
+ }
1501
+
1441
1502
  static inline int
1442
1503
  VM_FRAME_BMETHOD_P(const rb_control_frame_t *cfp)
1443
1504
  {
@@ -1463,12 +1524,30 @@ VM_FRAME_CFRAME_P(const rb_control_frame_t *cfp)
1463
1524
  return cframe_p;
1464
1525
  }
1465
1526
 
1527
+ static inline int
1528
+ VM_FRAME_CFRAME_P_UNCHECKED(const rb_control_frame_t *cfp)
1529
+ {
1530
+ return VM_ENV_FLAGS_UNCHECKED(cfp->ep, VM_FRAME_FLAG_CFRAME) != 0;
1531
+ }
1532
+
1466
1533
  static inline int
1467
1534
  VM_FRAME_RUBYFRAME_P(const rb_control_frame_t *cfp)
1468
1535
  {
1469
1536
  return !VM_FRAME_CFRAME_P(cfp);
1470
1537
  }
1471
1538
 
1539
+ static inline int
1540
+ VM_FRAME_RUBYFRAME_P_UNCHECKED(const rb_control_frame_t *cfp)
1541
+ {
1542
+ return !VM_FRAME_CFRAME_P_UNCHECKED(cfp);
1543
+ }
1544
+
1545
+ static inline int
1546
+ VM_FRAME_NS_REQUIRE_P(const rb_control_frame_t *cfp)
1547
+ {
1548
+ return VM_ENV_FLAGS(cfp->ep, VM_FRAME_FLAG_BOX_REQUIRE) != 0;
1549
+ }
1550
+
1472
1551
  #define RUBYVM_CFUNC_FRAME_P(cfp) \
1473
1552
  (VM_FRAME_TYPE(cfp) == VM_FRAME_MAGIC_CFUNC)
1474
1553
 
@@ -1481,20 +1560,57 @@ VM_ENV_LOCAL_P(const VALUE *ep)
1481
1560
  return VM_ENV_FLAGS(ep, VM_ENV_FLAG_LOCAL) ? 1 : 0;
1482
1561
  }
1483
1562
 
1563
+ static inline int
1564
+ VM_ENV_LOCAL_P_UNCHECKED(const VALUE *ep)
1565
+ {
1566
+ return VM_ENV_FLAGS_UNCHECKED(ep, VM_ENV_FLAG_LOCAL) ? 1 : 0;
1567
+ }
1568
+
1569
+ static inline const VALUE *
1570
+ VM_ENV_PREV_EP_UNCHECKED(const VALUE *ep)
1571
+ {
1572
+ return GC_GUARDED_PTR_REF(ep[VM_ENV_DATA_INDEX_SPECVAL]);
1573
+ }
1574
+
1484
1575
  static inline const VALUE *
1485
1576
  VM_ENV_PREV_EP(const VALUE *ep)
1486
1577
  {
1487
1578
  VM_ASSERT(VM_ENV_LOCAL_P(ep) == 0);
1488
- return GC_GUARDED_PTR_REF(ep[VM_ENV_DATA_INDEX_SPECVAL]);
1579
+ return VM_ENV_PREV_EP_UNCHECKED(ep);
1580
+ }
1581
+
1582
+ static inline bool
1583
+ VM_ENV_BOXED_P(const VALUE *ep)
1584
+ {
1585
+ return VM_ENV_FRAME_TYPE_P(ep, VM_FRAME_MAGIC_CLASS) || VM_ENV_FRAME_TYPE_P(ep, VM_FRAME_MAGIC_TOP);
1489
1586
  }
1490
1587
 
1491
1588
  static inline VALUE
1492
1589
  VM_ENV_BLOCK_HANDLER(const VALUE *ep)
1493
1590
  {
1591
+ if (VM_ENV_BOXED_P(ep)) {
1592
+ VM_ASSERT(VM_ENV_LOCAL_P(ep));
1593
+ return VM_BLOCK_HANDLER_NONE;
1594
+ }
1595
+
1494
1596
  VM_ASSERT(VM_ENV_LOCAL_P(ep));
1495
1597
  return ep[VM_ENV_DATA_INDEX_SPECVAL];
1496
1598
  }
1497
1599
 
1600
+ static inline const rb_box_t *
1601
+ VM_ENV_BOX(const VALUE *ep)
1602
+ {
1603
+ VM_ASSERT(VM_ENV_BOXED_P(ep));
1604
+ VM_ASSERT(VM_ENV_LOCAL_P(ep));
1605
+ return (const rb_box_t *)GC_GUARDED_PTR_REF(ep[VM_ENV_DATA_INDEX_SPECVAL]);
1606
+ }
1607
+
1608
+ static inline const rb_box_t *
1609
+ VM_ENV_BOX_UNCHECKED(const VALUE *ep)
1610
+ {
1611
+ return (const rb_box_t *)GC_GUARDED_PTR_REF(ep[VM_ENV_DATA_INDEX_SPECVAL]);
1612
+ }
1613
+
1498
1614
  #if VM_CHECK_MODE > 0
1499
1615
  int rb_vm_ep_in_heap_p(const VALUE *ep);
1500
1616
  #endif
@@ -1815,7 +1931,7 @@ NORETURN(void rb_bug_for_fatal_signal(ruby_sighandler_t default_sighandler, int
1815
1931
 
1816
1932
  /* functions about thread/vm execution */
1817
1933
  RUBY_SYMBOL_EXPORT_BEGIN
1818
- VALUE rb_iseq_eval(const rb_iseq_t *iseq);
1934
+ VALUE rb_iseq_eval(const rb_iseq_t *iseq, const rb_box_t *box);
1819
1935
  VALUE rb_iseq_eval_main(const rb_iseq_t *iseq);
1820
1936
  VALUE rb_iseq_path(const rb_iseq_t *iseq);
1821
1937
  VALUE rb_iseq_realpath(const rb_iseq_t *iseq);
@@ -1861,10 +1977,11 @@ void rb_thread_wakeup_timer_thread(int);
1861
1977
  static inline void
1862
1978
  rb_vm_living_threads_init(rb_vm_t *vm)
1863
1979
  {
1864
- ccan_list_head_init(&vm->waiting_fds);
1865
1980
  ccan_list_head_init(&vm->workqueue);
1866
1981
  ccan_list_head_init(&vm->ractor.set);
1982
+ #ifdef RUBY_THREAD_PTHREAD_H
1867
1983
  ccan_list_head_init(&vm->ractor.sched.zombie_threads);
1984
+ #endif
1868
1985
  }
1869
1986
 
1870
1987
  typedef int rb_backtrace_iter_func(void *, VALUE, int, VALUE);
@@ -1874,6 +1991,7 @@ VALUE *rb_vm_svar_lep(const rb_execution_context_t *ec, const rb_control_frame_t
1874
1991
  int rb_vm_get_sourceline(const rb_control_frame_t *);
1875
1992
  void rb_vm_stack_to_heap(rb_execution_context_t *ec);
1876
1993
  void ruby_thread_init_stack(rb_thread_t *th, void *local_in_parent_frame);
1994
+ void rb_thread_malloc_stack_set(rb_thread_t *th, void *stack);
1877
1995
  rb_thread_t * ruby_thread_from_native(void);
1878
1996
  int ruby_thread_set_native(rb_thread_t *th);
1879
1997
  int rb_vm_control_frame_id_and_class(const rb_control_frame_t *cfp, ID *idp, ID *called_idp, VALUE *klassp);
@@ -1888,9 +2006,10 @@ void rb_vm_register_special_exception_str(enum ruby_special_exceptions sp, VALUE
1888
2006
 
1889
2007
  void rb_gc_mark_machine_context(const rb_execution_context_t *ec);
1890
2008
 
1891
- void rb_vm_rewrite_cref(rb_cref_t *node, VALUE old_klass, VALUE new_klass, rb_cref_t **new_cref_ptr);
2009
+ rb_cref_t *rb_vm_rewrite_cref(rb_cref_t *node, VALUE old_klass, VALUE new_klass);
1892
2010
 
1893
2011
  const rb_callable_method_entry_t *rb_vm_frame_method_entry(const rb_control_frame_t *cfp);
2012
+ const rb_callable_method_entry_t *rb_vm_frame_method_entry_unchecked(const rb_control_frame_t *cfp);
1894
2013
 
1895
2014
  #define sysstack_error GET_VM()->special_exceptions[ruby_error_sysstack]
1896
2015
 
@@ -1917,14 +2036,22 @@ rb_execution_context_t *rb_vm_main_ractor_ec(rb_vm_t *vm); // ractor.c
1917
2036
  RUBY_EXTERN struct rb_ractor_struct *ruby_single_main_ractor; // ractor.c
1918
2037
  RUBY_EXTERN rb_vm_t *ruby_current_vm_ptr;
1919
2038
  RUBY_EXTERN rb_event_flag_t ruby_vm_event_flags;
1920
- RUBY_EXTERN rb_event_flag_t ruby_vm_event_enabled_global_flags;
1921
- RUBY_EXTERN unsigned int ruby_vm_event_local_num;
2039
+ RUBY_EXTERN rb_event_flag_t ruby_vm_event_enabled_global_flags; // only ever added to
2040
+ RUBY_EXTERN unsigned int ruby_vm_iseq_events_enabled;
2041
+ RUBY_EXTERN unsigned int ruby_vm_c_events_enabled;
1922
2042
 
1923
2043
  #define GET_VM() rb_current_vm()
1924
2044
  #define GET_RACTOR() rb_current_ractor()
1925
2045
  #define GET_THREAD() rb_current_thread()
1926
2046
  #define GET_EC() rb_current_execution_context(true)
1927
2047
 
2048
+ static inline rb_serial_t
2049
+ rb_ec_serial(struct rb_execution_context_struct *ec)
2050
+ {
2051
+ VM_ASSERT(ec->serial >= 1);
2052
+ return ec->serial;
2053
+ }
2054
+
1928
2055
  static inline rb_thread_t *
1929
2056
  rb_ec_thread_ptr(const rb_execution_context_t *ec)
1930
2057
  {
@@ -1944,6 +2071,14 @@ rb_ec_ractor_ptr(const rb_execution_context_t *ec)
1944
2071
  }
1945
2072
  }
1946
2073
 
2074
+ static inline rb_serial_t
2075
+ rb_ec_ractor_id(const rb_execution_context_t *ec)
2076
+ {
2077
+ rb_serial_t ractor_id = ec->ractor_id;
2078
+ RUBY_ASSERT(ractor_id);
2079
+ return ractor_id;
2080
+ }
2081
+
1947
2082
  static inline rb_vm_t *
1948
2083
  rb_ec_vm_ptr(const rb_execution_context_t *ec)
1949
2084
  {
@@ -1962,19 +2097,19 @@ static inline rb_execution_context_t *
1962
2097
  rb_current_execution_context(bool expect_ec)
1963
2098
  {
1964
2099
  #ifdef RB_THREAD_LOCAL_SPECIFIER
1965
- #if defined(__arm64__) || defined(__aarch64__)
1966
- rb_execution_context_t *ec = rb_current_ec();
2100
+ #ifdef RB_THREAD_CURRENT_EC_NOINLINE
2101
+ rb_execution_context_t * volatile ec = rb_current_ec();
1967
2102
  #else
1968
- rb_execution_context_t *ec = ruby_current_ec;
2103
+ rb_execution_context_t * volatile ec = ruby_current_ec;
1969
2104
  #endif
1970
2105
 
1971
2106
  /* On the shared objects, `__tls_get_addr()` is used to access the TLS
1972
2107
  * and the address of the `ruby_current_ec` can be stored on a function
1973
2108
  * frame. However, this address can be mis-used after native thread
1974
2109
  * migration of a coroutine.
1975
- * 1) Get `ptr =&ruby_current_ec` op NT1 and store it on the frame.
2110
+ * 1) Get `ptr = &ruby_current_ec` on NT1 and store it on the frame.
1976
2111
  * 2) Context switch and resume it on the NT2.
1977
- * 3) `ptr` is used on NT2 but it accesses to the TLS on NT1.
2112
+ * 3) `ptr` is used on NT2 but it accesses the TLS of NT1.
1978
2113
  * This assertion checks such misusage.
1979
2114
  *
1980
2115
  * To avoid accidents, `GET_EC()` should be called once on the frame.
@@ -1982,7 +2117,7 @@ rb_current_execution_context(bool expect_ec)
1982
2117
  */
1983
2118
  VM_ASSERT(ec == rb_current_ec_noinline());
1984
2119
  #else
1985
- rb_execution_context_t *ec = native_tls_get(ruby_current_ec_key);
2120
+ rb_execution_context_t * volatile ec = native_tls_get(ruby_current_ec_key);
1986
2121
  #endif
1987
2122
  VM_ASSERT(!expect_ec || ec != NULL);
1988
2123
  return ec;
@@ -2031,12 +2166,21 @@ void rb_ec_vm_lock_rec_release(const rb_execution_context_t *ec,
2031
2166
  unsigned int recorded_lock_rec,
2032
2167
  unsigned int current_lock_rec);
2033
2168
 
2169
+ /* This technically is a data race, as it's checked without the lock, however we
2170
+ * check against a value only our own thread will write. */
2171
+ NO_SANITIZE("thread", static inline bool
2172
+ vm_locked_by_ractor_p(rb_vm_t *vm, rb_ractor_t *cr))
2173
+ {
2174
+ VM_ASSERT(cr == GET_RACTOR());
2175
+ return vm->ractor.sync.lock_owner == cr;
2176
+ }
2177
+
2034
2178
  static inline unsigned int
2035
2179
  rb_ec_vm_lock_rec(const rb_execution_context_t *ec)
2036
2180
  {
2037
2181
  rb_vm_t *vm = rb_ec_vm_ptr(ec);
2038
2182
 
2039
- if (vm->ractor.sync.lock_owner != rb_ec_ractor_ptr(ec)) {
2183
+ if (!vm_locked_by_ractor_p(vm, rb_ec_ractor_ptr(ec))) {
2040
2184
  return 0;
2041
2185
  }
2042
2186
  else {
@@ -2063,8 +2207,12 @@ enum {
2063
2207
  #define RUBY_VM_SET_TRAP_INTERRUPT(ec) ATOMIC_OR((ec)->interrupt_flag, TRAP_INTERRUPT_MASK)
2064
2208
  #define RUBY_VM_SET_TERMINATE_INTERRUPT(ec) ATOMIC_OR((ec)->interrupt_flag, TERMINATE_INTERRUPT_MASK)
2065
2209
  #define RUBY_VM_SET_VM_BARRIER_INTERRUPT(ec) ATOMIC_OR((ec)->interrupt_flag, VM_BARRIER_INTERRUPT_MASK)
2066
- #define RUBY_VM_INTERRUPTED(ec) ((ec)->interrupt_flag & ~(ec)->interrupt_mask & \
2067
- (PENDING_INTERRUPT_MASK|TRAP_INTERRUPT_MASK))
2210
+
2211
+ static inline bool
2212
+ RUBY_VM_INTERRUPTED(rb_execution_context_t *ec)
2213
+ {
2214
+ return (ATOMIC_LOAD_RELAXED(ec->interrupt_flag) & ~(ec->interrupt_mask) & (PENDING_INTERRUPT_MASK|TRAP_INTERRUPT_MASK));
2215
+ }
2068
2216
 
2069
2217
  static inline bool
2070
2218
  RUBY_VM_INTERRUPTED_ANY(rb_execution_context_t *ec)
@@ -2077,7 +2225,7 @@ RUBY_VM_INTERRUPTED_ANY(rb_execution_context_t *ec)
2077
2225
  RUBY_VM_SET_TIMER_INTERRUPT(ec);
2078
2226
  }
2079
2227
  #endif
2080
- return ec->interrupt_flag & ~(ec)->interrupt_mask;
2228
+ return ATOMIC_LOAD_RELAXED(ec->interrupt_flag) & ~(ec)->interrupt_mask;
2081
2229
  }
2082
2230
 
2083
2231
  VALUE rb_exc_set_backtrace(VALUE exc, VALUE bt);
@@ -2111,7 +2259,7 @@ rb_vm_check_ints(rb_execution_context_t *ec)
2111
2259
  VM_ASSERT(ruby_assert_critical_section_entered == 0);
2112
2260
  #endif
2113
2261
 
2114
- VM_ASSERT(ec == GET_EC());
2262
+ VM_ASSERT(ec == rb_current_ec_noinline());
2115
2263
 
2116
2264
  if (UNLIKELY(RUBY_VM_INTERRUPTED_ANY(ec))) {
2117
2265
  rb_threadptr_execute_interrupts(rb_ec_thread_ptr(ec), 0);
@@ -2138,10 +2286,11 @@ struct rb_trace_arg_struct {
2138
2286
  };
2139
2287
 
2140
2288
  void rb_hook_list_mark(rb_hook_list_t *hooks);
2141
- void rb_hook_list_mark_and_update(rb_hook_list_t *hooks);
2289
+ void rb_hook_list_mark_and_move(rb_hook_list_t *hooks);
2142
2290
  void rb_hook_list_free(rb_hook_list_t *hooks);
2143
- void rb_hook_list_connect_tracepoint(VALUE target, rb_hook_list_t *list, VALUE tpval, unsigned int target_line);
2144
- void rb_hook_list_remove_tracepoint(rb_hook_list_t *list, VALUE tpval);
2291
+ void rb_hook_list_connect_local_tracepoint(rb_hook_list_t *list, VALUE tpval, unsigned int target_line);
2292
+ bool rb_hook_list_remove_local_tracepoint(rb_hook_list_t *list, VALUE tpval);
2293
+ unsigned int rb_hook_list_count(rb_hook_list_t *list);
2145
2294
 
2146
2295
  void rb_exec_event_hooks(struct rb_trace_arg_struct *trace_arg, rb_hook_list_t *hooks, int pop_p);
2147
2296
 
@@ -2180,6 +2329,8 @@ struct rb_ractor_pub {
2180
2329
  VALUE self;
2181
2330
  uint32_t id;
2182
2331
  rb_hook_list_t hooks;
2332
+ st_table *targeted_hooks; // also called "local hooks". {ISEQ => hook_list, def => hook_list...}
2333
+ unsigned int targeted_hooks_cnt; // ex: tp.enabled(target: method(:puts))
2183
2334
  };
2184
2335
 
2185
2336
  static inline rb_hook_list_t *
@@ -2189,11 +2340,31 @@ rb_ec_ractor_hooks(const rb_execution_context_t *ec)
2189
2340
  return &cr_pub->hooks;
2190
2341
  }
2191
2342
 
2343
+ static inline rb_hook_list_t *
2344
+ rb_vm_global_hooks(const rb_execution_context_t *ec)
2345
+ {
2346
+ return &rb_ec_vm_ptr(ec)->global_hooks;
2347
+ }
2348
+
2349
+ static inline rb_hook_list_t *
2350
+ rb_ec_hooks(const rb_execution_context_t *ec, rb_event_flag_t event)
2351
+ {
2352
+ // Should be a single bit set
2353
+ VM_ASSERT(event != 0 && ((event - 1) & event) == 0);
2354
+
2355
+ if (event & RUBY_INTERNAL_EVENT_OBJSPACE_MASK) {
2356
+ return rb_vm_global_hooks(ec);
2357
+ }
2358
+ else {
2359
+ return rb_ec_ractor_hooks(ec);
2360
+ }
2361
+ }
2362
+
2192
2363
  #define EXEC_EVENT_HOOK(ec_, flag_, self_, id_, called_id_, klass_, data_) \
2193
- EXEC_EVENT_HOOK_ORIG(ec_, rb_ec_ractor_hooks(ec_), flag_, self_, id_, called_id_, klass_, data_, 0)
2364
+ EXEC_EVENT_HOOK_ORIG(ec_, rb_ec_hooks(ec_, flag_), flag_, self_, id_, called_id_, klass_, data_, 0)
2194
2365
 
2195
2366
  #define EXEC_EVENT_HOOK_AND_POP_FRAME(ec_, flag_, self_, id_, called_id_, klass_, data_) \
2196
- EXEC_EVENT_HOOK_ORIG(ec_, rb_ec_ractor_hooks(ec_), flag_, self_, id_, called_id_, klass_, data_, 1)
2367
+ EXEC_EVENT_HOOK_ORIG(ec_, rb_ec_hooks(ec_, flag_), flag_, self_, id_, called_id_, klass_, data_, 1)
2197
2368
 
2198
2369
  static inline void
2199
2370
  rb_exec_event_hook_script_compiled(rb_execution_context_t *ec, const rb_iseq_t *iseq, VALUE eval_script)
@@ -1,5 +1,5 @@
1
1
  module Datadog
2
2
  module RubyCoreSource
3
- VERSION = '3.4.2'
3
+ VERSION = '3.5.0'
4
4
  end
5
5
  end