Skip to content
This repository
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 236 lines (212 sloc) 6.963 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235
#ifndef RBX_GLOBALS_HPP
#define RBX_GLOBALS_HPP

/** Rubinius Root objects
*
* This is the set of root objects that the system tracks.
* When performing garbage collection, it is these objects
* that are considered the root of the tree and walked
* to find all live objects.
*
* Typically, these are builtin class that the VM needs to
* reference directly. This is usually the case for things like
* String::create that need to have a reference to the ruby String
* class object to properly create a String instance.
*
* The rule of thumb for adding classes/modules to this list
* is whether or not the VM needs to directly reference the
* class/module. Again, this is typically only because the VM
* itself needs to create an instance of that class.
*
* There are a few non-class roots in here for runtime data.
*/


#define SPECIAL_CLASS_MASK 0x1f
#define SPECIAL_CLASS_SIZE 32

#include "gc/root.hpp"

namespace rubinius {

  class LookupTable;
  class Tuple;
  class Module;
  class Thread;
  class Class;
  class Symbol;
  class Exception;

  struct Globals {

    Roots roots;

    /* This requires some manual work when adding a root, but thats ok.
* First, add the root to the END of this list. Then add it to
* the constructor for Globals, again, at the END of the list. */

    /* classes for the core 'types' */
    TypedRoot<Class*> compiled_code, tuple, module, basicobject, object, array;
    TypedRoot<Class*> klass, methtbl, bytearray;
    TypedRoot<Class*> blokenv, bignum, regexp, matchdata;
    TypedRoot<Class*> string, symbol, io;
    TypedRoot<Class*> nil_class, true_class, false_class, fixnum_class, undef_class;
    TypedRoot<Class*> floatpoint, nmc, list, list_node;
    TypedRoot<Class*> channel, thread, constantscope, lookuptable;
    TypedRoot<Class*> iseq, executable, native_function, iobuffer;
    TypedRoot<Class*> included_module;

    /* the primary symbol table */
    TypedRoot<Symbol*> sym_method_missing;
    TypedRoot<Symbol*> sym_inherited;
    TypedRoot<Symbol*> sym_from_literal, sym_method_added, sym_s_method_added, sym_init_copy;
    TypedRoot<Symbol*> sym_plus, sym_minus, sym_equal, sym_nequal, sym_tequal, sym_lt, sym_gt;
    TypedRoot<Symbol*> sym_initialize;
    TypedRoot<Symbol*> sym_coerce_to_array;
    TypedRoot<Symbol*> sym_allocation_site;

    TypedRoot<Class*> exception;
    TypedRoot<Class*> exc_arg, exc_segfault;
    TypedRoot<Class*> exc_loe, exc_type, exc_rex, exc_rte;
    TypedRoot<Class*> exc_primitive_failure;

    TypedRoot<LookupTable*> external_ivars;
    TypedRoot<LookupTable*> errno_mapping;
    TypedRoot<Object*> config;
    TypedRoot<Symbol*> sym_send;
    TypedRoot<Symbol*> sym_public, sym_private, sym_protected, sym_const_missing;
    TypedRoot<Symbol*> sym_object_id, sym_call, sym_undef;

    TypedRoot<Object*> main, undefined;
    TypedRoot<Class*> dir;
    TypedRoot<Class*> compactlookuptable;
    TypedRoot<Class*> lookuptablebucket;
    TypedRoot<Class*> methtblbucket;
    TypedRoot<Class*> access_variable;
    TypedRoot<Module*> rubinius;
    TypedRoot<Class*> time_class;
    TypedRoot<Class*> integer;
    TypedRoot<Class*> numeric;
    TypedRoot<Class*> memory_pointer;
    TypedRoot<Module*> ffi;
    TypedRoot<Class*> ffi_pointer;
    TypedRoot<Class*> taskprobe;
    TypedRoot<Class*> randomizer;

    TypedRoot<Class*> nmethod; /**< NativeMethod */

    TypedRoot<Class*> data;

