[llvm-commits] CVS: llvm-java/lib/Compiler/Compiler.cpp
Alkis Evlogimenos
alkis at cs.uiuc.edu
Thu Mar 31 09:42:39 PST 2005
Changes in directory llvm-java/lib/Compiler:
Compiler.cpp updated: 1.270 -> 1.271
---
Log message:
Change emitStaticInitializers to take a VMClass as a parameter.
---
Diffs of the changes: (+16 -17)
Compiler.cpp | 33 ++++++++++++++++-----------------
1 files changed, 16 insertions(+), 17 deletions(-)
Index: llvm-java/lib/Compiler/Compiler.cpp
diff -u llvm-java/lib/Compiler/Compiler.cpp:1.270 llvm-java/lib/Compiler/Compiler.cpp:1.271
--- llvm-java/lib/Compiler/Compiler.cpp:1.270 Thu Mar 31 01:56:28 2005
+++ llvm-java/lib/Compiler/Compiler.cpp Thu Mar 31 11:42:28 2005
@@ -970,19 +970,17 @@
}
/// Emits static initializers for this class if not done already.
- void emitStaticInitializers(const ClassFile* classfile) {
- typedef SetVector<const ClassFile*> ClassFileSet;
- static ClassFileSet toInitClasses;
+ void emitStaticInitializers(const VMClass* clazz) {
+ static SetVector<const VMClass*> toInitClasses;
- if (toInitClasses.insert(classfile)) {
+ const ClassFile* classfile = clazz->getClassFile();
+ if (!classfile)
+ return;
+
+ if (toInitClasses.insert(clazz)) {
// If this class has a super class, initialize that first.
- if (classfile->getSuperClass())
- emitStaticInitializers(
- ClassFile::get(classfile->getSuperClass()->getName()->str()));
-
- const std::string& className =
- classfile->getThisClass()->getName()->str();
- const VMClass* clazz = resolver_->getClass(className);
+ if (const VMClass* superClass = clazz->getSuperClass())
+ emitStaticInitializers(superClass);
Function* hook = module_->getOrInsertFunction(LLVM_JAVA_STATIC_INIT,
Type::VoidTy, 0);
@@ -996,7 +994,8 @@
// Call its class initialization method if it exists.
if (const Method* method = classfile->getMethod("<clinit>()V")) {
- const std::string& functionName = className + '/' +
+ const std::string& functionName =
+ classfile->getThisClass()->getName()->str() + '/' +
method->getName()->str() + method->getDescriptor()->str();
Function* init =
module_->getOrInsertFunction(functionName, Type::VoidTy, 0);
@@ -1044,7 +1043,7 @@
while (true) {
const ClassFile* classfile = ClassFile::get(className);
- emitStaticInitializers(classfile);
+ emitStaticInitializers(resolver_->getClass(className));
Method* method = classfile->getMethod(methodNameAndDescr);
if (method)
@@ -1469,7 +1468,7 @@
void do_getstatic(unsigned index) {
const VMField* field = class_->getField(index);
- emitStaticInitializers(field->getParent()->getClassFile());
+ emitStaticInitializers(field->getParent());
Value* v = new LoadInst(field->getGlobal(), TMP, currentBB_);
push(v);
@@ -1477,7 +1476,7 @@
void do_putstatic(unsigned index) {
const VMField* field = class_->getField(index);
- emitStaticInitializers(field->getParent()->getClassFile());
+ emitStaticInitializers(field->getParent());
Value* v = pop(field->getClass()->getType());
new StoreInst(v, field->getGlobal(), currentBB_);
@@ -1581,7 +1580,7 @@
void do_invokestatic(unsigned index) {
const VMMethod* method = class_->getMethod(index);
- emitStaticInitializers(method->getParent()->getClassFile());
+ emitStaticInitializers(method->getParent());
Function* function = method->getFunction();
// Intercept java/lang/System/loadLibrary() calls and add
// library deps to the module
@@ -1669,7 +1668,7 @@
void do_new(unsigned index) {
const VMClass* clazz = class_->getClass(index);
- emitStaticInitializers(clazz->getClassFile());
+ emitStaticInitializers(clazz);
const VTableInfo& vi = getVTableInfo(clazz);
push(allocateObject(*clazz, vi, currentBB_));
More information about the llvm-commits
mailing list