From 4cd27d64b0bbdde61fa3f6674ceb24221853ac2c Mon Sep 17 00:00:00 2001 From: Alex Light Date: Tue, 18 Aug 2015 23:03:42 +0000 Subject: [PATCH] Revert "Introduce support for hardware simulators, starting with ARM64" This reverts commit c2e1a5edc438274159c6ef8e65455ac73723a8f1. This breaks the build for x86_64 targets. This is because on target the libvixl is not included as a library for the libart.so target build. The build of non-x86_64 targets only works because the compilers removes the dead-code that contains the libvixl symbols. Bug: 23321940 Change-Id: I39e93ff05b887665c47fb0986867f1d13ca65b9b --- compiler/optimizing/codegen_test.cc | 273 ++++++++++-------------------- runtime/Android.mk | 6 +- runtime/simulator/code_simulator.cc | 42 ----- runtime/simulator/code_simulator.h | 40 ----- runtime/simulator/code_simulator_arm64.cc | 68 -------- runtime/simulator/code_simulator_arm64.h | 60 ------- 6 files changed, 91 insertions(+), 398 deletions(-) delete mode 100644 runtime/simulator/code_simulator.cc delete mode 100644 runtime/simulator/code_simulator.h delete mode 100644 runtime/simulator/code_simulator_arm64.cc delete mode 100644 runtime/simulator/code_simulator_arm64.h diff --git a/compiler/optimizing/codegen_test.cc b/compiler/optimizing/codegen_test.cc index 28fc816ac..4fbb51d43 100644 --- a/compiler/optimizing/codegen_test.cc +++ b/compiler/optimizing/codegen_test.cc @@ -40,7 +40,6 @@ #include "optimizing_unit_test.h" #include "prepare_for_register_allocation.h" #include "register_allocator.h" -#include "simulator/code_simulator.h" #include "ssa_liveness_analysis.h" #include "utils.h" #include "utils/arm/managed_register_arm.h" @@ -121,85 +120,26 @@ class InternalCodeAllocator : public CodeAllocator { DISALLOW_COPY_AND_ASSIGN(InternalCodeAllocator); }; -static bool CanExecuteOnHardware(InstructionSet target_isa) { - return (target_isa == kRuntimeISA) - // Handle the special case of ARM, with two instructions sets - // (ARM32 and Thumb-2). - || (kRuntimeISA == kArm && target_isa == kThumb2); -} - -static bool CanExecute(InstructionSet target_isa) { - return CanExecuteOnHardware(target_isa) || CodeSimulator::CanSimulate(target_isa); -} - -template -static Expected SimulatorExecute(CodeSimulator* simulator, Expected (*f)()); - -template <> -bool SimulatorExecute(CodeSimulator* simulator, bool (*f)()) { - simulator->RunFrom(reinterpret_cast(f)); - return simulator->GetCReturnBool(); -} - -template <> -int32_t SimulatorExecute(CodeSimulator* simulator, int32_t (*f)()) { - simulator->RunFrom(reinterpret_cast(f)); - return simulator->GetCReturnInt32(); -} - -template <> -int64_t SimulatorExecute(CodeSimulator* simulator, int64_t (*f)()) { - simulator->RunFrom(reinterpret_cast(f)); - return simulator->GetCReturnInt64(); -} - -template -static void VerifyGeneratedCode(InstructionSet target_isa, - Expected (*f)(), - bool has_result, - Expected expected) { - ASSERT_TRUE(CanExecute(target_isa)) << "Target ISA is not executable " << target_isa; - - // Verify on simulator. - if (CodeSimulator::CanSimulate(target_isa)) { - std::unique_ptr simulator(CodeSimulator::CreateCodeSimulator(target_isa)); - Expected result = SimulatorExecute(simulator.get(), f); - if (has_result) { - ASSERT_EQ(expected, result); - } - } - - // Verify on hardware. - if (CanExecuteOnHardware(target_isa)) { - Expected result = f(); - if (has_result) { - ASSERT_EQ(expected, result); - } - } -} - template static void Run(const InternalCodeAllocator& allocator, const CodeGenerator& codegen, bool has_result, Expected expected) { - InstructionSet target_isa = codegen.GetInstructionSet(); - typedef Expected (*fptr)(); CommonCompilerTest::MakeExecutable(allocator.GetMemory(), allocator.GetSize()); fptr f = reinterpret_cast(allocator.GetMemory()); - if (target_isa == kThumb2) { + if (codegen.GetInstructionSet() == kThumb2) { // For thumb we need the bottom bit set. f = reinterpret_cast(reinterpret_cast(f) + 1); } - VerifyGeneratedCode(target_isa, f, has_result, expected); + Expected result = f(); + if (has_result) { + ASSERT_EQ(expected, result); + } } template -static void RunCodeBaseline(InstructionSet target_isa, - HGraph* graph, - bool has_result, - Expected expected) { +static void RunCodeBaseline(HGraph* graph, bool has_result, Expected expected) { InternalCodeAllocator allocator; CompilerOptions compiler_options; @@ -209,7 +149,7 @@ static void RunCodeBaseline(InstructionSet target_isa, // We avoid doing a stack overflow check that requires the runtime being setup, // by making sure the compiler knows the methods we are running are leaf methods. codegenX86.CompileBaseline(&allocator, true); - if (target_isa == kX86) { + if (kRuntimeISA == kX86) { Run(allocator, codegenX86, has_result, expected); } @@ -217,7 +157,7 @@ static void RunCodeBaseline(InstructionSet target_isa, ArmInstructionSetFeatures::FromCppDefines()); TestCodeGeneratorARM codegenARM(graph, *features_arm.get(), compiler_options); codegenARM.CompileBaseline(&allocator, true); - if (target_isa == kArm || target_isa == kThumb2) { + if (kRuntimeISA == kArm || kRuntimeISA == kThumb2) { Run(allocator, codegenARM, has_result, expected); } @@ -225,7 +165,7 @@ static void RunCodeBaseline(InstructionSet target_isa, X86_64InstructionSetFeatures::FromCppDefines()); x86_64::CodeGeneratorX86_64 codegenX86_64(graph, *features_x86_64.get(), compiler_options); codegenX86_64.CompileBaseline(&allocator, true); - if (target_isa == kX86_64) { + if (kRuntimeISA == kX86_64) { Run(allocator, codegenX86_64, has_result, expected); } @@ -233,7 +173,7 @@ static void RunCodeBaseline(InstructionSet target_isa, Arm64InstructionSetFeatures::FromCppDefines()); arm64::CodeGeneratorARM64 codegenARM64(graph, *features_arm64.get(), compiler_options); codegenARM64.CompileBaseline(&allocator, true); - if (target_isa == kArm64) { + if (kRuntimeISA == kArm64) { Run(allocator, codegenARM64, has_result, expected); } @@ -241,7 +181,7 @@ static void RunCodeBaseline(InstructionSet target_isa, Mips64InstructionSetFeatures::FromCppDefines()); mips64::CodeGeneratorMIPS64 codegenMIPS64(graph, *features_mips64.get(), compiler_options); codegenMIPS64.CompileBaseline(&allocator, true); - if (target_isa == kMips64) { + if (kRuntimeISA == kMips64) { Run(allocator, codegenMIPS64, has_result, expected); } } @@ -269,33 +209,32 @@ static void RunCodeOptimized(CodeGenerator* codegen, } template -static void RunCodeOptimized(InstructionSet target_isa, - HGraph* graph, +static void RunCodeOptimized(HGraph* graph, std::function hook_before_codegen, bool has_result, Expected expected) { CompilerOptions compiler_options; - if (target_isa == kArm || target_isa == kThumb2) { - std::unique_ptr features_arm( - ArmInstructionSetFeatures::FromCppDefines()); - TestCodeGeneratorARM codegenARM(graph, *features_arm.get(), compiler_options); + if (kRuntimeISA == kArm || kRuntimeISA == kThumb2) { + TestCodeGeneratorARM codegenARM(graph, + *ArmInstructionSetFeatures::FromCppDefines(), + compiler_options); RunCodeOptimized(&codegenARM, graph, hook_before_codegen, has_result, expected); - } else if (target_isa == kArm64) { - std::unique_ptr features_arm64( - Arm64InstructionSetFeatures::FromCppDefines()); - arm64::CodeGeneratorARM64 codegenARM64(graph, *features_arm64.get(), compiler_options); + } else if (kRuntimeISA == kArm64) { + arm64::CodeGeneratorARM64 codegenARM64(graph, + *Arm64InstructionSetFeatures::FromCppDefines(), + compiler_options); RunCodeOptimized(&codegenARM64, graph, hook_before_codegen, has_result, expected); - } else if (target_isa == kX86) { + } else if (kRuntimeISA == kX86) { std::unique_ptr features_x86( X86InstructionSetFeatures::FromCppDefines()); x86::CodeGeneratorX86 codegenX86(graph, *features_x86.get(), compiler_options); RunCodeOptimized(&codegenX86, graph, hook_before_codegen, has_result, expected); - } else if (target_isa == kX86_64) { + } else if (kRuntimeISA == kX86_64) { std::unique_ptr features_x86_64( X86_64InstructionSetFeatures::FromCppDefines()); x86_64::CodeGeneratorX86_64 codegenX86_64(graph, *features_x86_64.get(), compiler_options); RunCodeOptimized(&codegenX86_64, graph, hook_before_codegen, has_result, expected); - } else if (target_isa == kMips64) { + } else if (kRuntimeISA == kMips64) { std::unique_ptr features_mips64( Mips64InstructionSetFeatures::FromCppDefines()); mips64::CodeGeneratorMIPS64 codegenMIPS64(graph, *features_mips64.get(), compiler_options); @@ -303,10 +242,7 @@ static void RunCodeOptimized(InstructionSet target_isa, } } -static void TestCode(InstructionSet target_isa, - const uint16_t* data, - bool has_result = false, - int32_t expected = 0) { +static void TestCode(const uint16_t* data, bool has_result = false, int32_t expected = 0) { ArenaPool pool; ArenaAllocator arena(&pool); HGraph* graph = CreateGraph(&arena); @@ -316,13 +252,10 @@ static void TestCode(InstructionSet target_isa, ASSERT_TRUE(graph_built); // Remove suspend checks, they cannot be executed in this context. RemoveSuspendChecks(graph); - RunCodeBaseline(target_isa, graph, has_result, expected); + RunCodeBaseline(graph, has_result, expected); } -static void TestCodeLong(InstructionSet target_isa, - const uint16_t* data, - bool has_result, - int64_t expected) { +static void TestCodeLong(const uint16_t* data, bool has_result, int64_t expected) { ArenaPool pool; ArenaAllocator arena(&pool); HGraph* graph = CreateGraph(&arena); @@ -332,110 +265,108 @@ static void TestCodeLong(InstructionSet target_isa, ASSERT_TRUE(graph_built); // Remove suspend checks, they cannot be executed in this context. RemoveSuspendChecks(graph); - RunCodeBaseline(target_isa, graph, has_result, expected); + RunCodeBaseline(graph, has_result, expected); } -class CodegenTest: public ::testing::TestWithParam {}; - -TEST_P(CodegenTest, ReturnVoid) { +TEST(CodegenTest, ReturnVoid) { const uint16_t data[] = ZERO_REGISTER_CODE_ITEM(Instruction::RETURN_VOID); - TestCode(GetParam(), data); + TestCode(data); } -TEST_P(CodegenTest, CFG1) { +TEST(CodegenTest, CFG1) { const uint16_t data[] = ZERO_REGISTER_CODE_ITEM( Instruction::GOTO | 0x100, Instruction::RETURN_VOID); - TestCode(GetParam(), data); + TestCode(data); } -TEST_P(CodegenTest, CFG2) { +TEST(CodegenTest, CFG2) { const uint16_t data[] = ZERO_REGISTER_CODE_ITEM( Instruction::GOTO | 0x100, Instruction::GOTO | 0x100, Instruction::RETURN_VOID); - TestCode(GetParam(), data); + TestCode(data); } -TEST_P(CodegenTest, CFG3) { +TEST(CodegenTest, CFG3) { const uint16_t data1[] = ZERO_REGISTER_CODE_ITEM( Instruction::GOTO | 0x200, Instruction::RETURN_VOID, Instruction::GOTO | 0xFF00); - TestCode(GetParam(), data1); + TestCode(data1); const uint16_t data2[] = ZERO_REGISTER_CODE_ITEM( Instruction::GOTO_16, 3, Instruction::RETURN_VOID, Instruction::GOTO_16, 0xFFFF); - TestCode(GetParam(), data2); + TestCode(data2); const uint16_t data3[] = ZERO_REGISTER_CODE_ITEM( Instruction::GOTO_32, 4, 0, Instruction::RETURN_VOID, Instruction::GOTO_32, 0xFFFF, 0xFFFF); - TestCode(GetParam(), data3); + TestCode(data3); } -TEST_P(CodegenTest, CFG4) { +TEST(CodegenTest, CFG4) { const uint16_t data[] = ZERO_REGISTER_CODE_ITEM( Instruction::RETURN_VOID, Instruction::GOTO | 0x100, Instruction::GOTO | 0xFE00); - TestCode(GetParam(), data); + TestCode(data); } -TEST_P(CodegenTest, CFG5) { +TEST(CodegenTest, CFG5) { const uint16_t data[] = ONE_REGISTER_CODE_ITEM( Instruction::CONST_4 | 0 | 0, Instruction::IF_EQ, 3, Instruction::GOTO | 0x100, Instruction::RETURN_VOID); - TestCode(GetParam(), data); + TestCode(data); } -TEST_P(CodegenTest, IntConstant) { +TEST(CodegenTest, IntConstant) { const uint16_t data[] = ONE_REGISTER_CODE_ITEM( Instruction::CONST_4 | 0 | 0, Instruction::RETURN_VOID); - TestCode(GetParam(), data); + TestCode(data); } -TEST_P(CodegenTest, Return1) { +TEST(CodegenTest, Return1) { const uint16_t data[] = ONE_REGISTER_CODE_ITEM( Instruction::CONST_4 | 0 | 0, Instruction::RETURN | 0); - TestCode(GetParam(), data, true, 0); + TestCode(data, true, 0); } -TEST_P(CodegenTest, Return2) { +TEST(CodegenTest, Return2) { const uint16_t data[] = TWO_REGISTERS_CODE_ITEM( Instruction::CONST_4 | 0 | 0, Instruction::CONST_4 | 0 | 1 << 8, Instruction::RETURN | 1 << 8); - TestCode(GetParam(), data, true, 0); + TestCode(data, true, 0); } -TEST_P(CodegenTest, Return3) { +TEST(CodegenTest, Return3) { const uint16_t data[] = TWO_REGISTERS_CODE_ITEM( Instruction::CONST_4 | 0 | 0, Instruction::CONST_4 | 1 << 8 | 1 << 12, Instruction::RETURN | 1 << 8); - TestCode(GetParam(), data, true, 1); + TestCode(data, true, 1); } -TEST_P(CodegenTest, ReturnIf1) { +TEST(CodegenTest, ReturnIf1) { const uint16_t data[] = TWO_REGISTERS_CODE_ITEM( Instruction::CONST_4 | 0 | 0, Instruction::CONST_4 | 1 << 8 | 1 << 12, @@ -443,10 +374,10 @@ TEST_P(CodegenTest, ReturnIf1) { Instruction::RETURN | 0 << 8, Instruction::RETURN | 1 << 8); - TestCode(GetParam(), data, true, 1); + TestCode(data, true, 1); } -TEST_P(CodegenTest, ReturnIf2) { +TEST(CodegenTest, ReturnIf2) { const uint16_t data[] = TWO_REGISTERS_CODE_ITEM( Instruction::CONST_4 | 0 | 0, Instruction::CONST_4 | 1 << 8 | 1 << 12, @@ -454,12 +385,12 @@ TEST_P(CodegenTest, ReturnIf2) { Instruction::RETURN | 0 << 8, Instruction::RETURN | 1 << 8); - TestCode(GetParam(), data, true, 0); + TestCode(data, true, 0); } // Exercise bit-wise (one's complement) not-int instruction. #define NOT_INT_TEST(TEST_NAME, INPUT, EXPECTED_OUTPUT) \ -TEST_P(CodegenTest, TEST_NAME) { \ +TEST(CodegenTest, TEST_NAME) { \ const int32_t input = INPUT; \ const uint16_t input_lo = Low16Bits(input); \ const uint16_t input_hi = High16Bits(input); \ @@ -468,7 +399,7 @@ TEST_P(CodegenTest, TEST_NAME) { \ Instruction::NOT_INT | 1 << 8 | 0 << 12 , \ Instruction::RETURN | 1 << 8); \ \ - TestCode(GetParam(), data, true, EXPECTED_OUTPUT); \ + TestCode(data, true, EXPECTED_OUTPUT); \ } NOT_INT_TEST(ReturnNotIntMinus2, -2, 1) @@ -484,7 +415,7 @@ NOT_INT_TEST(ReturnNotIntINT32_MAX, 2147483647, -2147483648) // -(2^31) // Exercise bit-wise (one's complement) not-long instruction. #define NOT_LONG_TEST(TEST_NAME, INPUT, EXPECTED_OUTPUT) \ -TEST_P(CodegenTest, TEST_NAME) { \ +TEST(CodegenTest, TEST_NAME) { \ const int64_t input = INPUT; \ const uint16_t word0 = Low16Bits(Low32Bits(input)); /* LSW. */ \ const uint16_t word1 = High16Bits(Low32Bits(input)); \ @@ -495,7 +426,7 @@ TEST_P(CodegenTest, TEST_NAME) { \ Instruction::NOT_LONG | 2 << 8 | 0 << 12, \ Instruction::RETURN_WIDE | 2 << 8); \ \ - TestCodeLong(GetParam(), data, true, EXPECTED_OUTPUT); \ + TestCodeLong(data, true, EXPECTED_OUTPUT); \ } NOT_LONG_TEST(ReturnNotLongMinus2, INT64_C(-2), INT64_C(1)) @@ -534,7 +465,7 @@ NOT_LONG_TEST(ReturnNotLongINT64_MAX, #undef NOT_LONG_TEST -TEST_P(CodegenTest, IntToLongOfLongToInt) { +TEST(CodegenTest, IntToLongOfLongToInt) { const int64_t input = INT64_C(4294967296); // 2^32 const uint16_t word0 = Low16Bits(Low32Bits(input)); // LSW. const uint16_t word1 = High16Bits(Low32Bits(input)); @@ -548,48 +479,48 @@ TEST_P(CodegenTest, IntToLongOfLongToInt) { Instruction::INT_TO_LONG | 2 << 8 | 4 << 12, Instruction::RETURN_WIDE | 2 << 8); - TestCodeLong(GetParam(), data, true, 1); + TestCodeLong(data, true, 1); } -TEST_P(CodegenTest, ReturnAdd1) { +TEST(CodegenTest, ReturnAdd1) { const uint16_t data[] = TWO_REGISTERS_CODE_ITEM( Instruction::CONST_4 | 3 << 12 | 0, Instruction::CONST_4 | 4 << 12 | 1 << 8, Instruction::ADD_INT, 1 << 8 | 0, Instruction::RETURN); - TestCode(GetParam(), data, true, 7); + TestCode(data, true, 7); } -TEST_P(CodegenTest, ReturnAdd2) { +TEST(CodegenTest, ReturnAdd2) { const uint16_t data[] = TWO_REGISTERS_CODE_ITEM( Instruction::CONST_4 | 3 << 12 | 0, Instruction::CONST_4 | 4 << 12 | 1 << 8, Instruction::ADD_INT_2ADDR | 1 << 12, Instruction::RETURN); - TestCode(GetParam(), data, true, 7); + TestCode(data, true, 7); } -TEST_P(CodegenTest, ReturnAdd3) { +TEST(CodegenTest, ReturnAdd3) { const uint16_t data[] = ONE_REGISTER_CODE_ITEM( Instruction::CONST_4 | 4 << 12 | 0 << 8, Instruction::ADD_INT_LIT8, 3 << 8 | 0, Instruction::RETURN); - TestCode(GetParam(), data, true, 7); + TestCode(data, true, 7); } -TEST_P(CodegenTest, ReturnAdd4) { +TEST(CodegenTest, ReturnAdd4) { const uint16_t data[] = ONE_REGISTER_CODE_ITEM( Instruction::CONST_4 | 4 << 12 | 0 << 8, Instruction::ADD_INT_LIT16, 3, Instruction::RETURN); - TestCode(GetParam(), data, true, 7); + TestCode(data, true, 7); } -TEST_P(CodegenTest, NonMaterializedCondition) { +TEST(CodegenTest, NonMaterializedCondition) { ArenaPool pool; ArenaAllocator allocator(&pool); @@ -635,30 +566,30 @@ TEST_P(CodegenTest, NonMaterializedCondition) { block->InsertInstructionBefore(move, block->GetLastInstruction()); }; - RunCodeOptimized(GetParam(), graph, hook_before_codegen, true, 0); + RunCodeOptimized(graph, hook_before_codegen, true, 0); } -TEST_P(CodegenTest, ReturnMulInt) { +TEST(CodegenTest, ReturnMulInt) { const uint16_t data[] = TWO_REGISTERS_CODE_ITEM( Instruction::CONST_4 | 3 << 12 | 0, Instruction::CONST_4 | 4 << 12 | 1 << 8, Instruction::MUL_INT, 1 << 8 | 0, Instruction::RETURN); - TestCode(GetParam(), data, true, 12); + TestCode(data, true, 12); } -TEST_P(CodegenTest, ReturnMulInt2addr) { +TEST(CodegenTest, ReturnMulInt2addr) { const uint16_t data[] = TWO_REGISTERS_CODE_ITEM( Instruction::CONST_4 | 3 << 12 | 0, Instruction::CONST_4 | 4 << 12 | 1 << 8, Instruction::MUL_INT_2ADDR | 1 << 12, Instruction::RETURN); - TestCode(GetParam(), data, true, 12); + TestCode(data, true, 12); } -TEST_P(CodegenTest, ReturnMulLong) { +TEST(CodegenTest, ReturnMulLong) { const uint16_t data[] = FOUR_REGISTERS_CODE_ITEM( Instruction::CONST_4 | 3 << 12 | 0, Instruction::CONST_4 | 0 << 12 | 1 << 8, @@ -667,10 +598,10 @@ TEST_P(CodegenTest, ReturnMulLong) { Instruction::MUL_LONG, 2 << 8 | 0, Instruction::RETURN_WIDE); - TestCodeLong(GetParam(), data, true, 12); + TestCodeLong(data, true, 12); } -TEST_P(CodegenTest, ReturnMulLong2addr) { +TEST(CodegenTest, ReturnMulLong2addr) { const uint16_t data[] = FOUR_REGISTERS_CODE_ITEM( Instruction::CONST_4 | 3 << 12 | 0 << 8, Instruction::CONST_4 | 0 << 12 | 1 << 8, @@ -679,28 +610,28 @@ TEST_P(CodegenTest, ReturnMulLong2addr) { Instruction::MUL_LONG_2ADDR | 2 << 12, Instruction::RETURN_WIDE); - TestCodeLong(GetParam(), data, true, 12); + TestCodeLong(data, true, 12); } -TEST_P(CodegenTest, ReturnMulIntLit8) { +TEST(CodegenTest, ReturnMulIntLit8) { const uint16_t data[] = ONE_REGISTER_CODE_ITEM( Instruction::CONST_4 | 4 << 12 | 0 << 8, Instruction::MUL_INT_LIT8, 3 << 8 | 0, Instruction::RETURN); - TestCode(GetParam(), data, true, 12); + TestCode(data, true, 12); } -TEST_P(CodegenTest, ReturnMulIntLit16) { +TEST(CodegenTest, ReturnMulIntLit16) { const uint16_t data[] = ONE_REGISTER_CODE_ITEM( Instruction::CONST_4 | 4 << 12 | 0 << 8, Instruction::MUL_INT_LIT16, 3, Instruction::RETURN); - TestCode(GetParam(), data, true, 12); + TestCode(data, true, 12); } -TEST_P(CodegenTest, MaterializedCondition1) { +TEST(CodegenTest, MaterializedCondition1) { // Check that condition are materialized correctly. A materialized condition // should yield `1` if it evaluated to true, and `0` otherwise. // We force the materialization of comparisons for different combinations of @@ -741,11 +672,11 @@ TEST_P(CodegenTest, MaterializedCondition1) { block->InsertInstructionBefore(move, block->GetLastInstruction()); }; - RunCodeOptimized(GetParam(), graph, hook_before_codegen, true, lhs[i] < rhs[i]); + RunCodeOptimized(graph, hook_before_codegen, true, lhs[i] < rhs[i]); } } -TEST_P(CodegenTest, MaterializedCondition2) { +TEST(CodegenTest, MaterializedCondition2) { // Check that HIf correctly interprets a materialized condition. // We force the materialization of comparisons for different combinations of // inputs. An HIf takes the materialized combination as input and returns a @@ -807,53 +738,27 @@ TEST_P(CodegenTest, MaterializedCondition2) { block->InsertInstructionBefore(move, block->GetLastInstruction()); }; - RunCodeOptimized(GetParam(), graph, hook_before_codegen, true, lhs[i] < rhs[i]); + RunCodeOptimized(graph, hook_before_codegen, true, lhs[i] < rhs[i]); } } -TEST_P(CodegenTest, ReturnDivIntLit8) { +TEST(CodegenTest, ReturnDivIntLit8) { const uint16_t data[] = ONE_REGISTER_CODE_ITEM( Instruction::CONST_4 | 4 << 12 | 0 << 8, Instruction::DIV_INT_LIT8, 3 << 8 | 0, Instruction::RETURN); - TestCode(GetParam(), data, true, 1); + TestCode(data, true, 1); } -TEST_P(CodegenTest, ReturnDivInt2Addr) { +TEST(CodegenTest, ReturnDivInt2Addr) { const uint16_t data[] = TWO_REGISTERS_CODE_ITEM( Instruction::CONST_4 | 4 << 12 | 0, Instruction::CONST_4 | 2 << 12 | 1 << 8, Instruction::DIV_INT_2ADDR | 1 << 12, Instruction::RETURN); - TestCode(GetParam(), data, true, 2); + TestCode(data, true, 2); } -static ::std::vector GetTargetISAs() { - ::std::vector v; - // Add all ISAs that are executable on hardware or on simulator. - const ::std::vector executable_isa_candidates = { - kArm, - kArm64, - kThumb2, - kX86, - kX86_64, - kMips, - kMips64 - }; - - for (auto target_isa : executable_isa_candidates) { - if (CanExecute(target_isa)) { - v.push_back(target_isa); - } - } - - return v; -} - -INSTANTIATE_TEST_CASE_P(MultipleTargets, - CodegenTest, - ::testing::ValuesIn(GetTargetISAs())); - } // namespace art diff --git a/runtime/Android.mk b/runtime/Android.mk index 254c08c88..8f70d3089 100644 --- a/runtime/Android.mk +++ b/runtime/Android.mk @@ -196,8 +196,6 @@ LIBART_COMMON_SRC_FILES += \ arch/x86/instruction_set_features_x86.cc \ arch/x86/registers_x86.cc \ arch/x86_64/registers_x86_64.cc \ - simulator/code_simulator.cc \ - simulator/code_simulator_arm64.cc \ entrypoints/entrypoint_utils.cc \ entrypoints/interpreter/interpreter_entrypoints.cc \ entrypoints/jni/jni_entrypoints.cc \ @@ -496,11 +494,11 @@ $$(ENUM_OPERATOR_OUT_GEN): $$(GENERATED_SRC_DIR)/%_operator_out.cc : $(LOCAL_PAT LOCAL_SHARED_LIBRARIES += libcutils else # host ifeq ($$(art_static_or_shared),static) - LOCAL_STATIC_LIBRARIES += libziparchive-host libz libvixl + LOCAL_STATIC_LIBRARIES += libziparchive-host libz # For ashmem_create_region. LOCAL_STATIC_LIBRARIES += libcutils else - LOCAL_SHARED_LIBRARIES += libziparchive-host libz-host libvixl + LOCAL_SHARED_LIBRARIES += libziparchive-host libz-host # For ashmem_create_region. LOCAL_SHARED_LIBRARIES += libcutils endif diff --git a/runtime/simulator/code_simulator.cc b/runtime/simulator/code_simulator.cc deleted file mode 100644 index 5023e48b1..000000000 --- a/runtime/simulator/code_simulator.cc +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (C) 2015 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 "simulator/code_simulator.h" -#include "simulator/code_simulator_arm64.h" - -namespace art { - -CodeSimulator* CodeSimulator::CreateCodeSimulator(InstructionSet target_isa) { - DCHECK(CanSimulate(target_isa)); - switch (target_isa) { - case kArm64: - return new arm64::CodeSimulatorArm64(); - default: - UNREACHABLE(); - } -} - -bool CodeSimulator::CanSimulate(InstructionSet target_isa) { - switch (target_isa) { - case kArm64: - return arm64::CodeSimulatorArm64::CanSimulateArm64(); - default: - // No simulator support for target. - return false; - } -} - -} // namespace art diff --git a/runtime/simulator/code_simulator.h b/runtime/simulator/code_simulator.h deleted file mode 100644 index fe24c9544..000000000 --- a/runtime/simulator/code_simulator.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (C) 2015 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. - */ - -#ifndef ART_RUNTIME_SIMULATOR_CODE_SIMULATOR_H_ -#define ART_RUNTIME_SIMULATOR_CODE_SIMULATOR_H_ - -#include "arch/instruction_set.h" - -namespace art { - -class CodeSimulator { - public: - virtual ~CodeSimulator() {} - static CodeSimulator* CreateCodeSimulator(InstructionSet target_isa); - static bool CanSimulate(InstructionSet target_isa); - - virtual void RunFrom(intptr_t code_buffer) = 0; - - // Get return value according to C ABI. - virtual bool GetCReturnBool() = 0; - virtual int32_t GetCReturnInt32() = 0; - virtual int64_t GetCReturnInt64() = 0; -}; - -} // namespace art - -#endif // ART_RUNTIME_SIMULATOR_CODE_SIMULATOR_H_ diff --git a/runtime/simulator/code_simulator_arm64.cc b/runtime/simulator/code_simulator_arm64.cc deleted file mode 100644 index 3472e80ad..000000000 --- a/runtime/simulator/code_simulator_arm64.cc +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (C) 2015 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 "simulator/code_simulator_arm64.h" - -namespace art { -namespace arm64 { - -// VIXL has not been tested on 32bit arches, so vixl::Simulator is not always -// available. To avoid linker error on these arches, an early return is added in -// each of the following methods, when vixl::Simulator is not available. -// TODO: when vixl::Simulator is always available, remove the early returns. - -CodeSimulatorArm64::CodeSimulatorArm64() - : decoder_(nullptr), simulator_(nullptr) { - DCHECK(kCanSimulate); - if (!kCanSimulate) { - return; - } - decoder_ = new vixl::Decoder(); - simulator_ = new vixl::Simulator(decoder_); -} - -CodeSimulatorArm64::~CodeSimulatorArm64() { - if (!kCanSimulate) { - return; - } - delete simulator_; - delete decoder_; -} - -void CodeSimulatorArm64::RunFrom(intptr_t code_buffer) { - if (!kCanSimulate) { - return; - } - simulator_->RunFrom(reinterpret_cast(code_buffer)); -} - -bool CodeSimulatorArm64::GetCReturnBool() { - DCHECK(kCanSimulate); - return simulator_->wreg(0); -} - -int32_t CodeSimulatorArm64::GetCReturnInt32() { - DCHECK(kCanSimulate); - return simulator_->wreg(0); -} - -int64_t CodeSimulatorArm64::GetCReturnInt64() { - DCHECK(kCanSimulate); - return simulator_->xreg(0); -} - -} // namespace arm64 -} // namespace art diff --git a/runtime/simulator/code_simulator_arm64.h b/runtime/simulator/code_simulator_arm64.h deleted file mode 100644 index 5898fdaff..000000000 --- a/runtime/simulator/code_simulator_arm64.h +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (C) 2015 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. - */ - -#ifndef ART_RUNTIME_SIMULATOR_CODE_SIMULATOR_ARM64_H_ -#define ART_RUNTIME_SIMULATOR_CODE_SIMULATOR_ARM64_H_ - -#include "memory" -#include "simulator/code_simulator.h" -// TODO: make vixl clean wrt -Wshadow. -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunknown-pragmas" -#pragma GCC diagnostic ignored "-Wshadow" -#pragma GCC diagnostic ignored "-Wmissing-noreturn" -#include "vixl/a64/simulator-a64.h" -#pragma GCC diagnostic pop - -namespace art { -namespace arm64 { - -class CodeSimulatorArm64 : public CodeSimulator { - public: - CodeSimulatorArm64(); - virtual ~CodeSimulatorArm64(); - - static constexpr bool CanSimulateArm64() { - return kCanSimulate; - } - - void RunFrom(intptr_t code_buffer) OVERRIDE; - - bool GetCReturnBool() OVERRIDE; - int32_t GetCReturnInt32() OVERRIDE; - int64_t GetCReturnInt64() OVERRIDE; - - private: - vixl::Decoder* decoder_; - vixl::Simulator* simulator_; - - // TODO: Enable CodeSimulatorArm64 for more host ISAs once vixl::Simulator supports - // them. - static constexpr bool kCanSimulate = (kRuntimeISA == kX86_64); -}; - -} // namespace arm64 -} // namespace art - -#endif // ART_RUNTIME_SIMULATOR_CODE_SIMULATOR_ARM64_H_ -- 2.11.0