Home | History | Annotate | Download | only in c
      1 HANDLE_OPCODE(OP_NEW_INSTANCE /*vAA, class@BBBB*/)
      2     {
      3         ClassObject* clazz;
      4         Object* newObj;
      5 
      6         EXPORT_PC();
      7 
      8         vdst = INST_AA(inst);
      9         ref = FETCH(1);
     10         ILOGV("|new-instance v%d,class@0x%04x", vdst, ref);
     11         clazz = dvmDexGetResolvedClass(methodClassDex, ref);
     12         if (clazz == NULL) {
     13             clazz = dvmResolveClass(curMethod->clazz, ref, false);
     14             if (clazz == NULL)
     15                 GOTO_exceptionThrown();
     16         }
     17 
     18         if (!dvmIsClassInitialized(clazz) && !dvmInitClass(clazz))
     19             GOTO_exceptionThrown();
     20 
     21         /*
     22          * The JIT needs dvmDexGetResolvedClass() to return non-null.
     23          * Since we use the portable interpreter to build the trace, this extra
     24          * check is not needed for mterp.
     25          */
     26         if (!dvmDexGetResolvedClass(methodClassDex, ref)) {
     27             /* Class initialization is still ongoing - abandon the trace */
     28             ABORT_JIT_TSELECT();
     29         }
     30 
     31         /*
     32          * Verifier now tests for interface/abstract class.
     33          */
     34         //if (dvmIsInterfaceClass(clazz) || dvmIsAbstractClass(clazz)) {
     35         //    dvmThrowExceptionWithClassMessage("Ljava/lang/InstantiationError;",
     36         //        clazz->descriptor);
     37         //    GOTO_exceptionThrown();
     38         //}
     39         newObj = dvmAllocObject(clazz, ALLOC_DONT_TRACK);
     40         if (newObj == NULL)
     41             GOTO_exceptionThrown();
     42         SET_REGISTER(vdst, (u4) newObj);
     43     }
     44     FINISH(2);
     45 OP_END
     46