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

Commits on Jun 23, 2015

  1. Removed Thread#critical=.

    brixen committed Jun 23, 2015
    Copy the full SHA
    c53cd6c View commit details
  2. Copy the full SHA
    5e55964 View commit details
Showing with 12 additions and 63 deletions.
  1. +0 −12 vm/builtin/thread.cpp
  2. +0 −3 vm/builtin/thread.hpp
  3. +8 −8 vm/internal_threads.cpp
  4. +4 −1 vm/internal_threads.hpp
  5. +0 −29 vm/shared_state.cpp
  6. +0 −10 vm/shared_state.hpp
12 changes: 0 additions & 12 deletions vm/builtin/thread.cpp
Original file line number Diff line number Diff line change
@@ -329,7 +329,6 @@ namespace rubinius {
utilities::logger::debug("Thread: exit thread: id: %d", vm->thread_id());
}

shared.clear_critical(state);
shared.gc_independent();

vm->set_zombie();
@@ -502,15 +501,4 @@ namespace rubinius {

return self;
}

Object* Thread::set_critical(STATE, Object* obj, CallFrame* calling_environment) {
state->set_call_frame(calling_environment);
if(CBOOL(obj)) {
state->shared().set_critical(state, calling_environment);
return cTrue;
} else {
state->shared().clear_critical(state);
return cFalse;
}
}
}
3 changes: 0 additions & 3 deletions vm/builtin/thread.hpp
Original file line number Diff line number Diff line change
@@ -217,9 +217,6 @@ namespace rubinius {
// Rubinius.primitive :thread_join
Thread* join(STATE, GCToken gct, Object* timeout, CallFrame* calling_environment);

// Rubinius.primitive :thread_set_critical
static Object* set_critical(STATE, Object* obj, CallFrame* calling_environment);

// Rubinius.primitive :thread_unlock_locks
Object* unlock_locks(STATE, GCToken gct, CallFrame* calling_environment);

16 changes: 8 additions & 8 deletions vm/internal_threads.cpp
Original file line number Diff line number Diff line change
@@ -130,7 +130,7 @@ namespace rubinius {
if(exec_in_progress_) return;
exec_in_progress_ = true;

for(std::list<InternalThread*>::reverse_iterator i = threads_.rbegin();
for(InternalThreadList::reverse_iterator i = threads_.rbegin();
i != threads_.rend();
++i) {
(*i)->before_exec(state);
@@ -142,7 +142,7 @@ namespace rubinius {
// after execvp() call.
state->shared().env()->after_exec(state);

for(std::list<InternalThread*>::iterator i = threads_.begin();
for(InternalThreadList::iterator i = threads_.begin();
i != threads_.end();
++i) {
(*i)->after_exec(state);
@@ -157,7 +157,7 @@ namespace rubinius {
if(fork_exec_in_progress_) return;
fork_exec_in_progress_ = true;

for(std::list<InternalThread*>::reverse_iterator i = threads_.rbegin();
for(InternalThreadList::reverse_iterator i = threads_.rbegin();
i != threads_.rend();
++i) {
(*i)->before_fork_exec(state);
@@ -167,7 +167,7 @@ namespace rubinius {
void InternalThreads::after_fork_exec_parent(STATE) {
// We don't guard here on the assumption that only one thread is running
// after fork() call.
for(std::list<InternalThread*>::iterator i = threads_.begin();
for(InternalThreadList::iterator i = threads_.begin();
i != threads_.end();
++i) {
(*i)->after_fork_exec_parent(state);
@@ -179,7 +179,7 @@ namespace rubinius {
void InternalThreads::after_fork_exec_child(STATE) {
// We don't guard here on the assumption that only one thread is running
// after execvp() call.
for(std::list<InternalThread*>::iterator i = threads_.begin();
for(InternalThreadList::iterator i = threads_.begin();
i != threads_.end();
++i) {
(*i)->after_fork_exec_child(state);
@@ -195,7 +195,7 @@ namespace rubinius {
if(fork_in_progress_) return;
fork_in_progress_ = true;

for(std::list<InternalThread*>::reverse_iterator i = threads_.rbegin();
for(InternalThreadList::reverse_iterator i = threads_.rbegin();
i != threads_.rend();
++i) {
(*i)->before_fork(state);
@@ -205,7 +205,7 @@ namespace rubinius {
void InternalThreads::after_fork_parent(STATE) {
// We don't guard here on the assumption that only one thread is running
// after fork() call.
for(std::list<InternalThread*>::iterator i = threads_.begin();
for(InternalThreadList::iterator i = threads_.begin();
i != threads_.end();
++i) {
(*i)->after_fork_parent(state);
@@ -219,7 +219,7 @@ namespace rubinius {
// after fork() call.
state->shared().env()->after_fork_child(state);

for(std::list<InternalThread*>::iterator i = threads_.begin();
for(InternalThreadList::iterator i = threads_.begin();
i != threads_.end();
++i) {
(*i)->after_fork_child(state);
5 changes: 4 additions & 1 deletion vm/internal_threads.hpp
Original file line number Diff line number Diff line change
@@ -7,12 +7,15 @@
#include <list>

namespace rubinius {
class InternalThread;
class VM;

namespace metrics {
struct MetricsData;
}

typedef std::list<InternalThread*> InternalThreadList;

class InternalThread {
VM* vm_;
bool thread_running_;
@@ -73,7 +76,7 @@ namespace rubinius {
bool fork_exec_in_progress_;
bool shutdown_in_progress_;
utilities::thread::Mutex mutex_;
std::list<InternalThread*> threads_;
InternalThreadList threads_;

public:
InternalThreads()
29 changes: 0 additions & 29 deletions vm/shared_state.cpp
Original file line number Diff line number Diff line change
@@ -42,14 +42,11 @@ namespace rubinius {
, global_serial_(1)
, thread_ids_(1)
, initialized_(false)
, ruby_critical_set_(false)
, check_global_interrupts_(false)
, check_gc_(false)
, root_vm_(0)
, env_(env)
, tool_broker_(new tooling::ToolBroker)
, ruby_critical_lock_()
, set_critical_lock_()
, fork_exec_lock_()
, capi_ds_lock_()
, capi_locks_lock_()
@@ -230,8 +227,6 @@ namespace rubinius {

// Reinit the locks for this object
global_cache->reset();
ruby_critical_lock_.init();
set_critical_lock_.init();
fork_exec_lock_.init();
capi_ds_lock_.init();
capi_locks_lock_.init();
@@ -306,30 +301,6 @@ namespace rubinius {
return om->mark_address();
}

void SharedState::set_critical(STATE, CallFrame* call_frame) {
utilities::thread::SpinLock::LockGuard guard(set_critical_lock_);

if(!ruby_critical_set_ ||
!pthread_equal(ruby_critical_thread_, pthread_self())) {

GCIndependent gc_guard(state, call_frame);
ruby_critical_lock_.lock();
ruby_critical_thread_ = pthread_self();
ruby_critical_set_ = true;
}

return;
}

void SharedState::clear_critical(STATE) {
utilities::thread::SpinLock::LockGuard guard(set_critical_lock_);

if(ruby_critical_set_ && pthread_equal(ruby_critical_thread_, pthread_self())) {
ruby_critical_set_ = false;
ruby_critical_lock_.unlock();
}
}

void SharedState::enter_capi(STATE, const char* file, int line) {
NativeMethodEnvironment* env = state->vm()->native_method_environment;
if(int lock_index = env->current_native_frame()->capi_lock_index()) {
10 changes: 0 additions & 10 deletions vm/shared_state.hpp
Original file line number Diff line number Diff line change
@@ -102,20 +102,13 @@ namespace rubinius {
int thread_ids_;

bool initialized_;
bool ruby_critical_set_;
bool check_global_interrupts_;
bool check_gc_;

VM* root_vm_;
Environment* env_;
tooling::ToolBroker* tool_broker_;

// This lock is to implement Thread.critical. It is not critical as
// the name would make it sound.
utilities::thread::Mutex ruby_critical_lock_;
pthread_t ruby_critical_thread_;
utilities::thread::SpinLock set_critical_lock_;

utilities::thread::Mutex fork_exec_lock_;

utilities::thread::SpinLock capi_ds_lock_;
@@ -342,9 +335,6 @@ namespace rubinius {
void gc_independent(THREAD);
void gc_independent();

void set_critical(STATE, CallFrame* call_frame);
void clear_critical(STATE);

void enter_capi(STATE, const char* file, int line);
void leave_capi(STATE);