Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: rubinius/rubinius
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 08c6a865defc
Choose a base ref
...
head repository: rubinius/rubinius
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: e200552e61fc
Choose a head ref
  • 11 commits
  • 13 files changed
  • 1 contributor

Commits on Jun 6, 2016

  1. Copy the full SHA
    174a3ab View commit details
  2. Copy the full SHA
    7604c13 View commit details
  3. Another Travis test.

    brixen committed Jun 6, 2016
    Copy the full SHA
    a0a7287 View commit details
  4. Improved logging message format.

    Generally, log messages for non-exceptional events should follow the format:
    
      object: operation: details
    
    For example: 'process: fork: child: <PID, ...'
    
    For exceptional events, the format should be:
    
      <strerror result>: object: details
    brixen committed Jun 6, 2016
    Copy the full SHA
    125baf2 View commit details

Commits on Jun 7, 2016

  1. Copy the full SHA
    b7d9a10 View commit details
  2. Improved Fiber attributes and logging.

    Fiber#source returns the non-core library source code line where the Fiber
    was created. Fiber#thread_name returns the name of the Thread that created the
    Fiber. Fiber#fiber_id returns a unique ID for the Fiber instance.
    
    The Rubinius log includes entries for the Fiber create and exit events.
    brixen committed Jun 7, 2016
    Copy the full SHA
    862a8fd View commit details
  3. Copy the full SHA
    10fea49 View commit details
  4. Copy the full SHA
    1e56ff7 View commit details
  5. Revert "Enable ccache for faster builds (#3660)"

    This reverts commit 06a4629.
    brixen committed Jun 7, 2016
    Copy the full SHA
    3e92ea5 View commit details
  6. Revert "Another Travis test."

    This reverts commit a0a7287.
    brixen committed Jun 7, 2016
    Copy the full SHA
    55439d5 View commit details
  7. Copy the full SHA
    e200552 View commit details
15 changes: 4 additions & 11 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,33 +1,27 @@
language: cpp
cache:
ccache: true
directories:
- $HOME/vendor/bundle
- $HOME/.rvm/archives/
sudo: required
dist: trusty
compiler:
- clang
os:
- linux
- osx
ruby: 2.2.0
before_install:
- rvm install 2.2.0 && rvm use 2.2.0
- echo $LANG
- echo $LC_ALL
- if [ $TRAVIS_OS_NAME == linux ]; then ccache -s; export CC="ccache clang -Qunused-arguments -fcolor-diagnostics"; export CXX="ccache clang++ -Qunused-arguments -fcolor-diagnostics"; ./scripts/llvm.sh; fi
- if [ $TRAVIS_OS_NAME == osx ]; then brew update && brew install llvm ccache; ccache -s; export CC="ccache clang -Qunused-arguments -fcolor-diagnostics"; export CXX="ccache clang++ -Qunused-arguments -fcolor-diagnostics"; export PATH="/usr/local/opt/ccache/libexec:$PATH"; fi
- if [ $TRAVIS_OS_NAME == linux ]; then ./scripts/llvm.sh; fi
- if [ $TRAVIS_OS_NAME == osx ]; then brew update && brew install llvm; fi
- gem update --system
- gem --version
before_script:
- travis_retry bundle -j 2
- travis_retry bundle
- if [ $TRAVIS_OS_NAME == linux ]; then travis_retry ./configure --llvm-config=llvm-config-3.6; fi
- if [ $TRAVIS_OS_NAME == osx ]; then travis_retry ./configure; fi
script: rake ci
after_success:
- if [ $TRAVIS_OS_NAME == linux ]; then ./scripts/build_support.sh archive_core; fi
- if [ $TRAVIS_BRANCH == $TRAVIS_TAG ]; then ./scripts/deploy.sh release github website triggers; fi
- ccache -s
branches:
only:
- master
@@ -47,7 +41,6 @@ notifications:
on_start: always
env:
global:
- CCACHE_CPP2=yes
- LANG="en_US.UTF-8"
- secure: olbok/GN6rOYvPnHBYWGz7giCoCdLFpT/7WSBHukYO3E0uNeqAUOOgW2BFOwCVWdSEJ/iTvJXZQ4qVZHX+6jRfvILZeGv+D2P93VdD8UFQRoTOfFC7esAo525s9fuKm9ehUGWZxlzGOBHHckky1jn6pEf8mlXAVM5e76dlH0fck=
- secure: aqG9eB/PrzQ7XJQN6YX/00sNVvwSB77saxXQzguL2WFjAXB74h6168Hzq+awHtNX/vfOb6ta7fpWLHrA0D+gmZnvTR29VlP6nd0vs1tkdX1/jWbiBHjamRffp+NWVdKbJKYn5iLOGXcuUMOzY/opLKOdvxKZfkxGMxR2tTNLZUE=
2 changes: 1 addition & 1 deletion core/enumerator.rb
Original file line number Diff line number Diff line change
@@ -449,7 +449,7 @@ def zip(*lists)

if Rubinius::Fiber::ENABLED
class FiberGenerator
STACK_SIZE = 163_840
STACK_SIZE = 1_048_576

attr_reader :result

