[llvm-commits] CVS: llvm-java/lib/Compiler/OperandStack.h OperandStack.cpp Compiler.cpp
Alkis Evlogimenos
alkis at cs.uiuc.edu
Fri Dec 10 02:21:07 PST 2004
Changes in directory llvm-java/lib/Compiler:
OperandStack.h updated: 1.1 -> 1.2
OperandStack.cpp updated: 1.4 -> 1.5
Compiler.cpp updated: 1.176 -> 1.177
---
Log message:
Fix the updated If testcase.
---
Diffs of the changes: (+48 -23)
Index: llvm-java/lib/Compiler/OperandStack.h
diff -u llvm-java/lib/Compiler/OperandStack.h:1.1 llvm-java/lib/Compiler/OperandStack.h:1.2
--- llvm-java/lib/Compiler/OperandStack.h:1.1 Fri Oct 15 21:38:07 2004
+++ llvm-java/lib/Compiler/OperandStack.h Fri Dec 10 04:20:56 2004
@@ -19,7 +19,7 @@
#include <llvm/Instruction.h>
#include <llvm/Java/Bytecode.h>
-#include <stack>
+#include <vector>
namespace llvm {
@@ -30,9 +30,13 @@
namespace llvm { namespace Java {
class OperandStack {
- std::stack<AllocaInst*, std::vector<AllocaInst*> > TheStack;
+ unsigned currentDepth;
+ std::vector<AllocaInst*> TheStack;
public:
+ explicit OperandStack(unsigned maxDepth)
+ : currentDepth(0), TheStack(maxDepth) { }
+
/// @brief - Pushes the value \c value on the virtual operand
/// stack and appends any instructions to implement this to \c
/// insertAtEnd BasicBlock
Index: llvm-java/lib/Compiler/OperandStack.cpp
diff -u llvm-java/lib/Compiler/OperandStack.cpp:1.4 llvm-java/lib/Compiler/OperandStack.cpp:1.5
--- llvm-java/lib/Compiler/OperandStack.cpp:1.4 Wed Nov 24 14:32:18 2004
+++ llvm-java/lib/Compiler/OperandStack.cpp Fri Dec 10 04:20:56 2004
@@ -23,6 +23,8 @@
void OperandStack::push(Value* value, BasicBlock* insertAtEnd)
{
+ assert(currentDepth < TheStack.size() && "Pushing to a full stack!");
+
const Type* valueTy = value->getType();
// Values of jboolean, jbyte, jchar and jshort are extended to a
// jint when pushed on the operand stack.
@@ -32,27 +34,31 @@
valueTy == Type::ShortTy)
value = new CastInst(value, Type::IntTy, "int-extend", insertAtEnd);
- // Insert the alloca at the beginning of the entry block.
- BasicBlock* entry = &insertAtEnd->getParent()->getEntryBlock();
- if (entry->empty())
- TheStack.push(new AllocaInst(
- value->getType(),
- NULL,
- "opStack" + utostr(TheStack.size()),
- entry));
- else
- TheStack.push(new AllocaInst(
- value->getType(),
- NULL,
- "opStack" + utostr(TheStack.size()),
- &entry->front()));
+ // If we don't have an alloca already for this slot create one
+ if (!TheStack[currentDepth] ||
+ TheStack[currentDepth]->getAllocatedType() != value->getType()) {
+ // Insert the alloca at the beginning of the entry block.
+ BasicBlock* entry = &insertAtEnd->getParent()->getEntryBlock();
+ if (entry->empty())
+ TheStack[currentDepth] =
+ new AllocaInst(value->getType(),
+ NULL,
+ "opStack" + utostr(currentDepth),
+ entry);
+ else
+ TheStack[currentDepth] =
+ new AllocaInst(value->getType(),
+ NULL,
+ "opStack" + utostr(currentDepth),
+ &entry->front());
+ }
- new StoreInst(value, TheStack.top(), insertAtEnd);
+ new StoreInst(value, TheStack[currentDepth++], insertAtEnd);
}
llvm::Value* OperandStack::pop(BasicBlock* insertAtEnd)
{
- Value* val = TheStack.top();
- TheStack.pop();
- return new LoadInst(val, "pop", insertAtEnd);
+ assert(currentDepth != 0 && "Popping from an empty stack!");
+
+ return new LoadInst(TheStack[--currentDepth], "pop", insertAtEnd);
}
Index: llvm-java/lib/Compiler/Compiler.cpp
diff -u llvm-java/lib/Compiler/Compiler.cpp:1.176 llvm-java/lib/Compiler/Compiler.cpp:1.177
--- llvm-java/lib/Compiler/Compiler.cpp:1.176 Fri Dec 10 02:31:17 2004
+++ llvm-java/lib/Compiler/Compiler.cpp Fri Dec 10 04:20:56 2004
@@ -1253,11 +1253,20 @@
// HACK: skip most of the class libraries.
if (classMethodDesc.find("java/") == 0 &&
classMethodDesc.find("java/lang/Object") != 0 &&
+ (classMethodDesc.find("java/lang/Throwable") != 0 ||
+ classMethodDesc.find("java/lang/Throwable$StaticData/<cl") == 0) &&
+ classMethodDesc.find("java/lang/Exception") != 0 &&
+ classMethodDesc.find("java/lang/RuntimeException") != 0 &&
classMethodDesc.find("java/lang/Number") != 0 &&
classMethodDesc.find("java/lang/Byte") != 0 &&
classMethodDesc.find("java/lang/Integer") != 0 &&
classMethodDesc.find("java/lang/Long") != 0 &&
- classMethodDesc.find("java/lang/Short") != 0) {
+ classMethodDesc.find("java/lang/Short") != 0 &&
+ classMethodDesc.find("java/util/NoSuchElementException") != 0 &&
+ classMethodDesc.find("java/util/AbstractCollection") != 0 &&
+ classMethodDesc.find("java/util/AbstractList") != 0 &&
+ classMethodDesc.find("java/util/AbstractSequentialList") != 0 &&
+ classMethodDesc.find("java/util/LinkedList") != 0) {
DEBUG(std::cerr << "Skipping compilation of method: "
<< classMethodDesc << '\n');
return function;
@@ -1281,8 +1290,14 @@
}
// For the entry block the operand stack is empty and the locals
// contain the arguments to the function.
- bbInfoMap_.insert(std::make_pair(&function->getEntryBlock(),
- std::make_pair(locals, OperandStack())));
+ //
+ // NOTE: We create an operand stack one size too big because we
+ // push extra values on the stack to simplify code generation
+ // (see implementation of ifne).
+ bbInfoMap_.insert(
+ std::make_pair(&function->getEntryBlock(),
+ std::make_pair(locals,
+ OperandStack(codeAttr->getMaxStack()+1))));
// Insert the entry block to the work list.
bbWorkList_.push_back(&function->getEntryBlock());
More information about the llvm-commits
mailing list