Ruby 2.0.0p247(2013-06-27revision41674)

- Main Page
- Modules
- Data Structures
- Files

- File List
- Globals

Data Structures | Macros | Functions | Variables
objspace.c File Reference
`#include <ruby/ruby.h>`
`#include <ruby/st.h>`
`#include <ruby/io.h>`
`#include <ruby/re.h>`
`#include "node.h"`
`#include "gc.h"`
`#include "regint.h"`
`#include "internal.h"`
Include dependency graph for objspace.c:

Go to the source code of this file.

## Data Structures
struct | total_data
struct | rof_data

## Macros
#define | CASE_TYPE(t) case t: type = ID2SYM(rb_intern(#t)); break;
#define | COUNT_NODE(n) case n: node = ID2SYM(rb_intern(#n)); break;

## Functions
size_t | rb_str_memsize (VALUE)
size_t | rb_ary_memsize (VALUE)
size_t | rb_io_memsize (const rb_io_t *)
size_t | rb_generic_ivar_memsize (VALUE)
size_t | rb_objspace_data_type_memsize (VALUE obj)
static size_t | memsize_of (VALUE obj)
static VALUE | memsize_of_m (VALUE self, VALUE obj)
static int | total_i (void *vstart, void *vend, size_t stride, void *ptr)
static VALUE | memsize_of_all_m (int argc, VALUE *argv, VALUE self)
static int | set_zero_i (st_data_t key, st_data_t val, st_data_t arg)
static int | cos_i (void *vstart, void *vend, size_t stride, void *data)
static VALUE | type2sym (enum ruby_value_type i)
static VALUE | count_objects_size (int argc, VALUE *argv, VALUE os)
static int | cn_i (void *vstart, void *vend, size_t stride, void *n)
static VALUE | count_nodes (int argc, VALUE *argv, VALUE os)
static int | cto_i (void *vstart, void *vend, size_t stride, void *data)
static VALUE | count_tdata_objects (int argc, VALUE *argv, VALUE self)
static void | iow_mark (void *ptr)
static size_t | iow_size (const void *ptr)
static VALUE | iow_newobj (VALUE obj)
static VALUE | iow_type (VALUE self)
static VALUE | iow_inspect (VALUE self)
static VALUE | iow_internal_object_id (VALUE self)
static void | reachable_object_from_i (VALUE obj, void *data_ptr)
static int | collect_values (st_data_t key, st_data_t value, st_data_t data)
static VALUE | reachable_objects_from (VALUE self, VALUE obj)
void | Init_objspace (void)

## Variables
static const rb_data_type_t | iow_data_type
static VALUE | rb_mInternalObjectWrapper

## Macro Definition Documentation

#define CASE_TYPE | ( |  | t) |  | case t: type = ID2SYM(rb_intern(#t)); break;

Referenced by type2sym().

#define COUNT_NODE | ( |  | n) |  | case n: node = ID2SYM(rb_intern(#n)); break;

Referenced by count_nodes().

## Function Documentation

static int cn_i | ( | void * | vstart,
|  | void * | vend,
|  | size_t | stride,
|  | void * | n
| ) |  |
| static

Definition at line 371 of file objspace.c.

References BUILTIN_TYPE, nd_type, RBASIC, T_NODE, and v.

Referenced by count_nodes().

static int collect_values | ( | st_data_t | key,
|  | st_data_t | value,
|  | st_data_t | data
| ) |  |
| static

Definition at line 710 of file objspace.c.

References rb_ary_push(), and ST_CONTINUE.

Referenced by reachable_objects_from().

static int cos_i | ( | void * | vstart,
|  | void * | vend,
|  | size_t | stride,
|  | void * | data
| ) |  |
| static

Definition at line 260 of file objspace.c.

References BUILTIN_TYPE, memsize_of(), RBASIC, and v.

Referenced by count_objects_size().

static VALUE count_nodes | ( | int | argc,
|  | VALUE * | argv,
|  | VALUE | os
| ) |  |
| static

Definition at line 409 of file objspace.c.

