From ff093b31d75658c3404f9b51ee45760f346f06d9 Mon Sep 17 00:00:00 2001 From: Ian Rogers Date: Wed, 30 Apr 2014 19:04:27 -0700 Subject: [PATCH] Fix a few 64-bit compilation of 32-bit code issues. Bug: 13423943 Change-Id: I939389413af0a68c0d95b23cd598b7c42afa4383 --- compiler/dex/quick/codegen_util.cc | 11 ++++++----- compiler/dex/quick/gen_invoke.cc | 6 +++--- disassembler/disassembler_arm.cc | 6 +++--- runtime/quick_exception_handler.cc | 1 + 4 files changed, 13 insertions(+), 11 deletions(-) diff --git a/compiler/dex/quick/codegen_util.cc b/compiler/dex/quick/codegen_util.cc index c3f9b673d..b030bb4ec 100644 --- a/compiler/dex/quick/codegen_util.cc +++ b/compiler/dex/quick/codegen_util.cc @@ -555,8 +555,8 @@ static int AssignLiteralOffsetCommon(LIR* lir, CodeOffset offset) { return offset; } -static int AssignLiteralPointerOffsetCommon(LIR* lir, CodeOffset offset) { - unsigned int element_size = sizeof(void*); +static int AssignLiteralPointerOffsetCommon(LIR* lir, CodeOffset offset, + unsigned int element_size) { // Align to natural pointer size. offset = (offset + (element_size - 1)) & ~(element_size - 1); for (; lir != NULL; lir = lir->next) { @@ -726,9 +726,10 @@ void Mir2Lir::CreateNativeGcMap() { /* Determine the offset of each literal field */ int Mir2Lir::AssignLiteralOffset(CodeOffset offset) { offset = AssignLiteralOffsetCommon(literal_list_, offset); - offset = AssignLiteralPointerOffsetCommon(code_literal_list_, offset); - offset = AssignLiteralPointerOffsetCommon(method_literal_list_, offset); - offset = AssignLiteralPointerOffsetCommon(class_literal_list_, offset); + unsigned int ptr_size = GetInstructionSetPointerSize(cu_->instruction_set); + offset = AssignLiteralPointerOffsetCommon(code_literal_list_, offset, ptr_size); + offset = AssignLiteralPointerOffsetCommon(method_literal_list_, offset, ptr_size); + offset = AssignLiteralPointerOffsetCommon(class_literal_list_, offset, ptr_size); return offset; } diff --git a/compiler/dex/quick/gen_invoke.cc b/compiler/dex/quick/gen_invoke.cc index 05313a95a..93a23a6a6 100644 --- a/compiler/dex/quick/gen_invoke.cc +++ b/compiler/dex/quick/gen_invoke.cc @@ -455,14 +455,14 @@ static int NextSDCallInsn(CompilationUnit* cu, CallInfo* info, if (direct_code != 0 && direct_method != 0) { switch (state) { case 0: // Get the current Method* [sets kArg0] - if (direct_code != static_cast(-1)) { + if (direct_code != static_cast(-1)) { if (cu->instruction_set != kX86 && cu->instruction_set != kX86_64) { cg->LoadConstant(cg->TargetReg(kInvokeTgt), direct_code); } } else if (cu->instruction_set != kX86 && cu->instruction_set != kX86_64) { cg->LoadCodeAddress(target_method, type, kInvokeTgt); } - if (direct_method != static_cast(-1)) { + if (direct_method != static_cast(-1)) { cg->LoadConstant(cg->TargetReg(kArg0), direct_method); } else { cg->LoadMethodAddress(target_method, type, kArg0); @@ -483,7 +483,7 @@ static int NextSDCallInsn(CompilationUnit* cu, CallInfo* info, cg->TargetReg(kArg0)); // Set up direct code if known. if (direct_code != 0) { - if (direct_code != static_cast(-1)) { + if (direct_code != static_cast(-1)) { cg->LoadConstant(cg->TargetReg(kInvokeTgt), direct_code); } else if (cu->instruction_set != kX86 && cu->instruction_set != kX86_64) { CHECK_LT(target_method.dex_method_index, target_method.dex_file->NumMethodIds()); diff --git a/disassembler/disassembler_arm.cc b/disassembler/disassembler_arm.cc index d6d20586b..4e4a51271 100644 --- a/disassembler/disassembler_arm.cc +++ b/disassembler/disassembler_arm.cc @@ -1360,7 +1360,7 @@ size_t DisassemblerArm::DumpThumb32(std::ostream& os, const uint8_t* instr_ptr) } else if (Rn.r == 15) { intptr_t lit_adr = reinterpret_cast(instr_ptr); lit_adr = RoundDown(lit_adr, 4) + 4 + imm12; - args << " ; " << reinterpret_cast(*reinterpret_cast(lit_adr)); + args << StringPrintf(" ; 0x%08x", *reinterpret_cast(lit_adr)); } } else if (op3 == 3) { // LDRSH.W Rt, [Rn, #imm12] - 111 11 00 11 011 nnnn tttt iiiiiiiiiiii @@ -1373,7 +1373,7 @@ size_t DisassemblerArm::DumpThumb32(std::ostream& os, const uint8_t* instr_ptr) } else if (Rn.r == 15) { intptr_t lit_adr = reinterpret_cast(instr_ptr); lit_adr = RoundDown(lit_adr, 4) + 4 + imm12; - args << " ; " << reinterpret_cast(*reinterpret_cast(lit_adr)); + args << StringPrintf(" ; 0x%08x", *reinterpret_cast(lit_adr)); } } } @@ -1430,7 +1430,7 @@ size_t DisassemblerArm::DumpThumb32(std::ostream& os, const uint8_t* instr_ptr) } else if (Rn.r == 15) { intptr_t lit_adr = reinterpret_cast(instr_ptr); lit_adr = RoundDown(lit_adr, 4) + 4 + imm12; - args << " ; " << reinterpret_cast(*reinterpret_cast(lit_adr)); + args << StringPrintf(" ; 0x%08x", *reinterpret_cast(lit_adr)); } } else if (op4 == 0) { // LDR.W Rt, [Rn, Rm{, LSL #imm2}] - 111 11 00 00 101 nnnn tttt 000000iimmmm diff --git a/runtime/quick_exception_handler.cc b/runtime/quick_exception_handler.cc index a91fdf17e..aee0d6429 100644 --- a/runtime/quick_exception_handler.cc +++ b/runtime/quick_exception_handler.cc @@ -19,6 +19,7 @@ #include "catch_block_stack_visitor.h" #include "deoptimize_stack_visitor.h" #include "entrypoints/entrypoint_utils.h" +#include "mirror/art_method-inl.h" #include "sirt_ref-inl.h" namespace art { -- 2.11.0