From e7bdd8b8c6f3aae552b333d0bd9664ef5e63f0a0 Mon Sep 17 00:00:00 2001 From: Carl Shapiro Date: Fri, 17 Dec 2010 15:34:52 -0800 Subject: [PATCH] Remove the external allocation facility. Change-Id: Iff508a9173382f29c67ca9e6eb6f65855dce0be4 --- vm/Init.c | 11 - vm/Profile.h | 11 - vm/alloc/Alloc.h | 20 -- vm/alloc/Heap.c | 18 +- vm/alloc/HeapDebug.c | 5 +- vm/alloc/HeapSource.c | 429 ++---------------------------------- vm/native/dalvik_system_VMDebug.c | 28 --- vm/native/dalvik_system_VMRuntime.c | 72 ------ 8 files changed, 22 insertions(+), 572 deletions(-) diff --git a/vm/Init.c b/vm/Init.c index e1e771125..723e8d425 100644 --- a/vm/Init.c +++ b/vm/Init.c @@ -1031,17 +1031,6 @@ static int dvmProcessOptions(int argc, const char* const argv[], } } - /* External allocations count against the space we "reserve" by setting - * the heap max size greater than the heap start size. Without a gap, - * no external allocations will succeed. You won't get very far like that, - * so let's not even try. - */ - if (gDvm.heapSizeStart >= gDvm.heapSizeMax) { - dvmFprintf(stderr, "External allocations require a gap between the " - "heap start size and max size\n"); - return -1; - } - return 0; } diff --git a/vm/Profile.h b/vm/Profile.h index e2be2e07f..bca5096fb 100644 --- a/vm/Profile.h +++ b/vm/Profile.h @@ -82,17 +82,6 @@ typedef struct AllocProfState { int classInitCount; // #of initialized classes u8 classInitTime; // cumulative time spent in class init (nsec) - -#if PROFILE_EXTERNAL_ALLOCATIONS - int externalAllocCount; // #of calls to dvmTrackExternalAllocation() - int externalAllocSize; // #of bytes passed to ...ExternalAllocation() - - int failedExternalAllocCount; // #of times an allocation failed - int failedExternalAllocSize; // cumulative size of failed allocations - - int externalFreeCount; // #of calls to dvmTrackExternalFree() - int externalFreeSize; // #of bytes passed to ...ExternalFree() -#endif // PROFILE_EXTERNAL_ALLOCATIONS } AllocProfState; diff --git a/vm/alloc/Alloc.h b/vm/alloc/Alloc.h index fc8c089d0..64da479bf 100644 --- a/vm/alloc/Alloc.h +++ b/vm/alloc/Alloc.h @@ -160,26 +160,6 @@ void dvmSetTargetHeapUtilization(float newTarget); size_t dvmMinimumHeapSize(size_t size, bool set); /* - * Updates the internal count of externally-allocated memory. If there's - * enough room for that memory, returns true. If not, returns false and - * does not update the count. - * - * May cause a GC as a side-effect. - */ -bool dvmTrackExternalAllocation(size_t n); - -/* - * Reduces the internal count of externally-allocated memory. - */ -void dvmTrackExternalFree(size_t n); - -/* - * Returns the number of externally-allocated bytes being tracked by - * dvmTrackExternalAllocation/Free(). - */ -size_t dvmGetExternalBytesAllocated(void); - -/* * Initiate garbage collection. * * This usually happens automatically, but can also be caused by Runtime.gc(). diff --git a/vm/alloc/Heap.c b/vm/alloc/Heap.c index 7e47e738e..bfee5fcac 100644 --- a/vm/alloc/Heap.c +++ b/vm/alloc/Heap.c @@ -39,8 +39,7 @@ static const char* GcReasonStr[] = { [GC_FOR_MALLOC] = "GC_FOR_MALLOC", [GC_CONCURRENT] = "GC_CONCURRENT", - [GC_EXPLICIT] = "GC_EXPLICIT", - [GC_EXTERNAL_ALLOC] = "GC_EXTERNAL_ALLOC" + [GC_EXPLICIT] = "GC_EXPLICIT" }; /* @@ -529,7 +528,6 @@ void dvmCollectGarbageInternal(bool clearSoftRefs, GcReason reason) u4 totalTime; size_t numObjectsFreed, numBytesFreed; size_t currAllocated, currFootprint; - size_t extAllocated, extLimit; size_t percentFree; GcMode gcMode; int oldThreadPriority = kInvalidPriority; @@ -733,9 +731,7 @@ void dvmCollectGarbageInternal(bool clearSoftRefs, GcReason reason) * This doesn't actually resize any memory; * it just lets the heap grow more when necessary. */ - if (reason != GC_EXTERNAL_ALLOC) { - dvmHeapSourceGrowForUtilization(); - } + dvmHeapSourceGrowForUtilization(); currAllocated = dvmHeapSourceGetValue(HS_BYTES_ALLOCATED, NULL, 0); currFootprint = dvmHeapSourceGetValue(HS_FOOTPRINT, NULL, 0); @@ -785,21 +781,17 @@ void dvmCollectGarbageInternal(bool clearSoftRefs, GcReason reason) } } - extAllocated = dvmHeapSourceGetValue(HS_EXTERNAL_BYTES_ALLOCATED, NULL, 0); - extLimit = dvmHeapSourceGetValue(HS_EXTERNAL_LIMIT, NULL, 0); percentFree = 100 - (size_t)(100.0f * (float)currAllocated / currFootprint); if (reason != GC_CONCURRENT) { u4 markSweepTime = dirtyEnd - rootStart; bool isSmall = numBytesFreed > 0 && numBytesFreed < 1024; totalTime = rootSuspendTime + markSweepTime; - LOGD("%s freed %s%zdK, %d%% free %zdK/%zdK, external %zdK/%zdK, " - "paused %ums", + LOGD("%s freed %s%zdK, %d%% free %zdK/%zdK, paused %ums", GcReasonStr[reason], isSmall ? "<" : "", numBytesFreed ? MAX(numBytesFreed / 1024, 1) : 0, percentFree, currAllocated / 1024, currFootprint / 1024, - extAllocated / 1024, extLimit / 1024, markSweepTime); } else { u4 rootTime = rootEnd - rootStart; @@ -807,14 +799,12 @@ void dvmCollectGarbageInternal(bool clearSoftRefs, GcReason reason) u4 dirtyTime = dirtyEnd - dirtyStart; bool isSmall = numBytesFreed > 0 && numBytesFreed < 1024; totalTime = rootSuspendTime + rootTime + dirtySuspendTime + dirtyTime; - LOGD("%s freed %s%zdK, %d%% free %zdK/%zdK, external %zdK/%zdK, " - "paused %ums+%ums", + LOGD("%s freed %s%zdK, %d%% free %zdK/%zdK, paused %ums+%ums", GcReasonStr[reason], isSmall ? "<" : "", numBytesFreed ? MAX(numBytesFreed / 1024, 1) : 0, percentFree, currAllocated / 1024, currFootprint / 1024, - extAllocated / 1024, extLimit / 1024, rootTime, dirtyTime); } dvmLogGcStats(numObjectsFreed, numBytesFreed, totalTime); diff --git a/vm/alloc/HeapDebug.c b/vm/alloc/HeapDebug.c index cb8fb4849..9227db548 100644 --- a/vm/alloc/HeapDebug.c +++ b/vm/alloc/HeapDebug.c @@ -249,10 +249,7 @@ void dvmLogGcStats(size_t numFreed, size_t sizeFreed, size_t gcTimeMs) uordblks = footprint = 0; #endif - externalLimit = - dvmHeapSourceGetValue(HS_EXTERNAL_LIMIT, NULL, 0); - externalBytesAllocated = - dvmHeapSourceGetValue(HS_EXTERNAL_BYTES_ALLOCATED, NULL, 0); + externalLimit = externalBytesAllocated = 0; event3 = (long long)intToFloat12(footprint) << 36 | (long long)intToFloat12(uordblks) << 24 | diff --git a/vm/alloc/HeapSource.c b/vm/alloc/HeapSource.c index ed58d5021..26e5701f6 100644 --- a/vm/alloc/HeapSource.c +++ b/vm/alloc/HeapSource.c @@ -175,14 +175,6 @@ struct HeapSource { */ size_t numHeaps; - /* External allocation count. - */ - size_t externalBytesAllocated; - - /* The maximum number of external bytes that may be allocated. - */ - size_t externalLimit; - /* True if zygote mode was active when the HeapSource was created. */ bool sawZygote; @@ -692,16 +684,6 @@ dvmHeapSourceGetValue(enum HeapSourceValueSpec spec, size_t perHeapStats[], HS_BOILERPLATE(); - switch (spec) { - case HS_EXTERNAL_BYTES_ALLOCATED: - return hs->externalBytesAllocated; - case HS_EXTERNAL_LIMIT: - return hs->externalLimit; - default: - // look at all heaps. - ; - } - assert(arrayLen >= hs->numHeaps || perHeapStats == NULL); for (i = 0; i < hs->numHeaps; i++) { Heap *const heap = &hs->heaps[i]; @@ -896,24 +878,18 @@ heapAllocAndGrow(HeapSource *hs, Heap *heap, size_t n) size_t max; /* Grow as much as possible, but don't let the real footprint - * plus external allocations go over the absolute max. + * go over the absolute max. */ max = heap->absoluteMaxSize; - if (max > hs->externalBytesAllocated) { - max -= hs->externalBytesAllocated; - mspace_set_max_allowed_footprint(heap->msp, max); - ptr = dvmHeapSourceAlloc(n); - - /* Shrink back down as small as possible. Our caller may - * readjust max_allowed to a more appropriate value. - */ - mspace_set_max_allowed_footprint(heap->msp, - mspace_footprint(heap->msp)); - } else { - ptr = NULL; - } + mspace_set_max_allowed_footprint(heap->msp, max); + ptr = dvmHeapSourceAlloc(n); + /* Shrink back down as small as possible. Our caller may + * readjust max_allowed to a more appropriate value. + */ + mspace_set_max_allowed_footprint(heap->msp, + mspace_footprint(heap->msp)); return ptr; } @@ -1146,10 +1122,10 @@ dvmHeapSourceFootprint() } /* - * Return the real bytes used by old heaps and external memory - * plus the soft usage of the current heap. When a soft limit - * is in effect, this is effectively what it's compared against - * (though, in practice, it only looks at the current heap). + * Return the real bytes used by old heaps plus the soft usage of the + * current heap. When a soft limit is in effect, this is effectively + * what it's compared against (though, in practice, it only looks at + * the current heap). */ static size_t getSoftFootprint(bool includeActive) @@ -1159,7 +1135,7 @@ getSoftFootprint(bool includeActive) HS_BOILERPLATE(); - ret = oldHeapOverhead(hs, false) + hs->externalBytesAllocated; + ret = oldHeapOverhead(hs, false); if (includeActive) { ret += hs->heaps[0].bytesAllocated; } @@ -1236,7 +1212,7 @@ setIdealFootprint(size_t max) } /* Convert max into a size that applies to the active heap. - * Old heaps and external allocations will count against the ideal size. + * Old heaps will count against the ideal size. */ size_t overhead = getSoftFootprint(false); size_t activeMax; @@ -1250,12 +1226,10 @@ setIdealFootprint(size_t max) hs->idealSize = max; HSTRACE("IDEAL %zd->%zd (%d), soft %zd->%zd (%d), allowed %zd->%zd (%d), " - "ext %zd\n", oldHs.idealSize, hs->idealSize, hs->idealSize - oldHs.idealSize, oldHs.softLimit, hs->softLimit, hs->softLimit - oldHs.softLimit, oldAllowedFootprint, mspace_max_allowed_footprint(msp), - mspace_max_allowed_footprint(msp) - oldAllowedFootprint, - hs->externalBytesAllocated); + mspace_max_allowed_footprint(msp) - oldAllowedFootprint); } @@ -1330,12 +1304,6 @@ dvmMinimumHeapSize(size_t size, bool set) oldMinimumSize = hs->minimumSize; if (set) { - /* Don't worry about external allocations right now. - * setIdealFootprint() will take them into account when - * minimumSize is used, and it's better to hold onto the - * intended minimumSize than to clamp it arbitrarily based - * on the current allocations. - */ if (size > hs->absoluteMaxSize) { size = hs->absoluteMaxSize; } @@ -1412,26 +1380,8 @@ void dvmHeapSourceGrowForUtilization() * the current heap. */ currentHeapUsed = heap->bytesAllocated; -#define LET_EXTERNAL_INFLUENCE_UTILIZATION 1 -#if LET_EXTERNAL_INFLUENCE_UTILIZATION - /* This is a hack to deal with the side-effects of moving - * bitmap data out of the Dalvik heap. Since the amount - * of free space after a GC scales with the size of the - * live set, many apps expected the large free space that - * appeared along with megabytes' worth of bitmaps. When - * the bitmaps were removed, the free size shrank significantly, - * and apps started GCing constantly. This makes it so the - * post-GC free space is the same size it would have been - * if the bitmaps were still in the Dalvik heap. - */ - currentHeapUsed += hs->externalBytesAllocated; -#endif targetHeapSize = getUtilizationTarget(currentHeapUsed, hs->targetUtilization); -#if LET_EXTERNAL_INFLUENCE_UTILIZATION - currentHeapUsed -= hs->externalBytesAllocated; - targetHeapSize -= hs->externalBytesAllocated; -#endif /* The ideal size includes the old heaps; add overhead so that * it can be immediately subtracted again in setIdealFootprint(). @@ -1454,24 +1404,20 @@ void dvmHeapSourceGrowForUtilization() LOGD_HEAP("GC old usage %zd.%zd%%; now " "%zd.%03zdMB used / %zd.%03zdMB soft max " "(%zd.%03zdMB over, " - "%zd.%03zdMB ext, " "%zd.%03zdMB real max)\n", FRACTIONAL_PCT(currentHeapUsed, oldIdealSize), FRACTIONAL_MB(currentHeapUsed), FRACTIONAL_MB(hs->softLimit), FRACTIONAL_MB(overhead), - FRACTIONAL_MB(hs->externalBytesAllocated), FRACTIONAL_MB(newHeapMax)); } else { LOGD_HEAP("GC old usage %zd.%zd%%; now " "%zd.%03zdMB used / %zd.%03zdMB real max " - "(%zd.%03zdMB over, " - "%zd.%03zdMB ext)\n", + "(%zd.%03zdMB over)\n", FRACTIONAL_PCT(currentHeapUsed, oldIdealSize), FRACTIONAL_MB(currentHeapUsed), FRACTIONAL_MB(newHeapMax), - FRACTIONAL_MB(overhead), - FRACTIONAL_MB(hs->externalBytesAllocated)); + FRACTIONAL_MB(overhead)); } } @@ -1573,347 +1519,6 @@ dvmHeapSourceGetNumHeaps() return hs->numHeaps; } - -/* - * External allocation tracking - * - * In some situations, memory outside of the heap is tied to the - * lifetime of objects in the heap. Since that memory is kept alive - * by heap objects, it should provide memory pressure that can influence - * GCs. - */ - -/* - * Returns true if the requested number of bytes can be allocated from - * available storage. - */ -static bool externalBytesAvailable(const HeapSource *hs, size_t numBytes) -{ - const Heap *heap; - size_t currentHeapSize, newHeapSize; - - /* Make sure that this allocation is even possible. - * Don't let the external size plus the actual heap size - * go over the absolute max. This essentially treats - * external allocations as part of the active heap. - * - * Note that this will fail "mysteriously" if there's - * a small softLimit but a large heap footprint. - */ - heap = hs2heap(hs); - currentHeapSize = mspace_max_allowed_footprint(heap->msp); - newHeapSize = currentHeapSize + hs->externalBytesAllocated + numBytes; - if (newHeapSize <= heap->absoluteMaxSize) { - return true; - } - HSTRACE("externalBytesAvailable(): " - "footprint %zu + extAlloc %zu + n %zu >= max %zu (space for %zu)\n", - currentHeapSize, hs->externalBytesAllocated, numBytes, - heap->absoluteMaxSize, - heap->absoluteMaxSize - - (currentHeapSize + hs->externalBytesAllocated)); - return false; -} - -#define EXTERNAL_TARGET_UTILIZATION 820 // 80% - -/* - * Tries to update the internal count of externally-allocated memory. - * If there's enough room for that memory, returns true. If not, returns - * false and does not update the count. - * - * The caller must ensure externalBytesAvailable(hs, n) == true. - */ -static bool -externalAlloc(HeapSource *hs, size_t n, bool grow) -{ - assert(hs->externalLimit >= hs->externalBytesAllocated); - - HSTRACE("externalAlloc(%zd%s)\n", n, grow ? ", grow" : ""); - assert(externalBytesAvailable(hs, n)); // The caller must ensure this. - - /* External allocations have their own "free space" that they - * can allocate from without causing a GC. - */ - if (hs->externalBytesAllocated + n <= hs->externalLimit) { - hs->externalBytesAllocated += n; -#if PROFILE_EXTERNAL_ALLOCATIONS - if (gDvm.allocProf.enabled) { - Thread* self = dvmThreadSelf(); - gDvm.allocProf.externalAllocCount++; - gDvm.allocProf.externalAllocSize += n; - if (self != NULL) { - self->allocProf.externalAllocCount++; - self->allocProf.externalAllocSize += n; - } - } -#endif - return true; - } - if (!grow) { - return false; - } - - /* GROW */ - hs->externalBytesAllocated += n; - hs->externalLimit = getUtilizationTarget( - hs->externalBytesAllocated, EXTERNAL_TARGET_UTILIZATION); - HSTRACE("EXTERNAL grow limit to %zd\n", hs->externalLimit); - return true; -} - -static void -gcForExternalAlloc(bool collectSoftReferences) -{ - if (gDvm.allocProf.enabled) { - Thread* self = dvmThreadSelf(); - gDvm.allocProf.gcCount++; - if (self != NULL) { - self->allocProf.gcCount++; - } - } - dvmCollectGarbageInternal(collectSoftReferences, GC_EXTERNAL_ALLOC); -} - -/* - * Returns true if there is enough unused storage to perform an - * external allocation of the specified size. If there insufficient - * free storage we try to releasing memory from external allocations - * and trimming the heap. - */ -static bool externalAllocPossible(const HeapSource *hs, size_t n) -{ - size_t bytesTrimmed[HEAP_SOURCE_MAX_HEAP_COUNT]; - - /* - * If there is sufficient space return immediately. - */ - if (externalBytesAvailable(hs, n)) { - return true; - } - /* - * There is insufficient space. Wait for the garbage collector to - * become inactive before proceeding. - */ - while (gDvm.gcHeap->gcRunning) { - dvmWaitForConcurrentGcToComplete(); - } - /* - * The heap may have grown or become trimmed while we were - * waiting. - */ - if (externalBytesAvailable(hs, n)) { - return true; - } - /* - * Try a garbage collection that clears soft references. This may - * make trimming more effective. - */ - gcForExternalAlloc(true); - if (externalBytesAvailable(hs, n)) { - return true; - } - /* - * Try trimming the mspace to reclaim unused pages. - */ - dvmHeapSourceTrim(bytesTrimmed, NELEM(bytesTrimmed)); - snapIdealFootprint(); - if (externalBytesAvailable(hs, n)) { - return true; - } - /* - * Nothing worked, return an error. - */ - return false; -} - -/* - * Updates the internal count of externally-allocated memory. If there's - * enough room for that memory, returns true. If not, returns false and - * does not update the count. - * - * May cause a GC as a side-effect. - */ -bool -dvmTrackExternalAllocation(size_t n) -{ - HeapSource *hs = gHs; - bool ret = false; - - /* gHs caches an entry in gDvm.gcHeap; we need to hold the - * heap lock if we're going to look at it. - */ - dvmLockHeap(); - - HS_BOILERPLATE(); - assert(hs->externalLimit >= hs->externalBytesAllocated); - - /* - * The externalAlloc calls require the externalAllocPossible - * invariant to be established. - */ - if (!externalAllocPossible(hs, n)) { - LOGE_HEAP("%zd-byte external allocation " - "too large for this process.", n); - goto out; - } - - /* Try "allocating" using the existing "free space". - */ - HSTRACE("EXTERNAL alloc %zu (%zu < %zu)\n", - n, hs->externalBytesAllocated, hs->externalLimit); - if (externalAlloc(hs, n, false)) { - ret = true; - goto out; - } - /* - * Wait until garbage collector is quiescent before proceeding. - */ - while (gDvm.gcHeap->gcRunning) { - dvmWaitForConcurrentGcToComplete(); - } - /* - * Re-establish the invariant if it was lost while we were - * waiting. - */ - if (!externalAllocPossible(hs, n)) { - LOGE_HEAP("%zd-byte external allocation " - "too large for this process.", n); - goto out; - } - /* The "allocation" failed. Free up some space by doing - * a full garbage collection. This may grow the heap source - * if the live set is sufficiently large. - */ - HSTRACE("EXTERNAL alloc %zd: GC 1\n", n); - gcForExternalAlloc(false); // don't collect SoftReferences - if (externalAlloc(hs, n, false)) { - ret = true; - goto out; - } - - /* Even that didn't work; this is an exceptional state. - * Try harder, growing the heap source if necessary. - */ - HSTRACE("EXTERNAL alloc %zd: frag\n", n); - ret = externalAlloc(hs, n, true); - if (ret) { - goto out; - } - - /* We couldn't even grow enough to satisfy the request. - * Try one last GC, collecting SoftReferences this time. - */ - HSTRACE("EXTERNAL alloc %zd: GC 2\n", n); - gcForExternalAlloc(true); // collect SoftReferences - ret = externalAlloc(hs, n, true); - if (!ret) { - LOGE_HEAP("Out of external memory on a %zu-byte allocation.\n", n); - } - -#if PROFILE_EXTERNAL_ALLOCATIONS - if (gDvm.allocProf.enabled) { - Thread* self = dvmThreadSelf(); - gDvm.allocProf.failedExternalAllocCount++; - gDvm.allocProf.failedExternalAllocSize += n; - if (self != NULL) { - self->allocProf.failedExternalAllocCount++; - self->allocProf.failedExternalAllocSize += n; - } - } -#endif - -out: - dvmUnlockHeap(); - - return ret; -} - -/* - * Reduces the internal count of externally-allocated memory. - */ -void -dvmTrackExternalFree(size_t n) -{ - HeapSource *hs = gHs; - size_t newExternalLimit; - size_t oldExternalBytesAllocated; - - HSTRACE("EXTERNAL free %zu (%zu < %zu)\n", - n, hs->externalBytesAllocated, hs->externalLimit); - - /* gHs caches an entry in gDvm.gcHeap; we need to hold the - * heap lock if we're going to look at it. - */ - dvmLockHeap(); - - HS_BOILERPLATE(); - assert(hs->externalLimit >= hs->externalBytesAllocated); - - oldExternalBytesAllocated = hs->externalBytesAllocated; - if (n <= hs->externalBytesAllocated) { - hs->externalBytesAllocated -= n; - } else { - n = hs->externalBytesAllocated; - hs->externalBytesAllocated = 0; - } - -#if PROFILE_EXTERNAL_ALLOCATIONS - if (gDvm.allocProf.enabled) { - Thread* self = dvmThreadSelf(); - gDvm.allocProf.externalFreeCount++; - gDvm.allocProf.externalFreeSize += n; - if (self != NULL) { - self->allocProf.externalFreeCount++; - self->allocProf.externalFreeSize += n; - } - } -#endif - - /* Shrink as quickly as we can. - */ - newExternalLimit = getUtilizationTarget( - hs->externalBytesAllocated, EXTERNAL_TARGET_UTILIZATION); - if (newExternalLimit < oldExternalBytesAllocated) { - /* Make sure that the remaining free space is at least - * big enough to allocate something of the size that was - * just freed. This makes it more likely that - * externalFree(N); externalAlloc(N); - * will work without causing a GC. - */ - HSTRACE("EXTERNAL free preserved %zu extra free bytes\n", - oldExternalBytesAllocated - newExternalLimit); - newExternalLimit = oldExternalBytesAllocated; - } - if (newExternalLimit < hs->externalLimit) { - hs->externalLimit = newExternalLimit; - } - - dvmUnlockHeap(); -} - -/* - * Returns the number of externally-allocated bytes being tracked by - * dvmTrackExternalAllocation/Free(). - */ -size_t -dvmGetExternalBytesAllocated() -{ - const HeapSource *hs = gHs; - size_t ret; - - /* gHs caches an entry in gDvm.gcHeap; we need to hold the - * heap lock if we're going to look at it. We also need the - * lock for the call to setIdealFootprint(). - */ - dvmLockHeap(); - HS_BOILERPLATE(); - ret = hs->externalBytesAllocated; - dvmUnlockHeap(); - - return ret; -} - void *dvmHeapSourceGetImmuneLimit(GcMode mode) { if (mode == GC_PARTIAL) { diff --git a/vm/native/dalvik_system_VMDebug.c b/vm/native/dalvik_system_VMDebug.c index bbb62dc48..a119715e2 100644 --- a/vm/native/dalvik_system_VMDebug.c +++ b/vm/native/dalvik_system_VMDebug.c @@ -209,20 +209,6 @@ static void clearAllocProfStateFields(AllocProfState *allocProf, if (kinds & KIND_CLASS_INIT_TIME) { allocProf->classInitTime = 0; } -#if PROFILE_EXTERNAL_ALLOCATIONS - if (kinds & KIND_EXT_ALLOCATED_OBJECTS) { - allocProf->externalAllocCount = 0; - } - if (kinds & KIND_EXT_ALLOCATED_BYTES) { - allocProf->externalAllocSize = 0; - } - if (kinds & KIND_EXT_FREED_OBJECTS) { - allocProf->externalFreeCount = 0; - } - if (kinds & KIND_EXT_FREED_BYTES) { - allocProf->externalFreeSize = 0; - } -#endif // PROFILE_EXTERNAL_ALLOCATIONS } /* @@ -294,20 +280,6 @@ static void Dalvik_dalvik_system_VMDebug_getAllocCount(const u4* args, /* convert nsec to usec, reduce to 32 bits */ pResult->i = (int) (allocProf->classInitTime / 1000); break; -#if PROFILE_EXTERNAL_ALLOCATIONS - case KIND_EXT_ALLOCATED_OBJECTS: - pResult->i = allocProf->externalAllocCount; - break; - case KIND_EXT_ALLOCATED_BYTES: - pResult->i = allocProf->externalAllocSize; - break; - case KIND_EXT_FREED_OBJECTS: - pResult->i = allocProf->externalFreeCount; - break; - case KIND_EXT_FREED_BYTES: - pResult->i = allocProf->externalFreeSize; - break; -#endif // PROFILE_EXTERNAL_ALLOCATIONS default: assert(false); pResult->i = -1; diff --git a/vm/native/dalvik_system_VMRuntime.c b/vm/native/dalvik_system_VMRuntime.c index c020f8ae4..0672d7171 100644 --- a/vm/native/dalvik_system_VMRuntime.c +++ b/vm/native/dalvik_system_VMRuntime.c @@ -113,72 +113,6 @@ static void Dalvik_dalvik_system_VMRuntime_runFinalizationSync(const u4* args, } /* - * public native boolean trackExternalAllocation(long size) - * - * Asks the VM if bytes can be allocated in an external heap. - * This information may be used to limit the amount of memory available - * to Dalvik threads. Returns false if the VM would rather that the caller - * did not allocate that much memory. If the call returns false, the VM - * will not update its internal counts. - */ -static void Dalvik_dalvik_system_VMRuntime_trackExternalAllocation( - const u4* args, JValue* pResult) -{ - s8 longSize = GET_ARG_LONG(args, 1); - - /* Fit in 32 bits. */ - if (longSize < 0) { - dvmThrowException("Ljava/lang/IllegalArgumentException;", - "size must be positive"); - RETURN_VOID(); - } else if (longSize > INT_MAX) { - dvmThrowException("Ljava/lang/UnsupportedOperationException;", - "size must fit in 32 bits"); - RETURN_VOID(); - } - RETURN_BOOLEAN(dvmTrackExternalAllocation((size_t)longSize)); -} - -/* - * public native void trackExternalFree(long size) - * - * Tells the VM that bytes have been freed in an external - * heap. This information may be used to control the amount of memory - * available to Dalvik threads. - */ -static void Dalvik_dalvik_system_VMRuntime_trackExternalFree( - const u4* args, JValue* pResult) -{ - s8 longSize = GET_ARG_LONG(args, 1); - - /* Fit in 32 bits. */ - if (longSize < 0) { - dvmThrowException("Ljava/lang/IllegalArgumentException;", - "size must be positive"); - RETURN_VOID(); - } else if (longSize > INT_MAX) { - dvmThrowException("Ljava/lang/UnsupportedOperationException;", - "size must fit in 32 bits"); - RETURN_VOID(); - } - dvmTrackExternalFree((size_t)longSize); - - RETURN_VOID(); -} - -/* - * public native long getExternalBytesAllocated() - * - * Returns the number of externally-allocated bytes being tracked by - * trackExternalAllocation/Free(). - */ -static void Dalvik_dalvik_system_VMRuntime_getExternalBytesAllocated( - const u4* args, JValue* pResult) -{ - RETURN_LONG((s8)dvmGetExternalBytesAllocated()); -} - -/* * public native void startJitCompilation() * * Callback function from the framework to indicate that an app has gone @@ -228,12 +162,6 @@ const DalvikNativeMethod dvm_dalvik_system_VMRuntime[] = { Dalvik_dalvik_system_VMRuntime_gcSoftReferences }, { "runFinalizationSync", "()V", Dalvik_dalvik_system_VMRuntime_runFinalizationSync }, - { "trackExternalAllocation", "(J)Z", - Dalvik_dalvik_system_VMRuntime_trackExternalAllocation }, - { "trackExternalFree", "(J)V", - Dalvik_dalvik_system_VMRuntime_trackExternalFree }, - { "getExternalBytesAllocated", "()J", - Dalvik_dalvik_system_VMRuntime_getExternalBytesAllocated }, { "startJitCompilation", "()V", Dalvik_dalvik_system_VMRuntime_startJitCompilation }, { "disableJitCompilation", "()V", -- 2.11.0