9 changes: 9 additions & 0 deletions core/fiber.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
module Rubinius
class Fiber
attr_reader :stack_size
attr_reader :thread_name
attr_reader :fiber_id
attr_reader :source

def self.new(**kw, &block)
if block.nil?
@@ -35,5 +38,11 @@ def transfer(*args)
def alive?
!@dead
end

def inspect
str = "#<#{self.class}:0x#{object_id.to_s(16)} thread_name=#{@thread_name} fiber_id=#{@fiber_id} status=#{alive? ? "alive" : "dead"}"
str << " source=#{@source}" if @source
str << ">"
end
end
end
6 changes: 5 additions & 1 deletion core/thread.rb
Original file line number Diff line number Diff line change
@@ -8,6 +8,7 @@ class Thread
attr_reader :pid
attr_reader :exception
attr_reader :stack_size
attr_reader :source

def self.new(*args, **kw, &block)
stack_size = Rubinius::Type.try_convert kw[:stack_size], Fixnum, :to_int
@@ -132,7 +133,10 @@ def inspect
stat = status()
stat = "dead" unless stat

"#<#{self.class}:0x#{object_id.to_s(16)} id=#{@thread_id} #{stat}>"
str = "#<#{self.class}:0x#{object_id.to_s(16)} id=#{@thread_id} pid=#{@pid}"
str << " source=#{@source}" if @source
str << " status=#{stat || "dead"}"
str << ">"
end

