Ruby: mjit_worker.c File Reference

Ruby 3.0.5p211 (2022-11-24 revision ba5cf0f7c52d4d35cc6a173c89eda98ceffa2dcf)

Data Structures | Macros | Enumerations | Functions | Variables
mjit_worker.c File Reference
`#include "vm_core.h"`
`#include "vm_callinfo.h"`
`#include "mjit.h"`
`#include "gc.h"`
`#include "ruby_assert.h"`
`#include "ruby/debug.h"`
`#include "ruby/thread.h"`
`#include "ruby/version.h"`
`#include "builtin.h"`
`#include "insns.inc"`
`#include "insns_info.inc"`
`#include "internal/compile.h"`
`#include <sys/wait.h>`
`#include <sys/time.h>`
`#include <dlfcn.h>`
`#include <errno.h>`
`#include "dln.h"`
`#include "ruby/util.h"`
`#include "mjit_config.h"`

Go to the source code of this file.

## Data Structures
struct | rb_mjit_unit
struct | rb_mjit_unit_list
struct | mjit_cont

## Macros
#define | MAXPATHLEN 1024
#define | MJIT_ATOMIC_SET(var, val) (void)ATOMIC_PTR_EXCHANGE(var, val)
#define | MJIT_TMP_PREFIX "_ruby_mjit_"
#define | USE_JIT_COMPACTION 1
#define | GCC_PIC_FLAGS /* empty */
#define | MJIT_CFLAGS_PIPE 0
#define | GCC_NOSTDLIB_FLAGS
#define | CC_CODEFLAG_ARGS (mjit_opts.debug ? CC_DEBUG_ARGS : CC_OPTIMIZE_ARGS)
#define | append_str2(p, str, len) ((char *)memcpy((p), str, (len))+(len))
#define | append_str(p, str) append_str2(p, str, sizeof(str)-1)
#define | append_lit(p, str) append_str2(p, str, rb_strlen_lit(str))

## Enumerations
enum | { PCH_NOT_READY , PCH_FAILED , PCH_SUCCESS }

## Functions
void | rb_native_mutex_lock (rb_nativethread_lock_t *lock)
void | rb_native_mutex_unlock (rb_nativethread_lock_t *lock)
void | rb_native_mutex_initialize (rb_nativethread_lock_t *lock)
void | rb_native_mutex_destroy (rb_nativethread_lock_t *lock)
void | rb_native_cond_initialize (rb_nativethread_cond_t *cond)
void | rb_native_cond_destroy (rb_nativethread_cond_t *cond)
void | rb_native_cond_signal (rb_nativethread_cond_t *cond)
void | rb_native_cond_broadcast (rb_nativethread_cond_t *cond)
void | rb_native_cond_wait (rb_nativethread_cond_t *cond, rb_nativethread_lock_t *mutex)
rb_pid_t | ruby_waitpid_locked (rb_vm_t *, rb_pid_t, int *status, int options, rb_nativethread_cond_t *cond)
bool | mjit_valid_class_serial_p (rb_serial_t class_serial)
bool | rb_mjit_compiling_iseq_p (const rb_iseq_t *iseq)
const struct rb_callcache ** | mjit_iseq_cc_entries (const struct rb_iseq_constant_body *const body)
int | mjit_capture_cc_entries (const struct rb_iseq_constant_body *compiled_iseq, const struct rb_iseq_constant_body *captured_iseq)
void | mjit_worker (void)

## Variables
struct mjit_options | mjit_opts
bool | mjit_enabled = false
bool | mjit_call_p = false

## Macro Definition Documentation

## ◆ append_lit

#define append_lit | ( |  | p,
|  |  | str
| ) |  | append_str2(p, str, rb_strlen_lit(str))

Definition at line 789 of file mjit_worker.c.

## ◆ append_str

#define append_str | ( |  | p,
|  |  | str
| ) |  | append_str2(p, str, sizeof(str)-1)

Definition at line 788 of file mjit_worker.c.

## ◆ append_str2

#define append_str2 | ( |  | p,
|  |  | str,
|  |  | len
| ) |  | ((char *)memcpy((p), str, (len))+(len))

Definition at line 787 of file mjit_worker.c.

## ◆ CC_CODEFLAG_ARGS

#define CC_CODEFLAG_ARGS (mjit_opts.debug ? CC_DEBUG_ARGS : CC_OPTIMIZE_ARGS)

Definition at line 329 of file mjit_worker.c.

## ◆ GCC_NOSTDLIB_FLAGS

#define GCC_NOSTDLIB_FLAGS

Definition at line 292 of file mjit_worker.c.

## ◆ GCC_PIC_FLAGS

#define GCC_PIC_FLAGS /* empty */

Definition at line 283 of file mjit_worker.c.

## ◆ MAXPATHLEN

#define MAXPATHLEN 1024

Definition at line 122 of file mjit_worker.c.

## ◆ MJIT_ATOMIC_SET

#define MJIT_ATOMIC_SET | ( |  | var,
|  |  | val
| ) |  | (void)ATOMIC_PTR_EXCHANGE(var, val)

Definition at line 140 of file mjit_worker.c.

## ◆ MJIT_CFLAGS_PIPE

#define MJIT_CFLAGS_PIPE 0

