diff options
| author | Elliott Hughes <enh@google.com> | 2014-11-15 11:59:36 -0800 |
|---|---|---|
| committer | Elliott Hughes <enh@google.com> | 2014-11-15 12:06:41 -0800 |
| commit | 50e2a5861bf6310427bb043956fa7b545da3b044 (patch) | |
| tree | ac1b0cc82987c0e266dcb2282d4ba9d973186184 | |
| parent | 9013f53c778d11e7ba7a8bf745882a3e29fe938d (diff) | |
| download | android_dalvik-50e2a5861bf6310427bb043956fa7b545da3b044.tar.gz android_dalvik-50e2a5861bf6310427bb043956fa7b545da3b044.tar.bz2 android_dalvik-50e2a5861bf6310427bb043956fa7b545da3b044.zip | |
Clean up some dead dalvik cruft.
I don't know whether dmtracedump is still useful, so I'm assuming we should
keep it building. But at least now it's more obvious that it's the only user
of Profile.h.
Change-Id: Ieabce07cb278a19af72b566b08193db17d95e66d
| -rw-r--r-- | libdex/DexFile.h | 39 | ||||
| -rw-r--r-- | libdex/DexSwapVerify.cpp | 32 | ||||
| -rw-r--r-- | libdex/OptInvocation.cpp | 2 | ||||
| -rw-r--r-- | libdex/sha1.cpp | 7 | ||||
| -rw-r--r-- | tools/dmtracedump/Android.mk | 2 | ||||
| -rw-r--r-- | tools/dmtracedump/Profile.h | 43 | ||||
| -rw-r--r-- | vm/Common.h | 148 | ||||
| -rw-r--r-- | vm/DalvikVersion.h | 37 | ||||
| -rw-r--r-- | vm/Profile.h | 206 |
9 files changed, 86 insertions, 430 deletions
diff --git a/libdex/DexFile.h b/libdex/DexFile.h index 710400525..e8ab31924 100644 --- a/libdex/DexFile.h +++ b/libdex/DexFile.h @@ -33,7 +33,44 @@ #ifndef LIBDEX_DEXFILE_H_ #define LIBDEX_DEXFILE_H_ -#include "vm/Common.h" // basic type defs, e.g. u1/u2/u4/u8, and LOG +#ifndef LOG_TAG +# define LOG_TAG "libdex" +#endif + +#include <stdbool.h> +#include <stdint.h> +#include <stdio.h> +#include <assert.h> +#include "cutils/log.h" + +/* + * If "very verbose" logging is enabled, make it equivalent to ALOGV. + * Otherwise, make it disappear. + * + * Define this above the #include "Dalvik.h" to enable for only a + * single file. + */ +/* #define VERY_VERBOSE_LOG */ +#if defined(VERY_VERBOSE_LOG) +# define LOGVV ALOGV +# define IF_LOGVV() IF_ALOGV() +#else +# define LOGVV(...) ((void)0) +# define IF_LOGVV() if (false) +#endif + +/* + * These match the definitions in the VM specification. + */ +typedef uint8_t u1; +typedef uint16_t u2; +typedef uint32_t u4; +typedef uint64_t u8; +typedef int8_t s1; +typedef int16_t s2; +typedef int32_t s4; +typedef int64_t s8; + #include "libdex/SysUtil.h" /* diff --git a/libdex/DexSwapVerify.cpp b/libdex/DexSwapVerify.cpp index ff47ab5d1..7f18831d6 100644 --- a/libdex/DexSwapVerify.cpp +++ b/libdex/DexSwapVerify.cpp @@ -31,35 +31,9 @@ #include <stdlib.h> #include <string.h> -#ifndef __BYTE_ORDER -# error "byte ordering not defined" -#endif - -#if __BYTE_ORDER == __LITTLE_ENDIAN -# define SWAP2(_value) (_value) -# define SWAP4(_value) (_value) -# define SWAP8(_value) (_value) -#else -# define SWAP2(_value) endianSwapU2((_value)) -# define SWAP4(_value) endianSwapU4((_value)) -# define SWAP8(_value) endianSwapU8((_value)) -static u2 endianSwapU2(u2 value) { - return (value >> 8) | (value << 8); -} -static u4 endianSwapU4(u4 value) { - /* ABCD --> CDAB --> DCBA */ - value = (value >> 16) | (value << 16); - return ((value & 0xff00ff00) >> 8) | ((value << 8) & 0xff00ff00); -} -static u8 endianSwapU8(u8 value) { - /* ABCDEFGH --> EFGHABCD --> GHEFCDAB --> HGFEDCBA */ - value = (value >> 32) | (value << 32); - value = ((value & 0xffff0000ffff0000ULL) >> 16) | - ((value << 16) & 0xffff0000ffff0000ULL); - return ((value & 0xff00ff00ff00ff00ULL) >> 8) | - ((value << 8) & 0xff00ff00ff00ff00ULL); -} -#endif +#define SWAP2(_value) (_value) +#define SWAP4(_value) (_value) +#define SWAP8(_value) (_value) #define SWAP_FIELD2(_field) (_field) = SWAP2(_field) #define SWAP_FIELD4(_field) (_field) = SWAP4(_field) diff --git a/libdex/OptInvocation.cpp b/libdex/OptInvocation.cpp index 031ec9177..be7f70b50 100644 --- a/libdex/OptInvocation.cpp +++ b/libdex/OptInvocation.cpp @@ -18,8 +18,6 @@ * Utility functions for dealing with optimized dex files. */ -#include "vm/DalvikVersion.h" - #include <stdint.h> #include <stdlib.h> #include <unistd.h> diff --git a/libdex/sha1.cpp b/libdex/sha1.cpp index 15a81cca3..60c4d9395 100644 --- a/libdex/sha1.cpp +++ b/libdex/sha1.cpp @@ -93,12 +93,9 @@ A million repetitions of "a" # include <unistd.h> # include <stdlib.h> //# include <endian.h> - -#include "DexFile.h" // want common byte ordering def - -# if __BYTE_ORDER == __LITTLE_ENDIAN +//# if __BYTE_ORDER == __LITTLE_ENDIAN # define X_LITTLE_ENDIAN -# endif +//# endif #endif #include <ctype.h> diff --git a/tools/dmtracedump/Android.mk b/tools/dmtracedump/Android.mk index 5d3146e9a..933f4e5d8 100644 --- a/tools/dmtracedump/Android.mk +++ b/tools/dmtracedump/Android.mk @@ -10,7 +10,6 @@ LOCAL_PATH:= $(call my-dir) include $(CLEAR_VARS) LOCAL_SRC_FILES := TraceDump.c LOCAL_CFLAGS += -O0 -g -LOCAL_C_INCLUDES += dalvik/vm LOCAL_MODULE_TAGS := optional LOCAL_MODULE := dmtracedump include $(BUILD_HOST_EXECUTABLE) @@ -18,7 +17,6 @@ include $(BUILD_HOST_EXECUTABLE) include $(CLEAR_VARS) LOCAL_SRC_FILES := CreateTestTrace.c LOCAL_CFLAGS += -O0 -g -LOCAL_C_INCLUDES += dalvik/vm LOCAL_MODULE_TAGS := optional LOCAL_MODULE := create_test_dmtrace include $(BUILD_HOST_EXECUTABLE) diff --git a/tools/dmtracedump/Profile.h b/tools/dmtracedump/Profile.h new file mode 100644 index 000000000..efbedb35e --- /dev/null +++ b/tools/dmtracedump/Profile.h @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2008 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. + */ + +/* + * Android's method call profiling goodies. + */ +#ifndef DALVIK_PROFILE_H_ +#define DALVIK_PROFILE_H_ + +/* + * Enumeration for the two "action" bits. + */ +enum { + METHOD_TRACE_ENTER = 0x00, // method entry + METHOD_TRACE_EXIT = 0x01, // method exit + METHOD_TRACE_UNROLL = 0x02, // method exited by exception unrolling + // 0x03 currently unused +}; + +#define TOKEN_CHAR '*' + +/* + * Common definitions, shared with the dump tool. + */ +#define METHOD_ACTION_MASK 0x03 /* two bits */ +#define METHOD_ID(_method) ((_method) & (~METHOD_ACTION_MASK)) +#define METHOD_ACTION(_method) (((unsigned int)(_method)) & METHOD_ACTION_MASK) +#define METHOD_COMBINE(_method, _action) ((_method) | (_action)) + +#endif // DALVIK_PROFILE_H_ diff --git a/vm/Common.h b/vm/Common.h deleted file mode 100644 index af31b97f8..000000000 --- a/vm/Common.h +++ /dev/null @@ -1,148 +0,0 @@ -/* - * Copyright (C) 2008 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. - */ - -/* - * Common defines for all Dalvik code. - */ -#ifndef DALVIK_COMMON_H_ -#define DALVIK_COMMON_H_ - -#ifndef LOG_TAG -# define LOG_TAG "dalvikvm" -#endif - -#include <stdbool.h> -#include <stdint.h> -#include <stdio.h> -#include <assert.h> -#include "cutils/log.h" - -#if defined(HAVE_ENDIAN_H) -# include <endian.h> -#else /*not HAVE_ENDIAN_H*/ -# define __BIG_ENDIAN 4321 -# define __LITTLE_ENDIAN 1234 -# if defined(HAVE_LITTLE_ENDIAN) -# define __BYTE_ORDER __LITTLE_ENDIAN -# else -# define __BYTE_ORDER __BIG_ENDIAN -# endif -#endif /*not HAVE_ENDIAN_H*/ - -#if !defined(NDEBUG) && defined(WITH_DALVIK_ASSERT) -# undef assert -# define assert(x) \ - ((x) ? ((void)0) : (ALOGE("ASSERT FAILED (%s:%d): %s", \ - __FILE__, __LINE__, #x), *(int*)39=39, (void)0) ) -#endif - -#define MIN(x,y) (((x) < (y)) ? (x) : (y)) -#define MAX(x,y) (((x) > (y)) ? (x) : (y)) - -#define LIKELY(exp) (__builtin_expect((exp) != 0, true)) -#define UNLIKELY(exp) (__builtin_expect((exp) != 0, false)) - -#define ALIGN_UP(x, n) (((size_t)(x) + (n) - 1) & ~((n) - 1)) -#define ALIGN_DOWN(x, n) ((size_t)(x) & -(n)) -#define ALIGN_UP_TO_PAGE_SIZE(p) ALIGN_UP(p, SYSTEM_PAGE_SIZE) -#define ALIGN_DOWN_TO_PAGE_SIZE(p) ALIGN_DOWN(p, SYSTEM_PAGE_SIZE) - -#define CLZ(x) __builtin_clz(x) - -/* - * If "very verbose" logging is enabled, make it equivalent to ALOGV. - * Otherwise, make it disappear. - * - * Define this above the #include "Dalvik.h" to enable for only a - * single file. - */ -/* #define VERY_VERBOSE_LOG */ -#if defined(VERY_VERBOSE_LOG) -# define LOGVV ALOGV -# define IF_LOGVV() IF_ALOGV() -#else -# define LOGVV(...) ((void)0) -# define IF_LOGVV() if (false) -#endif - - -/* - * These match the definitions in the VM specification. - */ -typedef uint8_t u1; -typedef uint16_t u2; -typedef uint32_t u4; -typedef uint64_t u8; -typedef int8_t s1; -typedef int16_t s2; -typedef int32_t s4; -typedef int64_t s8; - -/* - * Storage for primitive types and object references. - * - * Some parts of the code (notably object field access) assume that values - * are "left aligned", i.e. given "JValue jv", "jv.i" and "*((s4*)&jv)" - * yield the same result. This seems to be guaranteed by gcc on big- and - * little-endian systems. - */ -struct Object; - -union JValue { -#if defined(HAVE_LITTLE_ENDIAN) - u1 z; - s1 b; - u2 c; - s2 s; - s4 i; - s8 j; - float f; - double d; - Object* l; -#endif -#if defined(HAVE_BIG_ENDIAN) - struct { - u1 _z[3]; - u1 z; - }; - struct { - s1 _b[3]; - s1 b; - }; - struct { - u2 _c; - u2 c; - }; - struct { - s2 _s; - s2 s; - }; - s4 i; - s8 j; - float f; - double d; - void* l; -#endif -}; - -#define OFFSETOF_MEMBER(t, f) \ - (reinterpret_cast<char*>( \ - &reinterpret_cast<t*>(16)->f) - \ - reinterpret_cast<char*>(16)) - -#define NELEM(x) ((int) (sizeof(x) / sizeof((x)[0]))) - -#endif // DALVIK_COMMON_H_ diff --git a/vm/DalvikVersion.h b/vm/DalvikVersion.h deleted file mode 100644 index e71c8393c..000000000 --- a/vm/DalvikVersion.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (C) 2008 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. - */ - -/* - * Dalvik VM version info. - */ -#ifndef DALVIK_VERSION_H_ -#define DALVIK_VERSION_H_ - -/* - * The version we show to tourists. - */ -#define DALVIK_MAJOR_VERSION 1 -#define DALVIK_MINOR_VERSION 6 -#define DALVIK_BUG_VERSION 0 - -/* - * VM build number. This must change whenever something that affects the - * way classes load changes, e.g. field ordering or vtable layout. Changing - * this guarantees that the optimized form of the DEX file is regenerated. - */ -#define DALVIK_VM_BUILD 27 - -#endif // DALVIK_VERSION_H_ diff --git a/vm/Profile.h b/vm/Profile.h deleted file mode 100644 index 9059181a9..000000000 --- a/vm/Profile.h +++ /dev/null @@ -1,206 +0,0 @@ -/* - * Copyright (C) 2008 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. - */ - -/* - * Android's method call profiling goodies. - */ -#ifndef DALVIK_PROFILE_H_ -#define DALVIK_PROFILE_H_ - -#ifndef NOT_VM /* for utilities that sneakily include this file */ - -#include <stdio.h> - -struct Thread; // extern - - -/* boot init */ -bool dvmProfilingStartup(void); -void dvmProfilingShutdown(void); - -/* - * Method trace state. This is currently global. In theory we could make - * most of this per-thread. - */ -struct MethodTraceState { - /* active state */ - pthread_mutex_t startStopLock; - pthread_cond_t threadExitCond; - FILE* traceFile; - bool directToDdms; - int bufferSize; - int flags; - - int traceEnabled; - u1* buf; - volatile int curOffset; - u8 startWhen; - int overflow; - - int traceVersion; - size_t recordSize; - - bool samplingEnabled; - pthread_t samplingThreadHandle; -}; - -/* - * Memory allocation profiler state. This is used both globally and - * per-thread. - * - * If you add a field here, zero it out in dvmStartAllocCounting(). - */ -struct AllocProfState { - bool enabled; // is allocation tracking enabled? - - int allocCount; // #of objects allocated - int allocSize; // cumulative size of objects - - int failedAllocCount; // #of times an allocation failed - int failedAllocSize; // cumulative size of failed allocations - - int freeCount; // #of objects freed - int freeSize; // cumulative size of freed objects - - int gcCount; // #of times an allocation triggered a GC - - int classInitCount; // #of initialized classes - u8 classInitTime; // cumulative time spent in class init (nsec) -}; - - -/* - * Start/stop method tracing. - */ -void dvmMethodTraceStart(const char* traceFileName, int traceFd, int bufferSize, - int flags, bool directToDdms, bool samplingEnabled, int intervalUs); -void dvmMethodTraceStop(void); - -/* - * Returns current method tracing mode. - */ -enum TracingMode { - TRACING_INACTIVE, - METHOD_TRACING_ACTIVE, - SAMPLE_PROFILING_ACTIVE, -}; -TracingMode dvmGetMethodTracingMode(void); - -/* - * Start/stop emulator tracing. - */ -void dvmEmulatorTraceStart(void); -void dvmEmulatorTraceStop(void); - -/* - * Start/stop Dalvik instruction counting. - */ -void dvmStartInstructionCounting(); -void dvmStopInstructionCounting(); - -/* - * Bit flags for dvmMethodTraceStart "flags" argument. These must match - * the values in android.os.Debug. - */ -enum { - TRACE_ALLOC_COUNTS = 0x01, -}; - -/* - * Call these when a method enters or exits. - */ -#define TRACE_METHOD_ENTER(_self, _method) \ - do { \ - if (_self->interpBreak.ctl.subMode & kSubModeMethodTrace) { \ - u4 cpuClockDiff = 0; \ - u4 wallClockDiff = 0; \ - dvmMethodTraceReadClocks(_self, &cpuClockDiff, &wallClockDiff); \ - dvmMethodTraceAdd(_self, _method, METHOD_TRACE_ENTER, \ - cpuClockDiff, wallClockDiff); \ - } \ - if (_self->interpBreak.ctl.subMode & kSubModeEmulatorTrace) \ - dvmEmitEmulatorTrace(_method, METHOD_TRACE_ENTER); \ - } while(0); -#define TRACE_METHOD_EXIT(_self, _method) \ - do { \ - if (_self->interpBreak.ctl.subMode & kSubModeMethodTrace) { \ - u4 cpuClockDiff = 0; \ - u4 wallClockDiff = 0; \ - dvmMethodTraceReadClocks(_self, &cpuClockDiff, &wallClockDiff); \ - dvmMethodTraceAdd(_self, _method, METHOD_TRACE_EXIT, \ - cpuClockDiff, wallClockDiff); \ - } \ - if (_self->interpBreak.ctl.subMode & kSubModeEmulatorTrace) \ - dvmEmitEmulatorTrace(_method, METHOD_TRACE_EXIT); \ - } while(0); -#define TRACE_METHOD_UNROLL(_self, _method) \ - do { \ - if (_self->interpBreak.ctl.subMode & kSubModeMethodTrace) { \ - u4 cpuClockDiff = 0; \ - u4 wallClockDiff = 0; \ - dvmMethodTraceReadClocks(_self, &cpuClockDiff, &wallClockDiff); \ - dvmMethodTraceAdd(_self, _method, METHOD_TRACE_UNROLL, \ - cpuClockDiff, wallClockDiff); \ - } \ - if (_self->interpBreak.ctl.subMode & kSubModeEmulatorTrace) \ - dvmEmitEmulatorTrace(_method, METHOD_TRACE_UNROLL); \ - } while(0); - -void dvmMethodTraceReadClocks(Thread* self, u4* cpuClockDiff, - u4* wallClockDiff); -void dvmMethodTraceAdd(struct Thread* self, const Method* method, int action, - u4 cpuClockDiff, u4 wallClockDiff); -void dvmEmitEmulatorTrace(const Method* method, int action); - -void dvmMethodTraceGCBegin(void); -void dvmMethodTraceGCEnd(void); -void dvmMethodTraceClassPrepBegin(void); -void dvmMethodTraceClassPrepEnd(void); - -extern "C" void dvmFastMethodTraceEnter(const Method* method, struct Thread* self); -extern "C" void dvmFastMethodTraceExit(struct Thread* self); -extern "C" void dvmFastNativeMethodTraceExit(const Method* method, struct Thread* self); - -/* - * Start/stop alloc counting. - */ -void dvmStartAllocCounting(void); -void dvmStopAllocCounting(void); - -#endif - - -/* - * Enumeration for the two "action" bits. - */ -enum { - METHOD_TRACE_ENTER = 0x00, // method entry - METHOD_TRACE_EXIT = 0x01, // method exit - METHOD_TRACE_UNROLL = 0x02, // method exited by exception unrolling - // 0x03 currently unused -}; - -#define TOKEN_CHAR '*' - -/* - * Common definitions, shared with the dump tool. - */ -#define METHOD_ACTION_MASK 0x03 /* two bits */ -#define METHOD_ID(_method) ((_method) & (~METHOD_ACTION_MASK)) -#define METHOD_ACTION(_method) (((unsigned int)(_method)) & METHOD_ACTION_MASK) -#define METHOD_COMBINE(_method, _action) ((_method) | (_action)) - -#endif // DALVIK_PROFILE_H_ |