References cn_i(), COUNT_NODE, hash(), i, INT2FIX, NODE_ALIAS, NODE_ALLOCA, NODE_AND, NODE_ARGS, NODE_ARGS_AUX, NODE_ARGSCAT, NODE_ARGSPUSH, NODE_ARRAY, NODE_ATTRASGN, NODE_BACK_REF, NODE_BEGIN, NODE_BLOCK, NODE_BLOCK_ARG, NODE_BLOCK_PASS, NODE_BMETHOD, NODE_BREAK, NODE_CALL, NODE_CASE, NODE_CDECL, NODE_CLASS, NODE_COLON2, NODE_COLON3, NODE_CONST, NODE_CREF, NODE_CVAR, NODE_CVASGN, NODE_CVDECL, NODE_DASGN, NODE_DASGN_CURR, NODE_DEFINED, NODE_DEFN, NODE_DEFS, NODE_DOT2, NODE_DOT3, NODE_DREGX, NODE_DREGX_ONCE, NODE_DSTR, NODE_DSYM, NODE_DVAR, NODE_DXSTR, NODE_ENSURE, NODE_ERRINFO, NODE_EVSTR, NODE_FALSE, NODE_FCALL, NODE_FLIP2, NODE_FLIP3, NODE_FOR, NODE_GASGN, NODE_GVAR, NODE_HASH, NODE_IASGN, NODE_IASGN2, NODE_IF, NODE_IFUNC, NODE_ITER, NODE_IVAR, NODE_KW_ARG, NODE_LAMBDA, NODE_LASGN, NODE_LAST, NODE_LIT, NODE_LVAR, NODE_MASGN, NODE_MATCH, NODE_MATCH2, NODE_MATCH3, NODE_MEMO, NODE_MODULE, NODE_NEXT, NODE_NIL, NODE_NTH_REF, NODE_OP_ASGN1, NODE_OP_ASGN2, NODE_OP_ASGN_AND, NODE_OP_ASGN_OR, NODE_OP_CDECL, NODE_OPT_ARG, NODE_OPT_N, NODE_OR, NODE_POSTARG, NODE_POSTEXE, NODE_PRELUDE, NODE_REDO, NODE_RESBODY, NODE_RESCUE, NODE_RETRY, NODE_RETURN, NODE_SCLASS, NODE_SCOPE, NODE_SELF, NODE_SPLAT, NODE_STR, NODE_SUPER, NODE_TO_ARY, NODE_TRUE, NODE_UNDEF, NODE_UNTIL, NODE_VALIAS, NODE_VALUES, NODE_VCALL, NODE_WHEN, NODE_WHILE, NODE_XSTR, NODE_YIELD, NODE_ZARRAY, NODE_ZSUPER, Qnil, rb_eTypeError, rb_hash_aset(), rb_hash_new(), rb_objspace_each_objects(), rb_raise(), rb_scan_args(), RB_TYPE_P, RHASH_EMPTY_P, RHASH_TBL, set_zero_i(), SIZET2NUM, st_foreach(), and T_HASH.

Referenced by Init_objspace().

static VALUE count_objects_size | ( | int | argc,
|  | VALUE * | argv,
|  | VALUE | os
| ) |  |
| static

Definition at line 334 of file objspace.c.

References cos_i(), hash(), i, ID2SYM, Qnil, rb_eTypeError, rb_hash_aset(), rb_hash_new(), rb_intern, rb_objspace_each_objects(), rb_raise(), rb_scan_args(), RB_TYPE_P, RHASH_EMPTY_P, RHASH_TBL, set_zero_i(), SIZET2NUM, st_foreach(), T_HASH, T_MASK, total_data::total, type, and type2sym().

Referenced by Init_objspace().

static VALUE count_tdata_objects | ( | int | argc,
|  | VALUE * | argv,
|  | VALUE | self
| ) |  |
| static

Definition at line 618 of file objspace.c.

References cto_i(), hash(), Qnil, rb_eTypeError, rb_hash_new(), rb_objspace_each_objects(), rb_raise(), rb_scan_args(), RB_TYPE_P, RHASH_EMPTY_P, RHASH_TBL, set_zero_i(), st_foreach(), and T_HASH.

