aboutsummaryrefslogtreecommitdiff
path: root/lib/Target/JSBackend/JSBackend.cpp
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2014-01-10 14:32:26 -0800
committerAlon Zakai <alonzakai@gmail.com>2014-01-10 14:32:26 -0800
commit28ff124c6e275da72d2550576f5c3282d0521d60 (patch)
tree84bd340bd1abfcbea3e7d52f0e9d60ec199bbebb /lib/Target/JSBackend/JSBackend.cpp
parentdaf116d3a6d43e8e4ae3f10e75181fd59e2e62a6 (diff)
exceptions support in backend itself
Diffstat (limited to 'lib/Target/JSBackend/JSBackend.cpp')
-rw-r--r--lib/Target/JSBackend/JSBackend.cpp31
1 files changed, 2 insertions, 29 deletions
diff --git a/lib/Target/JSBackend/JSBackend.cpp b/lib/Target/JSBackend/JSBackend.cpp
index 098b86915f..617f33b011 100644
--- a/lib/Target/JSBackend/JSBackend.cpp
+++ b/lib/Target/JSBackend/JSBackend.cpp
@@ -103,12 +103,13 @@ namespace {
FunctionTableMap FunctionTables; // sig => list of functions
std::vector<std::string> GlobalInitializers;
bool UsesSIMD;
+ int InvokeState; // cycles between 0, 1 after preInvoke, 2 after call, 0 again after postInvoke. hackish, no argument there.
#include "CallHandlers.h"
public:
static char ID;
- explicit JSWriter(formatted_raw_ostream &o) : ModulePass(ID), Out(o), UniqueNum(0), UsesSIMD(false) {}
+ explicit JSWriter(formatted_raw_ostream &o) : ModulePass(ID), Out(o), UniqueNum(0), UsesSIMD(false), InvokeState(0) {}
virtual const char *getPassName() const { return "JavaScript backend"; }
@@ -1238,24 +1239,6 @@ void JSWriter::generateInstruction(const Instruction *I, raw_string_ostream& Cod
Code << ";";
break;
}
- case Instruction::Invoke: {
- Code << "__THREW__ = 0;";
- const InvokeInst *II = cast<InvokeInst>(I);
- Code << handleCall(II) + ';';
- // the check and branch and done in the relooper setup code
- break;
- }
- case Instruction::LandingPad: {
- const LandingPadInst *LP = cast<const LandingPadInst>(I);
- Code << getAssign(iName, I->getType());
- Code << "___cxa_find_matching_catch(-1,-1";
- unsigned n = LP->getNumClauses();
- for (unsigned i = 0; i < n; i++) {
- Code << "," + getValueAsStr(LP->getClause(i));
- }
- Code << ")|0;";
- break;
- }
case Instruction::Resume: {
Code << "___resumeException(" + getValueAsStr(I->getOperand(0)) + "|0);";
break;
@@ -1380,16 +1363,6 @@ void JSWriter::printFunctionBody(const Function *F) {
}
break;
}
- case Instruction::Invoke: {
- const InvokeInst* II = cast<InvokeInst>(TI);
- BasicBlock *S0 = II->getNormalDest();
- BasicBlock *S1 = II->getUnwindDest();
- std::string P0 = getPhiCode(&*BI, S0);
- std::string P1 = getPhiCode(&*BI, S1);
- LLVMToRelooper[&*BI]->AddBranchTo(LLVMToRelooper[&*S0], "!__THREW__", P0.size() > 0 ? P0.c_str() : NULL);
- LLVMToRelooper[&*BI]->AddBranchTo(LLVMToRelooper[&*S1], NULL, P1.size() > 0 ? P1.c_str() : NULL);
- break;
- }
case Instruction::Ret:
case Instruction::Unreachable: break;
}