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

Commits on Apr 11, 2016

  1. Revert "Disable OnStack used for spawn."

    This reverts commit a932b23.
    
    Until we replace this mechanism, we're going to lock operations.
    brixen committed Apr 11, 2016
    Copy the full SHA
    9e243d0 View commit details
  2. Added locking to LinkedList operations.

    Until we remove this mechanism, we need to lock operations because somewhere
    around subprocess creation wires are getting crossed, as seen in the linked
    list assertion that randomly shows up on Travis.
    brixen committed Apr 11, 2016
    Copy the full SHA
    a69470c View commit details
Showing with 48 additions and 38 deletions.
  1. +1 −6 machine/builtin/system.cpp
  2. +22 −26 machine/linkedlist.cpp
  3. +25 −6 machine/linkedlist.hpp
7 changes: 1 addition & 6 deletions machine/builtin/system.cpp
Original file line number Diff line number Diff line change
@@ -418,12 +418,7 @@ namespace rubinius {
Object* System::vm_spawn(STATE, Object* spawn_state, String* path,
Array* args)
{
/* TODO: The spawn_state reference is reachable and the GC is not moving
* objects right now and there are sporadic failures in the spawn specs
* related to corruption of the structure used by OnStack, so this is
* temporarily disabled.
* OnStack<1> os(state, spawn_state);
*/
OnStack<1> os(state, spawn_state);

/* Setting up the command and arguments may raise an exception so do it
* before everything else.
48 changes: 22 additions & 26 deletions machine/linkedlist.cpp
Original file line number Diff line number Diff line change
@@ -2,39 +2,35 @@
#include <assert.h>
#include <iostream>

LinkedList::LinkedList() : head_(NULL), count_(0) { }
LinkedList::Node::Node() : next_(NULL), prev_(NULL) { }
namespace rubinius {
void LinkedList::add(LinkedList::Node* node) {
utilities::thread::SpinLock::LockGuard guard(lock_);

size_t LinkedList::size() const {
return count_;
}

void LinkedList::add(LinkedList::Node* node) {
assert(!node->next() && !node->prev());
// std::cout << "add: " << node << "\n";
assert(!node->next() && !node->prev());

if(head_) {
assert(!head_->prev());
head_->set_prev(node);
}
if(head_) {
assert(!head_->prev());
head_->set_prev(node);
}

node->set_next(head_);
head_ = node;
node->set_next(head_);
head_ = node;

count_++;
}
count_++;
}

void LinkedList::remove(LinkedList::Node* node) {
// std::cout << "remove: " << node << "\n";
void LinkedList::remove(LinkedList::Node* node) {
utilities::thread::SpinLock::LockGuard guard(lock_);

if(node == head_) {
head_ = node->next();
}
if(node == head_) {
head_ = node->next();
}

node->remove_linkage();
count_--;
node->remove_linkage();
count_--;

if(head_) {
assert(!head_->prev());
if(head_) {
assert(!head_->prev());
}
}
}
31 changes: 25 additions & 6 deletions machine/linkedlist.hpp
Original file line number Diff line number Diff line change
@@ -4,6 +4,9 @@
#include <stdio.h>
#include <assert.h>

#include "util/thread.hpp"

namespace rubinius{
class LinkedList {
public:

@@ -13,7 +16,10 @@ class LinkedList {
Node* prev_;

public:
Node();
Node()
: next_(NULL)
, prev_(NULL)
{ }

Node* next() const {
return next_;
@@ -50,16 +56,28 @@ class LinkedList {
private:
Node* head_;
size_t count_;
utilities::thread::SpinLock lock_;

public:
LinkedList();
Node* head() const {
LinkedList()
: head_(NULL)
, count_(0)
, lock_()
{ }

Node* head() {
utilities::thread::SpinLock::LockGuard guard(lock_);

return head_;
}

size_t size() const;
void add(Node*);
void remove(Node*);
size_t size() {
utilities::thread::SpinLock::LockGuard guard(lock_);
return count_;
}

void add(Node*);
void remove(Node*);

// Utility templates
template <typename Roots, typename Root>
@@ -101,5 +119,6 @@ class LinkedList {


};
}

#endif