Referenced by Init_objspace().

static int cto_i | ( | void * | vstart,
|  | void * | vend,
|  | size_t | stride,
|  | void * | data
| ) |  |
| static

Definition at line 554 of file objspace.c.

References BUILTIN_TYPE, FIX2INT, hash(), ID2SYM, INT2FIX, key, name, NIL_P, rb_hash_aref(), rb_hash_aset(), rb_intern, rb_objspace_data_type_name(), RBASIC, T_DATA, and v.

Referenced by count_tdata_objects().

void Init_objspace | ( | void | ) |  |

Definition at line 793 of file objspace.c.

References count_nodes(), count_objects_size(), count_tdata_objects(), iow_inspect(), iow_internal_object_id(), iow_type(), memsize_of_all_m(), memsize_of_m(), rb_cObject, rb_const_get(), rb_define_class_under(), rb_define_method(), rb_define_module_function(), rb_intern, rb_mInternalObjectWrapper, and reachable_objects_from().

static VALUE iow_inspect | ( | VALUE | self) |  |
| static

Definition at line 673 of file objspace.c.

References BUILTIN_TYPE, DATA_PTR, rb_id2name(), rb_sprintf(), SYM2ID, type, and type2sym().

Referenced by Init_objspace().

static VALUE iow_internal_object_id | ( | VALUE | self) |  |
| static

Definition at line 682 of file objspace.c.

References DATA_PTR, and rb_obj_id().

Referenced by Init_objspace().

static void iow_mark | ( | void * | ptr) |  |
| static

Definition at line 640 of file objspace.c.

References rb_gc_mark().

static VALUE iow_newobj | ( | VALUE | obj) |  |
| static

Definition at line 660 of file objspace.c.

References rb_data_typed_object_alloc(), and rb_mInternalObjectWrapper.

Referenced by reachable_object_from_i().

static size_t iow_size | ( | const void * | ptr) |  |
| static

Definition at line 646 of file objspace.c.

References memsize_of().

static VALUE iow_type | ( | VALUE | self) |  |
| static

Definition at line 666 of file objspace.c.

References BUILTIN_TYPE, DATA_PTR, and type2sym().

Referenced by Init_objspace().

static size_t memsize_of | ( | VALUE | obj) |  |
| static

Definition at line 42 of file objspace.c.

References BDIGIT, BUILTIN_TYPE, rmatch::char_offset_num_allocated, FL_EXIVAR, FL_TEST, nd_type, NODE_ALLOCA, NODE_SCOPE, onig_memsize(), onig_region_memsize(), rb_ary_memsize(), rb_bug(), rb_generic_ivar_memsize(), rb_io_memsize(), rb_objspace_data_type_memsize(), rb_str_memsize(), RBASIC, RBIGNUM_DIGITS, RBIGNUM_EMBED_FLAG, RBIGNUM_LEN, RCLASS, RCLASS_IV_INDEX_TBL, RCLASS_IV_TBL, RCLASS_M_TBL, rmatch::regs, RFILE, RHASH, RMATCH, RNODE, ROBJECT, ROBJECT_EMBED, RREGEXP, RSTRUCT, RSTRUCT_EMBED_LEN_MASK, RSTRUCT_LEN, size, SPECIAL_CONST_P, st_memsize(), T_ARRAY, T_BIGNUM, T_CLASS, T_COMPLEX, T_DATA, T_FILE, T_FLOAT, T_HASH, T_ICLASS, T_MATCH, T_MODULE, T_NODE, T_OBJECT, T_RATIONAL, T_REGEXP, T_STRING, T_STRUCT, and T_ZOMBIE.

Referenced by cos_i(), iow_size(), memsize_of_m(), and total_i().

static VALUE memsize_of_all_m | ( | int | argc,
|  | VALUE * | argv,
|  | VALUE | self
| ) |  |
| static

Definition at line 238 of file objspace.c.

References total_data::klass, rb_objspace_each_objects(), rb_scan_args(), SIZET2NUM, total_data::total, and total_i().

Referenced by Init_objspace().

