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

Commits on Jun 28, 2016

  1. Copy the full SHA
    cb53413 View commit details
  2. Copy the full SHA
    54ba0f5 View commit details
  3. Copy the full SHA
    3a80de6 View commit details
Showing with 79 additions and 13 deletions.
  1. +8 −0 core/exception.rb
  2. +30 −0 machine/builtin/exception.cpp
  3. +6 −0 machine/builtin/exception.hpp
  4. +4 −2 machine/console.cpp
  5. +16 −8 machine/instructions.cpp
  6. +4 −0 machine/machine_threads.hpp
  7. +2 −0 machine/ontology.cpp
  8. +1 −1 machine/oop.hpp
  9. +8 −2 machine/vm.cpp
8 changes: 8 additions & 0 deletions core/exception.rb
Original file line number Diff line number Diff line change
@@ -545,6 +545,14 @@ def message
end
end

class InterpreterError < Exception

end

class DeadlockError < Exception

end

# MRI has an Exception class named "fatal" that is raised
# by the rb_fatal function. The class is not accessible from
# ruby because the name is begins with a lower-case letter.
30 changes: 30 additions & 0 deletions machine/builtin/exception.cpp
Original file line number Diff line number Diff line change
@@ -114,6 +114,28 @@ namespace rubinius {
RubyException::raise(Exception::make_no_method_error(state, args), true);
}

Exception* Exception::make_interpreter_error(STATE, const char* reason) {
return Exception::make_exception(state,
get_interpreter_error(state), reason);
}

void Exception::interpreter_error(STATE, const char* reason) {
Exception* exc = Exception::make_interpreter_error(state, reason);
exc->locations(state, Location::from_call_stack(state));
state->raise_exception(exc);
}

Exception* Exception::make_deadlock_error(STATE, const char* reason) {
return Exception::make_exception(state,
get_deadlock_error(state), reason);
}

void Exception::deadlock_error(STATE, const char* reason) {
Exception* exc = Exception::make_deadlock_error(state, reason);
exc->locations(state, Location::from_call_stack(state));
state->raise_exception(exc);
}

