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 #if defined(WITH_JIT)
     22         /*
     23          * The JIT needs dvmDexGetResolvedClass() to return non-null.
     24          * Since we use the portable interpreter to build the trace, this extra
     25          * check is not needed for mterp.
     26          */
     27         if ((self->interpBreak.ctl.subMode & kSubModeJitTraceBuild) &&
     28             (!dvmDexGetResolvedClass(methodClassDex, ref))) {
     29             /* Class initialization is still ongoing - end the trace */
     30             dvmJitEndTraceSelect(self,pc);
     31         }
     32 #endif
     33 
     34         /*
     35          * Verifier now tests for interface/abstract class.
     36          */
     37         //if (dvmIsInterfaceClass(clazz) || dvmIsAbstractClass(clazz)) {
     38         //    dvmThrowExceptionWithClassMessage(gDvm.exInstantiationError,
     39         //        clazz->descriptor);
     40         //    GOTO_exceptionThrown();
     41         //}
     42         newObj = dvmAllocObject(clazz, ALLOC_DONT_TRACK);
     43         if (newObj == NULL)
     44             GOTO_exceptionThrown();
     45         SET_REGISTER(vdst, (u4) newObj);
     46     }
     47     FINISH(2);
     48 OP_END
     49