Remove allocation limit checking.
Change-Id: Ie9a23da2baf201c50cad5ba0d0992cec9bcace54
diff --git a/vm/Dvm.mk b/vm/Dvm.mk
index 081c44f..af5c122 100644
--- a/vm/Dvm.mk
+++ b/vm/Dvm.mk
@@ -66,7 +66,6 @@
LOCAL_CFLAGS += -DWITH_INSTR_CHECKS
LOCAL_CFLAGS += -DWITH_EXTRA_OBJECT_VALIDATION
LOCAL_CFLAGS += -DWITH_TRACKREF_CHECKS
- LOCAL_CFLAGS += -DWITH_ALLOC_LIMITS
LOCAL_CFLAGS += -DWITH_EXTRA_GC_CHECKS=1
#LOCAL_CFLAGS += -DCHECK_MUTEX
#LOCAL_CFLAGS += -DPROFILE_FIELD_ACCESS
diff --git a/vm/Globals.h b/vm/Globals.h
index 1862cb7..bb3995c 100644
--- a/vm/Globals.h
+++ b/vm/Globals.h
@@ -581,13 +581,6 @@
int allocRecordHead; /* most-recently-added entry */
int allocRecordCount; /* #of valid entries */
-#ifdef WITH_ALLOC_LIMITS
- /* set on first use of an alloc limit, never cleared */
- bool checkAllocLimits;
- /* allocation limit, for setGlobalAllocationLimit() regression testing */
- int allocationLimit;
-#endif
-
#ifdef WITH_DEADLOCK_PREDICTION
/* global lock on history tree accesses */
pthread_mutex_t deadlockHistoryLock;
diff --git a/vm/Init.c b/vm/Init.c
index 77c1490..5335081 100644
--- a/vm/Init.c
+++ b/vm/Init.c
@@ -149,9 +149,6 @@
#ifdef WITH_HPROF_STACK
" hprof_stack"
#endif
-#ifdef WITH_ALLOC_LIMITS
- " alloc_limits"
-#endif
#ifdef WITH_TRACKREF_CHECKS
" trackref_checks"
#endif
diff --git a/vm/Thread.c b/vm/Thread.c
index 54d0f4b..ccfbc9b 100644
--- a/vm/Thread.c
+++ b/vm/Thread.c
@@ -936,10 +936,6 @@
thread->status = THREAD_INITIALIZING;
thread->suspendCount = 0;
-#ifdef WITH_ALLOC_LIMITS
- thread->allocLimit = -1;
-#endif
-
/*
* Allocate and initialize the interpreted code stack. We essentially
* "lose" the alloc pointer, which points at the bottom of the stack,
diff --git a/vm/Thread.h b/vm/Thread.h
index ce53c33..e805c1c 100644
--- a/vm/Thread.h
+++ b/vm/Thread.h
@@ -219,11 +219,6 @@
struct LockedObjectData* pLockedObjects;
#endif
-#ifdef WITH_ALLOC_LIMITS
- /* allocation limit, for Debug.setAllocationLimit() regression testing */
- int allocLimit;
-#endif
-
/* base time for per-thread CPU timing (used by method profiling) */
bool cpuClockBaseSet;
u8 cpuClockBase;
diff --git a/vm/alloc/Heap.c b/vm/alloc/Heap.c
index bd782bd..d6e08ae 100644
--- a/vm/alloc/Heap.c
+++ b/vm/alloc/Heap.c
@@ -52,11 +52,6 @@
{
GcHeap *gcHeap;
-#if defined(WITH_ALLOC_LIMITS)
- gDvm.checkAllocLimits = false;
- gDvm.allocationLimit = -1;
-#endif
-
gcHeap = dvmHeapSourceStartup(gDvm.heapSizeStart, gDvm.heapSizeMax);
if (gcHeap == NULL) {
return false;
@@ -410,45 +405,6 @@
GcHeap *gcHeap = gDvm.gcHeap;
void *ptr;
-#if defined(WITH_ALLOC_LIMITS)
- /*
- * See if they've exceeded the allocation limit for this thread.
- *
- * A limit value of -1 means "no limit".
- *
- * This is enabled at compile time because it requires us to do a
- * TLS lookup for the Thread pointer. This has enough of a performance
- * impact that we don't want to do it if we don't have to. (Now that
- * we're using gDvm.checkAllocLimits we may want to reconsider this,
- * but it's probably still best to just compile the check out of
- * production code -- one less thing to hit on every allocation.)
- */
- if (gDvm.checkAllocLimits) {
- Thread* self = dvmThreadSelf();
- if (self != NULL) {
- int count = self->allocLimit;
- if (count > 0) {
- self->allocLimit--;
- } else if (count == 0) {
- /* fail! */
- assert(!gDvm.initializing);
- self->allocLimit = -1;
- dvmThrowException("Ldalvik/system/AllocationLimitError;",
- "thread allocation limit exceeded");
- return NULL;
- }
- }
- }
-
- if (gDvm.allocationLimit >= 0) {
- assert(!gDvm.initializing);
- gDvm.allocationLimit = -1;
- dvmThrowException("Ldalvik/system/AllocationLimitError;",
- "global allocation limit exceeded");
- return NULL;
- }
-#endif
-
dvmLockHeap();
/* Try as hard as possible to allocate some memory.
diff --git a/vm/native/dalvik_system_VMDebug.c b/vm/native/dalvik_system_VMDebug.c
index cc0ac01..7712a98 100644
--- a/vm/native/dalvik_system_VMDebug.c
+++ b/vm/native/dalvik_system_VMDebug.c
@@ -442,23 +442,8 @@
static void Dalvik_dalvik_system_VMDebug_setAllocationLimit(const u4* args,
JValue* pResult)
{
-#if defined(WITH_ALLOC_LIMITS)
- gDvm.checkAllocLimits = true;
-
- Thread* self = dvmThreadSelf();
- int newLimit = args[0];
- int oldLimit = self->allocLimit;
-
- if (newLimit < -1) {
- LOGE("WARNING: bad limit request (%d)\n", newLimit);
- newLimit = -1;
- }
- self->allocLimit = newLimit;
- RETURN_INT(oldLimit);
-#else
UNUSED_PARAMETER(args);
RETURN_INT(-1);
-#endif
}
/*
@@ -469,23 +454,8 @@
static void Dalvik_dalvik_system_VMDebug_setGlobalAllocationLimit(const u4* args,
JValue* pResult)
{
-#if defined(WITH_ALLOC_LIMITS)
- gDvm.checkAllocLimits = true;
-
- int newLimit = args[0];
- int oldLimit = gDvm.allocationLimit;
-
- if (newLimit < -1 || newLimit > 0) {
- LOGE("WARNING: bad limit request (%d)\n", newLimit);
- newLimit = -1;
- }
- // TODO: should use an atomic swap here
- gDvm.allocationLimit = newLimit;
- RETURN_INT(oldLimit);
-#else
UNUSED_PARAMETER(args);
RETURN_INT(-1);
-#endif
}
/*