const Method* meth = (const Method*) methodID;
const char* desc = meth->shorty;
- ClassObject* clazz;
LOGV("V-checking %s.%s:%s...\n", meth->clazz->descriptor, meth->name, desc);
}
}
-bail:
JNI_EXIT();
#endif
}
const Method* meth = (const Method*) methodID;
const char* desc = meth->shorty;
- ClassObject* clazz;
int idx = 0;
LOGV("A-checking %s.%s:%s...\n", meth->clazz->descriptor, meth->name, desc);
idx++;
}
-bail:
JNI_EXIT();
#endif
}
int mode)
{
ArrayObject* arrObj = (ArrayObject*) dvmDecodeIndirectRef(env, jarr);
- PrimitiveType primType = arrObj->obj.clazz->elementClass->primitiveType;
- //int len = array->length * dvmPrimitiveTypeWidth(primType);
bool release, copyBack;
u1* result;
{
return (RefTypeId) registerObject((Object*) clazz, kRefTypeId, true);
}
+#if 0
static RefTypeId classObjectToRefTypeIdNoReg(ClassObject* clazz)
{
return (RefTypeId) registerObject((Object*) clazz, kRefTypeId, false);
}
+#endif
static ClassObject* refTypeIdToClassObject(RefTypeId id)
{
assert(objectIsRegistered(id, kRefTypeId) || !gDvm.debuggerConnected);
{
Method* method;
u8 start, end;
- int i;
DebugCallbackContext context;
memset (&context, 0, sizeof(DebugCallbackContext));
#
LOCAL_CFLAGS += -fstrict-aliasing -Wstrict-aliasing=2 -fno-align-jumps
#LOCAL_CFLAGS += -DUSE_INDIRECT_REF
+LOCAL_CFLAGS += -Wall -Wextra -Wno-unused-parameter
#
# Optional features. These may impact the size or performance of the VM.
{
const ArrayObject* stackData = (const ArrayObject*) ostackData;
const int* intVals;
- int i, stackSize;
+ int stackSize;
stackSize = stackData->length / 2;
intVals = (const int*) stackData->contents;
static inline void updateSlotRemove(IndirectRefTable* pRef, int slot)
{
if (pRef->slotData != NULL) {
- IndirectRefSlot* pSlot = &pRef->slotData[slot];
+ //IndirectRefSlot* pSlot = &pRef->slotData[slot];
//LOGI("+++ remove [%d] slot %d, serial now %d\n",
// pRef->kind, slot, pSlot->serial);
}
IRTSegmentState prevState;
prevState.all = cookie;
int topIndex = pRef->segmentState.parts.topIndex;
- int bottomIndex = prevState.parts.topIndex;
assert(obj != NULL);
assert(dvmIsValidObject(obj));
Object** pScan = &pRef->table[topIndex - 1];
assert(*pScan != NULL);
while (*--pScan != NULL) {
- assert(pScan >= pRef->table + bottomIndex);
+ assert(pScan >= pRef->table + prevState.parts.topIndex);
}
updateSlotAdd(pRef, obj, pScan - pRef->table);
result = dvmObjectToIndirectRef(pRef, obj, pScan - pRef->table,
strncmp(argv[i], "-agentlib:jdwp=", 15) == 0)
{
const char* tail;
- bool result = false;
if (argv[i][1] == 'X')
tail = argv[i] + 10;
ArrayObject* compArray;
const u2* thisChars;
const u2* compChars;
- int i, minCount, countDiff;
+ int minCount, countDiff;
thisCount = dvmGetFieldInt((Object*) arg0, STRING_FIELDOFF_COUNT);
compCount = dvmGetFieldInt((Object*) arg1, STRING_FIELDOFF_COUNT);
*/
int otherRes = __memcmp16(thisChars, compChars, minCount);
# ifdef CHECK_MEMCMP16
+ int i;
for (i = 0; i < minCount; i++) {
if (thisChars[i] != compChars[i]) {
pResult->i = (s4) thisChars[i] - (s4) compChars[i];
* the characters that overlap, and if they're all the same then return
* the difference in lengths.
*/
+ int i;
for (i = 0; i < minCount; i++) {
if (thisChars[i] != compChars[i]) {
pResult->i = (s4) thisChars[i] - (s4) compChars[i];
ArrayObject* compArray;
const u2* thisChars;
const u2* compChars;
- int i;
/* quick length check */
thisCount = dvmGetFieldInt((Object*) arg0, STRING_FIELDOFF_COUNT);
* meaningful comparison when the strings don't match (could also test
* with palindromes).
*/
+ int i;
//for (i = 0; i < thisCount; i++)
for (i = thisCount-1; i >= 0; --i)
{
if (newFile) {
u8 startWhen, extractWhen, endWhen;
bool result;
- off_t dexOffset, fileLen;
+ off_t dexOffset;
dexOffset = lseek(fd, 0, SEEK_CUR);
result = (dexOffset > 0);
}
#endif
-bail:
dvmUnlockMutex(&gDvm.jniGlobalRefLock);
return jobj;
}
JValue unused;
dvmCallMethod(self, gDvm.methJavaLangRefPhantomReference_init, phantomObj,
- &unused, jobj, NULL);
+ &unused, obj, NULL);
dvmReleaseTrackedAlloc(phantomObj, self);
if (dvmCheckException(self)) {
#else
ReferenceTable* pRefTable = getLocalRefTable(env);
Thread* self = dvmThreadSelf();
- //Object** top;
- Object** ptr;
if (dvmIsWeakGlobalRef(jobj)) {
return JNIWeakGlobalRefType;
{
JNI_ENTER();
ClassObject* clazz = (ClassObject*) dvmDecodeIndirectRef(env, jcls);
- Object* obj = dvmCreateReflectObjForField(jcls, (Field*) fieldID);
+ Object* obj = dvmCreateReflectObjForField(clazz, (Field*) fieldID);
dvmReleaseTrackedAlloc(obj, NULL);
jobject jobj = addLocalReference(env, obj);
JNI_EXIT();
*/
int dvmCountSetBits(const BitVector* pBits)
{
- int word, bit;
+ int word;
int count = 0;
for (word = 0; word < pBits->storageSize; word++) {
static SharedLib* addSharedLibEntry(SharedLib* pLib)
{
u4 hash = dvmComputeUtf8Hash(pLib->pathName);
- void* ent;
/*
* Do the lookup with the "add" flag set. If we add it, we will get
/*
* Verify that the set is in sorted order.
*/
+#ifndef NDEBUG
static bool verifySorted(PointerSet* pSet)
{
const void* last = NULL;
return true;
}
-
+#endif
/*
* Allocate a new PointerSet.
*/
bool dvmPointerSetRemoveEntry(PointerSet* pSet, const void* ptr)
{
- int i, where;
+ int where;
if (!dvmPointerSetHas(pSet, ptr, &where))
return false;
FILE* fp = (FILE*) vfp;
Method* meth;
char* name;
- int i, lineNum;
+ int i;
dexStringCacheInit(&stringCache);
* Read until shutdown time.
*/
while (!gDvm.haltStdioConverter) {
- ssize_t actual;
fd_set readfds;
int maxFd, fdCount;
u4 relativePc;
char eventBuffer[132];
const char *fileName;
- char procName[33], *selfName, *ownerName;
+ char procName[33], *selfName;
char *cp;
size_t len;
int fd;
*/
static void lockMonitor(Thread* self, Monitor* mon)
{
- Thread *owner;
ThreadStatus oldStatus;
u4 waitThreshold, samplePercent;
u8 waitStart, waitEnd, waitMs;
{
Object* exception;
Object* handlerObj;
- ClassObject* throwable;
Method* uncaughtHandler = NULL;
InstField* threadHandler;
}
}
+#ifdef USE_INDIRECT_REF
static void gcScanIndirectRefTable(IndirectRefTable* pRefTable)
{
Object** op = pRefTable->table;
op++;
}
}
+#endif
/*
* Scan a Thread and mark any objects it references.
{
if (*gcHeap != NULL && (*gcHeap)->heapSource != NULL) {
HeapSource *hs;
- size_t i;
hs = (*gcHeap)->heapSource;
{
HeapSource *hs = gHs;
uintptr_t base, max;
- size_t i, offset;
+ size_t i;
HS_BOILERPLATE();
void dvmMarkImmuneObjects(const char *immuneLimit)
{
char *dst, *src;
- size_t i, offset, index, length;
+ size_t i, index, length;
/*
* Copy the contents of the live bit vector for immune object
/* fwd */
+#ifndef NDEBUG
static void checkMergeTab(void);
+#endif
static bool isInitMethod(const Method* meth);
static RegType getInvocationThis(const RegType* insnRegs,\
const int insnRegCount, const DecodedInstruction* pDecInsn,
/*
* Is this method a class initializer?
*/
+#if 0
static bool isClassInitMethod(const Method* meth)
{
return (*meth->name == '<' && strcmp(meth->name+1, "clinit>") == 0);
}
+#endif
/*
* Look up a class reference given as a simple string descriptor.
static inline RegType getRegisterType(const RegType* insnRegs,
const int insnRegCount, u4 vsrc, VerifyError* pFailure)
{
- RegType type;
-
if (vsrc >= (u4) insnRegCount) {
*pFailure = VERIFY_ERROR_GENERIC;
return kRegTypeUnknown;
{
bool result = false;
const int insnsSize = dvmGetMethodInsnsSize(meth);
- const u2* insns = meth->insns;
const bool generateRegisterMap = gDvm.generateRegisterMaps;
- int i, offset;
- bool isConditional;
RegisterTable regTable;
memset(®Table, 0, sizeof(regTable));
RegisterTable* regTable, UninitInstanceMap* uninitMap)
{
const int insnsSize = dvmGetMethodInsnsSize(meth);
- const u2* insns = meth->insns;
RegType workRegs[meth->registersSize + kExtraRegs];
bool result = false;
bool debugVerbose = false;
- int insnIdx, startGuess, prevAddr;
+ int insnIdx, startGuess;
/*
* Begin by marking the first instruction as "changed".
const DexFile* pDexFile = meth->clazz->pDvmDex->pDexFile;
RegType entryRegs[meth->registersSize + kExtraRegs];
ClassObject* resClass;
- const char* className;
int branchTarget = 0;
const int insnRegCount = meth->registersSize;
RegType tmpType;
case OP_IF_NE:
{
RegType type1, type2;
- bool tmpResult;
type1 = getRegisterType(workRegs, insnRegCount, decInsn.vA,
&failure);
goto iget_1nr_common;
iget_1nr_common:
{
- ClassObject* fieldClass;
InstField* instField;
RegType objType, fieldType;
case OP_IGET_WIDE_VOLATILE:
{
RegType dstType;
- ClassObject* fieldClass;
InstField* instField;
RegType objType;
iput_1nr_common:
{
RegType srcType, fieldType, objType;
- ClassObject* fieldClass;
InstField* instField;
srcType = getRegisterType(workRegs, insnRegCount, decInsn.vA,
checkWidePair(tmpType, typeHi, &failure);
}
if (VERIFY_OK(failure)) {
- ClassObject* fieldClass;
InstField* instField;
RegType objType;
* do this for all registers that have the same object
* instance in them, not just the "this" register.
*/
- int uidx = regTypeToUninitIndex(thisType);
markRefsAsInitialized(workRegs, insnRegCount, uninitMap,
thisType, &failure);
if (!VERIFY_OK(failure))
*/
if ((nextFlags & kInstrCanThrow) != 0 && dvmInsnIsInTry(insnFlags, insnIdx))
{
- DexFile* pDexFile = meth->clazz->pDvmDex->pDexFile;
const DexCode* pCode = dvmGetMethodCode(meth);
DexCatchIterator iterator;
optHdr.flags = headerFlags;
optHdr.checksum = optChecksum;
- ssize_t actual;
lseek(fd, 0, SEEK_SET);
if (sysWriteFully(fd, &optHdr, sizeof(optHdr), "DexOpt opt header") != 0)
goto bail;
static int writeDependencies(int fd, u4 modWhen, u4 crc)
{
u1* buf = NULL;
- ssize_t actual;
int result = -1;
ssize_t bufLen;
ClassPathEntry* cpe;
- int i, numDeps;
+ int numDeps;
/*
* Count up the number of completed entries in the bootclasspath.
*/
static bool writeChunk(int fd, u4 type, const void* data, size_t size)
{
- ssize_t actual;
union { /* save a syscall by grouping these together */
char raw[8];
struct {
bool result = false;
UninitInstanceMap* uninitMap = NULL;
InsnFlags* insnFlags = NULL;
- int i, newInstanceCount;
+ int newInstanceCount;
/*
* If there aren't any instructions, make sure that's expected, then
int width = dvmInsnGetWidth(insnFlags, i);
OpCode opcode = *insns & 0xff;
InstructionFlags opFlags = dexGetInstrFlags(gDvm.instrFlags, opcode);
- int offset, absOffset;
if ((opFlags & gcMask) != 0) {
/*
/* fwd */
-static void optimizeLoadedClasses(DexFile* pDexFile);
-static void optimizeClass(ClassObject* clazz);
static bool optimizeMethod(Method* method);
static void rewriteInstField(Method* method, u2* insns, OpCode newOpc);
static bool rewriteVirtualInvoke(Method* method, u2* insns, OpCode newOpc);
ClassObject* clazz = method->clazz;
u2 fieldIdx = insns[1];
InstField* field;
- int byteOffset;
field = dvmOptResolveInstField(clazz, fieldIdx, NULL);
if (field == NULL) {
*
* Run through the instructions in this method, altering the constants used.
*/
+#if DVM_RESOLVER_CACHE == DVM_RC_EXPANDING
static void updateUsedConstants(DexFile* pDexFile, const char* classDescriptor,
DexMethod* pDexMethod, void* arg)
{
//printf(" (no code)\n");
}
}
+#endif
/*
* Count up the bits and show a count.
static void summarizeResults(DvmDex* pDvmDex, ScanResults* pResults)
{
DexFile* pDexFile = pDvmDex->pDexFile;
+#if 0
int i;
-#if 0
for (i = 0; i < (int) pDvmDex->pDexFile->pHeader->typeIdsSize; i++) {
const DexTypeId* pDexTypeId;
const char* classDescr;
* Construct an "expanding" chunk, with maps that convert instructions
* with reduced constants back to their full original values.
*/
+#if DVM_RESOLVER_CACHE == DVM_RC_EXPANDING
static bool constructExpandingDataChunk(IndexMapSet* pIndexMapSet)
{
int chunkLen = 0;
return true;
}
+#endif
/*
* Construct the "chunk" of data that will be appended to the optimized DEX
ScanResults* pResults)
{
IndexMapSet* pIndexMapSet;
- int setCount;
bool okay = true;
pIndexMapSet = calloc(1, sizeof(*pIndexMapSet));
/* verbose logging */
#define REGISTER_MAP_VERBOSE false
+//#define REGISTER_MAP_STATS
// fwd
static void outputTypeVector(const RegType* regs, int insnRegCount, u1* data);
static bool verifyMap(VerifierData* vdata, const RegisterMap* pMap);
static int compareMaps(const RegisterMap* pMap1, const RegisterMap* pMap2);
+#ifdef REGISTER_MAP_STATS
static void computeMapStats(RegisterMap* pMap, const Method* method);
+#endif
static RegisterMap* compressMapDifferential(const RegisterMap* pMap,\
const Method* meth);
static RegisterMap* uncompressMapDifferential(const RegisterMap* pMap);
-
-//#define REGISTER_MAP_STATS
#ifdef REGISTER_MAP_STATS
/*
* Generate some statistics on the register maps we create and use.
if (false) {
const char* cd = "Landroid/net/http/Request;";
const char* mn = "readResponse";
- const char* sg = "(Landroid/net/http/AndroidHttpClientConnection;)V";
if (strcmp(vdata->method->clazz->descriptor, cd) == 0 &&
strcmp(vdata->method->name, mn) == 0)
{
dvmAbort();
}
- const u1* dataStart = rawMap;
const RegType* regs = vdata->addrRegs[addr];
if (regs == NULL) {
LOGE("GLITCH: addr %d has no data\n", addr);
/*
* Compute some stats on an uncompressed register map.
*/
+#ifdef REGISTER_MAP_STATS
static void computeMapStats(RegisterMap* pMap, const Method* method)
{
-#ifdef REGISTER_MAP_STATS
MapStats* pStats = (MapStats*) gDvm.registerMapStats;
const u1 format = dvmRegisterMapGetFormat(pMap);
const u2 numEntries = dvmRegisterMapGetNumEntries(pMap);
prevAddr = addr;
prevData = dataStart;
}
-#endif
}
-
+#endif
/*
* Compute the difference between two bit vectors.
bool dvmSetTryFlags(const Method* meth, InsnFlags* insnFlags)
{
u4 insnsSize = dvmGetMethodInsnsSize(meth);
- DexFile* pDexFile = meth->clazz->pDvmDex->pDexFile;
const DexCode* pCode = dvmGetMethodCode(meth);
u4 triesSize = pCode->triesSize;
const DexTry* pTries;
int curOffset, bool selfOkay)
{
const int insnCount = dvmGetMethodInsnsSize(meth);
- const u2* insns = meth->insns + curOffset;
int offset, absOffset;
bool isConditional;
int curOffset, int* pOffset, bool* pConditional)
{
const u2* insns = meth->insns + curOffset;
- int tmp;
switch (*insns & 0xff) {
case OP_GOTO:
const char* sig = dexProtoGetShorty(proto);
int padFlags, jniHints;
char sigByte;
- int stackOffset, padMask, hints;
+ int stackOffset, padMask;
stackOffset = padFlags = 0;
padMask = 0x00000001;
gDvmJit.compilerQueueLength--;
if (gDvmJit.compilerQueueLength == 0) {
int cc = pthread_cond_signal(&gDvmJit.compilerQueueEmpty);
+ assert(cc == 0);
}
/* Remember the high water mark of the queue length */
static void *compilerThreadStart(void *arg)
{
- int ret;
- struct timespec ts;
-
dvmChangeStatus(NULL, THREAD_VMWAIT);
/*
int dfAttributes =
dvmCompilerDataFlowAttributes[mir->dalvikInsn.opCode];
- int numUses = 0;
-
DecodedInstruction *dInsn = &mir->dalvikInsn;
if (!(dfAttributes & DF_HAS_DEFS)) continue;
/*
* dvmHashTableLookup() callback
*/
+#if defined(WITH_JIT_TUNING)
static int compareMethod(const CompilerMethodStats *m1,
const CompilerMethodStats *m2)
{
return (int) m1->method - (int) m2->method;
}
-#if defined(WITH_JIT_TUNING)
/*
* Analyze each method whose traces are ever compiled. Collect a variety of
* statistics like the ratio of exercised vs overall code and code bloat
/* Returns true if the loop body cannot throw any exceptions */
static bool doLoopBodyCodeMotion(CompilationUnit *cUnit)
{
- BasicBlock *entry = cUnit->blockList[0];
BasicBlock *loopBody = cUnit->blockList[1];
MIR *mir;
bool loopBodyCanThrow = false;
- int numDalvikRegs = cUnit->method->registersSize;
for (mir = loopBody->firstMIRInsn; mir; mir = mir->next) {
DecodedInstruction *dInsn = &mir->dalvikInsn;
int useIdx = refIdx + 1;
int subNRegArray =
dvmConvertSSARegToDalvik(cUnit, mir->ssaRep->uses[refIdx]);
- int arrayReg = DECODE_REG(subNRegArray);
int arraySub = DECODE_SUB(subNRegArray);
/*
static void dumpHoistedChecks(CompilationUnit *cUnit)
{
- ArrayAccessInfo *arrayAccessInfo;
LoopAnalysis *loopAnalysis = cUnit->loopAnalysis;
unsigned int i;
unsigned int i;
BasicBlock *entry = cUnit->blockList[0];
LoopAnalysis *loopAnalysis = cUnit->loopAnalysis;
- ArrayAccessInfo *arrayAccessInfo;
int globalMaxC = 0;
int globalMinC = 0;
/* Should be loop invariant */
/* Main entry point to do loop optimization */
void dvmCompilerLoopOpt(CompilationUnit *cUnit)
{
- int numDalvikReg = cUnit->method->registersSize;
LoopAnalysis *loopAnalysis = dvmCompilerNew(sizeof(LoopAnalysis), true);
assert(cUnit->blockList[0]->blockType == kEntryBlock);
int seqNum = 0;
LiveRange *ranges;
RegLocation *loc;
- int *ssaToDalvikMap = (int *) cUnit->ssaToDalvikMap->elemList;
/* Allocate the location map */
loc = (RegLocation*)dvmCompilerNew(cUnit->numSSARegs * sizeof(*loc), true);
(CompilerMethodStats *) compilerMethodStats;
CompilerMethodStats *totalStats =
(CompilerMethodStats *) totalMethodStats;
- const Method *method = methodStats->method;
totalStats->dalvikSize += methodStats->dalvikSize;
totalStats->compiledDalvikSize += methodStats->compiledDalvikSize;
/* If over 3/4 of the Dalvik code is compiled, print something */
if (methodStats->compiledDalvikSize >= limit) {
LOGD("Method stats: %s%s, %d/%d (compiled/total Dalvik), %d (native)",
- method->clazz->descriptor, method->name,
+ methodStats->method->clazz->descriptor,
+ methodStats->method->name,
methodStats->compiledDalvikSize,
methodStats->dalvikSize,
methodStats->nativeSize);
char opName[256];
int offset = lir->generic.offset;
int dest = lir->operands[0];
- u2 *cPtr = (u2*)baseAddr;
const bool dumpNop = false;
/* Handle pseudo-ops individually, and all regular insns as a group */
* Attempt to enqueue a work order to patch an inline cache for a predicted
* chaining cell for virtual/interface calls.
*/
+#if !defined(WITH_SELF_VERIFICATION)
static bool inlineCachePatchEnqueue(PredictedChainingCell *cellAddr,
PredictedChainingCell *newContent)
{
dvmUnlockMutex(&gDvmJit.compilerICPatchLock);
return result;
}
+#endif
/*
* This method is called from the invoke templates for virtual and interface
int cellSize;
u4* pChainCells;
u4* pStart;
- u4 thumb1;
- u4 thumb2;
u4 newInst;
int i,j;
PredictedChainingCell *predChainCell;
//LOGD("*** THUMB2 - Addr: 0x%x Insn: 0x%x", lr, insn);
int opcode12 = (insn >> 20) & 0xFFF;
- int opcode6 = (insn >> 6) & 0x3F;
int opcode4 = (insn >> 8) & 0xF;
int imm2 = (insn >> 4) & 0x3;
int imm8 = insn & 0xFF;
static void selfVerificationBranchInsertPass(CompilationUnit *cUnit)
{
ArmLIR *thisLIR;
- ArmLIR *branchLIR = dvmCompilerNew(sizeof(ArmLIR), true);
TemplateOpCode opCode = TEMPLATE_MEM_OP_DECODE;
for (thisLIR = (ArmLIR *) cUnit->firstLIRInsn;
/* Load a wide field from an object instance */
static void genIGetWide(CompilationUnit *cUnit, MIR *mir, int fieldOffset)
{
- DecodedInstruction *dInsn = &mir->dalvikInsn;
RegLocation rlObj = dvmCompilerGetSrc(cUnit, mir, 0);
RegLocation rlDest = dvmCompilerGetDestWide(cUnit, mir, 0, 1);
RegLocation rlResult;
/* Store a wide field to an object instance */
static void genIPutWide(CompilationUnit *cUnit, MIR *mir, int fieldOffset)
{
- DecodedInstruction *dInsn = &mir->dalvikInsn;
RegLocation rlSrc = dvmCompilerGetSrcWide(cUnit, mir, 0, 1);
RegLocation rlObj = dvmCompilerGetSrc(cUnit, mir, 2);
rlObj = loadValue(cUnit, rlObj, kCoreReg);
static void genIGet(CompilationUnit *cUnit, MIR *mir, OpSize size,
int fieldOffset)
{
- int regPtr;
RegLocation rlResult;
- DecodedInstruction *dInsn = &mir->dalvikInsn;
RegLocation rlObj = dvmCompilerGetSrc(cUnit, mir, 0);
RegLocation rlDest = dvmCompilerGetDest(cUnit, mir, 0);
rlObj = loadValue(cUnit, rlObj, kCoreReg);
static void genIPut(CompilationUnit *cUnit, MIR *mir, OpSize size,
int fieldOffset)
{
- DecodedInstruction *dInsn = &mir->dalvikInsn;
RegLocation rlSrc = dvmCompilerGetSrc(cUnit, mir, 0);
RegLocation rlObj = dvmCompilerGetSrc(cUnit, mir, 1);
rlObj = loadValue(cUnit, rlObj, kCoreReg);
rlSrc = loadValue(cUnit, rlSrc, kAnyReg);
- int regPtr;
genNullCheck(cUnit, rlObj.sRegLow, rlObj.lowReg, mir->offset,
NULL);/* null object? */
* The return LIR is a branch based on the comparison result. The actual branch
* target will be setup in the caller.
*/
+#if 0
static ArmLIR *genCheckPredictedChain(CompilationUnit *cUnit,
ArmLIR *predChainingCell,
ArmLIR *retChainingCell,
return opCondBranch(cUnit, kArmCondEq);
}
+#endif
/* Geneate a branch to go back to the interpreter */
static void genPuntToInterp(CompilationUnit *cUnit, unsigned int offset)
* "len < 0": bail to the interpreter to re-execute the
* instruction
*/
- ArmLIR *pcrLabel =
- genRegImmCheck(cUnit, kArmCondMi, r1, 0, mir->offset, NULL);
+ genRegImmCheck(cUnit, kArmCondMi, r1, 0, mir->offset, NULL);
loadConstant(cUnit, r2, ALLOC_DONT_TRACK);
opReg(cUnit, kOpBlx, r3);
dvmCompilerClobberCallRegs(cUnit);
dvmCompilerFlushAllRegs(cUnit); /* Everything to home location */
loadValueDirectFixed(cUnit, rlSrc, r1);
dvmCompilerLockAllTemps(cUnit);
- const u2 *switchData =
- cUnit->method->insns + mir->offset + mir->dalvikInsn.vB;
- u2 size = switchData[1];
-
if (dalvikOpCode == OP_PACKED_SWITCH) {
LOAD_FUNC_ADDR(cUnit, r4PC, (int)findPackedSwitchIndex);
} else {
case OP_INVOKE_INTERFACE:
case OP_INVOKE_INTERFACE_RANGE: {
ArmLIR *predChainingCell = &labelList[bb->taken->id];
- int methodIndex = dInsn->vB;
/* Ensure that nothing is both live and dirty */
dvmCompilerFlushAllRegs(cUnit);
const InlineOperation* inLineTable = dvmGetInlineOpsTable();
int offset = offsetof(InterpState, retval);
int operation = dInsn->vB;
- int tReg1;
- int tReg2;
switch (operation) {
case INLINE_EMPTYINLINEMETHOD:
return false; /* Nop */
DecodedInstruction *dInsn = &mir->dalvikInsn;
const int lenOffset = offsetof(ArrayObject, length);
const int maxC = dInsn->arg[0];
- const int minC = dInsn->arg[1];
int regLength;
RegLocation rlArray = cUnit->regLocation[mir->dalvikInsn.vA];
RegLocation rlIdxEnd = cUnit->regLocation[mir->dalvikInsn.vC];
const int lenOffset = offsetof(ArrayObject, length);
const int regLength = dvmCompilerAllocTemp(cUnit);
const int maxC = dInsn->arg[0];
- const int minC = dInsn->arg[1];
RegLocation rlArray = cUnit->regLocation[mir->dalvikInsn.vA];
RegLocation rlIdxInit = cUnit->regLocation[mir->dalvikInsn.vB];
static RegLocation loadValue(CompilationUnit *cUnit, RegLocation rlSrc,
RegisterClass opKind)
{
- RegisterInfo *pReg;
rlSrc = dvmCompilerEvalLoc(cUnit, rlSrc, opKind, false);
if (rlSrc.location == kLocDalvikFrame) {
loadValueDirect(cUnit, rlSrc, rlSrc.lowReg);
static void storeValue(CompilationUnit *cUnit, RegLocation rlDest,
RegLocation rlSrc)
{
- RegisterInfo *pRegLo;
LIR *defStart;
LIR *defEnd;
assert(!rlDest.wide);
static RegLocation loadValueWide(CompilationUnit *cUnit, RegLocation rlSrc,
RegisterClass opKind)
{
- RegisterInfo *pRegLo;
- RegisterInfo *pRegHi;
assert(rlSrc.wide);
rlSrc = dvmCompilerEvalLoc(cUnit, rlSrc, opKind, false);
if (rlSrc.location == kLocDalvikFrame) {
static void storeValueWide(CompilationUnit *cUnit, RegLocation rlDest,
RegLocation rlSrc)
{
- RegisterInfo *pRegLo;
- RegisterInfo *pRegHi;
LIR *defStart;
LIR *defEnd;
- bool srcFP = FPREG(rlSrc.lowReg) && FPREG(rlSrc.highReg);
assert(FPREG(rlSrc.lowReg)==FPREG(rlSrc.highReg));
assert(rlDest.wide);
assert(rlSrc.wide);
static bool genInlineSqrt(CompilationUnit *cUnit, MIR *mir)
{
ArmLIR *branch;
- DecodedInstruction *dInsn = &mir->dalvikInsn;
RegLocation rlSrc = dvmCompilerGetSrcWide(cUnit, mir, 0, 1);
RegLocation rlDest = inlinedTargetWide(cUnit, mir, true);
rlSrc = loadValueWide(cUnit, rlSrc, kFPReg);
{
bool isDouble;
int defaultResult;
- bool ltNaNBias;
RegLocation rlResult;
switch(mir->dalvikInsn.opCode) {
continue;
}
if (isDalvikStore(thisLIR)) {
- int dRegId = DECODE_ALIAS_INFO_REG(thisLIR->aliasInfo);
- int dRegIdHi = dRegId + DECODE_ALIAS_INFO_WIDE(thisLIR->aliasInfo);
int nativeRegId = thisLIR->operands[0];
ArmLIR *checkLIR;
int sinkDistance = 0;
if (isDalvikLoad(thisLIR)) {
int dRegId = DECODE_ALIAS_INFO_REG(thisLIR->aliasInfo);
- int dRegIdHi = dRegId + DECODE_ALIAS_INFO_WIDE(thisLIR->aliasInfo);
int nativeRegId = thisLIR->operands[0];
ArmLIR *checkLIR;
int hoistDistance = 0;
dvmCompilerAbort(cUnit);
}
-static void lockArgRegs(CompilationUnit *cUnit)
-{
- dvmCompilerLockTemp(cUnit, r0);
- dvmCompilerLockTemp(cUnit, r1);
- dvmCompilerLockTemp(cUnit, r2);
- dvmCompilerLockTemp(cUnit, r3);
-}
-
/* Clobber all regs that might be used by an external C call */
extern void dvmCompilerClobberCallRegs(CompilationUnit *cUnit)
{
infoHi->partner = lowReg;
}
-static void markRegSingle(CompilationUnit *cUnit, int reg)
-{
- RegisterInfo *info = getRegInfo(cUnit, reg);
- info->pair = false;
-}
-
extern void dvmCompilerMarkClean(CompilationUnit *cUnit, int reg)
{
RegisterInfo *info = getRegInfo(cUnit, reg);
info->inUse = true;
}
-/* Return true if live & dirty */
-static bool isDirty(CompilationUnit *cUnit, int reg)
-{
- RegisterInfo *info = getRegInfo(cUnit, reg);
- return (info && info->live && info->dirty);
-}
-
void copyRegInfo(CompilationUnit *cUnit, int newReg, int oldReg)
{
RegisterInfo *newInfo = getRegInfo(cUnit, newReg);
extern RegLocation dvmCompilerEvalLoc(CompilationUnit *cUnit, RegLocation loc,
int regClass, bool update)
{
- RegisterInfo *infoLo = NULL;
int newReg;
if (loc.wide)
return evalLocWide(cUnit, loc, regClass, update);
*/
static int coreTemps[] = {r0, r1, r2, r3, r4PC, r7, r8, r9, r10, r11, r12};
-static int corePreserved[] = {};
static int fpTemps[] = {fr16, fr17, fr18, fr19, fr20, fr21, fr22, fr23,
fr24, fr25, fr26, fr27, fr28, fr29, fr30, fr31};
-static int fpPreserved[] = {};
static int encodeImmSingle(int value)
{
static ArmLIR *opRegImm(CompilationUnit *cUnit, OpKind op, int rDestSrc1,
int value)
{
- ArmLIR *res;
bool neg = (value < 0);
int absValue = (neg) ? -value : value;
bool shortForm = (((absValue & 0xff) == absValue) && LOWREG(rDestSrc1));
ArmOpCode opCode = kThumbBkpt;
bool shortForm = false;
bool thumb2Form = (displacement < 4092 && displacement >= 0);
- int shortMax = 128;
bool allLowRegs = (LOWREG(rBase) && LOWREG(rDest));
int encodedDisp = displacement;
ArmOpCode opCode = kThumbBkpt;
bool shortForm = false;
bool thumb2Form = (displacement < 4092 && displacement >= 0);
- int shortMax = 128;
bool allLowRegs = (LOWREG(rBase) && LOWREG(rSrc));
int encodedDisp = displacement;
void dvmCompilerInitializeRegAlloc(CompilationUnit *cUnit)
{
- int i;
int numTemps = sizeof(coreTemps)/sizeof(int);
int numFPTemps = sizeof(fpTemps)/sizeof(int);
RegisterPool *pool = dvmCompilerNew(sizeof(*pool), true);
static void genMonitorEnter(CompilationUnit *cUnit, MIR *mir)
{
RegLocation rlSrc = dvmCompilerGetSrc(cUnit, mir, 0);
- bool enter = (mir->dalvikInsn.opCode == OP_MONITOR_ENTER);
ArmLIR *target;
ArmLIR *hopTarget;
ArmLIR *branch;
LOGV("Flushing breakpoint at %p for %s\n",
pBreak->addr, clazz->descriptor);
if (instructionIsMagicNop(pBreak->addr)) {
- const Method* method = pBreak->method;
LOGV("Refusing to flush breakpoint on %04x at %s.%s + 0x%x\n",
- *pBreak->addr, method->clazz->descriptor,
- method->name, pBreak->addr - method->insns);
+ *pBreak->addr, pBreak->method->clazz->descriptor,
+ pBreak->method->name, pBreak->addr - pBreak->method->insns);
} else {
dvmDexChangeDex1(clazz->pDvmDex, (u1*)pBreak->addr,
OP_BREAKPOINT);
s4 dvmInterpHandleSparseSwitch(const u2* switchData, s4 testVal)
{
const int kInstrLen = 3;
- u2 ident, size;
+ u2 size;
const s4* keys;
const s4* entries;
*/
int dvmCheckJit(const u2* pc, Thread* self, InterpState* interpState)
{
- int flags,i,len;
+ int flags, len;
int switchInterp = false;
bool debugOrProfile = dvmDebuggerOrProfilerActive();
interpState->lastPC = pc;
switch (interpState->jitState) {
- char* nopStr;
- int target;
int offset;
DecodedInstruction decInsn;
case kJitTSelect:
void dvmCallMethod(Thread* self, const Method* method, Object* obj,
JValue* pResult, ...)
{
- JValue result;
-
va_list args;
va_start(args, pResult);
dvmCallMethodV(self, method, obj, false, pResult, args);
dvmInterpret(self, method, pResult);
}
+#ifndef NDEBUG
bail:
+#endif
dvmPopFrame(self);
}
int dvmComputeVagueFrameDepth(Thread* thread, const void* fp)
{
const u1* interpStackStart = thread->interpStackStart;
- const u1* interpStackBottom = interpStackStart - thread->interpStackSize;
- assert((u1*) fp >= interpStackBottom && (u1*) fp < interpStackStart);
+ assert((u1*) fp >= interpStackStart - thread->interpStackSize);
+ assert((u1*) fp < interpStackStart);
return interpStackStart - (u1*) fp;
}
state->eventList = pEvent;
state->numEvents++;
-bail:
unlockEventMutex(state);
return err;
return false;
return strcmp(pattern+1, target + (targetLen-patLen)) == 0;
} else if (pattern[patLen-1] == '*') {
- int i;
-
return strncmp(pattern, target, patLen-1) == 0;
} else {
return strcmp(pattern, target) == 0;
u4 numClasses;
size_t strLen;
RefTypeId refTypeId;
- int i;
classDescriptor = readNewUtf8String(&buf, &strLen);
LOGV(" Req for class by signature '%s'\n", classDescriptor);
static JdwpError handleVM_Capabilities(JdwpState* state,
const u1* buf, int dataLen, ExpandBuf* pReply)
{
- int i;
-
expandBufAdd1(pReply, false); /* canWatchFieldModification */
expandBufAdd1(pReply, false); /* canWatchFieldAccess */
expandBufAdd1(pReply, false); /* canGetBytecodes */
const u1* buf, int dataLen, ExpandBuf* pReply)
{
RefTypeId refTypeId;
- ObjectId classLoaderId;
refTypeId = dvmReadRefTypeId(&buf);
const u1* buf, int dataLen, ExpandBuf* pReply)
{
RefTypeId refTypeId;
- int i, numFields;
refTypeId = dvmReadRefTypeId(&buf);
LOGV(" Req for fields in refTypeId=0x%llx\n", refTypeId);
const u1* buf, int dataLen, ExpandBuf* pReply)
{
RefTypeId refTypeId;
- int i;
refTypeId = dvmReadRefTypeId(&buf);
ObjectId threadId;
MethodId methodId;
ObjectId objectId;
- u4 numArgs;
classId = dvmReadRefTypeId(&buf);
threadId = dvmReadObjectId(&buf);
u1 fieldTag;
int width;
u1* ptr;
- const char* fieldName;
fieldId = dvmReadFieldId(&buf);
{
ObjectId threadGroupId;
u4 threadCount;
- ObjectId threadId;
ObjectId* pThreadIds;
ObjectId* walker;
int i;
ObjectId arrayId;
u4 firstIndex;
u4 values;
- u1 tag;
- int i;
arrayId = dvmReadObjectId(&buf);
firstIndex = read4BE(&buf);
JdwpState* dvmJdwpStartup(const JdwpStartupParams* pParams)
{
JdwpState* state = NULL;
- int i, sleepIter;
- u8 startWhen;
/* comment this out when debugging JDWP itself */
android_setMinPriority(LOG_TAG, ANDROID_LOG_DEBUG);
*/
while (state->run) {
bool first;
- int cc;
if (state->params.server) {
/*
/*
* Returns "true" if the fd is ready, "false" if not.
*/
+#if 0
static bool isFdReadable(int sock)
{
fd_set readfds;
LOGE("WEIRD: odd behavior in select (count=%d)\n", count);
return false;
}
+#endif
#if 0
/*
struct sockaddr addrPlain;
} addr;
struct hostent* pEntry;
- char auxBuf[128];
- int cc, h_errno;
+ int h_errno;
assert(state != NULL && state->netState != NULL);
assert(!state->params.server);
//#warning "forcing non-R"
#ifdef HAVE_GETHOSTBYNAME_R
struct hostent he;
- cc = gethostbyname_r(state->params.host, &he, auxBuf, sizeof(auxBuf),
+ char auxBuf[128];
+ int cc = gethostbyname_r(state->params.host, &he, auxBuf, sizeof(auxBuf),
&pEntry, &h_errno);
if (cc != 0) {
LOGW("gethostbyname_r('%s') failed: %s\n",
/*
* Dump the contents of a packet to stdout.
*/
+#if 0
static void dumpPacket(const unsigned char* packetBuf)
{
const unsigned char* buf = packetBuf;
if (dataLen > 0)
dvmPrintHexDumpDbg(buf, dataLen, LOG_TAG);
}
+#endif
/*
* Handle a packet. Returns "false" if we encounter a connection-fatal error.
*/
const StepControl* pCtrl = &gDvm.stepControl;
if (pCtrl->active && pCtrl->thread == self) {
- int line, frameDepth;
+ int frameDepth;
bool doStop = false;
const char* msg = NULL;
*/
const StepControl* pCtrl = &gDvm.stepControl;
if (pCtrl->active && pCtrl->thread == self) {
- int line, frameDepth;
+ int frameDepth;
bool doStop = false;
const char* msg = NULL;
{
StringObject* sourceNameObj = (StringObject*) args[0];
StringObject* outputNameObj = (StringObject*) args[1];
- int flags = args[2];
DexOrJar* pDexOrJar = NULL;
JarFile* pJarFile;
RawDexFile* pRawDexFile;
static void Dalvik_dalvik_system_Zygote_fork(const u4* args, JValue* pResult)
{
pid_t pid;
- int err;
if (!gDvm.zygote) {
dvmThrowException("Ljava/lang/IllegalStateException;",
ClassObject* clazz = NULL;
char* name = NULL;
char* descriptor = NULL;
- char* cp;
if (nameObj == NULL) {
dvmThrowException("Ljava/lang/NullPointerException;", NULL);
*/
static void Dalvik_java_lang_VMThread_sleep(const u4* args, JValue* pResult)
{
- Thread* self = dvmThreadSelf();
dvmThreadSleep(GET_ARG_LONG(args,0), args[2]);
RETURN_VOID();
}
static int computeJniArgInfo(const DexProto* proto)
{
const char* sig = dexProtoGetShorty(proto);
- int returnType, padFlags, jniArgInfo;
- char sigByte;
- int stackOffset, padMask;
+ int returnType, jniArgInfo;
u4 hints;
/* The first shorty character is the return type. */
Method* resMethod;
const DexMethodId* pMethodId;
const char* name;
- const char* signature;
/* if we've already resolved this method, return it */
resMethod = dvmDexGetResolvedMethod(referrer->pDvmDex, methodIdx);
const u1** pPtr)
{
Thread* self = dvmThreadSelf();
- const DexFile* pDexFile = clazz->pDvmDex->pDexFile;
Object* newAnno = NULL;
ArrayObject* elementArray = NULL;
const ClassObject* annoClass;
*/
static bool skipEncodedAnnotation(const ClassObject* clazz, const u1** pPtr)
{
- const DexFile* pDexFile = clazz->pDvmDex->pDexFile;
const u1* ptr;
u4 size;
int expectedType, const char* debugAnnoName)
{
const u1* ptr;
- Object* obj;
AnnotationValue avalue;
/* find the annotation */
DexFile* pDexFile = clazz->pDvmDex->pDexFile;
const DexAnnotationsDirectoryItem* pAnnoDir;
const DexFieldAnnotationsItem* pFieldList;
- const DexAnnotationSetItem* pAnnoSet = NULL;
pAnnoDir = getAnnoDirectory(pDexFile, clazz);
if (pAnnoDir == NULL)
{
ClassObject* clazz = field->clazz;
ArrayObject* annoArray = NULL;
- DexFile* pDexFile = clazz->pDvmDex->pDexFile;
- const DexAnnotationsDirectoryItem* pAnnoDir;
const DexAnnotationSetItem* pAnnoSet = NULL;
pAnnoSet = findAnnotationSetForField(field);
static int copyWithoutDuplicates(Method** allMethods, int allCount,
Method** outMethods, ArrayObject* throwLists)
{
- Method* best;
int outCount = 0;
int i, j;
Object* handler;
Method* invoke;
ClassObject* returnType;
- int hOffset;
JValue invokeResult;
/*
bool dvmUnwrapPrimitive(Object* value, ClassObject* returnType,
JValue* pResult)
{
- JValue result;
PrimitiveType typeIndex = returnType->primitiveType;
PrimitiveType valueIndex;
- //const u4* dataPtr;
if (typeIndex == PRIM_NOT) {
if (value != NULL && !dvmInstanceof(value->clazz, returnType)) {
for (dvmHashIterBegin(pTab, &iter); !dvmHashIterDone(&iter);
dvmHashIterNext(&iter))
{
- const char* str = (const char*) dvmHashIterData(&iter);
+ //const char* str = (const char*) dvmHashIterData(&iter);
//printf(" '%s'\n", str);
// (should verify strings)
count++;