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

Alkis Evlogimenos alkis at cs.uiuc.edu
Sun Nov 7 01:47:13 PST 2004



Changes in directory llvm-java/lib/Compiler:

Compiler.cpp updated: 1.141 -> 1.142
---
Log message:

Make arrays of bools arrays of bytes since the same opcode is used to
load/store to them.

Remove some code used before the operand stack was converting
jboolean, jchar, jbyte and jshort to jint when pushed on the operand
stack.

Ignore jsr and ret bytecodes.


---
Diffs of the changes:  (+25 -21)

Index: llvm-java/lib/Compiler/Compiler.cpp
diff -u llvm-java/lib/Compiler/Compiler.cpp:1.141 llvm-java/lib/Compiler/Compiler.cpp:1.142
--- llvm-java/lib/Compiler/Compiler.cpp:1.141	Sat Nov  6 11:58:17 2004
+++ llvm-java/lib/Compiler/Compiler.cpp	Sun Nov  7 03:47:03 2004
@@ -434,7 +434,10 @@
     const ClassInfo& getPrimitiveArrayInfo(JType type) {
       switch (type) {
       case BOOLEAN: {
-        static ClassInfo arrayInfo = buildArrayClassInfo(Type::BoolTy);
+        // Because baload/bastore is used to load/store to both byte
+        // arrays and boolean arrays we use sbyte for java boolean
+        // arrays as well.
+        static ClassInfo arrayInfo = buildArrayClassInfo(Type::SByteTy);
         return arrayInfo;
       }
       case CHAR: {
@@ -812,7 +815,10 @@
     const VTableInfo& getPrimitiveArrayVTableInfo(JType type) {
       switch (type) {
       case BOOLEAN: {
-        static VTableInfo arrayInfo = buildArrayVTableInfo(Type::BoolTy);
+        // Because baload/bastore is used to load/store to both byte
+        // arrays and boolean arrays we use sbyte for java boolean
+        // arrays as well.
+        static VTableInfo arrayInfo = buildArrayVTableInfo(Type::SByteTy);
         return arrayInfo;
       }
       case CHAR: {
@@ -1285,6 +1291,8 @@
       for (unsigned i = 0; i != toCompileFunctions_.size(); ++i) {
         Function* f = toCompileFunctions_[i];
         compileMethodOnly(f->getName());
+        DEBUG(std::cerr << i << '/' << toCompileFunctions_.size()
+              << " functions compiled\n");
       }
 
       return function;
@@ -1338,15 +1346,10 @@
     void do_laload() { do_aload_common(); }
     void do_faload() { do_aload_common(); }
     void do_daload() { do_aload_common(); }
-    void do_aaload() {
-      do_aload_common();
-      do_cast_common(
-        PointerType::get(
-          getClassInfo(ClassFile::get("java/lang/Object")).type));
-    }
-    void do_baload() { do_aload_common(); do_cast_common(Type::IntTy); }
-    void do_caload() { do_aload_common(); do_cast_common(Type::IntTy); }
-    void do_saload() { do_aload_common(); do_cast_common(Type::IntTy); }
+    void do_aaload() { do_aload_common(); }
+    void do_baload() { do_aload_common(); }
+    void do_caload() { do_aload_common(); }
+    void do_saload() { do_aload_common(); }
 
     void do_aload_common() {
       Value* index = currentOpStack_->pop(currentBB_);
@@ -1379,22 +1382,21 @@
     void do_fastore() { do_astore_common(); }
     void do_dastore() { do_astore_common(); }
     void do_aastore() {
-      do_cast_common(
+      do_astore_common(
         PointerType::get(
           getClassInfo(ClassFile::get("java/lang/Object")).type));
-      do_astore_common();
     }
-    void do_bastore() { do_cast_common(Type::SByteTy); do_astore_common(); }
-    void do_castore() { do_cast_common(Type::UShortTy); do_astore_common(); }
-    void do_sastore() { do_cast_common(Type::ShortTy); do_astore_common(); }
+    void do_bastore() { do_astore_common(Type::SByteTy); }
+    void do_castore() { do_astore_common(Type::UShortTy); }
+    void do_sastore() { do_astore_common(Type::ShortTy); }
 
-    void do_astore_common() {
+    void do_astore_common(Type* castTo = NULL) {
       Value* value = currentOpStack_->pop(currentBB_);
+      if (castTo)
+        value = new CastInst(value, castTo, TMP, currentBB_);
       Value* index = currentOpStack_->pop(currentBB_);
       Value* arrayRef = currentOpStack_->pop(currentBB_);
 
-      arrayRef->dump();
-
       std::vector<Value*> indices;
       indices.reserve(3);
       indices.push_back(ConstantUInt::get(Type::UIntTy, 0));
@@ -1767,11 +1769,13 @@
     }
 
     void do_jsr(unsigned target) {
-      assert(0 && "not implemented");
+      // assert(0 && "not implemented");
+      std::cerr << "WARNING: jsr is not implemented and ignored!\n";
     }
 
     void do_ret(unsigned index) {
-      assert(0 && "not implemented");
+      // assert(0 && "not implemented");
+      std::cerr << "WARNING: ret is not implemented and ignored!\n";
     }
 
     void do_switch(unsigned defTarget, const SwitchCases& sw) {






More information about the llvm-commits mailing list