Permalink
Browse files

Convert abort()s into bug()s

  • Loading branch information...
1 parent 1954d89 commit b3cf5f25a27ab0b1becab6c5cbd3bbb1bc0f805c @evanphx evanphx committed May 26, 2011
@@ -43,9 +43,13 @@ namespace rubinius {
if(unlikely(!ba)) {
Exception::memory_error(state);
}
+
+ if(!ba->pin()) {
+ rubinius::bug("unable to allocate pinned ByteArray");
+ }
+
ba->full_size_ = body;
memset(ba->bytes, 0, bytes);
- if(!ba->pin()) { abort(); }
return ba;
}
@@ -127,7 +127,9 @@ namespace rubinius {
// We pin this so we can pass condition_ out without worrying about
// us moving it.
- if(!this->pin()) rubinius::abort();
+ if(!this->pin()) {
+ rubinius::bug("unable to pin Channel");
+ }
struct timeval tv = {0,0};
if(use_timed_wait) {
@@ -43,9 +43,13 @@ namespace rubinius {
if(unlikely(!ba)) {
Exception::memory_error(state);
}
+
+ if(!ba->pin()) {
+ rubinius::bug("unable to allocate pinned CharArray");
+ }
+
ba->full_size_ = body;
memset(ba->bytes, 0, bytes);
- if(!ba->pin()) { abort(); }
return ba;
}
@@ -181,7 +181,7 @@ namespace rubinius {
* This locks the class so that construction is serialized.
*/
void Class::auto_pack(STATE) {
- if(lock(state) != eLocked) rubinius::abort();
+ hard_lock(state);
// If another thread did this work while we were waiting on the lock,
// don't redo it.
@@ -232,7 +232,7 @@ namespace rubinius {
set_object_type(state, PackedObject::type);
- if(unlock(state) != eUnlocked) rubinius::abort();
+ hard_unlock(state);
}
Class* Class::real_class(STATE, Class* klass) {
@@ -103,7 +103,8 @@ namespace rubinius {
VMMethod* vmm = backend_method_;
atomic::memory_barrier();
if(!vmm) {
- if(lock(state) != eLocked) rubinius::abort();
+ hard_lock(state);
+
vmm = backend_method_;
if(!vmm) {
{
@@ -130,7 +131,7 @@ namespace rubinius {
backend_method_ = vmm;
}
- unlock(state);
+ hard_unlock(state);
}
return vmm;
}
@@ -98,7 +98,7 @@ namespace rubinius {
assert(0 && "fatal start_on_stack error");
#else
- abort();
+ rubinius::bug("Fibers not supported on this platform");
#endif
}
@@ -103,7 +103,7 @@ namespace rubinius {
MethodTableBucket* entry;
MethodTableBucket* last = NULL;
- if(lock(state) != eLocked) rubinius::abort();
+ hard_lock(state);
Executable* method;
if(exec->nil_p()) {
@@ -130,7 +130,7 @@ namespace rubinius {
if(entry->name() == name) {
entry->method(state, method);
entry->visibility(state, vis);
- if(unlock(state) != eUnlocked) rubinius::abort();
+ hard_unlock(state);
return name;
}
last = entry;
@@ -145,7 +145,7 @@ namespace rubinius {
entries(state, Fixnum::from(num_entries + 1));
- if(unlock(state) != eUnlocked) rubinius::abort();
+ hard_unlock(state);
return name;
}
@@ -157,7 +157,7 @@ namespace rubinius {
MethodTableBucket* entry;
MethodTableBucket* last = NULL;
- if(lock(state) != eLocked) rubinius::abort();
+ hard_lock(state);
Executable* orig_exec;
if(Alias* alias = try_as<Alias>(orig_method)) {
@@ -186,7 +186,7 @@ namespace rubinius {
if(entry->name() == name) {
entry->method(state, method);
entry->visibility(state, vis);
- if(unlock(state) != eUnlocked) rubinius::abort();
+ hard_unlock(state);
return name;
}
last = entry;
@@ -200,7 +200,7 @@ namespace rubinius {
}
entries(state, Fixnum::from(num_entries + 1));
- if(unlock(state) != eUnlocked) rubinius::abort();
+ hard_unlock(state);
return name;
}
MethodTableBucket* MethodTable::find_entry(STATE, Symbol* name) {
@@ -248,7 +248,7 @@ namespace rubinius {
MethodTableBucket* entry;
MethodTableBucket* last = NULL;
- if(lock(state) != eLocked) rubinius::abort();
+ hard_lock(state);
size_t num_entries = entries_->to_native();
size_t num_bins = bins_->to_native();
@@ -269,15 +269,15 @@ namespace rubinius {
values_->put(state, bin, entry->next());
}
entries(state, Fixnum::from(entries_->to_native() - 1));
- if(unlock(state) != eUnlocked) rubinius::abort();
+ hard_unlock(state);
return val;
}
last = entry;
entry = try_as<MethodTableBucket>(entry->next());
}
- if(unlock(state) != eUnlocked) rubinius::abort();
+ hard_unlock(state);
return nil<Executable>();
}
@@ -144,7 +144,7 @@ namespace rubinius {
return sizeof(void*);
default:
- abort();
+ rubinius::bug("Unsupported FFI type");
return 0; // Keep GCC happy
}
}
@@ -169,7 +169,7 @@ namespace rubinius {
}
void NativeMethodEnvironment::delete_global(VALUE val) {
- abort();
+ rubinius::bug("NME::delete_global was used");
}
Object* NativeMethodEnvironment::block() {
View
@@ -9,14 +9,11 @@
#include "prelude.hpp"
#include "builtin/object.hpp"
+#include "bug.hpp"
+
namespace rubinius {
class Exception;
- void abort();
- void bug(const char* message);
- void bug(const char* message, const char* arg);
- void print_backtrace(size_t max=100);
-
/**
* Base class for the various exception.
*
@@ -19,7 +19,7 @@ namespace rubinius {
long_jump(__jump_buffer, 1);
// If control reaches here, longjmp failed, i.e. disaster.
- abort();
+ rubinius::bug("ExceptionPoint return_to failed");
}
void ExceptionPoint::pop(NativeMethodEnvironment* env) {
View
@@ -118,8 +118,7 @@ namespace rubinius {
InflatedHeader* ih = obj->deflate_header();
ih->reset_object(copy);
if(!copy->set_inflated_header(ih)) {
- std::cerr << "Massive IMMIX inflated header bug.\n";
- abort();
+ rubinius::bug("Massive IMMIX inflated header screwup.");
}
}
View
@@ -123,7 +123,7 @@ namespace rubinius {
} while(1);
// Shouldn't be here!
- rubinius::abort();
+ rubinius::bug("Control flow bug in method lookup");
}
bool InlineCache::fill_private(STATE, Symbol* name, Module* start,
@@ -192,7 +192,7 @@ namespace rubinius {
} while(1);
// Shouldn't be here!
- rubinius::abort();
+ rubinius::bug("Control flow bug in method lookup");
}
bool InlineCache::fill_method_missing(STATE, Class* klass,
@@ -243,7 +243,7 @@ namespace rubinius {
} while(1);
// Shouldn't be here!
- rubinius::abort();
+ rubinius::bug("Control flow bug in method lookup");
}
MethodCacheEntry* InlineCache::update_and_validate(STATE, CallFrame* call_frame, Object* recv) {
View
@@ -137,7 +137,7 @@ Object* VMMethod::interpreter(STATE,
// There is no reason to be here. Either the bytecode loop exits,
// or it jumps to exception;
- abort();
+ rubinius::bug("Control flow error in interpreter");
// If control finds it's way down here, there is an exception.
exception:
@@ -210,9 +210,7 @@ Object* VMMethod::interpreter(STATE,
break;
} // switch
- std::cout << "bug!\n";
- call_frame->print_backtrace(state);
- abort();
+ rubinius::bug("Control flow error in interpreter");
return NULL;
}
@@ -293,7 +291,7 @@ Object* VMMethod::uncommon_interpreter(STATE,
}
// No reason to be here!
- abort();
+ rubinius::bug("Control flow error in interpreter");
exception:
ThreadState* th = state->thread_state();
@@ -365,9 +363,7 @@ Object* VMMethod::uncommon_interpreter(STATE,
break;
} // switch
- std::cout << "bug!\n";
- call_frame->print_backtrace(state);
- abort();
+ rubinius::bug("Control flow error in interpreter");
return NULL;
}
@@ -439,7 +435,7 @@ Object* VMMethod::debugger_interpreter(STATE,
}
// no reason to be here!
- abort();
+ rubinius::bug("Control flow error in interpreter");
// If control finds it's way down here, there is an exception.
exception:
@@ -514,9 +510,7 @@ Object* VMMethod::debugger_interpreter(STATE,
break;
} // switch
- std::cout << "bug!\n";
- call_frame->print_backtrace(state);
- abort();
+ rubinius::bug("Control flow error in interpreter");
return NULL;
}
@@ -572,7 +566,7 @@ Object* VMMethod::debugger_interpreter_continue(STATE,
}
// No reason to be here!
- abort();
+ rubinius::bug("Control flow error in interpreter");
exception:
ThreadState* th = state->thread_state();
@@ -644,8 +638,6 @@ Object* VMMethod::debugger_interpreter_continue(STATE,
break;
} // switch
- std::cout << "bug!\n";
- call_frame->print_backtrace(state);
- abort();
+ rubinius::bug("Control flow error in interpreter");
return NULL;
}
@@ -71,7 +71,7 @@ namespace rubinius {
#undef HANDLE_INST2
default:
- abort();
+ rubinius::bug("Unknown instruction used");
return -1;
}
}
View
@@ -472,7 +472,9 @@ namespace rubinius {
BasicBlock* entry = work.setup_inline(self, blk, args);
- if(!work.generate_body()) { abort(); }
+ if(!work.generate_body()) {
+ rubinius::bug("LLVM failed to compile a function");
+ }
// Branch to the inlined method!
ops_.create_branch(entry);
@@ -522,7 +524,9 @@ namespace rubinius {
BasicBlock* entry = work.setup_inline_block(self,
ops_.constant(Qnil, ops_.state()->ptr_type("Module")));
- if(!work.generate_body()) { abort(); }
+ if(!work.generate_body()) {
+ rubinius::bug("LLVM failed to compile a function");
+ }
// Branch to the inlined block!
ops_.create_branch(entry);
@@ -756,7 +760,7 @@ namespace rubinius {
}
default:
- abort();
+ rubinius::bug("Unknown FFI type in JIT FFI inliner");
}
}
@@ -882,9 +886,7 @@ namespace rubinius {
default:
result = 0;
- std::cout << "Invalid return type.\n";
- abort();
-
+ rubinius::bug("Invalid FFI type in JIT");
}
exception_safe();
Oops, something went wrong.

0 comments on commit b3cf5f2

Please sign in to comment.