Permalink
Switch branches/tags
Commits on May 27, 2012
  1. Correct misaligned Fiber stack frames on x86-64

    ryoqun committed May 26, 2012
    Currently stack frames used by fibers are incorrectly aligned on x86-64.
    
    According to 3.2.2 The Stack Frame in
    System V Application Binary Interface AMD64 Architecture Processor Supplement
    (http://x86-64.org/documentation/abi.pdf), stack frames shall be aligned on a
    16 byte boundary:
    
      The end of the input argument area shall be aligned on a 16 (32, if
       __m256 is passed on stack) byte boundary. In other words, the value
      (%rsp + 8) is always a multiple of 16 (32) when control is transferred
      to the function entry point.
    
    But fiber stack frames currently aren't aligned as such. When compiled by GCC,
    there is no problem. However, when compiled by Clang, this causes SEGV, due to
    the movaps instruction in generated code used on the assumption of 16-byte
    aligned stack frames.
    
    To align correctly, this commit adjusts the initial stack frame created by
    ourselves to be 16-byte aligned. Subsequent stack frames are correctly managed
    by generated code from compilers.
    
    A sample of Segmentation fault:
    
      Program received signal SIGSEGV, Segmentation fault.
      0x00000000005c9c87 in rubinius::BytecodeVerification::verify(rubinius::State*) ()
      (gdb) disassemble
         0x00000000005c9c83 <+611>: pxor   %xmm0,%xmm0
      => 0x00000000005c9c87 <+615>: movaps %xmm0,-0x40(%rbp)
         0x00000000005c9c8b <+619>: lea    -0x40(%rbp),%r15
      (gdb) info registers rbp
      rbp            0x7ffff7eff4b8 0x7ffff7eff4b8
    
    Difference of stack frame alignment
    
    Before:
    
      (gdb) disassemble
      Dump of assembler code for function rubinius::fiber_wrap_main():
      => 0x00000000005e17c0 <+0>: mov    %r13,%rdi
         0x00000000005e17c3 <+3>: jmpq   *%r12
         0x00000000005e17c6 <+6>: retq
      End of assembler dump.
      (gdb) info registers rsp
      rsp            0x7ffff7f80000 0x7ffff7f80000
      (gdb) info frame
      Stack level 0, frame at 0x7ffff7f80008:
       rip = 0x5e17c0 in rubinius::fiber_wrap_main (vm/fiber_data.cpp:14); saved rip 0xdeadcafedeadcafe
       called by frame at 0x7ffff7f80010
       source language c++.
       Arglist at 0x7ffff7f7fff8, args:
       Locals at 0x7ffff7f7fff8, Previous frame's sp is 0x7ffff7f80008
       Saved registers:
        rip at 0x7ffff7f80000
    
    After:
    
      (gdb) disassemble
      Dump of assembler code for function rubinius::fiber_wrap_main():
      => 0x00000000005e17c0 <+0>: mov    %r13,%rdi
         0x00000000005e17c3 <+3>: jmpq   *%r12
         0x00000000005e17c6 <+6>: retq
      (gdb) info registers rsp
      rsp            0x7ffff7f7fff8 0x7ffff7f7fff8
      (gdb) info frame
      Stack level 0, frame at 0x7ffff7f80000:
       rip = 0x5e17c0 in rubinius::fiber_wrap_main (vm/fiber_data.cpp:14); saved rip 0xdeadcafedeadcafe
       called by frame at 0x7ffff7f80008
       source language c++.
       Arglist at 0x7ffff7f7fff0, args:
       Locals at 0x7ffff7f7fff0, Previous frame's sp is 0x7ffff7f80000
       Saved registers:
        rip at 0x7ffff7f7fff8
Commits on May 26, 2012
  1. Remove tags for passing specs

    dbussink committed May 26, 2012
  2. Cleanup String#squeeze! and String#delete!

    dbussink committed May 26, 2012
    With the change to the String#tr_expand! primitive these custom changes
    are no longer necessary. This closes pull requests #1736 and #1665. Both
    pull requests had useful stuff that I reused, but both also changed much
    more than necessary and also in the wrong places.
    
    Since multiple people apparently took this on and changed things in
    different places, I thought it's a good idea to solve this problem
    properly now and close the open pull requests.
  3. Merge pull request #1746 from voxik/master

    dbussink committed May 26, 2012
    RubyGems carries some obsolete files
  4. Merge pull request #1749 from mpapis/fix_rpathflag

    dbussink committed May 26, 2012
    fix RPATHFLAG, fix #1674
  5. fix RPATHFLAG, fix #1674

    mpapis committed May 26, 2012
  6. Add missing rb_num_coerce_relop in 1.8 CAPI header

    ryoqun committed May 26, 2012
    This suppresses the following warning from Clang:
    
      spec/ruby/optional/capi/ext/numeric_spec.c:77:10: warning:
        implicit declaration of function 'rb_num_coerce_relop' is invalid in C99
            [-Wimplicit-function-declaration]
        return rb_num_coerce_relop(x, y, SYM2ID(op));
               ^
      1 warning generated.
  7. Add specs to show assignment of a MatchData instance to $~ also chang…

    ileitch committed May 26, 2012
    …es derived globals.
Commits on May 25, 2012
  1. Global $~ raises a TypeError if assigned an object that is not nil or…

    ileitch committed May 25, 2012
    … an instance of MatchData.
  2. Fix rb_define_readonly_variable

    ileitch committed May 25, 2012
  3. Add rb_lastline_get. #1747

    ileitch committed May 25, 2012
  4. Specs for rb_lastline_get

    ileitch committed May 25, 2012
  5. Merge pull request #1745 from dtykocki/master

    ileitch committed May 25, 2012
    Fix for OpenStruct#initialize_copy (MRI issue #6028)
  6. Remove obsolete RubyGems files.

    voxik committed May 25, 2012
  7. Remove initialize_copy tag

    dtykocki committed May 25, 2012
  8. Fix OpenStruct#initialize_copy

    dtykocki committed May 25, 2012
Commits on May 24, 2012
  1. Revert "Move immix under rubinius::"

    ryoqun committed May 24, 2012
    This reverts commit 04923cf.
  2. Revert "Move config under rubinius::"

    ryoqun committed May 24, 2012
    This reverts commit 1c2981e.
  3. Revert "Move thread under rubinius::thread"

    ryoqun committed May 24, 2012
    This reverts commit 46e615e.
Commits on May 23, 2012
  1. Remove old LLVM task

    dbussink committed May 22, 2012
  2. Revert "Remove unused LLVM file"

    dbussink committed May 22, 2012
    This reverts commit c20a599.
  3. Move immix under rubinius::

    ryoqun committed May 23, 2012
  4. Move config under rubinius::

    ryoqun committed May 23, 2012
Commits on May 22, 2012
  1. Optimize GlobalCache for faster boot and require

    ryoqun committed Mar 20, 2012
    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*)
  2. Merge pull request #1737 from ryoqun/libffi-with-clang

    dbussink committed May 22, 2012
    Fix libffi build issue with Clang
  3. Remove an unneeded C-style cast

    ryoqun committed May 22, 2012
  4. Remove unused LLVM file

    dbussink committed May 22, 2012
Commits on May 21, 2012
  1. Exit after -Xconfig.print

    ileitch committed May 21, 2012