From 68e74fda779ca28ecb2b3af10d5193691603b3d0 Mon Sep 17 00:00:00 2001 From: Ben Cheng Date: Fri, 26 Jul 2013 09:46:06 -0700 Subject: [PATCH] Minor code cleanup to address warnings found by Clang. cherry-picked from internal Android branch 55617c82a73d84ff3695bdd5526159448262d009 Change-Id: I0f78ca6b8293c13d7dbb535556543f6ea9f4dd45 --- vm/Dvm.mk | 7 ++++++- vm/analysis/Optimize.cpp | 6 +++--- vm/analysis/RegisterMap.cpp | 2 ++ vm/compiler/Loop.cpp | 2 +- vm/hprof/Hprof.h | 4 ++-- vm/hprof/HprofHeap.cpp | 9 +++------ 6 files changed, 17 insertions(+), 13 deletions(-) diff --git a/vm/Dvm.mk b/vm/Dvm.mk index 5c0f74ed1..2af05823b 100644 --- a/vm/Dvm.mk +++ b/vm/Dvm.mk @@ -24,10 +24,15 @@ # # Compiler defines. # -LOCAL_CFLAGS += -fstrict-aliasing -Wstrict-aliasing=2 -fno-align-jumps + +LOCAL_CFLAGS += -fstrict-aliasing -Wstrict-aliasing=2 LOCAL_CFLAGS += -Wall -Wextra -Wno-unused-parameter LOCAL_CFLAGS += -DARCH_VARIANT=\"$(dvm_arch_variant)\" +ifneq ($(strip $(LOCAL_CLANG)),true) +LOCAL_CFLAGS += -fno-align-jumps +endif + # # Optional features. These may impact the size or performance of the VM. # diff --git a/vm/analysis/Optimize.cpp b/vm/analysis/Optimize.cpp index 55e715340..b61b82c18 100644 --- a/vm/analysis/Optimize.cpp +++ b/vm/analysis/Optimize.cpp @@ -375,16 +375,16 @@ void dvmUpdateCodeUnit(const Method* meth, u2* ptr, u2 newVal) * 16-bit op, we convert the opcode from "packed" form (e.g. 0x0108) to * bytecode form (e.g. 0x08ff). */ -static inline void updateOpcode(const Method* meth, u2* ptr, Opcode opcode) +static inline void updateOpcode(const Method* meth, u2* ptr, u2 opcode) { if (opcode >= 256) { /* opcode low byte becomes high byte, low byte becomes 0xff */ assert((ptr[0] & 0xff) == 0xff); - dvmUpdateCodeUnit(meth, ptr, (u2) (opcode << 8) | 0x00ff); + dvmUpdateCodeUnit(meth, ptr, (opcode << 8) | 0x00ff); } else { /* 8-bit op, just replace the low byte */ assert((ptr[0] & 0xff) != 0xff); - dvmUpdateCodeUnit(meth, ptr, (ptr[0] & 0xff00) | (u2) opcode); + dvmUpdateCodeUnit(meth, ptr, (ptr[0] & 0xff00) | opcode); } } diff --git a/vm/analysis/RegisterMap.cpp b/vm/analysis/RegisterMap.cpp index c62ec4760..197fb7ab4 100644 --- a/vm/analysis/RegisterMap.cpp +++ b/vm/analysis/RegisterMap.cpp @@ -508,6 +508,8 @@ static bool verifyMap(VerifierData* vdata, const RegisterMap* pMap) /* shouldn't happen */ ALOGE("GLITCH: bad format (%d)", format); dvmAbort(); + /* Make compiler happy */ + addr = 0; } const RegType* regs = vdata->registerLines[addr].regTypes; diff --git a/vm/compiler/Loop.cpp b/vm/compiler/Loop.cpp index f82668628..dc04a1135 100644 --- a/vm/compiler/Loop.cpp +++ b/vm/compiler/Loop.cpp @@ -352,7 +352,7 @@ static bool doLoopBodyCodeMotion(CompilationUnit *cUnit) dvmCompilerDataFlowAttributes[mir->dalvikInsn.opcode]; /* Skip extended MIR instructions */ - if (dInsn->opcode >= kNumPackedOpcodes) continue; + if ((u2) dInsn->opcode >= kNumPackedOpcodes) continue; int instrFlags = dexGetFlagsFromOpcode(dInsn->opcode); diff --git a/vm/hprof/Hprof.h b/vm/hprof/Hprof.h index 3ee8c61a3..c8075291a 100644 --- a/vm/hprof/Hprof.h +++ b/vm/hprof/Hprof.h @@ -176,8 +176,8 @@ int hprofFinishHeapDump(hprof_context_t *ctx); int hprofSetGcScanState(hprof_context_t *ctx, hprof_heap_tag_t state, u4 threadSerialNumber); -int hprofMarkRootObject(hprof_context_t *ctx, - const Object *obj, jobject jniObj); +void hprofMarkRootObject(hprof_context_t *ctx, + const Object *obj, jobject jniObj); int hprofDumpHeapObject(hprof_context_t *ctx, const Object *obj); diff --git a/vm/hprof/HprofHeap.cpp b/vm/hprof/HprofHeap.cpp index 40e773bb8..8c34ff346 100644 --- a/vm/hprof/HprofHeap.cpp +++ b/vm/hprof/HprofHeap.cpp @@ -119,14 +119,14 @@ static hprof_basic_type primitiveToBasicTypeAndSize(PrimitiveType prim, * only true when marking the root set or unreachable * objects. Used to add rootset references to obj. */ -int hprofMarkRootObject(hprof_context_t *ctx, const Object *obj, jobject jniObj) +void hprofMarkRootObject(hprof_context_t *ctx, const Object *obj, + jobject jniObj) { hprof_record_t *rec = &ctx->curRec; - int err; hprof_heap_tag_t heapTag = (hprof_heap_tag_t)ctx->gcScanState; if (heapTag == 0) { - return 0; + return; } if (ctx->objectsInSegment >= OBJECTS_PER_SEGMENT || @@ -197,13 +197,10 @@ int hprofMarkRootObject(hprof_context_t *ctx, const Object *obj, jobject jniObj) break; default: - err = 0; break; } ctx->objectsInSegment++; - - return err; } static int stackTraceSerialNumber(const void *obj) -- 2.11.0