Ruby 3.1.3p185 (2022-11-24 revision 1a6b16756e0ba6b95ab71a441357ed5484e33498)
Data Fields
RRegexp Struct Reference

Ruby's regular expression. More...

#include <rregexp.h>

Data Fields

struct RBasic basic
 Basic part, including flags and class. More...
 
struct re_pattern_bufferptr
 The pattern buffer. More...
 
const VALUE src
 Source code of this expression. More...
 
unsigned long usecnt
 Reference count. More...
 

Detailed Description

Ruby's regular expression.

A regexp is compiled into its own intermediate representation. This one holds that info. Regexp "match" operation then executes that IR.

Definition at line 3740 of file rb_mjit_min_header-3.1.3.h.

Field Documentation

◆ basic

struct RBasic RRegexp::basic

Basic part, including flags and class.

Definition at line 3741 of file rb_mjit_min_header-3.1.3.h.

◆ ptr

struct re_pattern_buffer * RRegexp::ptr

The pattern buffer.

This is a quasi-opaque struct that holds compiled intermediate representation of the regular expression.

Note
Compilation of a regexp could be delayed until actual match.

Definition at line 3742 of file rb_mjit_min_header-3.1.3.h.

◆ src

const VALUE RRegexp::src

Source code of this expression.

Definition at line 3743 of file rb_mjit_min_header-3.1.3.h.

◆ usecnt

unsigned long RRegexp::usecnt

Reference count.

A regexp match can take extraordinarily long time to run. Ruby's regular expression is heavily extended and not a regular language any longer; runs in NP-time in practice. Now, Ruby also has threads and GVL. In order to prevent long GVL lockup, our regexp engine can release it on occasions. This means that multiple threads can touch a regular expressions at once. That itself is okay. But their cleanup phase shall wait for all the concurrent runs, to prevent use-after-free situation. This field is used to count such threads that are executing this particular pattern buffer.

Warning
Of course, touching this field from extension libraries causes catastrophic effects. Just leave it.

Definition at line 3744 of file rb_mjit_min_header-3.1.3.h.


The documentation for this struct was generated from the following files: