Class: RubyVM

Inherits:
Object show all
Defined in:
vm.c

Defined Under Namespace

Classes: Env, InstructionSequence

Constant Summary collapse

OPTS =

RubyVM::OPTS, which shows vm build options

:
INSTRUCTION_NAMES =

RubyVM::INSTRUCTION_NAMES

:
DEFAULT_PARAMS =

RubyVM::DEFAULT_PARAMS This constant variable shows 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

Class Method Details

.NSDRObject

:nodoc:



2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
# File 'vm.c', line 2633

static VALUE
nsdr(void)
{
    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;
}

.SDRObject

:nodoc:



2625
2626
2627
2628
2629
2630
# File 'vm.c', line 2625

static VALUE
sdr(void)
{
    rb_vm_bugreport(NULL);
    return Qnil;
}

.statHash .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_method_state=>251,
  :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.

Overloads:



295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
# File 'vm.c', line 295

static VALUE
vm_stat(int argc, VALUE *argv, VALUE self)
{
    static VALUE sym_global_method_state, sym_global_constant_state, sym_class_serial;
    VALUE arg = Qnil;
    VALUE hash = Qnil, key = Qnil;

    if (rb_scan_args(argc, argv, "01", &arg) == 1) {
	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 if (NIL_P(arg)) {
	hash = rb_hash_new();
    }

    if (sym_global_method_state == 0) {
#define S(s) sym_##s = ID2SYM(rb_intern_const(#s))
	S(global_method_state);
	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_method_state, ruby_vm_global_method_state);
    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_STOPObject



2658
# File 'vm.c', line 2658

static VALUE usage_analysis_insn_stop(VALUE self);

.USAGE_ANALYSIS_OPERAND_STOPObject



2659
# File 'vm.c', line 2659

static VALUE usage_analysis_operand_stop(VALUE self);

.USAGE_ANALYSIS_REGISTER_STOPObject



2660
# File 'vm.c', line 2660

static VALUE usage_analysis_register_stop(VALUE self);