/* * Populate the methods table on first use. It's possible the class * hasn't been resolved yet, so we need to do the full "calling the * method for the first time" routine. (It's probably okay to skip * the access checks.) * * Currently assuming that we're only inlining stuff loaded by the * bootstrap class loader. This is a safe assumption for many reasons. */ Method* dvmResolveInlineNative(int opIndex) { assert(opIndex >= 0 && opIndex < NELEM(gDvmInlineOpsTable)); Method* method = gDvm.inlinedMethods[opIndex]; if (method != NULL) { return method; } method = dvmFindInlinableMethod( gDvmInlineOpsTable[opIndex].classDescriptor, gDvmInlineOpsTable[opIndex].methodName, gDvmInlineOpsTable[opIndex].methodSignature); if (method == NULL) { /* We already reported the error. */ return NULL; } gDvm.inlinedMethods[opIndex] = method; IF_ALOGV() { char* desc = dexProtoCopyMethodDescriptor(&method->prototype); ALOGV("Registered for profile: %s.%s %s", method->clazz->descriptor, method->name, desc); free(desc); } return method; }
/* * Create a table of inline substitutions. Sets gDvm.inlineSubs. * * TODO: this is currently just a linear array. We will want to put this * into a hash table as the list size increases. */ bool dvmCreateInlineSubsTable() { const InlineOperation* ops = dvmGetInlineOpsTable(); const int count = dvmGetInlineOpsTableLength(); InlineSub* table; int i, tableIndex; assert(gDvm.inlineSubs == NULL); /* * One slot per entry, plus an end-of-list marker. */ table = (InlineSub*) calloc(count + 1, sizeof(InlineSub)); if (!table) { ALOGE("table allocation failed"); return false; } tableIndex = 0; for (i = 0; i < count; i++) { Method* method = dvmFindInlinableMethod(ops[i].classDescriptor, ops[i].methodName, ops[i].methodSignature); if (method == NULL) { /* * Not expected. We only use this for key methods in core * classes, so we should always be able to find them. */ ALOGE("Unable to find method for inlining: %s.%s:%s", ops[i].classDescriptor, ops[i].methodName, ops[i].methodSignature); free(table); return false; } table[tableIndex].method = method; table[tableIndex].inlineIdx = i; tableIndex++; } /* mark end of table */ table[tableIndex].method = NULL; gDvm.inlineSubs = table; return true; }