本文整理汇总了C++中dvmAbort函数的典型用法代码示例。如果您正苦于以下问题:C++ dvmAbort函数的具体用法?C++ dvmAbort怎么用?C++ dvmAbort使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了dvmAbort函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: dvmPopFrame
/*
* Pop a frame we added. There should be one method frame and one break
* frame.
*
* If JNI Push/PopLocalFrame calls were mismatched, we might end up
* popping multiple method frames before we find the break.
*
* Returns "false" if there was no frame to pop.
*/
static bool dvmPopFrame(Thread* self)
{
StackSaveArea* saveBlock;
if (self->interpSave.curFrame == NULL)
return false;
saveBlock = SAVEAREA_FROM_FP(self->interpSave.curFrame);
assert(!dvmIsBreakFrame((u4*)self->interpSave.curFrame));
/*
* Remove everything up to the break frame. If this was a call into
* native code, pop the JNI local references table.
*/
while (saveBlock->prevFrame != NULL && saveBlock->method != NULL) {
/* probably a native->native JNI call */
if (dvmIsNativeMethod(saveBlock->method)) {
LOGVV("Popping JNI stack frame for %s.%s%s",
saveBlock->method->clazz->descriptor,
saveBlock->method->name,
(SAVEAREA_FROM_FP(saveBlock->prevFrame)->method == NULL) ?
"" : " (JNI local)");
dvmPopJniLocals(self, saveBlock);
}
saveBlock = SAVEAREA_FROM_FP(saveBlock->prevFrame);
}
if (saveBlock->method != NULL) {
ALOGE("PopFrame missed the break");
assert(false);
dvmAbort(); // stack trashed -- nowhere to go in this thread
}
LOGVV("POP frame: cur=%p new=%p",
self->interpSave.curFrame, saveBlock->prevFrame);
self->interpSave.curFrame = saveBlock->prevFrame;
#ifdef WITH_OFFLOAD
offStackFramePopped(self);
self->breakFrames--;
CHECK_BREAK_FRAMES();
#endif
return true;
}
开发者ID:acpaluri,项目名称:591_Comet,代码行数:55,代码来源:Stack.cpp
示例2: convertStringArray
/*
* Convert an array of char* into a String[].
*
* Returns NULL on failure, with an exception raised.
*/
static ArrayObject* convertStringArray(char** strings, size_t count)
{
Thread* self = dvmThreadSelf();
/*
* Allocate an array to hold the String objects.
*/
ClassObject* stringArrayClass =
dvmFindArrayClass("[Ljava/lang/String;", NULL);
if (stringArrayClass == NULL) {
/* shouldn't happen */
LOGE("Unable to find [Ljava/lang/String;\n");
dvmAbort();
}
ArrayObject* stringArray =
dvmAllocArrayByClass(stringArrayClass, count, ALLOC_DEFAULT);
if (stringArray == NULL) {
/* probably OOM */
LOGD("Failed allocating array of %d strings\n", count);
assert(dvmCheckException(self));
return NULL;
}
/*
* Create the individual String objects and add them to the array.
*/
size_t i;
for (i = 0; i < count; i++) {
Object *str =
(Object *)dvmCreateStringFromCstr(strings[i]);
if (str == NULL) {
/* probably OOM; drop out now */
assert(dvmCheckException(self));
dvmReleaseTrackedAlloc((Object*)stringArray, self);
return NULL;
}
dvmSetObjectArrayElement(stringArray, i, str);
/* stored in tracked array, okay to release */
dvmReleaseTrackedAlloc(str, self);
}
dvmReleaseTrackedAlloc((Object*)stringArray, self);
return stringArray;
}
开发者ID:OMFGB,项目名称:dalvik,代码行数:50,代码来源:dalvik_system_VMDebug.c
示例3: dvmHandleStackOverflow
/*
* Open up the reserved area and throw an exception. The reserved area
* should only be needed to create and initialize the exception itself.
*
* If we already opened it and we're continuing to overflow, abort the VM.
*
* We have to leave the "reserved" area open until the "catch" handler has
* finished doing its processing. This is because the catch handler may
* need to resolve classes, which requires calling into the class loader if
* the classes aren't already in the "initiating loader" list.
*/
void dvmHandleStackOverflow(Thread* self, const Method* method)
{
/*
* Can we make the reserved area available?
*/
if (self->stackOverflowed) {
/*
* Already did, nothing to do but bail.
*/
LOGE("DalvikVM: double-overflow of stack in threadid=%d; aborting\n",
self->threadId);
dvmDumpThread(self, false);
dvmAbort();
}
/* open it up to the full range */
LOGI("threadid=%d: stack overflow on call to %s.%s:%s\n",
self->threadId,
method->clazz->descriptor, method->name, method->shorty);
StackSaveArea* saveArea = SAVEAREA_FROM_FP(self->curFrame);
LOGI(" method requires %d+%d+%d=%d bytes, fp is %p (%d left)\n",
method->registersSize * 4, sizeof(StackSaveArea), method->outsSize * 4,
(method->registersSize + method->outsSize) * 4 + sizeof(StackSaveArea),
saveArea, (u1*) saveArea - self->interpStackEnd);
LOGI(" expanding stack end (%p to %p)\n", self->interpStackEnd,
self->interpStackStart - self->interpStackSize);
//dvmDumpThread(self, false);
self->interpStackEnd = self->interpStackStart - self->interpStackSize;
self->stackOverflowed = true;
/*
* If we were trying to throw an exception when the stack overflowed,
* we will blow up when doing the class lookup on StackOverflowError
* because of the pending exception. So, we clear it and make it
* the cause of the SOE.
*/
Object* excep = dvmGetException(self);
if (excep != NULL) {
LOGW("Stack overflow while throwing exception\n");
dvmClearException(self);
}
dvmThrowChainedExceptionByClass(gDvm.classJavaLangStackOverflowError,
NULL, excep);
}
开发者ID:Andproject,项目名称:platform_dalvik,代码行数:55,代码来源:Stack.c
示例4: dvmPopFrame
/*
* Pop a frame we added. There should be one method frame and one break
* frame.
*
* If JNI Push/PopLocalFrame calls were mismatched, we might end up
* popping multiple method frames before we find the break.
*
* Returns "false" if there was no frame to pop.
*/
static bool dvmPopFrame(Thread* self)
{
StackSaveArea* saveBlock;
if (self->curFrame == NULL)
return false;
saveBlock = SAVEAREA_FROM_FP(self->curFrame);
assert(!dvmIsBreakFrame(self->curFrame));
/*
* Remove everything up to the break frame. If this was a call into
* native code, pop the JNI local references table.
*/
while (saveBlock->prevFrame != NULL && saveBlock->method != NULL) {
/* probably a native->native JNI call */
if (dvmIsNativeMethod(saveBlock->method)) {
LOGVV("Popping JNI stack frame for %s.%s%s\n",
saveBlock->method->clazz->descriptor,
saveBlock->method->name,
(SAVEAREA_FROM_FP(saveBlock->prevFrame)->method == NULL) ?
"" : " (JNI local)");
assert(saveBlock->xtra.localRefCookie != 0);
//assert(saveBlock->xtra.localRefCookie >= self->jniLocalRefTable.table &&
// saveBlock->xtra.localRefCookie <=self->jniLocalRefTable.nextEntry);
dvmPopJniLocals(self, saveBlock);
}
saveBlock = SAVEAREA_FROM_FP(saveBlock->prevFrame);
}
if (saveBlock->method != NULL) {
LOGE("PopFrame missed the break\n");
assert(false);
dvmAbort(); // stack trashed -- nowhere to go in this thread
}
LOGVV("POP frame: cur=%p new=%p\n",
self->curFrame, saveBlock->prevFrame);
self->curFrame = saveBlock->prevFrame;
return true;
}
开发者ID:Andproject,项目名称:platform_dalvik,代码行数:53,代码来源:Stack.c
示例5: Dalvik_dalvik_system_ZygoteHooks_preFork
/*
* native public static long nativePreFork()
*/
static void Dalvik_dalvik_system_ZygoteHooks_preFork(const u4* args,
JValue* pResult)
{
dvmDumpLoaderStats("zygote");
if (!gDvm.zygote) {
dvmThrowIllegalStateException(
"VM instance not started with -Xzygote");
RETURN_LONG(-1L);
}
if (!dvmGcPreZygoteFork()) {
ALOGE("pre-fork heap failed");
dvmAbort();
}
RETURN_LONG(0L);
}
开发者ID:azraelee,项目名称:platform_dalvik,代码行数:22,代码来源:dalvik_system_ZygoteHooks.cpp
示例6: dvmReleaseTrackedAlloc
/*
* Stop tracking an object.
*
* We allow attempts to delete NULL "obj" so that callers don't have to wrap
* calls with "if != NULL".
*/
void dvmReleaseTrackedAlloc(Object* obj, Thread* self)
{
if (obj == NULL)
return;
if (self == NULL)
self = dvmThreadSelf();
assert(self != NULL);
//LOGI("TRACK REM %p (%s)\n", obj,
// (obj->clazz != NULL) ? obj->clazz->name : "");
if (!dvmRemoveFromReferenceTable(&self->internalLocalRefTable,
self->internalLocalRefTable.table, obj))
{
LOGE("threadid=%d: failed to remove %p from internal ref table\n",
self->threadId, obj);
dvmAbort();
}
}
开发者ID:dslab-epfl,项目名称:dimmunix,代码行数:26,代码来源:Alloc.c
示例7: getSignature
/*
* Get the SHA-1 signature.
*/
static const u1* getSignature(const ClassPathEntry* cpe)
{
DvmDex* pDvmDex;
switch (cpe->kind) {
case kCpeJar:
pDvmDex = dvmGetJarFileDex((JarFile*) cpe->ptr);
break;
case kCpeDex:
pDvmDex = dvmGetRawDexFileDex((RawDexFile*) cpe->ptr);
break;
default:
LOGE("unexpected cpe kind %d\n", cpe->kind);
dvmAbort();
pDvmDex = NULL; // make gcc happy
}
assert(pDvmDex != NULL);
return pDvmDex->pDexFile->pHeader->signature;
}
开发者ID:ThoreTechnics,项目名称:in-the-box,代码行数:23,代码来源:DexPrepare.c
示例8: Dalvik_dalvik_system_ZygoteHooks_postForkChild
/*
* native public static int nativePostForkChild(long token, int debug_flags),
*/
static void Dalvik_dalvik_system_ZygoteHooks_postForkChild(
const u4* args, JValue* pResult)
{
/*
* Our system thread ID has changed. Get the new one.
*/
Thread* thread = dvmThreadSelf();
thread->systemTid = dvmGetSysThreadId();
/* configure additional debug options */
enableDebugFeatures(args[1]);
gDvm.zygote = false;
if (!dvmInitAfterZygote()) {
ALOGE("error in post-zygote initialization");
dvmAbort();
}
RETURN_VOID();
}
开发者ID:azraelee,项目名称:platform_dalvik,代码行数:23,代码来源:dalvik_system_ZygoteHooks.cpp
示例9: dvmCreateMonitor
/*
* Create and initialize a monitor.
*/
Monitor* dvmCreateMonitor(Object* obj)
{
Monitor* mon;
mon = (Monitor*) calloc(1, sizeof(Monitor));
if (mon == NULL) {
ALOGE("Unable to allocate monitor");
dvmAbort();
}
mon->obj = obj;
dvmInitMutex(&mon->lock);
/* replace the head of the list with the new monitor */
do {
mon->next = gDvm.monitorList;
} while (android_atomic_release_cas((int32_t)mon->next, (int32_t)mon,
(int32_t*)(void*)&gDvm.monitorList) != 0);
return mon;
}
开发者ID:1mobilesuper,项目名称:platform_dalvik,代码行数:23,代码来源:Sync.cpp
示例10: dexspyAddLocalReference
// work-around to get a reference wrapper to an object so that it can be used
// for certain calls to the JNI environment. almost verbatim copy from Jni.cpp
static jobject dexspyAddLocalReference(::Thread* self, Object* obj) {
if (obj == NULL) {
return NULL;
}
IndirectRefTable* pRefTable = &self->jniLocalRefTable;
void* curFrame = self->interpSave.curFrame;
u4 cookie = SAVEAREA_FROM_FP(curFrame)->xtra.localRefCookie;
jobject jobj = (jobject) pRefTable->add(cookie, obj);
if (UNLIKELY(jobj == NULL)) {
pRefTable->dump("JNI local");
ALOGE("Failed adding to JNI local ref table (has %zd entries)", pRefTable->capacity());
dvmDumpThread(self, false);
dvmAbort(); // spec says call FatalError; this is equivalent
}
if (UNLIKELY(gDvmJni.workAroundAppJniBugs)) {
// Hand out direct pointers to support broken old apps.
return reinterpret_cast<jobject>(obj);
}
return jobj;
}
开发者ID:MiCode,项目名称:Xposed,代码行数:23,代码来源:dexspy.cpp
示例11: dvmCompilerAllocTemp
/*
* Perform a "reg cmp reg" operation and jump to the PCR region if condition
* satisfies.
*/
static MipsLIR *genRegRegCheck(CompilationUnit *cUnit,
MipsConditionCode cond,
int reg1, int reg2, int dOffset,
MipsLIR *pcrLabel)
{
MipsLIR *res = NULL;
if (cond == kMipsCondGe) { /* signed >= case */
int tReg = dvmCompilerAllocTemp(cUnit);
res = newLIR3(cUnit, kMipsSlt, tReg, reg1, reg2);
MipsLIR *branch = opCompareBranch(cUnit, kMipsBeqz, tReg, -1);
genCheckCommon(cUnit, dOffset, branch, pcrLabel);
} else if (cond == kMipsCondCs) { /* unsigned >= case */
int tReg = dvmCompilerAllocTemp(cUnit);
res = newLIR3(cUnit, kMipsSltu, tReg, reg1, reg2);
MipsLIR *branch = opCompareBranch(cUnit, kMipsBeqz, tReg, -1);
genCheckCommon(cUnit, dOffset, branch, pcrLabel);
} else {
ALOGE("Unexpected condition in genRegRegCheck: %d\n", (int) cond);
dvmAbort();
}
return res;
}
开发者ID:0omega,项目名称:platform_dalvik,代码行数:26,代码来源:CodegenFactory.cpp
示例12: assembleInstructions
/* Return TRUE if error happens */
static bool assembleInstructions(CompilationUnit *cUnit, intptr_t startAddr)
{
short *bufferAddr = (short *) cUnit->codeBuffer;
ArmLIR *lir;
for (lir = (ArmLIR *) cUnit->firstLIRInsn; lir; lir = NEXT_LIR(lir)) {
if (lir->opCode < 0) {
if ((lir->opCode == ARM_PSEUDO_ALIGN4) &&
/* 1 means padding is needed */
(lir->operands[0] == 1)) {
*bufferAddr++ = PADDING_MOV_R0_R0;
}
continue;
}
if (lir->isNop) {
continue;
}
if (lir->opCode == THUMB_LDR_PC_REL ||
lir->opCode == THUMB_ADD_PC_REL) {
ArmLIR *lirTarget = (ArmLIR *) lir->generic.target;
intptr_t pc = (lir->generic.offset + 4) & ~3;
/*
* Allow an offset (stored in operands[2] to be added to the
* PC-relative target. Useful to get to a fixed field inside a
* chaining cell.
*/
intptr_t target = lirTarget->generic.offset + lir->operands[2];
int delta = target - pc;
if (delta & 0x3) {
LOGE("PC-rel distance is not multiples of 4: %d\n", delta);
dvmAbort();
}
if (delta > 1023) {
return true;
}
lir->operands[1] = delta >> 2;
} else if (lir->opCode == THUMB2_CBNZ || lir->opCode == THUMB2_CBZ) {
开发者ID:SecretSemariten,项目名称:platform_dalvik,代码行数:40,代码来源:Assemble.c
示例13: makeStringObject
/*
* Allocate a new instance of the class String, performing first-use
* initialization of the class if necessary. Upon success, the
* returned value will have all its fields except hashCode already
* filled in, including a reference to a newly-allocated char[] for
* the contents, sized as given. Additionally, a reference to the
* chars array is stored to the pChars pointer. Callers must
* subsequently call dvmReleaseTrackedAlloc() on the result pointer.
* This function returns NULL on failure.
*/
static StringObject* makeStringObject(u4 charsLength, ArrayObject** pChars)
{
/*
* The String class should have already gotten found (but not
* necessarily initialized) before making it here. We assert it
* explicitly, since historically speaking, we have had bugs with
* regard to when the class String gets set up. The assert helps
* make any regressions easier to diagnose.
*/
assert(gDvm.classJavaLangString != NULL);
if (!dvmIsClassInitialized(gDvm.classJavaLangString)) {
/* Perform first-time use initialization of the class. */
if (!dvmInitClass(gDvm.classJavaLangString)) {
LOGE("FATAL: Could not initialize class String");
dvmAbort();
}
}
Object* result = dvmAllocObject(gDvm.classJavaLangString, ALLOC_DEFAULT);
if (result == NULL) {
return NULL;
}
ArrayObject* chars = dvmAllocPrimitiveArray('C', charsLength, ALLOC_DEFAULT);
if (chars == NULL) {
dvmReleaseTrackedAlloc(result, NULL);
return NULL;
}
dvmSetFieldInt(result, STRING_FIELDOFF_COUNT, charsLength);
dvmSetFieldObject(result, STRING_FIELDOFF_VALUE, (Object*) chars);
dvmReleaseTrackedAlloc((Object*) chars, NULL);
/* Leave offset and hashCode set to zero. */
*pChars = chars;
return (StringObject*) result;
}
开发者ID:0x4d4e,项目名称:platform_dalvik,代码行数:48,代码来源:UtfString.cpp
示例14: dvmReleaseTrackedAlloc
/*
* Stop tracking an object.
*
* We allow attempts to delete NULL "obj" so that callers don't have to wrap
* calls with "if != NULL".
*/
void dvmReleaseTrackedAlloc(Object* obj, Thread* self)
{
if (obj == NULL)
return;
if (self == NULL)
self = dvmThreadSelf();
assert(self != NULL);
pthread_mutex_lock(&gDvm.s_mtx);
if(gDvm.freeObjHook) {
gDvm.freeObjHook(obj, self);
}
pthread_mutex_unlock(&gDvm.s_mtx);
if (!dvmRemoveFromReferenceTable(&self->internalLocalRefTable,
self->internalLocalRefTable.table, obj))
{
ALOGE("threadid=%d: failed to remove %p from internal ref table",
self->threadId, obj);
dvmAbort();
}
}
开发者ID:jysunhy,项目名称:disl-android,代码行数:29,代码来源:Alloc.cpp
示例15: addToDexFileTable
/*
* Add given DexOrJar to the hash table of user-loaded dex files.
*/
static void addToDexFileTable(DexOrJar* pDexOrJar) {
/*
* Later on, we will receive this pointer as an argument and need
* to find it in the hash table without knowing if it's valid or
* not, which means we can't compute a hash value from anything
* inside DexOrJar. We don't share DexOrJar structs when the same
* file is opened multiple times, so we can just use the low 32
* bits of the pointer as the hash.
*/
u4 hash = (u4) pDexOrJar;
void* result;
dvmHashTableLock(gDvm.userDexFiles);
result = dvmHashTableLookup(gDvm.userDexFiles, hash, pDexOrJar,
hashcmpDexOrJar, true);
dvmHashTableUnlock(gDvm.userDexFiles);
if (result != pDexOrJar) {
ALOGE("Pointer has already been added?");
dvmAbort();
}
pDexOrJar->okayToFree = true;
}
开发者ID:1mobilesuper,项目名称:platform_dalvik,代码行数:27,代码来源:dalvik_system_DexFile.cpp
示例16: negateOpcode
/* Used for normalized loop exit condition checks */
static Opcode negateOpcode(Opcode opcode)
{
switch (opcode) {
/* reg/reg cmp */
case OP_IF_EQ:
return OP_IF_NE;
case OP_IF_NE:
return OP_IF_EQ;
case OP_IF_LT:
return OP_IF_GE;
case OP_IF_GE:
return OP_IF_LT;
case OP_IF_GT:
return OP_IF_LE;
case OP_IF_LE:
return OP_IF_GT;
/* reg/zero cmp */
case OP_IF_EQZ:
return OP_IF_NEZ;
case OP_IF_NEZ:
return OP_IF_EQZ;
case OP_IF_LTZ:
return OP_IF_GEZ;
case OP_IF_GEZ:
return OP_IF_LTZ;
case OP_IF_GTZ:
return OP_IF_LEZ;
case OP_IF_LEZ:
return OP_IF_GTZ;
default:
LOGE("opcode %d cannot be negated", opcode);
dvmAbort();
break;
}
return (Opcode)-1; // unreached
}
开发者ID:0x4d4e,项目名称:platform_dalvik,代码行数:37,代码来源:Loop.cpp
示例17: dvmDumpRunningThreadStack
/*
* Dump the stack for the specified thread, which is still running.
*
* This is very dangerous, because stack frames are being pushed on and
* popped off, and if the thread exits we'll be looking at freed memory.
* The plan here is to take a snapshot of the stack and then dump that
* to try to minimize the chances of catching it mid-update. This should
* work reasonably well on a single-CPU system.
*
* There is a small chance that calling here will crash the VM.
*/
void dvmDumpRunningThreadStack(const DebugOutputTarget* target, Thread* thread)
{
StackSaveArea* saveArea;
const u1* origStack;
u1* stackCopy = NULL;
int origSize, fpOffset;
void* fp;
int depthLimit = 200;
if (thread == NULL || thread->interpSave.curFrame == NULL) {
dvmPrintDebugMessage(target,
"DumpRunning: Thread at %p has no curFrame (threadid=%d)\n",
thread, (thread != NULL) ? thread->threadId : 0);
return;
}
/* wait for a full quantum */
sched_yield();
/* copy the info we need, then the stack itself */
origSize = thread->interpStackSize;
origStack = (const u1*) thread->interpStackStart - origSize;
stackCopy = (u1*) malloc(origSize);
fpOffset = (u1*) thread->interpSave.curFrame - origStack;
memcpy(stackCopy, origStack, origSize);
/*
* Run through the stack and rewrite the "prev" pointers.
*/
//ALOGI("DR: fpOff=%d (from %p %p)",fpOffset, origStack,
// thread->interpSave.curFrame);
fp = stackCopy + fpOffset;
while (true) {
int prevOffset;
if (depthLimit-- < 0) {
/* we're probably screwed */
dvmPrintDebugMessage(target, "DumpRunning: depth limit hit\n");
dvmAbort();
}
saveArea = SAVEAREA_FROM_FP(fp);
if (saveArea->prevFrame == NULL)
break;
prevOffset = (u1*) saveArea->prevFrame - origStack;
if (prevOffset < 0 || prevOffset > origSize) {
dvmPrintDebugMessage(target,
"DumpRunning: bad offset found: %d (from %p %p)\n",
prevOffset, origStack, saveArea->prevFrame);
saveArea->prevFrame = NULL;
break;
}
saveArea->prevFrame = (u4*)(stackCopy + prevOffset);
fp = saveArea->prevFrame;
}
/*
* We still need to pass the Thread for some monitor wait stuff.
*/
dumpFrames(target, stackCopy + fpOffset, thread);
free(stackCopy);
}
开发者ID:nesl,项目名称:CAreDroid,代码行数:74,代码来源:Stack.cpp
示例18: thread_daemon
/* Runs the main thread daemmon loop looking for incoming messages from its
* parallel thread on what action it should take. */
static void* thread_daemon(void* pself) {
Thread* self = (Thread*)pself;
while(1) {
u1 event = offReadU1(self);
if(!gDvm.offConnected) {
ALOGI("THREAD %d LOST CONNECTION", self->threadId);
return NULL;
}
ALOGI("THREAD %d GOT EVENT %d", self->threadId, event);
switch(event) {
case OFF_ACTION_RESUME: {
/* We got a resume message, drop back to our caller. */
return NULL;
} break;
case OFF_ACTION_LOCK: {
offPerformLock(self);
} break;
case OFF_ACTION_NOTIFY: {
offPerformNotify(self);
} break;
case OFF_ACTION_BROADCAST: {
offPerformNotifyAll(self);
} break;
case OFF_ACTION_DEX_QUERYDEX: {
offPerformQueryDex(self);
} break;
case OFF_ACTION_SYNC: {
offSyncPull();
offWriteU1(self, 0);
} break;
case OFF_ACTION_INTERRUPT: {
offPerformInterrupt(self);
} break;
case OFF_ACTION_TRIMGC: {
dvmLockHeap();
self->offTrimSignaled = true;
if (gDvm.gcHeap->gcRunning) {
dvmWaitForConcurrentGcToComplete();
}
dvmCollectGarbageInternal(GC_BEFORE_OOM);
self->offTrimSignaled = false;
dvmUnlockHeap();
} break;
case OFF_ACTION_GRABVOL: {
offPerformGrabVolatiles(self);
} break;
case OFF_ACTION_MIGRATE: {
if(offPerformMigrate(self)) {
return NULL;
}
} break;
case OFF_ACTION_CLINIT: {
offPerformClinit(self);
} break;
case OFF_ACTION_DEATH: {
self->offFlagDeath = true;
return NULL;
} break;
default: {
ALOGE("Unknown action %d sent to thread %d",
event, self->threadId);
dvmAbort();
}
}
}
}
开发者ID:acpaluri,项目名称:591_Comet,代码行数:68,代码来源:Threading.cpp
示例19: dvmHeapSourceStartup
/*
* Initializes the heap source; must be called before any other
* dvmHeapSource*() functions. Returns a GcHeap structure
* allocated from the heap source.
*/
GcHeap* dvmHeapSourceStartup(size_t startSize, size_t maximumSize,
size_t growthLimit)
{
GcHeap *gcHeap = NULL;
HeapSource *hs = NULL;
mspace msp;
size_t length;
void *base;
assert(gHs == NULL);
if (!(startSize <= growthLimit && growthLimit <= maximumSize)) {
ALOGE("Bad heap size parameters (start=%zd, max=%zd, limit=%zd)",
startSize, maximumSize, growthLimit);
return NULL;
}
/*
* Allocate a contiguous region of virtual memory to subdivided
* among the heaps managed by the garbage collector.
*/
length = ALIGN_UP_TO_PAGE_SIZE(maximumSize);
base = dvmAllocRegion(length, PROT_NONE, gDvm.zygote ? "dalvik-zygote" : "dalvik-heap");
if (base == NULL) {
dvmAbort();
}
/* Create an unlocked dlmalloc mspace to use as
* a heap source.
*/
msp = createMspace(base, kInitialMorecoreStart, startSize);
if (msp == NULL) {
dvmAbort();
}
gcHeap = (GcHeap *)calloc(1, sizeof(*gcHeap));
if (gcHeap == NULL) {
LOGE_HEAP("Can't allocate heap descriptor");
dvmAbort();
}
hs = (HeapSource *)calloc(1, sizeof(*hs));
if (hs == NULL) {
LOGE_HEAP("Can't allocate heap source");
dvmAbort();
}
hs->targetUtilization = gDvm.heapTargetUtilization * HEAP_UTILIZATION_MAX;
hs->minFree = gDvm.heapMinFree;
hs->maxFree = gDvm.heapMaxFree;
hs->startSize = startSize;
hs->maximumSize = maximumSize;
hs->growthLimit = growthLimit;
hs->idealSize = startSize;
hs->softLimit = SIZE_MAX; // no soft limit at first
hs->numHeaps = 0;
hs->sawZygote = gDvm.zygote;
hs->nativeBytesAllocated = 0;
hs->nativeFootprintGCWatermark = startSize;
hs->nativeFootprintLimit = startSize * 2;
hs->nativeNeedToRunFinalization = false;
hs->hasGcThread = false;
hs->heapBase = (char *)base;
hs->heapLength = length;
if (hs->maxFree > hs->maximumSize) {
hs->maxFree = hs->maximumSize;
}
if (hs->minFree < CONCURRENT_START) {
hs->minFree = CONCURRENT_START;
} else if (hs->minFree > hs->maxFree) {
hs->minFree = hs->maxFree;
}
if (!addInitialHeap(hs, msp, growthLimit)) {
LOGE_HEAP("Can't add initial heap");
dvmAbort();
}
if (!dvmHeapBitmapInit(&hs->liveBits, base, length, "dalvik-bitmap-1")) {
LOGE_HEAP("Can't create liveBits");
dvmAbort();
}
if (!dvmHeapBitmapInit(&hs->markBits, base, length, "dalvik-bitmap-2")) {
LOGE_HEAP("Can't create markBits");
dvmHeapBitmapDelete(&hs->liveBits);
dvmAbort();
}
if (!allocMarkStack(&gcHeap->markContext.stack, hs->maximumSize)) {
ALOGE("Can't create markStack");
dvmHeapBitmapDelete(&hs->markBits);
dvmHeapBitmapDelete(&hs->liveBits);
dvmAbort();
}
gcHeap->markContext.bitmap = &hs->markBits;
gcHeap->heapSource = hs;
//.........这里部分代码省略.........
开发者ID:sawrus,项目名称:dalvik,代码行数:101,代码来源:HeapSource.cpp
示例20: hprofContextInit
/*
* Initialize an hprof context struct.
*
* This will take ownership of "fileName".
*
* NOTE: ctx is expected to have been zeroed out prior to calling this
* function.
*/
void hprofContextInit(hprof_context_t *ctx, char *fileName, int fd,
bool writeHeader, bool directToDdms)
{
/*
* Have to do this here, because it must happen after we
* memset the struct (want to treat fileDataPtr/fileDataSize
* as read-only while the file is open).
*/
FILE* fp = open_memstream(&ctx->fileDataPtr, &ctx->fileDataSize);
if (fp == NULL) {
/* not expected */
ALOGE("hprof: open_memstream failed: %s", strerror(errno));
dvmAbort();
}
ctx->directToDdms = directToDdms;
ctx->fileName = fileName;
ctx->memFp = fp;
ctx->fd = fd;
ctx->curRec.allocLen = 128;
ctx->curRec.body = (unsigned char *)malloc(ctx->curRec.allocLen);
//xxx check for/return an error
if (writeHeader) {
char magic[] = HPROF_MAGIC_STRING;
unsigned char buf[4];
struct timeval now;
u8 nowMs;
/* Write the file header.
*
* [u1]*: NUL-terminated magic string.
*/
fwrite(magic, 1, sizeof(magic), fp);
/* u4: size of identifiers. We're using addresses
* as IDs, so make sure a pointer fits.
*/
U4_TO_BUF_BE(buf, 0, sizeof(void *));
fwrite(buf, 1, sizeof(u4), fp);
/* The current time, in milliseconds since 0:00 GMT, 1/1/70.
*/
if (gettimeofday(&now, NULL) < 0) {
nowMs = 0;
} else {
nowMs = (u8)now.tv_sec * 1000 + now.tv_usec / 1000;
}
/* u4: high word of the 64-bit time.
*/
U4_TO_BUF_BE(buf, 0, (u4)(nowMs >> 32));
fwrite(buf, 1, sizeof(u4), fp);
/* u4: low word of the 64-bit time.
*/
U4_TO_BUF_BE(buf, 0, (u4)(nowMs & 0xffffffffULL));
fwrite(buf, 1, sizeof(u4), fp); //xxx fix the time
}
}
开发者ID:0omega,项目名称:platform_dalvik,代码行数:69,代码来源:HprofOutput.cpp
注:本文中的dvmAbort函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论