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: dfb3f71f8508
Choose a base ref
...
head repository: rubinius/rubinius
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 21185c0a4b38
Choose a head ref
  • 2 commits
  • 9 files changed
  • 1 contributor

Commits on Feb 18, 2015

  1. Fixed Console plumbing.

    Also fixes finalizer and immix mark thread so that the associated
    Ruby thread is initialized. This needs to be refactored.
    brixen committed Feb 18, 2015
    Copy the full SHA
    ee8069e View commit details
  2. Copy the full SHA
    21185c0 View commit details
Showing with 42 additions and 18 deletions.
  1. +1 −0 Rakefile
  2. +22 −13 vm/builtin/thread.cpp
  3. +3 −1 vm/builtin/thread.hpp
  4. +1 −1 vm/capi/thread.cpp
  5. +9 −1 vm/console.cpp
  6. +2 −0 vm/gc/finalize.cpp
  7. +2 −0 vm/gc/immix_marker.cpp
  8. +1 −1 vm/test/test_thread.hpp
  9. +1 −1 vm/vm.cpp
1 change: 1 addition & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -80,6 +80,7 @@ class SpecRunner

@at_exit_handler_set = false
@at_exit_status = 0
@flags = nil

def self.at_exit_status
@at_exit_status
35 changes: 22 additions & 13 deletions vm/builtin/thread.cpp
Original file line number Diff line number Diff line change
@@ -47,16 +47,18 @@ namespace rubinius {
G(thread)->set_object_type(state, Thread::type);
}

Thread* Thread::create(STATE, VM* target, Object* self, ThreadFunction function) {
Thread* thr = state->vm()->new_object_mature<Thread>(G(thread));
Thread* Thread::create(STATE, VM* vm) {
return Thread::create(state, G(thread), vm);
}

if(!target) {
target = state->shared().new_vm();
target->metrics().init(metrics::eRubyMetrics);
}
Thread* Thread::create(STATE, Class* klass, VM* vm) {
Thread* thr = state->vm()->new_object_mature<Thread>(G(thread));

thr->pin();
thr->thread_id(state, Fixnum::from(target->thread_id()));
thr->init_lock_.init();

thr->vm_ = vm;
thr->thread_id(state, Fixnum::from(vm->thread_id()));
thr->sleep(state, cFalse);
thr->control_channel(state, nil<Channel>());
thr->locals(state, LookupTable::create(state));
@@ -69,13 +71,20 @@ namespace rubinius {
thr->joins(state, Array::create(state, 1));
thr->killed(state, cFalse);
thr->priority(state, Fixnum::from(0));
thr->klass(state, klass);

thr->vm_ = target;
thr->klass(state, as<Class>(self));
thr->function_ = function;
thr->init_lock_.init();
vm->thread.set(thr);

return thr;
}

target->thread.set(thr);
Thread* Thread::create(STATE, Object* self, ThreadFunction function) {
VM* vm = state->shared().new_vm();
vm->metrics().init(metrics::eRubyMetrics);

Thread* thr = Thread::create(state, as<Class>(self), vm);

thr->function_ = function;

state->memory()->needs_finalization(thr, (FinalizerFunction)&Thread::finalize);

@@ -96,7 +105,7 @@ namespace rubinius {
}

Thread* Thread::allocate(STATE, Object* self) {
return Thread::create(state, NULL, self, send_run);
return Thread::create(state, self, send_run);
}

Thread* Thread::current(STATE) {
4 changes: 3 additions & 1 deletion vm/builtin/thread.hpp
Original file line number Diff line number Diff line change
@@ -281,7 +281,9 @@ namespace rubinius {
*
* @see Thread::allocate().
*/
static Thread* create(STATE, VM* target, Object* self, ThreadFunction function);
static Thread* create(STATE, Object* self, ThreadFunction function);
static Thread* create(STATE, VM* vm);
static Thread* create(STATE, Class* klass, VM* vm);

static void finalize(STATE, Thread* thread);

2 changes: 1 addition & 1 deletion vm/capi/thread.cpp
Original file line number Diff line number Diff line change
@@ -332,7 +332,7 @@ extern "C" {

Pointer* ptr = Pointer::create(state, arg);

Thread* thr = Thread::create(env->state(), NULL, G(thread), run_function);
Thread* thr = Thread::create(env->state(), G(thread), run_function);

thr->locals_store(state, state->symbol("function"), nm);
thr->locals_store(state, state->symbol("argument"), ptr);
10 changes: 9 additions & 1 deletion vm/console.cpp
Original file line number Diff line number Diff line change
@@ -188,6 +188,8 @@ namespace rubinius {
path_ = state->shared().fsapi_path + "/console-response";
console_->server_class(state)->set_const(state, state->symbol("ResponsePath"),
String::create(state, path_.c_str()));

Thread::create(state, vm());
}

void Response::start_thread(STATE) {
@@ -313,7 +315,13 @@ namespace rubinius {
result = console_->evaluate(state, request);
}

if(String* response = try_as<String>(result)) {
if(!result) {
if(Exception* exception = try_as<Exception>(
state->thread_state()->current_exception())) {
String* msg = as<String>(exception->reason_message());
logger::error("console: response: exception: %s", msg->c_str(state));
}
} else if(String* response = try_as<String>(result)) {
write_response(state,
reinterpret_cast<const char*>(response->byte_address()),
response->byte_size());
2 changes: 2 additions & 0 deletions vm/gc/finalize.cpp
Original file line number Diff line number Diff line change
@@ -103,6 +103,8 @@ namespace rubinius {
void FinalizerThread::initialize(STATE) {
InternalThread::initialize(state);

Thread::create(state, vm());

live_guard_.init();
worker_lock_.init();
worker_cond_.init();
2 changes: 2 additions & 0 deletions vm/gc/immix_marker.cpp
Original file line number Diff line number Diff line change
@@ -33,6 +33,8 @@ namespace rubinius {
void ImmixMarker::initialize(STATE) {
InternalThread::initialize(state);

Thread::create(state, vm());

run_lock_.init();
run_cond_.init();
}
2 changes: 1 addition & 1 deletion vm/test/test_thread.hpp
Original file line number Diff line number Diff line change
@@ -20,7 +20,7 @@ class TestThread : public CxxTest::TestSuite, public VMTest {
}

void test_create() {
Thread* thr = Thread::create(state, new_vm(), G(thread), 0);
Thread* thr = Thread::create(state, new_vm());

TS_ASSERT_DIFFERS(thr, Thread::current(state));
}
2 changes: 1 addition & 1 deletion vm/vm.cpp
Original file line number Diff line number Diff line change
@@ -141,7 +141,7 @@ namespace rubinius {

// Setup the main Thread, which is wrapper of the main native thread
// when the VM boots.
thread.set(Thread::create(&state, this, G(thread), 0), &globals().roots);
Thread::create(&state, this);
thread->alive(&state, cTrue);
thread->sleep(&state, cFalse);