alias_method :to_s, :inspect
16 changes: 10 additions & 6 deletions machine/builtin/data.cpp
Original file line number Diff line number Diff line change
@@ -25,7 +25,9 @@ namespace rubinius {
// the handle and populate it as an RData now.
capi::Handle* handle = data->handle(state);

assert(!handle && "can't already have a handle, it's brand new!");
if(handle) {
Exception::raise_runtime_error(state, "new Data instance already has C-API handle");
}

handle = state->memory()->add_capi_handle(state, data);

@@ -59,7 +61,9 @@ namespace rubinius {
// the handle and populate it as an RData now.
capi::Handle* handle = data->handle(state);

assert(!handle && "can't already have a handle, it's brand new!");
if(handle) {
Exception::raise_runtime_error(state, "new Data instance already has C-API handle");
}

handle = state->memory()->add_capi_handle(state, data);

@@ -110,17 +114,17 @@ namespace rubinius {
capi::Handle* handle = data->handle(state);

if(!handle->valid_p()) {
logger::fatal("finalizer: Data object has invalid handle");
logger::error("finalizer: Data object has invalid handle");
return;
}

if(handle->object() != data) {
logger::fatal("finalizer: Data object handle does not reference the object");
logger::error("finalizer: Data object handle does not reference the object");
return;
}

if(data->freed_p()) {
logger::fatal("finalizer: Data finalize called for already freed object");
logger::error("finalizer: Data finalize called for already freed object");
return;
}
data->set_freed();
@@ -156,7 +160,7 @@ namespace rubinius {
}

if(data->freed_p()) {
logger::fatal("finalizer: Data mark called for already freed object");
logger::error("finalizer: Data mark called for already freed object");
return;
}

37 changes: 32 additions & 5 deletions machine/builtin/fiber.cpp
Original file line number Diff line number Diff line change
@@ -12,19 +12,29 @@

#include "memory/gc.hpp"

#include <ostream>
#include <string>

namespace rubinius {
std::atomic<uint32_t> Fiber::fiber_ids_;

void Fiber::bootstrap(STATE) {
GO(fiber).set(state->memory()->new_class<Class, Fiber>(
state, G(rubinius), "Fiber"));

fiber_ids_.store(0);

#ifdef RBX_FIBER_ENABLED
G(fiber)->set_const(state, "ENABLED", cTrue);
#else
G(fiber)->set_const(state, "ENABLED", cFalse);
#endif
}

double Fiber::run_time() {
return timer::time_elapsed_seconds(start_time());
}

Fiber* Fiber::current(STATE) {
#ifdef RBX_FIBER_ENABLED
Fiber* fib = state->vm()->current_fiber.get();
@@ -72,6 +82,10 @@ namespace rubinius {
fib->dead(cTrue);
fib->set_call_frame(state, 0);

logger::write("fiber: exit: %s, %d, %fs",
fib->thread_name()->c_str(state),
fib->fiber_id()->to_native(), fib->run_time());

Fiber* dest = fib->prev();

// If this fiber has already been cleaned up, just ignore this
@@ -116,6 +130,22 @@ namespace rubinius {
fib->stack_size(state, size);
}

if(CallFrame* call_frame = state->vm()->get_noncore_frame(state)) {
std::ostringstream source;

source << call_frame->file(state)->cpp_str(state).c_str()
<< ":" << call_frame->line(state);

logger::write("fiber: new: %s, %d, %s",
fib->thread_name()->c_str(state),
fib->fiber_id()->to_native(), source.str().c_str());

fib->source(state, String::create(state, source.str().c_str()));
} else {
logger::write("fiber: new: %s, %d",
fib->thread_name()->c_str(state), fib->fiber_id()->to_native());
}

state->vm()->metrics().system.fibers_created++;

state->memory()->native_finalizer(state, fib,
@@ -288,12 +318,9 @@ namespace rubinius {

void Fiber::finalize(STATE, Fiber* fib) {
#ifdef RBX_FIBER_ENABLED
if(!fib->data()) {
logger::fatal("finalizer: Fiber finalize called on instance with NULL data");
return;
}
logger::write("finalizer: fiber: %ld", (intptr_t)fib);

logger::fatal("finalizer: Fiber finalize");
if(!fib->data()) return;
fib->data()->orphan(state);

delete fib->data();
18 changes: 18 additions & 0 deletions machine/builtin/fiber.hpp
Original file line number Diff line number Diff line change
@@ -8,6 +8,12 @@
#include "builtin/exception.hpp"
#include "builtin/lookup_table.hpp"
#include "builtin/object.hpp"
#include "builtin/string.hpp"

#include "instruments/timing.hpp"

#include <stdint.h>
#include <atomic>

namespace rubinius {
class LookupTable;
@@ -16,6 +22,8 @@ namespace rubinius {
public:
const static object_type type = FiberType;

static std::atomic<uint32_t> fiber_ids_;

enum Status {
eNotStarted, eSleeping, eRunning, eDead
};
@@ -27,11 +35,15 @@ namespace rubinius {
attr_accessor(locals, LookupTable);
attr_accessor(dead, Object);
attr_accessor(stack_size, Fixnum);
attr_accessor(thread_name, String);
attr_accessor(fiber_id, Fixnum);
attr_accessor(source, String);

private:
attr_field(status, Status);
attr_field(root, bool);
attr_field(data, FiberData*);
attr_field(start_time, uint64_t);

public:
bool root_p() const {
@@ -84,15 +96,21 @@ namespace rubinius {
obj->locals(nil<LookupTable>());
obj->dead(nil<Object>());
obj->stack_size(Fixnum::from(state->shared().config.machine_fiber_stack_size.value));
obj->thread_name(String::create(state, state->vm()->name().c_str()));
obj->fiber_id(Fixnum::from(++Fiber::fiber_ids_));
obj->source(nil<String>());
obj->status(eNotStarted);
obj->root(false);
obj->data(NULL);
obj->start_time(get_current_time());
}

// Rubinius.primitive :fiber_new
static Fiber* create(STATE, Object* self, Object* stack_size, Object* callable);
static void start_on_stack();

double run_time();

// Rubinius.primitive :fiber_s_current
static Fiber* current(STATE);

16 changes: 8 additions & 8 deletions machine/builtin/system.cpp
Original file line number Diff line number Diff line change
@@ -489,13 +489,13 @@ namespace rubinius {
close(errors[1]);

if(CallFrame* call_frame = state->vm()->get_noncore_frame(state)) {
logger::write("spawn: %d: %s, %s, %s:%d",
logger::write("process: spawn: %d: %s, %s, %s:%d",
pid, exe.command(),
state->vm()->name().c_str(),
call_frame->file(state)->cpp_str(state).c_str(),
call_frame->line(state));
} else {
logger::write("spawn: %d: %s, %s",
logger::write("process: spawn: %d: %s, %s",
pid, exe.command(),
state->vm()->name().c_str());
}
@@ -609,13 +609,13 @@ namespace rubinius {
close(output[1]);

if(CallFrame* call_frame = state->vm()->get_noncore_frame(state)) {
logger::write("backtick: %d: %s, %s, %s:%d",
logger::write("process: backtick: %d: %s, %s, %s:%d",
pid, exe.command(),
state->vm()->name().c_str(),
call_frame->file(state)->cpp_str(state).c_str(),
call_frame->line(state));
} else {
logger::write("backtick: %d: %s, %s",
logger::write("process: backtick: %d: %s, %s",
pid, exe.command(),
state->vm()->name().c_str());
}
@@ -693,12 +693,12 @@ namespace rubinius {
ExecCommand exe(state, path, args);

if(CallFrame* call_frame = state->vm()->get_noncore_frame(state)) {
logger::write("exec: %s, %s, %s:%d", exe.command(),
logger::write("process: exec: %s, %s, %s:%d", exe.command(),
state->vm()->name().c_str(),
call_frame->file(state)->cpp_str(state).c_str(),
call_frame->line(state));
} else {
logger::write("exec: %s, %s", exe.command(),
logger::write("process: exec: %s, %s", exe.command(),
state->vm()->name().c_str());
}

@@ -847,12 +847,12 @@ namespace rubinius {
state->shared().machine_threads()->after_fork_parent(state);

if(CallFrame* call_frame = state->vm()->get_noncore_frame(state)) {
logger::write("fork: child: %d, %s, %s:%d", pid,
logger::write("process: fork: child: %d, %s, %s:%d", pid,
state->vm()->name().c_str(),
call_frame->file(state)->cpp_str(state).c_str(),
call_frame->line(state));
} else {
logger::write("fork: child: %d, %s", pid,
logger::write("process: fork: child: %d, %s", pid,
state->vm()->name().c_str());
}
} else if(pid == 0) {
Loading