[vmkit-commits] [vmkit] r53596 - /vmkit/trunk/lib/N3/VMCore/Opcodes.cpp

Nicolas Geoffray nicolas.geoffray at lip6.fr
Tue Jul 15 01:51:31 PDT 2008


Author: geoffray
Date: Tue Jul 15 03:51:31 2008
New Revision: 53596

URL: http://llvm.org/viewvc/llvm-project?rev=53596&view=rev
Log:
Implement INITOBJ.
Bugfix for ADD.


Modified:
    vmkit/trunk/lib/N3/VMCore/Opcodes.cpp

Modified: vmkit/trunk/lib/N3/VMCore/Opcodes.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/VMCore/Opcodes.cpp?rev=53596&r1=53595&r2=53596&view=diff

==============================================================================
--- vmkit/trunk/lib/N3/VMCore/Opcodes.cpp (original)
+++ vmkit/trunk/lib/N3/VMCore/Opcodes.cpp Tue Jul 15 03:51:31 2008
@@ -206,7 +206,7 @@
   for(uint32 i = 0; i < codeLength; ++i) {
     
     if (bytecodes[i] != 0xFE) {
-      PRINT_DEBUG(N3_COMPILE, 1, COLOR_NORMAL, "\t[at %x] %-5d ", i,
+      PRINT_DEBUG(N3_COMPILE, 1, COLOR_NORMAL, "\t[at %5x] %-5d ", i,
                   bytecodes[i]);
       PRINT_DEBUG(N3_COMPILE, 1, LIGHT_BLUE, "compiling %s::", compilingMethod->printString());
       PRINT_DEBUG(N3_COMPILE, 1, LIGHT_CYAN, OpcodeNames[bytecodes[i]]);
@@ -247,9 +247,15 @@
       
       case ADD: {
         Value* val2 = pop();
+        bool isPointer = (val2->getType() == mvm::jit::ptrType);
         Value* val1 = pop();
+        isPointer |= (val1->getType() == mvm::jit::ptrType);
         verifyType(val1, val2, currentBlock);
-        push(BinaryOperator::createAdd(val1, val2, "", currentBlock));
+        Value* res = BinaryOperator::createAdd(val1, val2, "", currentBlock);
+        if (isPointer) {
+          res = new IntToPtrInst(res, mvm::jit::ptrType, "", currentBlock);
+        }
+        push(res);
         break;
       }
       
@@ -1547,7 +1553,7 @@
         if (!(cl->super == MSCorlib::pValue || cl->super == MSCorlib::pEnum)) {
           push(new LoadInst(pop(), "", isVolatile, currentBlock));
           isVolatile = false;
-        }
+        } 
         break;
       }
 
@@ -1816,7 +1822,7 @@
       }
 
       case 0xFE : {
-        PRINT_DEBUG(N3_COMPILE, 1, COLOR_NORMAL, "\t[at %x] %-5d ", i,
+        PRINT_DEBUG(N3_COMPILE, 1, COLOR_NORMAL, "\t[at %5x] %-5d ", i,
                     bytecodes[i + 1]);
         PRINT_DEBUG(N3_COMPILE, 1, LIGHT_BLUE, "compiling %s::", compilingMethod->printString());
         PRINT_DEBUG(N3_COMPILE, 1, LIGHT_CYAN, OpcodeNamesFE[bytecodes[i + 1]]);
@@ -1940,7 +1946,24 @@
           }
       
           case INITOBJ : {
-            VMThread::get()->vm->error("implement me");
+            uint32 token = readU4(bytecodes, i);
+            Assembly* assembly = compilingClass->assembly;
+            N3* vm = (N3*)(VMThread::get()->vm);
+            VMCommonClass* type = assembly->loadType(vm, token, true, false, false,
+                                                     true);
+            if (type->super == MSCorlib::pValue) {
+              uint64 size = mvm::jit::getTypeSize(type->naturalType);
+        
+              std::vector<Value*> params;
+              params.push_back(new BitCastInst(pop(), mvm::jit::ptrType, "",
+                                               currentBlock));
+              params.push_back(mvm::jit::constantInt8Zero);
+              params.push_back(ConstantInt::get(Type::Int32Ty, size));
+              params.push_back(mvm::jit::constantZero);
+              CallInst::Create(mvm::jit::llvm_memset_i32, params.begin(),
+                               params.end(), "", currentBlock);
+            }
+
             break;  
           }
           
@@ -1995,7 +2018,7 @@
   for(uint32 i = 0; i < codeLength; ++i) {
     
     if (bytecodes[i] != 0xFE) {
-      PRINT_DEBUG(N3_COMPILE, 1, COLOR_NORMAL, "\t[at %5d] %-5d ", i,
+      PRINT_DEBUG(N3_COMPILE, 1, COLOR_NORMAL, "\t[at %5x] %-5d ", i,
                   bytecodes[i]);
       PRINT_DEBUG(N3_COMPILE, 1, LIGHT_BLUE, "exploring %s::", compilingMethod->printString());
       PRINT_DEBUG(N3_COMPILE, 1, LIGHT_CYAN, OpcodeNames[bytecodes[i]]);
@@ -2439,7 +2462,7 @@
 
       case 0xFE : {
       
-        PRINT_DEBUG(N3_COMPILE, 1, COLOR_NORMAL, "\t[at %5d] %-5d ", i,
+        PRINT_DEBUG(N3_COMPILE, 1, COLOR_NORMAL, "\t[at %5x] %-5d ", i,
                     bytecodes[i + 1]);
         PRINT_DEBUG(N3_COMPILE, 1, LIGHT_BLUE, "exploring %s::", compilingMethod->printString());
         PRINT_DEBUG(N3_COMPILE, 1, LIGHT_CYAN, OpcodeNamesFE[bytecodes[i + 1]]);
@@ -2504,7 +2527,7 @@
           }
       
           case INITOBJ : {
-            VMThread::get()->vm->error("implement me");
+            i += 4;
             break;  
           }
           





More information about the vmkit-commits mailing list