static VALUE memsize_of_m | ( | VALUE | self,
|  | VALUE | obj
| ) |  |
| static

Definition at line 172 of file objspace.c.

References memsize_of(), and SIZET2NUM.

Referenced by Init_objspace().

size_t rb_ary_memsize | ( | VALUE | ) |  |

Definition at line 479 of file array.c.

size_t rb_generic_ivar_memsize | ( | VALUE | ) |  |

Definition at line 1033 of file variable.c.

References st_lookup(), and st_memsize().

Referenced by memsize_of().

size_t rb_io_memsize | ( | const rb_io_t * | ) |  |

Definition at line 4175 of file io.c.

References rb_io_buffer_t::capa, rb_io_t::cbuf, rb_econv_memsize(), rb_io_t::rbuf, rb_io_t::readconv, size, rb_io_t::wbuf, and rb_io_t::writeconv.

Referenced by memsize_of().

size_t rb_objspace_data_type_memsize | ( | VALUE | obj) |  |

Definition at line 738 of file gc.c.

Referenced by memsize_of().

size_t rb_str_memsize | ( | VALUE | ) |  |

Definition at line 838 of file string.c.

References RSTRING, STR_EMBED_P, and STR_SHARED_P.

Referenced by memsize_of().

static void reachable_object_from_i | ( | VALUE | obj,
|  | void * | data_ptr
| ) |  |
| static

Definition at line 694 of file objspace.c.

References rof_data::internals, iow_newobj(), key, rb_ary_push(), rb_objspace_internal_object_p(), rb_objspace_markable_object_p(), rof_data::refs, st_insert(), and val.

Referenced by reachable_objects_from().

static VALUE reachable_objects_from | ( | VALUE | self,
|  | VALUE | obj
| ) |  |
| static

Definition at line 759 of file objspace.c.

References collect_values(), DATA_PTR, rof_data::internals, Qnil, rb_ary_new(), rb_objspace_markable_object_p(), rb_objspace_reachable_objects_from(), rb_typeddata_is_kind_of(), reachable_object_from_i(), rof_data::refs, st_foreach(), and st_init_numtable().

Referenced by Init_objspace().

static int set_zero_i | ( | st_data_t | key,
|  | st_data_t | val,
|  | st_data_t | arg
| ) |  |
| static

Definition at line 251 of file objspace.c.

References hash(), INT2FIX, rb_hash_aset(), and ST_CONTINUE.

Referenced by count_nodes(), count_objects_size(), and count_tdata_objects().

static int total_i | ( | void * | vstart,
|  | void * | vend,
|  | size_t | stride,
|  | void * | ptr
| ) |  |
| static

Definition at line 183 of file objspace.c.

References BUILTIN_TYPE, FL_SINGLETON, FL_TEST, total_data::klass, memsize_of(), rb_obj_is_kind_of(), RBASIC, T_CLASS, T_ICLASS, T_NODE, T_NONE, T_ZOMBIE, total_data::total, and v.

Referenced by memsize_of_all_m().

static VALUE type2sym | ( | enum ruby_value_type | i) |  |
| static

Definition at line 274 of file objspace.c.

References CASE_TYPE, rb_bug(), T_ARRAY, T_BIGNUM, T_CLASS, T_COMPLEX, T_DATA, T_FALSE, T_FILE, T_FIXNUM, T_FLOAT, T_HASH, T_ICLASS, T_MATCH, T_MODULE, T_NIL, T_NODE, T_NONE, T_OBJECT, T_RATIONAL, T_REGEXP, T_STRING, T_STRUCT, T_SYMBOL, T_TRUE, T_UNDEF, T_ZOMBIE, and type.

Referenced by count_objects_size(), iow_inspect(), and iow_type().

## Variable Documentation

const rb_data_type_t iow_data_type
| static

Initial value:
= {
"ObjectSpace::InternalObjectWrapper",
{iow_mark, 0, iow_size,},
}

Definition at line 652 of file objspace.c.

VALUE rb_mInternalObjectWrapper
| static

Definition at line 657 of file objspace.c.

Referenced by Init_objspace(), and iow_newobj().