diff options
-rw-r--r-- | libdex/CmdUtils.h | 8 | ||||
-rw-r--r-- | libdex/DexCatch.h | 8 | ||||
-rw-r--r-- | libdex/DexClass.h | 8 | ||||
-rw-r--r-- | libdex/DexDataMap.h | 8 | ||||
-rw-r--r-- | libdex/DexFile.h | 8 | ||||
-rw-r--r-- | libdex/DexOpcodes.h | 8 | ||||
-rw-r--r-- | libdex/DexOptData.h | 8 | ||||
-rw-r--r-- | libdex/DexProto.h | 8 | ||||
-rw-r--r-- | libdex/DexUtf.h | 8 | ||||
-rw-r--r-- | libdex/InstrUtils.h | 8 | ||||
-rw-r--r-- | libdex/Leb128.h | 8 | ||||
-rw-r--r-- | libdex/ZipArchive.h | 7 | ||||
-rw-r--r-- | libdex/sha1.h | 8 | ||||
-rw-r--r-- | vm/Dvm.mk | 60 | ||||
-rw-r--r-- | vm/InlineNative.h | 69 | ||||
-rw-r--r-- | vm/UtfString.c | 2 | ||||
-rw-r--r-- | vm/UtfString.h | 2 | ||||
-rw-r--r-- | vm/interp/Stack.c | 39 | ||||
-rw-r--r-- | vm/interp/Stack.h | 7 | ||||
-rw-r--r-- | vm/native/InternalNative.cpp (renamed from vm/native/InternalNative.c) | 0 | ||||
-rw-r--r-- | vm/native/dalvik_bytecode_OpcodeInfo.cpp (renamed from vm/native/dalvik_bytecode_OpcodeInfo.c) | 2 | ||||
-rw-r--r-- | vm/native/dalvik_system_DexFile.cpp (renamed from vm/native/dalvik_system_DexFile.c) | 0 | ||||
-rw-r--r-- | vm/native/dalvik_system_VMDebug.cpp (renamed from vm/native/dalvik_system_VMDebug.c) | 26 | ||||
-rw-r--r-- | vm/native/dalvik_system_VMRuntime.cpp (renamed from vm/native/dalvik_system_VMRuntime.c) | 2 | ||||
-rw-r--r-- | vm/native/dalvik_system_VMStack.cpp (renamed from vm/native/dalvik_system_VMStack.c) | 66 | ||||
-rw-r--r-- | vm/native/dalvik_system_Zygote.cpp (renamed from vm/native/dalvik_system_Zygote.c) | 6 | ||||
-rw-r--r-- | vm/native/java_lang_Class.cpp (renamed from vm/native/java_lang_Class.c) | 2 | ||||
-rw-r--r-- | vm/native/java_lang_Double.cpp (renamed from vm/native/java_lang_Double.c) | 0 | ||||
-rw-r--r-- | vm/native/java_lang_Float.cpp (renamed from vm/native/java_lang_Float.c) | 0 | ||||
-rw-r--r-- | vm/native/java_lang_Math.cpp (renamed from vm/native/java_lang_Math.c) | 0 | ||||
-rw-r--r-- | vm/native/java_lang_Object.cpp (renamed from vm/native/java_lang_Object.c) | 0 | ||||
-rw-r--r-- | vm/native/java_lang_Runtime.cpp (renamed from vm/native/java_lang_Runtime.c) | 0 | ||||
-rw-r--r-- | vm/native/java_lang_String.cpp (renamed from vm/native/java_lang_String.c) | 0 | ||||
-rw-r--r-- | vm/native/java_lang_System.cpp (renamed from vm/native/java_lang_System.c) | 6 | ||||
-rw-r--r-- | vm/native/java_lang_Throwable.cpp (renamed from vm/native/java_lang_Throwable.c) | 0 | ||||
-rw-r--r-- | vm/native/java_lang_VMClassLoader.cpp (renamed from vm/native/java_lang_VMClassLoader.c) | 0 | ||||
-rw-r--r-- | vm/native/java_lang_VMThread.cpp (renamed from vm/native/java_lang_VMThread.c) | 0 | ||||
-rw-r--r-- | vm/native/java_lang_reflect_AccessibleObject.cpp (renamed from vm/native/java_lang_reflect_AccessibleObject.c) | 0 | ||||
-rw-r--r-- | vm/native/java_lang_reflect_Array.cpp (renamed from vm/native/java_lang_reflect_Array.c) | 2 | ||||
-rw-r--r-- | vm/native/java_lang_reflect_Constructor.cpp (renamed from vm/native/java_lang_reflect_Constructor.c) | 0 | ||||
-rw-r--r-- | vm/native/java_lang_reflect_Field.cpp (renamed from vm/native/java_lang_reflect_Field.c) | 0 | ||||
-rw-r--r-- | vm/native/java_lang_reflect_Method.cpp (renamed from vm/native/java_lang_reflect_Method.c) | 0 | ||||
-rw-r--r-- | vm/native/java_lang_reflect_Proxy.cpp (renamed from vm/native/java_lang_reflect_Proxy.c) | 0 | ||||
-rw-r--r-- | vm/native/java_util_concurrent_atomic_AtomicLong.cpp (renamed from vm/native/java_util_concurrent_atomic_AtomicLong.c) | 0 | ||||
-rw-r--r-- | vm/native/org_apache_harmony_dalvik_NativeTestTarget.cpp (renamed from vm/native/org_apache_harmony_dalvik_NativeTestTarget.c) | 0 | ||||
-rw-r--r-- | vm/native/org_apache_harmony_dalvik_ddmc_DdmServer.cpp (renamed from vm/native/org_apache_harmony_dalvik_ddmc_DdmServer.c) | 0 | ||||
-rw-r--r-- | vm/native/org_apache_harmony_dalvik_ddmc_DdmVmInternal.cpp (renamed from vm/native/org_apache_harmony_dalvik_ddmc_DdmVmInternal.c) | 0 | ||||
-rw-r--r-- | vm/native/sun_misc_Unsafe.cpp (renamed from vm/native/sun_misc_Unsafe.c) | 0 | ||||
-rw-r--r-- | vm/reflect/Reflect.h | 8 |
49 files changed, 270 insertions, 132 deletions
diff --git a/libdex/CmdUtils.h b/libdex/CmdUtils.h index 7a8528710..3f05affe8 100644 --- a/libdex/CmdUtils.h +++ b/libdex/CmdUtils.h @@ -31,6 +31,10 @@ #ifndef _LIBDEX_CMDUTILS #define _LIBDEX_CMDUTILS +#ifdef __cplusplus +extern "C" { +#endif + /* encode the result of unzipping to a file */ typedef enum UnzipToFileResult { kUTFRSuccess = 0, @@ -70,4 +74,8 @@ UnzipToFileResult dexOpenAndMap(const char* fileName, const char* tempFileName, UnzipToFileResult dexUnzipToFile(const char* zipFileName, const char* outFileName, bool quiet); +#ifdef __cplusplus +} +#endif + #endif /*_LIBDEX_CMDUTILS*/ diff --git a/libdex/DexCatch.h b/libdex/DexCatch.h index c0eec7c57..7c40bc57c 100644 --- a/libdex/DexCatch.h +++ b/libdex/DexCatch.h @@ -24,6 +24,10 @@ #include "DexFile.h" #include "Leb128.h" +#ifdef __cplusplus +extern "C" { +#endif + /* * Catch handler entry, used while iterating over catch_handler_items. */ @@ -159,4 +163,8 @@ DEX_INLINE bool dexFindCatchHandler(DexCatchIterator *pIterator, } } +#ifdef __cplusplus +} +#endif + #endif diff --git a/libdex/DexClass.h b/libdex/DexClass.h index 3d1e11be5..6003fcf2f 100644 --- a/libdex/DexClass.h +++ b/libdex/DexClass.h @@ -24,6 +24,10 @@ #include "DexFile.h" #include "Leb128.h" +#ifdef __cplusplus +extern "C" { +#endif + /* expanded form of a class_data_item header */ typedef struct DexClassDataHeader { u4 staticFieldsSize; @@ -159,4 +163,8 @@ DEX_INLINE void dexReadClassDataMethod(const u1** pData, DexMethod* pMethod, *lastIndex = index; } +#ifdef __cplusplus +} +#endif + #endif diff --git a/libdex/DexDataMap.h b/libdex/DexDataMap.h index fa556d5aa..654933c54 100644 --- a/libdex/DexDataMap.h +++ b/libdex/DexDataMap.h @@ -23,6 +23,10 @@ #include "DexFile.h" +#ifdef __cplusplus +extern "C" { +#endif + typedef struct DexDataMap { u4 count; /* number of items currently in the map */ u4 max; /* maximum number of items that may be held */ @@ -70,4 +74,8 @@ DEX_INLINE bool dexDataMapVerify0Ok(DexDataMap* map, u4 offset, u2 type) { return dexDataMapVerify(map, offset, type); } +#ifdef __cplusplus +} +#endif + #endif /*_LIBDEX_DEXDATAMAP*/ diff --git a/libdex/DexFile.h b/libdex/DexFile.h index 45f9a9119..66522863f 100644 --- a/libdex/DexFile.h +++ b/libdex/DexFile.h @@ -36,6 +36,10 @@ #include "vm/Common.h" // basic type defs, e.g. u1/u2/u4/u8, and LOG #include "libdex/SysUtil.h" +#ifdef __cplusplus +extern "C" { +#endif + /* * gcc-style inline management -- ensures we have a copy of all functions * in the library, so code that links against us will work whether or not @@ -960,4 +964,8 @@ const char* dexGetBoxedTypeDescriptor(PrimitiveType type); */ PrimitiveType dexGetPrimitiveTypeFromDescriptorChar(char descriptorChar); +#ifdef __cplusplus +} +#endif + #endif /*_LIBDEX_DEXFILE*/ diff --git a/libdex/DexOpcodes.h b/libdex/DexOpcodes.h index 07188b2d0..68b849868 100644 --- a/libdex/DexOpcodes.h +++ b/libdex/DexOpcodes.h @@ -30,6 +30,10 @@ #include "DexFile.h" +#ifdef __cplusplus +extern "C" { +#endif + /* * kMaxOpcodeValue: the highest possible raw (unpacked) opcode value * @@ -1133,4 +1137,8 @@ DEX_INLINE Opcode dexOpcodeFromCodeUnit(u2 codeUnit) { */ const char* dexGetOpcodeName(Opcode op); +#ifdef __cplusplus +} +#endif + #endif /*_LIBDEX_DEXOPCODES*/ diff --git a/libdex/DexOptData.h b/libdex/DexOptData.h index 69eda0142..562553df0 100644 --- a/libdex/DexOptData.h +++ b/libdex/DexOptData.h @@ -24,6 +24,10 @@ #include "libdex/DexFile.h" +#ifdef __cplusplus +extern "C" { +#endif + /* * Parse the optimized data tables in the given dex file. * @@ -39,4 +43,8 @@ bool dexParseOptData(const u1* data, size_t length, DexFile* pDexFile); */ u4 dexComputeOptChecksum(const DexOptHeader* pOptHeader); +#ifdef __cplusplus +} +#endif + #endif /* def _LIBDEX_DEXOPTDATA */ diff --git a/libdex/DexProto.h b/libdex/DexProto.h index 50d4bf330..a300d3fde 100644 --- a/libdex/DexProto.h +++ b/libdex/DexProto.h @@ -23,6 +23,10 @@ #include "DexFile.h" +#ifdef __cplusplus +extern "C" { +#endif + /* * Single-thread single-string cache. This structure holds a pointer to * a string which is semi-automatically manipulated by some of the @@ -226,6 +230,8 @@ u4 dexParameterIteratorNextIndex(DexParameterIterator* pIterator); const char* dexParameterIteratorNextDescriptor( DexParameterIterator* pIterator); - +#ifdef __cplusplus +} +#endif #endif /*_LIBDEX_DEXPROTO*/ diff --git a/libdex/DexUtf.h b/libdex/DexUtf.h index a7eb28ceb..88d98b011 100644 --- a/libdex/DexUtf.h +++ b/libdex/DexUtf.h @@ -23,6 +23,10 @@ #include "DexFile.h" +#ifdef __cplusplus +extern "C" { +#endif + /* * Retrieve the next UTF-16 character from a UTF-8 string. * @@ -128,4 +132,8 @@ bool dexIsClassDescriptor(const char* s); * is for anything but "void". */ bool dexIsFieldDescriptor(const char* s); +#ifdef __cplusplus +} +#endif + #endif /* def _LIBDEX_DEXUTF */ diff --git a/libdex/InstrUtils.h b/libdex/InstrUtils.h index f09429cf0..88804cf24 100644 --- a/libdex/InstrUtils.h +++ b/libdex/InstrUtils.h @@ -23,6 +23,10 @@ #include "DexFile.h" #include "DexOpcodes.h" +#ifdef __cplusplus +extern "C" { +#endif + /* * Possible instruction formats associated with Dalvik opcodes. * @@ -198,4 +202,8 @@ DEX_INLINE InstructionIndexType dexGetIndexTypeFromOpcode(Opcode opcode) */ void dexDecodeInstruction(const u2* insns, DecodedInstruction* pDec); +#ifdef __cplusplus +} +#endif + #endif /*_LIBDEX_INSTRUTILS*/ diff --git a/libdex/Leb128.h b/libdex/Leb128.h index 41799fe5e..3287c1623 100644 --- a/libdex/Leb128.h +++ b/libdex/Leb128.h @@ -23,6 +23,10 @@ #include "DexFile.h" +#ifdef __cplusplus +extern "C" { +#endif + /* * Reads an unsigned LEB128 value, updating the given pointer to point * just past the end of the read value. This function tolerates @@ -161,4 +165,8 @@ DEX_INLINE int unsignedLeb128Size(u4 data) return count; } +#ifdef __cplusplus +} +#endif + #endif diff --git a/libdex/ZipArchive.h b/libdex/ZipArchive.h index bf4edf972..872ceedb2 100644 --- a/libdex/ZipArchive.h +++ b/libdex/ZipArchive.h @@ -23,6 +23,9 @@ #include "SysUtil.h" #include "DexFile.h" // need DEX_INLINE +#ifdef __cplusplus +extern "C" { +#endif /* * Trivial typedef to ensure that ZipEntry is not treated as a simple @@ -179,4 +182,8 @@ int dexZipExtractEntryToFile(const ZipArchive* pArchive, u4 dexInitCrc32(void); u4 dexComputeCrc32(u4 crc, const void* buf, size_t len); +#ifdef __cplusplus +} +#endif + #endif /*_LIBDEX_ZIPARCHIVE*/ diff --git a/libdex/sha1.h b/libdex/sha1.h index 65cf667cd..0cef6234b 100644 --- a/libdex/sha1.h +++ b/libdex/sha1.h @@ -4,6 +4,10 @@ #ifndef _DALVIK_SHA1 #define _DALVIK_SHA1 +#ifdef __cplusplus +extern "C" { +#endif + typedef struct { unsigned long state[5]; unsigned long count[2]; @@ -17,4 +21,8 @@ void SHA1Update(SHA1_CTX* context, const unsigned char* data, unsigned long len); void SHA1Final(unsigned char digest[HASHSIZE], SHA1_CTX* context); +#ifdef __cplusplus +} +#endif + #endif /*_DALVIK_SHA1*/ @@ -148,35 +148,35 @@ LOCAL_SRC_FILES := \ jdwp/JdwpSocket.c \ mterp/Mterp.c.arm \ mterp/out/InterpC-portable.c.arm \ - native/InternalNative.c \ - native/dalvik_bytecode_OpcodeInfo.c \ - native/dalvik_system_DexFile.c \ - native/dalvik_system_VMDebug.c \ - native/dalvik_system_VMRuntime.c \ - native/dalvik_system_VMStack.c \ - native/dalvik_system_Zygote.c \ - native/java_lang_Class.c \ - native/java_lang_Double.c \ - native/java_lang_Float.c \ - native/java_lang_Math.c \ - native/java_lang_Object.c \ - native/java_lang_Runtime.c \ - native/java_lang_String.c \ - native/java_lang_System.c \ - native/java_lang_Throwable.c \ - native/java_lang_VMClassLoader.c \ - native/java_lang_VMThread.c \ - native/java_lang_reflect_AccessibleObject.c \ - native/java_lang_reflect_Array.c \ - native/java_lang_reflect_Constructor.c \ - native/java_lang_reflect_Field.c \ - native/java_lang_reflect_Method.c \ - native/java_lang_reflect_Proxy.c \ - native/java_util_concurrent_atomic_AtomicLong.c \ - native/org_apache_harmony_dalvik_NativeTestTarget.c \ - native/org_apache_harmony_dalvik_ddmc_DdmServer.c \ - native/org_apache_harmony_dalvik_ddmc_DdmVmInternal.c \ - native/sun_misc_Unsafe.c \ + native/InternalNative.cpp \ + native/dalvik_bytecode_OpcodeInfo.cpp \ + native/dalvik_system_DexFile.cpp \ + native/dalvik_system_VMDebug.cpp \ + native/dalvik_system_VMRuntime.cpp \ + native/dalvik_system_VMStack.cpp \ + native/dalvik_system_Zygote.cpp \ + native/java_lang_Class.cpp \ + native/java_lang_Double.cpp \ + native/java_lang_Float.cpp \ + native/java_lang_Math.cpp \ + native/java_lang_Object.cpp \ + native/java_lang_Runtime.cpp \ + native/java_lang_String.cpp \ + native/java_lang_System.cpp \ + native/java_lang_Throwable.cpp \ + native/java_lang_VMClassLoader.cpp \ + native/java_lang_VMThread.cpp \ + native/java_lang_reflect_AccessibleObject.cpp \ + native/java_lang_reflect_Array.cpp \ + native/java_lang_reflect_Constructor.cpp \ + native/java_lang_reflect_Field.cpp \ + native/java_lang_reflect_Method.cpp \ + native/java_lang_reflect_Proxy.cpp \ + native/java_util_concurrent_atomic_AtomicLong.cpp \ + native/org_apache_harmony_dalvik_NativeTestTarget.cpp \ + native/org_apache_harmony_dalvik_ddmc_DdmServer.cpp \ + native/org_apache_harmony_dalvik_ddmc_DdmVmInternal.cpp \ + native/sun_misc_Unsafe.cpp \ oo/AccessCheck.c \ oo/Array.c \ oo/Class.c \ @@ -224,9 +224,9 @@ LOCAL_C_INCLUDES += \ dalvik \ dalvik/vm \ external/zlib \ + libcore/include \ $(KERNEL_HEADERS) - ifeq ($(dvm_simulator),true) LOCAL_LDLIBS += -lpthread -ldl ifeq ($(HOST_OS),linux) diff --git a/vm/InlineNative.h b/vm/InlineNative.h index 4f86cef5f..bf08412ff 100644 --- a/vm/InlineNative.h +++ b/vm/InlineNative.h @@ -125,6 +125,75 @@ bool dvmPerformInlineOp4Dbg(u4 arg0, u4 arg1, u4 arg2, u4 arg3, */ Method* dvmResolveInlineNative(int opIndex); +/* + * The actual inline native definitions. + */ +bool javaLangString_charAt(u4 arg0, u4 arg1, u4 arg2, u4 arg3, + JValue* pResult); + +bool javaLangString_compareTo(u4 arg0, u4 arg1, u4 arg2, u4 arg3, + JValue* pResult); + +bool javaLangString_equals(u4 arg0, u4 arg1, u4 arg2, u4 arg3, + JValue* pResult); + +bool javaLangString_length(u4 arg0, u4 arg1, u4 arg2, u4 arg3, + JValue* pResult); + +bool javaLangString_isEmpty(u4 arg0, u4 arg1, u4 arg2, u4 arg3, + JValue* pResult); + +bool javaLangString_fastIndexOf_II(u4 arg0, u4 arg1, u4 arg2, u4 arg3, + JValue* pResult); + +bool javaLangMath_abs_int(u4 arg0, u4 arg1, u4 arg2, u4 arg3, + JValue* pResult); + +bool javaLangMath_abs_long(u4 arg0, u4 arg1, u4 arg2, u4 arg3, + JValue* pResult); + +bool javaLangMath_abs_float(u4 arg0, u4 arg1, u4 arg2, u4 arg3, + JValue* pResult); + +bool javaLangMath_abs_double(u4 arg0, u4 arg1, u4 arg2, u4 arg3, + JValue* pResult); + +bool javaLangMath_min_int(u4 arg0, u4 arg1, u4 arg2, u4 arg3, + JValue* pResult); + +bool javaLangMath_max_int(u4 arg0, u4 arg1, u4 arg2, u4 arg3, + JValue* pResult); + +bool javaLangMath_sqrt(u4 arg0, u4 arg1, u4 arg2, u4 arg3, + JValue* pResult); + +bool javaLangMath_cos(u4 arg0, u4 arg1, u4 arg2, u4 arg3, + JValue* pResult); + +bool javaLangMath_sin(u4 arg0, u4 arg1, u4 arg2, u4 arg3, + JValue* pResult); + +bool javaLangFloat_floatToIntBits(u4 arg0, u4 arg1, u4 arg2, u4 arg, + JValue* pResult); + +bool javaLangFloat_floatToRawIntBits(u4 arg0, u4 arg1, u4 arg2, u4 arg, + JValue* pResult); + +bool javaLangFloat_intBitsToFloat(u4 arg0, u4 arg1, u4 arg2, u4 arg, + JValue* pResult); + +bool javaLangDouble_doubleToLongBits(u4 arg0, u4 arg1, u4 arg2, u4 arg, + JValue* pResult); + +bool javaLangDouble_longBitsToDouble(u4 arg0, u4 arg1, u4 arg2, u4 arg, + JValue* pResult); + +bool javaLangDouble_doubleToRawLongBits(u4 arg0, u4 arg1, u4 arg2, + u4 arg, JValue* pResult); + +bool javaLangDouble_longBitsToDouble(u4 arg0, u4 arg1, u4 arg2, u4 arg, + JValue* pResult); + #ifdef __cplusplus } #endif diff --git a/vm/UtfString.c b/vm/UtfString.c index 58545cd00..ec35cdf63 100644 --- a/vm/UtfString.c +++ b/vm/UtfString.c @@ -418,7 +418,7 @@ int dvmHashcmpStrings(const void* vstrObj1, const void* vstrObj2) len1 * sizeof(u2)); } -ArrayObject* dvmCreateStringArray(char** strings, size_t count) +ArrayObject* dvmCreateStringArray(const char** strings, size_t count) { Thread* self = dvmThreadSelf(); diff --git a/vm/UtfString.h b/vm/UtfString.h index f0413a48e..a1ee71231 100644 --- a/vm/UtfString.h +++ b/vm/UtfString.h @@ -67,7 +67,7 @@ u4 dvmComputeStringHash(const StringObject* strObj); * * Returns NULL and throws an exception on failure. */ -ArrayObject* dvmCreateStringArray(char** strings, size_t count); +ArrayObject* dvmCreateStringArray(const char** strings, size_t count); /* * Create a java/lang/String from a C string. diff --git a/vm/interp/Stack.c b/vm/interp/Stack.c index 97fbeb562..85e54ffcb 100644 --- a/vm/interp/Stack.c +++ b/vm/interp/Stack.c @@ -971,37 +971,24 @@ ClassObject* dvmGetCaller3Class(const void* curFrame) } /* - * Create a flat array of methods that comprise the current interpreter - * stack trace. Pass in the current frame ptr. - * - * Allocates a new array and fills it with method pointers. Break frames - * are skipped, but reflection invocations are not. The caller must free - * "*pArray". + * Fill a flat array of methods that comprise the current interpreter + * stack trace. Pass in the current frame ptr. Break frames are + * skipped, but reflection invocations are not. * * The current frame will be in element 0. - * - * Returns "true" on success, "false" on failure (e.g. malloc failed). */ -bool dvmCreateStackTraceArray(const void* fp, const Method*** pArray, - int* pLength) +void dvmFillStackTraceArray(const void* fp, const Method** array, size_t length) { - const Method** array; - int idx, depth; - - depth = dvmComputeExactFrameDepth(fp); - array = (const Method**) malloc(depth * sizeof(Method*)); - if (array == NULL) - return false; - - for (idx = 0; fp != NULL; fp = SAVEAREA_FROM_FP(fp)->prevFrame) { - if (!dvmIsBreakFrame((u4*)fp)) - array[idx++] = SAVEAREA_FROM_FP(fp)->method; + assert(fp != NULL); + assert(array != NULL); + size_t i = 0; + while (fp != NULL) { + if (!dvmIsBreakFrame((u4*)fp)) { + assert(i < length); + array[i++] = SAVEAREA_FROM_FP(fp)->method; + } + fp = SAVEAREA_FROM_FP(fp)->prevFrame; } - assert(idx == depth); - - *pArray = array; - *pLength = depth; - return true; } /* diff --git a/vm/interp/Stack.h b/vm/interp/Stack.h index 403cae23c..99bef1acd 100644 --- a/vm/interp/Stack.h +++ b/vm/interp/Stack.h @@ -266,11 +266,10 @@ ClassObject* dvmGetCaller2Class(const void* curFrame); ClassObject* dvmGetCaller3Class(const void* curFrame); /* - * Allocate and fill an array of method pointers representing the current - * stack trace (element 0 is current frame). + * Fill an array of method pointers representing the current stack + * trace (element 0 is current frame). */ -bool dvmCreateStackTraceArray(const void* fp, const Method*** pArray, - int* pLength); +void dvmFillStackTraceArray(const void* fp, const Method** array, size_t length); /* * Common handling for stack overflow. diff --git a/vm/native/InternalNative.c b/vm/native/InternalNative.cpp index c8734726d..c8734726d 100644 --- a/vm/native/InternalNative.c +++ b/vm/native/InternalNative.cpp diff --git a/vm/native/dalvik_bytecode_OpcodeInfo.c b/vm/native/dalvik_bytecode_OpcodeInfo.cpp index cabd7b197..3861fef32 100644 --- a/vm/native/dalvik_bytecode_OpcodeInfo.c +++ b/vm/native/dalvik_bytecode_OpcodeInfo.cpp @@ -31,7 +31,7 @@ static void Dalvik_dalvik_bytecode_OpcodeInfo_isInvoke(const u4* args, JValue* pResult) { - jint opcode = (jint) args[0]; + Opcode opcode = static_cast<Opcode>(args[0]); int flags = dexGetFlagsFromOpcode(opcode); bool result = (flags & kInstrInvoke) != 0; RETURN_BOOLEAN(result); diff --git a/vm/native/dalvik_system_DexFile.c b/vm/native/dalvik_system_DexFile.cpp index 5ebb52971..5ebb52971 100644 --- a/vm/native/dalvik_system_DexFile.c +++ b/vm/native/dalvik_system_DexFile.cpp diff --git a/vm/native/dalvik_system_VMDebug.c b/vm/native/dalvik_system_VMDebug.cpp index 146f562ca..cfd8ebc42 100644 --- a/vm/native/dalvik_system_VMDebug.c +++ b/vm/native/dalvik_system_VMDebug.cpp @@ -21,10 +21,8 @@ #include "native/InternalNativePriv.h" #include "hprof/Hprof.h" -#include <cutils/array.h> #include <string.h> #include <unistd.h> -#include <errno.h> /* @@ -51,30 +49,20 @@ static int getFileDescriptor(Object* obj) * static String[] getVmFeatureList() * * Return a set of strings describing available VM features (this is chiefly - * of interest to DDMS). Some features may be controlled by compile-time - * or command-line flags. + * of interest to DDMS). */ static void Dalvik_dalvik_system_VMDebug_getVmFeatureList(const u4* args, JValue* pResult) { - Array* features = arrayCreate(); - - /* VM responds to DDMS method profiling requests */ - arrayAdd(features, "method-trace-profiling"); - arrayAdd(features, "method-trace-profiling-streaming"); - /* VM responds to DDMS heap dump requests */ - arrayAdd(features, "hprof-heap-dump"); - arrayAdd(features, "hprof-heap-dump-streaming"); - - char** strings = (char**) arrayUnwrap(features); - int count = arraySize(features); - ArrayObject* result = dvmCreateStringArray(strings, count); + const char* strings[] = { "method-trace-profiling", + "method-trace-profiling-streaming", + "hprof-heap-dump", + "hprof-heap-dump-streaming" }; + ArrayObject* result = dvmCreateStringArray(strings, NELEM(strings)); dvmReleaseTrackedAlloc((Object*) result, dvmThreadSelf()); - arrayFree(features); RETURN_PTR(result); } - /* These must match the values in dalvik.system.VMDebug. */ enum { @@ -416,7 +404,7 @@ static void Dalvik_dalvik_system_VMDebug_getInstructionCount(const u4* args, ArrayObject* countArray = (ArrayObject*) args[0]; if (countArray != NULL) { - int* storage = (int*) countArray->contents; + int* storage = (int*)(void*)countArray->contents; u4 length = countArray->length; /* diff --git a/vm/native/dalvik_system_VMRuntime.c b/vm/native/dalvik_system_VMRuntime.cpp index 3642f9098..c133e64cd 100644 --- a/vm/native/dalvik_system_VMRuntime.c +++ b/vm/native/dalvik_system_VMRuntime.cpp @@ -145,7 +145,7 @@ static void Dalvik_dalvik_system_VMRuntime_clearGrowthLimit(const u4* args, static void Dalvik_dalvik_system_VMRuntime_properties(const u4* args, JValue* pResult) { - char** strings = (char**) arrayUnwrap(gDvm.properties); + const char** strings = (const char**) arrayUnwrap(gDvm.properties); int count = arraySize(gDvm.properties); ArrayObject* result = dvmCreateStringArray(strings, count); dvmReleaseTrackedAlloc((Object*) result, dvmThreadSelf()); diff --git a/vm/native/dalvik_system_VMStack.c b/vm/native/dalvik_system_VMStack.cpp index 045a100c0..05b439fee 100644 --- a/vm/native/dalvik_system_VMStack.c +++ b/vm/native/dalvik_system_VMStack.cpp @@ -18,9 +18,9 @@ * dalvik.system.VMStack */ #include "Dalvik.h" +#include "UniquePtr.h" #include "native/InternalNativePriv.h" - /* * public static ClassLoader getCallingClassLoader() * @@ -81,36 +81,23 @@ static void Dalvik_dalvik_system_VMStack_getClasses(const u4* args, JValue* pResult) { /* note "maxSize" is unsigned, so -1 turns into a very large value */ - unsigned int maxSize = args[0]; - unsigned int size = 0; - const unsigned int kSkip = 2; - const Method** methods = NULL; - int methodCount; + size_t maxSize = args[0]; + size_t size = 0; + const size_t kSkip = 2; /* * Get an array with the stack trace in it. */ - if (!dvmCreateStackTraceArray(dvmThreadSelf()->curFrame, &methods, - &methodCount)) - { - LOGE("Failed to create stack trace array\n"); - dvmThrowInternalError(NULL); - RETURN_VOID(); - } - - //int i; - //LOGI("dvmCreateStackTraceArray results:\n"); - //for (i = 0; i < methodCount; i++) { - // LOGI(" %2d: %s.%s\n", - // i, methods[i]->clazz->descriptor, methods[i]->name); - //} + void *fp = dvmThreadSelf()->curFrame; + size_t depth = dvmComputeExactFrameDepth(fp); + UniquePtr<const Method*[]> methods(new const Method*[depth]); + dvmFillStackTraceArray(fp, methods.get(), depth); /* * Run through the array and count up how many elements there are. */ - unsigned int idx; - for (idx = kSkip; (int) idx < methodCount && size < maxSize; idx++) { - const Method* meth = methods[idx]; + for (size_t i = kSkip; i < depth && size < maxSize; ++i) { + const Method* meth = methods[i]; if (dvmIsReflectionMethod(meth)) continue; @@ -122,37 +109,36 @@ static void Dalvik_dalvik_system_VMStack_getClasses(const u4* args, * Create an array object to hold the classes. * TODO: can use gDvm.classJavaLangClassArray here? */ - ClassObject* classArrayClass = NULL; - ArrayObject* classes = NULL; - classArrayClass = dvmFindArrayClass("[Ljava/lang/Class;", NULL); + ClassObject* classArrayClass = dvmFindArrayClass("[Ljava/lang/Class;", + NULL); if (classArrayClass == NULL) { - LOGW("Unable to find java.lang.Class array class\n"); - goto bail; + LOGW("Unable to find java.lang.Class array class"); + return; } - classes = dvmAllocArray(classArrayClass, size, kObjectArrayRefWidth, - ALLOC_DEFAULT); + ArrayObject* classes = dvmAllocArray(classArrayClass, + size, + kObjectArrayRefWidth, + ALLOC_DEFAULT); if (classes == NULL) { - LOGW("Unable to allocate class array (%d elems)\n", size); - goto bail; + LOGW("Unable to allocate class array of %zd elements", size); + return; } /* * Fill in the array. */ - unsigned int objCount = 0; - for (idx = kSkip; (int) idx < methodCount; idx++) { - if (dvmIsReflectionMethod(methods[idx])) { + size_t objCount = 0; + for (size_t i = kSkip; i < depth; ++i) { + if (dvmIsReflectionMethod(methods[i])) { continue; } - dvmSetObjectArrayElement(classes, objCount, - (Object *)methods[idx]->clazz); + Object* klass = (Object *)methods[i]->clazz; + dvmSetObjectArrayElement(classes, objCount, klass); objCount++; } assert(objCount == classes->length); -bail: - free(methods); - dvmReleaseTrackedAlloc((Object*) classes, NULL); + dvmReleaseTrackedAlloc((Object*)classes, NULL); RETURN_PTR(classes); } diff --git a/vm/native/dalvik_system_Zygote.c b/vm/native/dalvik_system_Zygote.cpp index 6f7e6fa69..62cd0c2dd 100644 --- a/vm/native/dalvik_system_Zygote.c +++ b/vm/native/dalvik_system_Zygote.cpp @@ -168,7 +168,7 @@ static int setgroupsIntarray(ArrayObject* gidArray) /* just in case gid_t and u4 are different... */ gids = (gid_t *)alloca(sizeof(gid_t) * gidArray->length); - contents = (s4 *)gidArray->contents; + contents = (s4 *)(void *)gidArray->contents; for (i = 0 ; i < gidArray->length ; i++) { gids[i] = (gid_t) contents[i]; @@ -196,11 +196,11 @@ static int setrlimitsFromArray(ArrayObject* rlimits) memset (&rlim, 0, sizeof(rlim)); - ArrayObject** tuples = (ArrayObject **)(rlimits->contents); + ArrayObject** tuples = (ArrayObject **)(void *)rlimits->contents; for (i = 0; i < rlimits->length; i++) { ArrayObject * rlimit_tuple = tuples[i]; - s4* contents = (s4 *)rlimit_tuple->contents; + s4* contents = (s4 *)(void *)rlimit_tuple->contents; int err; if (rlimit_tuple->length != 3) { diff --git a/vm/native/java_lang_Class.c b/vm/native/java_lang_Class.cpp index a3839a367..f05faefe7 100644 --- a/vm/native/java_lang_Class.c +++ b/vm/native/java_lang_Class.cpp @@ -192,7 +192,7 @@ static void Dalvik_java_lang_Class_getDeclaredClasses(const u4* args, } } else if (publicOnly) { u4 count, newIdx, publicCount = 0; - ClassObject** pSource = (ClassObject**) classes->contents; + ClassObject** pSource = (ClassObject**)(void*)classes->contents; u4 length = classes->length; /* count up public classes */ diff --git a/vm/native/java_lang_Double.c b/vm/native/java_lang_Double.cpp index b019c8c39..b019c8c39 100644 --- a/vm/native/java_lang_Double.c +++ b/vm/native/java_lang_Double.cpp diff --git a/vm/native/java_lang_Float.c b/vm/native/java_lang_Float.cpp index e99e4aaa2..e99e4aaa2 100644 --- a/vm/native/java_lang_Float.c +++ b/vm/native/java_lang_Float.cpp diff --git a/vm/native/java_lang_Math.c b/vm/native/java_lang_Math.cpp index 7c17242a1..7c17242a1 100644 --- a/vm/native/java_lang_Math.c +++ b/vm/native/java_lang_Math.cpp diff --git a/vm/native/java_lang_Object.c b/vm/native/java_lang_Object.cpp index 12f701ff8..12f701ff8 100644 --- a/vm/native/java_lang_Object.c +++ b/vm/native/java_lang_Object.cpp diff --git a/vm/native/java_lang_Runtime.c b/vm/native/java_lang_Runtime.cpp index 112448c78..112448c78 100644 --- a/vm/native/java_lang_Runtime.c +++ b/vm/native/java_lang_Runtime.cpp diff --git a/vm/native/java_lang_String.c b/vm/native/java_lang_String.cpp index 38f9e3161..38f9e3161 100644 --- a/vm/native/java_lang_String.c +++ b/vm/native/java_lang_String.cpp diff --git a/vm/native/java_lang_System.c b/vm/native/java_lang_System.cpp index ad0b397ff..e6b2f1afe 100644 --- a/vm/native/java_lang_System.c +++ b/vm/native/java_lang_System.cpp @@ -51,7 +51,7 @@ #endif #ifdef HAVE_MEMMOVE_WORDS -extern void _memmove_words(void* dest, const void* src, size_t n); +extern "C" void _memmove_words(void* dest, const void* src, size_t n); #define move16 _memmove_words #define move32 _memmove_words #else @@ -252,8 +252,8 @@ static void Dalvik_java_lang_System_arraycopy(const u4* args, JValue* pResult) int copyCount; ClassObject* clazz = NULL; - srcObj = ((Object**) srcArray->contents) + srcPos; - dstObj = ((Object**) dstArray->contents) + dstPos; + srcObj = ((Object**)(void*)srcArray->contents) + srcPos; + dstObj = ((Object**)(void*)dstArray->contents) + dstPos; if (length > 0 && srcObj[0] != NULL) { diff --git a/vm/native/java_lang_Throwable.c b/vm/native/java_lang_Throwable.cpp index f96ee6dac..f96ee6dac 100644 --- a/vm/native/java_lang_Throwable.c +++ b/vm/native/java_lang_Throwable.cpp diff --git a/vm/native/java_lang_VMClassLoader.c b/vm/native/java_lang_VMClassLoader.cpp index 387290c9d..387290c9d 100644 --- a/vm/native/java_lang_VMClassLoader.c +++ b/vm/native/java_lang_VMClassLoader.cpp diff --git a/vm/native/java_lang_VMThread.c b/vm/native/java_lang_VMThread.cpp index 0a0202051..0a0202051 100644 --- a/vm/native/java_lang_VMThread.c +++ b/vm/native/java_lang_VMThread.cpp diff --git a/vm/native/java_lang_reflect_AccessibleObject.c b/vm/native/java_lang_reflect_AccessibleObject.cpp index 46a13571c..46a13571c 100644 --- a/vm/native/java_lang_reflect_AccessibleObject.c +++ b/vm/native/java_lang_reflect_AccessibleObject.cpp diff --git a/vm/native/java_lang_reflect_Array.c b/vm/native/java_lang_reflect_Array.cpp index fe6647cdd..1de0ea12e 100644 --- a/vm/native/java_lang_reflect_Array.c +++ b/vm/native/java_lang_reflect_Array.cpp @@ -87,7 +87,7 @@ static void Dalvik_java_lang_reflect_Array_createMultiArray(const u4* args, numDim = dimArray->length; assert(numDim > 0 && numDim <= 255); - dimensions = (int*) dimArray->contents; + dimensions = (int*)(void*)dimArray->contents; for (i = 0; i < numDim; i++) { if (dimensions[i] < 0) { dvmThrowNegativeArraySizeException(dimensions[i]); diff --git a/vm/native/java_lang_reflect_Constructor.c b/vm/native/java_lang_reflect_Constructor.cpp index 84fd20715..84fd20715 100644 --- a/vm/native/java_lang_reflect_Constructor.c +++ b/vm/native/java_lang_reflect_Constructor.cpp diff --git a/vm/native/java_lang_reflect_Field.c b/vm/native/java_lang_reflect_Field.cpp index 2e8aab5af..2e8aab5af 100644 --- a/vm/native/java_lang_reflect_Field.c +++ b/vm/native/java_lang_reflect_Field.cpp diff --git a/vm/native/java_lang_reflect_Method.c b/vm/native/java_lang_reflect_Method.cpp index d38a62b41..d38a62b41 100644 --- a/vm/native/java_lang_reflect_Method.c +++ b/vm/native/java_lang_reflect_Method.cpp diff --git a/vm/native/java_lang_reflect_Proxy.c b/vm/native/java_lang_reflect_Proxy.cpp index da1232c1d..da1232c1d 100644 --- a/vm/native/java_lang_reflect_Proxy.c +++ b/vm/native/java_lang_reflect_Proxy.cpp diff --git a/vm/native/java_util_concurrent_atomic_AtomicLong.c b/vm/native/java_util_concurrent_atomic_AtomicLong.cpp index eb1d0de46..eb1d0de46 100644 --- a/vm/native/java_util_concurrent_atomic_AtomicLong.c +++ b/vm/native/java_util_concurrent_atomic_AtomicLong.cpp diff --git a/vm/native/org_apache_harmony_dalvik_NativeTestTarget.c b/vm/native/org_apache_harmony_dalvik_NativeTestTarget.cpp index ccc946710..ccc946710 100644 --- a/vm/native/org_apache_harmony_dalvik_NativeTestTarget.c +++ b/vm/native/org_apache_harmony_dalvik_NativeTestTarget.cpp diff --git a/vm/native/org_apache_harmony_dalvik_ddmc_DdmServer.c b/vm/native/org_apache_harmony_dalvik_ddmc_DdmServer.cpp index 570d4699b..570d4699b 100644 --- a/vm/native/org_apache_harmony_dalvik_ddmc_DdmServer.c +++ b/vm/native/org_apache_harmony_dalvik_ddmc_DdmServer.cpp diff --git a/vm/native/org_apache_harmony_dalvik_ddmc_DdmVmInternal.c b/vm/native/org_apache_harmony_dalvik_ddmc_DdmVmInternal.cpp index caa280b45..caa280b45 100644 --- a/vm/native/org_apache_harmony_dalvik_ddmc_DdmVmInternal.c +++ b/vm/native/org_apache_harmony_dalvik_ddmc_DdmVmInternal.cpp diff --git a/vm/native/sun_misc_Unsafe.c b/vm/native/sun_misc_Unsafe.cpp index 16e3ec040..16e3ec040 100644 --- a/vm/native/sun_misc_Unsafe.c +++ b/vm/native/sun_misc_Unsafe.cpp diff --git a/vm/reflect/Reflect.h b/vm/reflect/Reflect.h index 80e96fa66..21523ebfa 100644 --- a/vm/reflect/Reflect.h +++ b/vm/reflect/Reflect.h @@ -19,6 +19,10 @@ #ifndef _DALVIK_REFLECT_REFLECT #define _DALVIK_REFLECT_REFLECT +#ifdef __cplusplus +extern "C" { +#endif + /* * During startup, validate the "box" classes, e.g. java/lang/Integer. */ @@ -260,4 +264,8 @@ bool dvmEncodedArrayIteratorHasNext(const EncodedArrayIterator* iterator); bool dvmEncodedArrayIteratorGetNext(EncodedArrayIterator* iterator, AnnotationValue* value); +#ifdef __cplusplus +} +#endif + #endif /*_DALVIK_REFLECT_REFLECT*/ |