Class: RubyVM
Overview
The RubyVM module only exists on MRI. RubyVM
is not defined in other Ruby implementations such as JRuby and TruffleRuby.
The RubyVM module provides some access to MRI internals. This module is for very limited purposes, such as debugging, prototyping, and research. Normal users must not use it. This module is not portable between Ruby implementations.
Defined Under Namespace
Modules: AbstractSyntaxTree, MJIT Classes: InstructionSequence
Constant Summary collapse
- OPTS =
RubyVM::OPTS An Array of VM build options. This constant is MRI specific.
:
- INSTRUCTION_NAMES =
RubyVM::INSTRUCTION_NAMES A list of bytecode instruction names in MRI. This constant is MRI specific.
:
- DEFAULT_PARAMS =
RubyVM::DEFAULT_PARAMS This constant exposes the VM’s default parameters. Note that changing these values does not affect VM execution. Specification is not stable and you should not depend on this value. Of course, this constant is MRI specific.
:
Class Method Summary collapse
- .each_builtin ⇒ Object
- .mtbl(obj, sym) ⇒ Object
- .mtbl2(obj, sym) ⇒ Object
-
.NSDR ⇒ Object
:nodoc:.
- .reset_debug_counters ⇒ Object
-
.SDR ⇒ Object
:nodoc:.
- .show_debug_counters ⇒ Object
-
.stat(*args) ⇒ Object
Returns a Hash containing implementation-dependent counters inside the VM.
- .USAGE_ANALYSIS_INSN_CLEAR ⇒ Object
- .USAGE_ANALYSIS_INSN_RUNNING ⇒ Object
- .USAGE_ANALYSIS_INSN_START ⇒ Object
- .USAGE_ANALYSIS_INSN_STOP ⇒ Object
- .USAGE_ANALYSIS_OPERAND_CLEAR ⇒ Object
- .USAGE_ANALYSIS_OPERAND_RUNNING ⇒ Object
- .USAGE_ANALYSIS_OPERAND_START ⇒ Object
- .USAGE_ANALYSIS_OPERAND_STOP ⇒ Object
- .USAGE_ANALYSIS_REGISTER_CLEAR ⇒ Object
- .USAGE_ANALYSIS_REGISTER_RUNNING ⇒ Object
- .USAGE_ANALYSIS_REGISTER_START ⇒ Object
- .USAGE_ANALYSIS_REGISTER_STOP ⇒ Object
Class Method Details
.each_builtin ⇒ Object
64 65 66 67 68 69 |
# File 'mini_builtin.c', line 64
static VALUE
each_builtin(VALUE self)
{
st_foreach(loaded_builtin_table, each_builtin_i, 0);
return Qnil;
}
|
.mtbl(obj, sym) ⇒ Object
3325 3326 3327 3328 3329 3330 |
# File 'vm.c', line 3325
static VALUE
vm_mtbl(VALUE self, VALUE obj, VALUE sym)
{
vm_mtbl_dump(CLASS_OF(obj), RTEST(sym) ? SYM2ID(sym) : 0);
return Qnil;
}
|
.mtbl2(obj, sym) ⇒ Object
3332 3333 3334 3335 3336 3337 |
# File 'vm.c', line 3332
static VALUE
vm_mtbl2(VALUE self, VALUE obj, VALUE sym)
{
vm_mtbl_dump(obj, RTEST(sym) ? SYM2ID(sym) : 0);
return Qnil;
}
|
.NSDR ⇒ Object
:nodoc:
3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 |
# File 'vm.c', line 3268
static VALUE
nsdr(VALUE self)
{
VALUE ary = rb_ary_new();
#if HAVE_BACKTRACE
#include <execinfo.h>
#define MAX_NATIVE_TRACE 1024
static void *trace[MAX_NATIVE_TRACE];
int n = (int)backtrace(trace, MAX_NATIVE_TRACE);
char **syms = backtrace_symbols(trace, n);
int i;
if (syms == 0) {
rb_memerror();
}
for (i=0; i<n; i++) {
rb_ary_push(ary, rb_str_new2(syms[i]));
}
free(syms); /* OK */
#endif
return ary;
}
|
.reset_debug_counters ⇒ Object
.SDR ⇒ Object
:nodoc:
3260 3261 3262 3263 3264 3265 |
# File 'vm.c', line 3260
static VALUE
sdr(VALUE self)
{
rb_vm_bugreport(NULL);
return Qnil;
}
|
.show_debug_counters ⇒ Object
.stat ⇒ Hash .stat(hsh) ⇒ Hash .stat(Symbol) ⇒ Numeric
Returns a Hash containing implementation-dependent counters inside the VM.
This hash includes information about method/constant cache serials:
{
:global_constant_state=>481,
:class_serial=>9029
}
The contents of the hash are implementation specific and may be changed in the future.
This method is only expected to work on C Ruby.
487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 |
# File 'vm.c', line 487
static VALUE
vm_stat(int argc, VALUE *argv, VALUE self)
{
static VALUE sym_global_constant_state, sym_class_serial;
VALUE arg = Qnil;
VALUE hash = Qnil, key = Qnil;
if (rb_check_arity(argc, 0, 1) == 1) {
arg = argv[0];
if (SYMBOL_P(arg))
key = arg;
else if (RB_TYPE_P(arg, T_HASH))
hash = arg;
else
rb_raise(rb_eTypeError, "non-hash or symbol given");
}
else {
hash = rb_hash_new();
}
if (sym_global_constant_state == 0) {
#define S(s) sym_##s = ID2SYM(rb_intern_const(#s))
S(global_constant_state);
S(class_serial);
#undef S
}
#define SET(name, attr) \
if (key == sym_##name) \
return SERIALT2NUM(attr); \
else if (hash != Qnil) \
rb_hash_aset(hash, sym_##name, SERIALT2NUM(attr));
SET(global_constant_state, ruby_vm_global_constant_state);
SET(class_serial, ruby_vm_class_serial);
#undef SET
if (!NIL_P(key)) { /* matched key should return above */
rb_raise(rb_eArgError, "unknown key: %"PRIsVALUE, rb_sym2str(key));
}
return hash;
}
|
.USAGE_ANALYSIS_INSN_CLEAR ⇒ Object
3302 |
# File 'vm.c', line 3302 static VALUE usage_analysis_insn_clear(VALUE self); |
.USAGE_ANALYSIS_INSN_RUNNING ⇒ Object
3299 |
# File 'vm.c', line 3299 static VALUE usage_analysis_insn_running(VALUE self); |
.USAGE_ANALYSIS_INSN_START ⇒ Object
3293 |
# File 'vm.c', line 3293 static VALUE usage_analysis_insn_start(VALUE self); |
.USAGE_ANALYSIS_INSN_STOP ⇒ Object
3296 |
# File 'vm.c', line 3296 static VALUE usage_analysis_insn_stop(VALUE self); |
.USAGE_ANALYSIS_OPERAND_CLEAR ⇒ Object
3303 |
# File 'vm.c', line 3303 static VALUE usage_analysis_operand_clear(VALUE self); |
.USAGE_ANALYSIS_OPERAND_RUNNING ⇒ Object
3300 |
# File 'vm.c', line 3300 static VALUE usage_analysis_operand_running(VALUE self); |
.USAGE_ANALYSIS_OPERAND_START ⇒ Object
3294 |
# File 'vm.c', line 3294 static VALUE usage_analysis_operand_start(VALUE self); |
.USAGE_ANALYSIS_OPERAND_STOP ⇒ Object
3297 |
# File 'vm.c', line 3297 static VALUE usage_analysis_operand_stop(VALUE self); |
.USAGE_ANALYSIS_REGISTER_CLEAR ⇒ Object
3304 |
# File 'vm.c', line 3304 static VALUE usage_analysis_register_clear(VALUE self); |
.USAGE_ANALYSIS_REGISTER_RUNNING ⇒ Object
3301 |
# File 'vm.c', line 3301 static VALUE usage_analysis_register_running(VALUE self); |
.USAGE_ANALYSIS_REGISTER_START ⇒ Object
3295 |
# File 'vm.c', line 3295 static VALUE usage_analysis_register_start(VALUE self); |
.USAGE_ANALYSIS_REGISTER_STOP ⇒ Object
3298 |
# File 'vm.c', line 3298 static VALUE usage_analysis_register_stop(VALUE self); |