Permalink
Browse files

Turn statically failing guard into an exception

  • Loading branch information...
1 parent 8c51186 commit 698017cf4ee3b0c3eaa626ebb31ae4176e05863a @nominolo committed Oct 23, 2012
Showing with 21 additions and 2 deletions.
  1. +5 −0 vm/ir.hh
  2. +1 −2 vm/ir_fold.cc
  3. +15 −0 vm/jit.cc
View
@@ -202,6 +202,11 @@ inline bool isFloatType(IRType t) {
#define IRT(o, t) (cast(u4, ((o) << 8) | (t)))
+// Exception error codes
+enum {
+ IROPTERR_FAILING_GUARD = 1
+};
+
class IRBuffer; // Defined below.
class IR {
View
@@ -370,8 +370,7 @@ TRef IRBuffer::optFold() {
if (ref == KLITFOLD)
return literal(fold_.ins.type(), fold_.literal);
if (ref == FAILFOLD) {
- cerr << "NYI: Recover from FAILFOLD\n";
- exit(EXIT_FAILURE);
+ throw (int)IROPTERR_FAILING_GUARD;
}
LC_ASSERT(ref == DROPFOLD);
return TRef();
View
@@ -309,6 +309,8 @@ bool Jit::recordGenericApply(uint32_t call_info, Word *base,
}
bool Jit::recordIns(BcIns *ins, Word *base, const Code *code) {
+ try {
+
if (LC_UNLIKELY(shouldAbort_))
goto abort_recording;
buf_.pc_ = ins;
@@ -778,6 +780,19 @@ bool Jit::recordIns(BcIns *ins, Word *base, const Code *code) {
abort_recording:
resetRecorderState();
return true;
+
+
+ } catch (int err) {
+ switch (err) {
+ case IROPTERR_FAILING_GUARD:
+ DBG(cerr << "Aborting due to permanently failing guard.\n");
+ resetRecorderState();
+ return true;
+ default:
+ cerr << "Unknown error condition.\n";
+ throw err;
+ }
+ }
}
inline void Jit::resetRecorderState() {

0 comments on commit 698017c

Please sign in to comment.