File: C:/Ruby27-x64/share/doc/ruby/html/RubyVM.html
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>class RubyVM - RDoc Documentation</title>
<script type="text/javascript">
var rdoc_rel_prefix = "./";
var index_rel_prefix = "./";
</script>
<script src="./js/navigation.js" defer></script>
<script src="./js/search.js" defer></script>
<script src="./js/search_index.js" defer></script>
<script src="./js/searcher.js" defer></script>
<script src="./js/darkfish.js" defer></script>
<link href="./css/fonts.css" rel="stylesheet">
<link href="./css/rdoc.css" rel="stylesheet">
<body id="top" role="document" class="class">
<nav role="navigation">
<div id="project-navigation">
<div id="home-section" role="region" title="Quick navigation" class="nav-section">
<h2>
<a href="./index.html" rel="home">Home</a>
</h2>
<div id="table-of-contents-navigation">
<a href="./table_of_contents.html#pages">Pages</a>
<a href="./table_of_contents.html#classes">Classes</a>
<a href="./table_of_contents.html#methods">Methods</a>
</div>
</div>
<div id="search-section" role="search" class="project-section initially-hidden">
<form action="#" method="get" accept-charset="utf-8">
<div id="search-field-wrapper">
<input id="search-field" role="combobox" aria-label="Search"
aria-autocomplete="list" aria-controls="search-results"
type="text" name="search" placeholder="Search" spellcheck="false"
title="Type to search, Up and Down to navigate, Enter to load">
</div>
<ul id="search-results" aria-label="Search Results"
aria-busy="false" aria-expanded="false"
aria-atomic="false" class="initially-hidden"></ul>
</form>
</div>
</div>
<div id="class-metadata">
<div id="parent-class-section" class="nav-section">
<h3>Parent</h3>
<p class="link"><a href="Object.html">Object</a>
</div>
<!-- Method Quickref -->
<div id="method-list-section" class="nav-section">
<h3>Methods</h3>
<ul class="link-list" role="directory">
<li ><a href="#method-c-each_builtin">::each_builtin</a>
<li ><a href="#method-c-stat">::stat</a>
</ul>
</div>
</div>
</nav>
<main role="main" aria-labelledby="class-RubyVM">
<h1 id="class-RubyVM" class="class">
class RubyVM
</h1>
<section class="description">
<p>for ast.c</p>
<p>The <a href="RubyVM.html"><code>RubyVM</code></a> module only exists on MRI. <code>RubyVM</code> is not defined in other Ruby implementations such as JRuby and TruffleRuby.</p>
<p>The <a href="RubyVM.html"><code>RubyVM</code></a> 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.</p>
</section>
<section id="5Buntitled-5D" class="documentation-section">
<section class="constants-list">
<header>
<h3>Constants</h3>
</header>
<dl>
<dt id="DEFAULT_PARAMS">DEFAULT_PARAMS
<dd><p><a href="RubyVM.html#DEFAULT_PARAMS"><code>DEFAULT_PARAMS</code></a> 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.</p>
<dt id="INSTRUCTION_NAMES">INSTRUCTION_NAMES
<dd><p><a href="RubyVM.html#INSTRUCTION_NAMES"><code>INSTRUCTION_NAMES</code></a> A list of bytecode instruction names in MRI. This constant is MRI specific.</p>
<dt id="OPTS">OPTS
<dd><p><a href="RubyVM.html#OPTS"><code>OPTS</code></a> An <a href="Array.html"><code>Array</code></a> of VM build options. This constant is MRI specific.</p>
</dl>
</section>
<section id="public-class-5Buntitled-5D-method-details" class="method-section">
<header>
<h3>Public Class Methods</h3>
</header>
<div id="method-c-each_builtin" class="method-detail ">
<div class="method-heading">
<span class="method-name">each_builtin</span><span
class="method-args">()</span>
<span class="method-click-advice">click to toggle source</span>
</div>
<div class="method-description">
<div class="method-source-code" id="each_builtin-source">
<pre>static VALUE
each_builtin(VALUE self)
{
st_foreach(loaded_builtin_table, each_builtin_i, 0);
return Qnil;
}</pre>
</div>
</div>
</div>
<div id="method-c-stat" class="method-detail ">
<div class="method-heading">
<span class="method-callseq">
stat → Hash
</span>
<span class="method-click-advice">click to toggle source</span>
</div>
<div class="method-heading">
<span class="method-callseq">
stat(hsh) → hsh
</span>
</div>
<div class="method-heading">
<span class="method-callseq">
stat(Symbol) → Numeric
</span>
</div>
<div class="method-description">
<p>Returns a <a href="Hash.html"><code>Hash</code></a> containing implementation-dependent counters inside the VM.</p>
<p>This hash includes information about method/constant cache serials:</p>
<pre class="ruby">{
<span class="ruby-value">:global_method_state</span><span class="ruby-operator">=></span><span class="ruby-value">251</span>,
<span class="ruby-value">:global_constant_state</span><span class="ruby-operator">=></span><span class="ruby-value">481</span>,
<span class="ruby-value">:class_serial</span><span class="ruby-operator">=></span><span class="ruby-value">9029</span>
}
</pre>
<p>The contents of the hash are implementation specific and may be changed in the future.</p>
<p>This method is only expected to work on C Ruby.</p>
<div class="method-source-code" id="stat-source">
<pre>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_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_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;
}</pre>
</div>
</div>
</div>
</section>
</section>
</main>
<footer id="validator-badges" role="contentinfo">
<p><a href="https://validator.w3.org/check/referer">Validate</a>
<p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.2.1.1.
<p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
</footer>