diff options
author | Ian Rogers <irogers@google.com> | 2012-08-17 17:01:51 -0700 |
---|---|---|
committer | Ian Rogers <irogers@google.com> | 2012-08-20 14:55:28 -0700 |
commit | bba37bd191843ef29ef9c7a8839e98b73debfffa (patch) | |
tree | e3261ba89177be63072c6136b4f1d4b3b6e14c76 /vm/alloc/DlMalloc.cpp | |
parent | 57573862ca6b377c73958d5ba876a406445b4490 (diff) | |
download | android_dalvik-bba37bd191843ef29ef9c7a8839e98b73debfffa.tar.gz android_dalvik-bba37bd191843ef29ef9c7a8839e98b73debfffa.tar.bz2 android_dalvik-bba37bd191843ef29ef9c7a8839e98b73debfffa.zip |
Upgrade to dlmalloc 2.8.5.
Switch to using dlmalloc 2.8.5. Define mspace functionality directly
using dlmalloc rather than taking from libcutils.
Remove growth limit check in tryMalloc that only checks initial growth
limit.
Implement trimming at the end of the mspace.
Depends upon: https://android-review.googlesource.com/41717
Change-Id: Ia2c6b50bdb0b0d5aae4b18deefbd1bf50dfa49d5
Diffstat (limited to 'vm/alloc/DlMalloc.cpp')
-rw-r--r-- | vm/alloc/DlMalloc.cpp | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/vm/alloc/DlMalloc.cpp b/vm/alloc/DlMalloc.cpp new file mode 100644 index 000000000..8638ab5fa --- /dev/null +++ b/vm/alloc/DlMalloc.cpp @@ -0,0 +1,51 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "DlMalloc.h" + +#include <stdint.h> +#include "Common.h" + +/* Dalvik specific morecore implementation defined in HeapSource.cpp. */ +#define MORECORE(x) dvmHeapSourceMorecore(m, x) +extern void* dvmHeapSourceMorecore(void* mspace, intptr_t increment); + +/* Custom heap error handling. */ +#define PROCEED_ON_ERROR 0 +static void heap_error(const char* msg, const char* function, void* p); +#define CORRUPTION_ERROR_ACTION(m) \ + heap_error("HEAP MEMORY CORRUPTION", __FUNCTION__, NULL) +#define USAGE_ERROR_ACTION(m,p) \ + heap_error("ARGUMENT IS INVALID HEAP ADDRESS", __FUNCTION__, p) + +/* + * Ugly inclusion of C file so that Dalvik specific #defines configure + * dlmalloc for our use for mspaces (regular dlmalloc is still declared + * in bionic). + */ +#pragma GCC diagnostic ignored "-Wempty-body" +#pragma GCC diagnostic ignored "-Wstrict-aliasing" +#include "../../../bionic/libc/upstream-dlmalloc/malloc.c" +#pragma GCC diagnostic warning "-Wstrict-aliasing" +#pragma GCC diagnostic warning "-Wempty-body" + + +static void heap_error(const char* msg, const char* function, void* p) { + ALOG(LOG_FATAL, LOG_TAG, "@@@ ABORTING: DALVIK: %s IN %s addr=%p", msg, + function, p); + /* So that we can get a memory dump around p */ + *((int **) 0xdeadbaad) = (int *) p; +} |