Definition at line 284 of file mjit_worker.c.

## ◆ MJIT_TMP_PREFIX

#define MJIT_TMP_PREFIX "_ruby_mjit_"

Definition at line 142 of file mjit_worker.c.

## ◆ USE_JIT_COMPACTION

#define USE_JIT_COMPACTION 1

Definition at line 150 of file mjit_worker.c.

## Enumeration Type Documentation

## ◆ anonymous enum

anonymous enum

Enumerator
PCH_NOT_READY |
PCH_FAILED |
PCH_SUCCESS |

Definition at line 263 of file mjit_worker.c.

## Function Documentation

## ◆ mjit_capture_cc_entries()

int mjit_capture_cc_entries | ( | const struct rb_iseq_constant_body * | compiled_iseq,
|  | const struct rb_iseq_constant_body * | captured_iseq
| ) |  |

Definition at line 1283 of file mjit_worker.c.

References rb_iseq_constant_body::call_data, rb_call_data::cc, rb_mjit_unit::cc_entries, rb_mjit_unit::cc_entries_size, rb_iseq_constant_body::ci_size, malloc, NULL, realloc, and VM_ASSERT.

## ◆ mjit_iseq_cc_entries()

const struct rb_callcache ** mjit_iseq_cc_entries | ( | const struct rb_iseq_constant_body *const | body | ) |

Definition at line 1270 of file mjit_worker.c.

## ◆ mjit_valid_class_serial_p()

bool mjit_valid_class_serial_p | ( | rb_serial_t | class_serial | ) |

Definition at line 497 of file mjit_worker.c.

References LONG2FIX, NULL, and rb_hash_stlike_lookup().

## ◆ mjit_worker()

void mjit_worker | ( | void |  | ) |

Definition at line 1418 of file mjit_worker.c.

References rb_iseq_struct::body, rb_mjit_unit_list::head, rb_mjit_unit::iseq, rb_mjit_unit_list::length, MJIT_ATOMIC_SET, mjit_enabled, mjit_opts, PCH_FAILED, PCH_NOT_READY, RB_DEBUG_COUNTER_INC, RB_DEBUG_COUNTER_INC_IF, rb_native_cond_signal(), rb_native_cond_wait(), rb_mjit_unit::stale_p, and rb_mjit_unit::unode.

## ◆ rb_mjit_compiling_iseq_p()

bool rb_mjit_compiling_iseq_p | ( | const rb_iseq_t * | iseq | ) |

Definition at line 770 of file mjit_worker.c.

References assert, rb_mjit_unit::iseq, and NULL.

## ◆ rb_native_cond_broadcast()

void rb_native_cond_broadcast | ( | rb_nativethread_cond_t * | cond | ) |

## ◆ rb_native_cond_destroy()

void rb_native_cond_destroy | ( | rb_nativethread_cond_t * | cond | ) |

## ◆ rb_native_cond_initialize()

void rb_native_cond_initialize | ( | rb_nativethread_cond_t * | cond | ) |

## ◆ rb_native_cond_signal()

void rb_native_cond_signal | ( | rb_nativethread_cond_t * | cond | ) |

Referenced by mjit_worker().

## ◆ rb_native_cond_wait()

void rb_native_cond_wait | ( | rb_nativethread_cond_t * | cond,
|  | rb_nativethread_lock_t * | mutex
| ) |  |

Referenced by mjit_worker().

## ◆ rb_native_mutex_destroy()

void rb_native_mutex_destroy | ( | rb_nativethread_lock_t * | lock | ) |

## ◆ rb_native_mutex_initialize()

void rb_native_mutex_initialize | ( | rb_nativethread_lock_t * | lock | ) |

## ◆ rb_native_mutex_lock()

void rb_native_mutex_lock | ( | rb_nativethread_lock_t * | lock | ) |

## ◆ rb_native_mutex_unlock()

void rb_native_mutex_unlock | ( | rb_nativethread_lock_t * | lock | ) |

## ◆ ruby_waitpid_locked()

rb_pid_t ruby_waitpid_locked | ( | rb_vm_t * | vm,
|  | rb_pid_t | pid,
|  | int * | status,
|  | int | options,
|  | rb_nativethread_cond_t * | cond
| ) |  |

Definition at line 1198 of file process.c.

References assert, waitpid_state::cond, waitpid_state::ec, waitpid_state::errnum, waitpid_state::options, waitpid_state::pid, rb_native_cond_wait(), rb_native_mutex_lock(), rb_native_mutex_unlock(), rb_sigwait_fd_get(), rb_sigwait_fd_put(), rb_sigwait_sleep(), waitpid_state::ret, ruby_thread_has_gvl_p(), waitpid_state::status, rb_vm_struct::waiting_grps, rb_vm_struct::waiting_pids, rb_vm_struct::waitpid_lock, waitpid_state::wnode, and WNOHANG.

## Variable Documentation

## ◆ mjit_call_p

bool mjit_call_p = false

Definition at line 205 of file mjit_worker.c.

## ◆ mjit_enabled

bool mjit_enabled = false

Definition at line 202 of file mjit_worker.c.

Referenced by mjit_worker().

## ◆ mjit_opts

struct mjit_options mjit_opts

Definition at line 199 of file mjit_worker.c.

Referenced by mjit_worker().