[llvm-commits] CVS: llvm-java/lib/Compiler/Compiler.cpp

Alkis Evlogimenos alkis at cs.uiuc.edu
Fri Aug 6 04:25:50 PDT 2004



Changes in directory llvm-java/lib/Compiler:

Compiler.cpp updated: 1.79 -> 1.80
---
Log message:

Implement the 'new' java bytecode.


---
Diffs of the changes:  (+14 -1)

Index: llvm-java/lib/Compiler/Compiler.cpp
diff -u llvm-java/lib/Compiler/Compiler.cpp:1.79 llvm-java/lib/Compiler/Compiler.cpp:1.80
--- llvm-java/lib/Compiler/Compiler.cpp:1.79	Fri Aug  6 06:06:06 2004
+++ llvm-java/lib/Compiler/Compiler.cpp	Fri Aug  6 06:25:39 2004
@@ -976,7 +976,20 @@
     }
 
     void do_new(unsigned bcI, unsigned index) {
-      assert(0 && "not implemented");
+      ConstantClass* classRef = cf_->getConstantClass(index);
+      const std::string& className = classRef->getName()->str();
+      ClassFile* cf = ClassFile::getClassFile(className);
+      const ClassInfo& ci = getClassInfo(className);
+      const VTableInfo& vi = getVTableInfo(className);
+
+      Value* objRef = new MallocInst(ci.type,
+                                     ConstantUInt::get(Type::UIntTy, 0),
+                                     TMP, getBBAt(bcI));
+      Value* vtable = getField(bcI, className, "<llvm_java_base>", objRef);
+      vtable = new CastInst(vtable, PointerType::get(vi.vtable->getType()),
+                            TMP, getBBAt(bcI));
+      vtable = new StoreInst(vi.vtable, vtable, getBBAt(bcI));
+      opStack_.push(objRef);
     }
 
     void do_newarray(unsigned bcI, JType type) {






More information about the llvm-commits mailing list