Exception* Exception::make_frozen_exception(STATE, Object* obj) {
std::ostringstream msg;
msg << "can't modify frozen instance of ";
@@ -504,6 +526,14 @@ namespace rubinius {
return as<Class>(G(object)->get_const(state, "IOError"));
}

Class* Exception::get_interpreter_error(STATE) {
return as<Class>(G(object)->get_const(state, "InterpreterError"));
}

Class* Exception::get_deadlock_error(STATE) {
return as<Class>(G(object)->get_const(state, "DeadlockError"));
}

void Exception::Info::show(STATE, Object* self, int level) {
Exception* exc = as<Exception>(self);

6 changes: 6 additions & 0 deletions machine/builtin/exception.hpp
Original file line number Diff line number Diff line change
@@ -49,6 +49,8 @@ namespace rubinius {
static Exception* make_encoding_compatibility_error(STATE, Object* a, Object* b);
static Exception* make_frozen_exception(STATE, Object* obj);
static Exception* make_no_method_error(STATE, Arguments& args);
static Exception* make_interpreter_error(STATE, const char* reason);
static Exception* make_deadlock_error(STATE, const char* reason);

NORETURN(static void raise_argument_error(STATE, int expected, int given));
NORETURN(static void raise_argument_error(STATE, const char* reason));
@@ -89,6 +91,8 @@ namespace rubinius {
static void type_error(STATE, const char* reason);
static void internal_error(STATE, const char* reason);
static void frozen_error(STATE, Object* obj);
static void interpreter_error(STATE, const char* reason);
static void deadlock_error(STATE, const char* reason);

static void encoding_compatibility_error(STATE, Object* a, Object* b);

@@ -129,6 +133,8 @@ namespace rubinius {
static Class* get_encoding_compatibility_error(STATE);
static Class* get_not_implemented_error(STATE);
static Class* get_no_method_error(STATE);
static Class* get_interpreter_error(STATE);
static Class* get_deadlock_error(STATE);

class Info : public TypeInfo {
public:
6 changes: 4 additions & 2 deletions machine/console.cpp
Original file line number Diff line number Diff line change
@@ -368,8 +368,10 @@ namespace rubinius {
void Listener::wakeup(STATE) {
MachineThread::wakeup(state);

if(write(fd_, "\0", 1) < 0) {
logger::error("%s: console: unable to wake listener thread", strerror(errno));
while(thread_running_p()) {
if(write(fd_, "\0", 1) < 0) {
logger::error("%s: console: unable to wake listener thread", strerror(errno));
}
}
}

24 changes: 16 additions & 8 deletions machine/instructions.cpp
Original file line number Diff line number Diff line change
@@ -125,7 +125,8 @@ Object* MachineCode::interpreter(STATE, MachineCode* const mcode) {

// There is no reason to be here. Either the bytecode loop exits,
// or it jumps to exception;
rubinius::bug("Control flow error in interpreter");
Exception::interpreter_error(state, "interpreter failed to dispatch");
return NULL;

// If control finds it's way down here, there is an exception.
exception:
@@ -201,7 +202,8 @@ Object* MachineCode::interpreter(STATE, MachineCode* const mcode) {
break;
} // switch

rubinius::bug("Control flow error in interpreter");
Exception::interpreter_error(state,
"interpreter exception handler failed to dispatch");
return NULL;
}

@@ -278,7 +280,8 @@ Object* MachineCode::uncommon_interpreter(STATE,
}

// No reason to be here!
rubinius::bug("Control flow error in interpreter");
Exception::interpreter_error(state, "interpreter failed to dispatch");
return NULL;

exception:
VMThreadState* th = state->vm()->thread_state();
@@ -351,7 +354,8 @@ Object* MachineCode::uncommon_interpreter(STATE,
break;
} // switch

rubinius::bug("Control flow error in interpreter");
Exception::interpreter_error(state,
"interpreter exception handler failed to dispatch");
return NULL;
}

@@ -424,7 +428,8 @@ Object* MachineCode::debugger_interpreter(STATE, MachineCode* const mcode) {
}

// no reason to be here!
rubinius::bug("Control flow error in interpreter");
Exception::interpreter_error(state, "interpreter failed to dispatch");
return NULL;

// If control finds it's way down here, there is an exception.
exception:
@@ -500,7 +505,8 @@ Object* MachineCode::debugger_interpreter(STATE, MachineCode* const mcode) {
break;
} // switch

rubinius::bug("Control flow error in interpreter");
Exception::interpreter_error(state,
"interpreter exception handler failed to dispatch");
return NULL;
}

@@ -560,7 +566,8 @@ Object* MachineCode::debugger_interpreter_continue(STATE,
}

// No reason to be here!
rubinius::bug("Control flow error in interpreter");
Exception::interpreter_error(state, "interpreter failed to dispatch");
return NULL;

exception:
VMThreadState* th = state->vm()->thread_state();
@@ -633,6 +640,7 @@ Object* MachineCode::debugger_interpreter_continue(STATE,
break;
} // switch

rubinius::bug("Control flow error in interpreter");
Exception::interpreter_error(state,
"interpreter exception handler failed to dispatch");
return NULL;
}
4 changes: 4 additions & 0 deletions machine/machine_threads.hpp
Original file line number Diff line number Diff line change
@@ -54,6 +54,10 @@ namespace rubinius {
return vm_;
}

bool thread_running_p() {
return thread_running_;
}

virtual void initialize(STATE);
virtual void start(STATE);
virtual void start_thread(STATE);
2 changes: 2 additions & 0 deletions machine/ontology.cpp
Original file line number Diff line number Diff line change
@@ -518,6 +518,8 @@ namespace rubinius {
dexc(FloatDomainError, rng);
dexc(ZeroDivisionError, std);
dexc(IOError, std);
dexc(InterpreterError, exc);
dexc(DeadlockError, exc);

GO(jump_error).set(lje);

2 changes: 1 addition & 1 deletion machine/oop.hpp
Original file line number Diff line number Diff line change
@@ -54,7 +54,7 @@ namespace rubinius {
* various object types and are used to define predicates. Use the predicates
* (ie reference_p(), fixnum_p(), symbol_p()) directly.
*/
#define __REFERENCE_P__(v) ((v) && (((intptr_t)(v) & TAG_REF_MASK) == TAG_REF))
#define __REFERENCE_P__(v) (((intptr_t)(v) & TAG_REF_MASK) == TAG_REF)
#define __FIXNUM_P__(v) (((intptr_t)(v) & TAG_FIXNUM_MASK) == TAG_FIXNUM)
#define __SYMBOL_P__(v) (((intptr_t)(v) & TAG_SYMBOL_MASK) == TAG_SYMBOL)

10 changes: 8 additions & 2 deletions machine/vm.cpp
Original file line number Diff line number Diff line change
@@ -113,9 +113,15 @@ namespace rubinius {
}

VM::~VM() {
if(profile_) delete[] profile_;
if(profile_) {
delete[] profile_;
profile_ = NULL;
}

delete park_;
if(park_) {
delete park_;
park_ = NULL;
}
}

void VM::discard(STATE, VM* vm) {