Optimize GlobalCache for faster boot and require

After a typical cachegrind session, a bottle neck is found in the startup phase
of Rubinius. As shown by Cachegrind results at bottom, there are too many CPU
L1 data cache misses.

Namely, the bottle neck is GlobalCache::clear(STATE, Symbol* name), which is
inlined into System::vm_reset_method_cache(STATE, rubinius::Symbol*). This is
confirmed by OProfile result at bottom.

clear() is frequently called when defining classes and modules (eg, starting up
Rubinius itself and loading source files).

The cause of the bottle neck is that clear() writes to non-continuous memory in
its extremely-tight loop. Of course, that's not CPU cache friendly.

This commit simply arranges memory layout to make clear()'s write memory access
pattern contiguous. This layout change incurs a tiny trade-off.  It is that
GlobalCache's lookup-related functions get slow by a negligible fraction in
relation to the entire VM execution. And they are not heavily called as much as
clear(). By these reasons, no hot code path is affected by this tiny trade-off.
Thus, the trade-off is justified.

As show below, Rubinius's startup gets faster by about ~10%.

Benchmark results

Before:
  $ ./bin/benchmark ./benchmark/real_world/bench_startup.rb
  === bin/rbx ===
   startup        3.2 (±0.0%) i/s -         96 in  30.231348s (cycle=1)

After:
  $ ./bin/benchmark ./benchmark/real_world/bench_startup.rb
  === bin/rbx ===
    startup        3.5 (±0.0%) i/s -        105 in  30.205996s (cycle=1)

Cachegrind results

Before:
  Command:          ./bin/rbx -e nil

  --------------------------------------------------------------------------------
           Ir    I1mr  ILmr         Dr       D1mr    DLmr        Dw    D1mw    DLmw  file:function
  --------------------------------------------------------------------------------
  154,972,950     768     1 25,825,280 19,371,341      10    12,762   1,231       0  /home/ryoqun/rubinius-master/vm/global_cache.hpp:rubinius::System::vm_reset_method_cache(rubinius::State*, rubinius::Symbol*)
   54,637,620 149,561    64  7,544,407      2,882      46 4,077,709      22       0  /build/buildd/eglibc-2.15/stdlib/../stdlib/strtol_l.c:____strtol_l_internal
   33,793,180 106,669    20  8,502,053        979      10 5,318,282      21       0  /build/buildd/gcc-4.6-4.6.3/build/x86_64-linux-gnu/libstdc++-v3/include/bits/istream.tcc:std::istream::sentry::sentry(std::istream&, bool)
   29,731,837   8,233    30  8,504,145    195,451   6,440 2,953,027     126       2  /home/ryoqun/rubinius-master/vm/symboltable.cpp:rubinius::SymbolTable::lookup(char const*, unsigned long, unsigned int)
   25,182,478  24,355    24  6,715,362          1       0 3,693,388       0       0  /build/buildd/gcc-4.6-4.6.3/build/x86_64-linux-gnu/libstdc++-v3/src/../../../../src/libstdc++-v3/src/istream.cc:std::istream::getline(char*, long, char)

After:
  Command:          ./bin/rbx -e nil
  --------------------------------------------------------------------------------
           Ir    I1mr ILmr         Dr      D1mr    DLmr        Dw    D1mw    DLmw  file:function
  --------------------------------------------------------------------------------
  129,143,424     833    1 25,825,280 3,152,848   2,026    12,768   3,240     250  /home/ryoqun/rubinius-master/vm/global_cache.hpp:rubinius::System::vm_reset_method_cache(rubinius::State*, rubinius::Symbol*)
   54,637,620 149,494   64  7,544,407     2,888      46 4,077,709      10       0  /build/buildd/eglibc-2.15/stdlib/../stdlib/strtol_l.c:____strtol_l_internal
   33,793,180 106,660   20  8,502,053       728       9 5,318,282      18       0  /build/buildd/gcc-4.6-4.6.3/build/x86_64-linux-gnu/libstdc++-v3/include/bits/istream.tcc:std::istream::sentry::sentry(std::istream&, bool)
   29,733,057   7,809   30  8,504,495   195,446   6,076 2,953,147     144       5  /home/ryoqun/rubinius-master/vm/symboltable.cpp:rubinius::SymbolTable::lookup(char const*, unsigned long, unsigned int)
   25,182,478  24,552   24  6,715,362         0       0 3,693,388       0       0  /build/buildd/gcc-4.6-4.6.3/build/x86_64-linux-gnu/libstdc++-v3/src/../../../../src/libstdc++-v3/src/istream.cc:std::istream::getline(char*, long, char)

OProfile's opannotate results (after running "./bin/rbx -e nil" several times)

Before:
  $ opannotate --merge all image:/home/ryoqun/rubinius-master/bin/rbx -t 1 \
               --source
                 :    void clear(STATE, Symbol* name) {
                 :      thread::SpinLock::LockGuard guard(lock_);
    4490 18.6323 :      for(size_t i = 0; i < CPU_CACHE_SIZE; i++) {
     228  0.9461 :        if(entries[i].name == name) {
                 :          entries[i].clear();
                 :        }
                 :      }
                 :    }

After:
  $ opannotate --merge all image:/home/ryoqun/rubinius-master/bin/rbx -t 1 \
               --source
                 :    void clear(STATE, Symbol* name) {
                 :      thread::SpinLock::LockGuard guard(lock_);
     957  6.6648 :      for(size_t i = 0; i < CPU_CACHE_SIZE; i++) {
     687  4.7845 :        if(entry_names[i] == name) {
                 :          entry_names[i] = NULL;
       1  0.0070 :          entries[i].clear();
                 :        }
                 :      }
                 :    }

OProfile's opreport results (after running "./bin/rbx -e nil" several times)

Before:
  $ opreport --merge all image:/home/ryoqun/rubinius-master/bin/rbx --symbols -t 1
  samples  %        symbol name
  1105     19.4611  rubinius::System::vm_reset_method_cache(rubinius::State*, rubinius::Symbol*)
  770      13.5611  rubinius::SymbolTable::lookup(char const*, unsigned long, unsigned int)
  563       9.9155  rubinius::VMMethod::interpreter(rubinius::State*, rubinius::VMMethod*, rubinius::InterpreterCallFrame*)
  272       4.7904  rubinius::BakerGC::saw_object(rubinius::Object*)
  201       3.5400  rubinius::InlineCacheRegistry::clear(rubinius::State*, rubinius::Symbol*)

After:
  $ opreport --merge all image:/home/ryoqun/rubinius-master/bin/rbx --symbols -t 1
  samples  %        symbol name
  2375     12.4190  rubinius::SymbolTable::lookup(char const*, unsigned long, unsigned int)
  2101     10.9862  rubinius::VMMethod::interpreter(rubinius::State*, rubinius::VMMethod*, rubinius::InterpreterCallFrame*)
  2099     10.9757  rubinius::System::vm_reset_method_cache(rubinius::State*, rubinius::Symbol*)
  1073      5.6108  rubinius::BakerGC::saw_object(rubinius::Object*)
  822       4.2983  rubinius::InlineCacheRegistry::clear(rubinius::State*, rubinius::Symbol*)