    TypedRoot<Class*> autoload; /**< Autoload class */
    TypedRoot<Class*> proc; /**< Proc class */
    TypedRoot<Class*> variable_scope;
    TypedRoot<Class*> location;
    TypedRoot<Class*> stack_error;
    TypedRoot<Class*> jump_error;
    TypedRoot<Class*> exc_vm_internal;
    TypedRoot<Class*> exc_vm_bad_bytecode;
    TypedRoot<Class*> global_cache_entry;
    TypedRoot<Class*> cls_weakref;
    TypedRoot<Class*> fiber;
    TypedRoot<Class*> alias;
    TypedRoot<Class*> encoding;
    TypedRoot<Module*> type;
    TypedRoot<Class*> vm_class;
    TypedRoot<Class*> atomic_ref;
    TypedRoot<Class*> mirror;

    /* Add new globals above this line. */

    /* Leave this as the last data member always */
    TypedRoot<Class*> special_classes[SPECIAL_CLASS_SIZE];

    Globals() :
      compiled_code(&roots),
      tuple(&roots),
      module(&roots),
      basicobject(&roots),
      object(&roots),
      array(&roots),
      klass(&roots),
      methtbl(&roots),
      bytearray(&roots),
      blokenv(&roots),
      bignum(&roots),
      regexp(&roots),
      matchdata(&roots),
      string(&roots),
      symbol(&roots),
      io(&roots),
      nil_class(&roots),
      true_class(&roots),
      false_class(&roots),
      fixnum_class(&roots),
      undef_class(&roots),
      floatpoint(&roots),
      nmc(&roots),
      list(&roots),
      list_node(&roots),
      channel(&roots),
      thread(&roots),
      constantscope(&roots),
      lookuptable(&roots),
      iseq(&roots),
      executable(&roots),
      native_function(&roots),
      iobuffer(&roots),
      included_module(&roots),
      sym_method_missing(&roots),
      sym_inherited(&roots),
      sym_from_literal(&roots),
      sym_method_added(&roots),
      sym_s_method_added(&roots),
      sym_init_copy(&roots),
      sym_plus(&roots),
      sym_minus(&roots),
      sym_equal(&roots),
      sym_nequal(&roots),
      sym_tequal(&roots),
      sym_lt(&roots),
      sym_gt(&roots),
      sym_initialize(&roots),
      sym_coerce_to_array(&roots),
      sym_allocation_site(&roots),
      exception(&roots),
      exc_arg(&roots),
      exc_segfault(&roots),
      exc_loe(&roots),
      exc_type(&roots),
      exc_rex(&roots),
      exc_rte(&roots),
      exc_primitive_failure(&roots),
      external_ivars(&roots),
      errno_mapping(&roots),
      config(&roots),
      sym_send(&roots),
      sym_public(&roots),
      sym_private(&roots),
      sym_protected(&roots),
      sym_const_missing(&roots),
      sym_object_id(&roots),
      sym_call(&roots),
      sym_undef(&roots),
      main(&roots),
      undefined(&roots),
      dir(&roots),
      compactlookuptable(&roots),
      lookuptablebucket(&roots),
      methtblbucket(&roots),
      access_variable(&roots),
      rubinius(&roots),
      time_class(&roots),
      integer(&roots),
      numeric(&roots),
      memory_pointer(&roots),
      ffi(&roots),
      ffi_pointer(&roots),
      taskprobe(&roots),
      randomizer(&roots),

      nmethod(&roots),
      data(&roots),
      autoload(&roots),
      proc(&roots),
      variable_scope(&roots),
      location(&roots),
      stack_error(&roots),
      jump_error(&roots),
      exc_vm_internal(&roots),
      exc_vm_bad_bytecode(&roots),
      global_cache_entry(&roots),
      cls_weakref(&roots),
      fiber(&roots),
      alias(&roots),
      encoding(&roots),
      type(&roots),
      vm_class(&roots),
      atomic_ref(&roots),
      mirror(&roots)

      /* Add initialize of globals above this line. */
    { }
  };
};

#endif
Something went wrong with that request. Please try again.