diff options
| -rw-r--r-- | runtime/entrypoints_order_test.cc | 4 | ||||
| -rw-r--r-- | runtime/interpreter/mterp/arm/main.S | 32 | ||||
| -rw-r--r-- | runtime/interpreter/mterp/arm64/main.S | 31 | ||||
| -rw-r--r-- | runtime/interpreter/mterp/common/gen_setup.py | 21 | ||||
| -rwxr-xr-x | runtime/interpreter/mterp/gen_mterp.py | 4 | ||||
| -rw-r--r-- | runtime/interpreter/mterp/mterp.cc | 6 | ||||
| -rw-r--r-- | runtime/interpreter/mterp/mterp.h | 2 | ||||
| -rw-r--r-- | runtime/interpreter/mterp/x86/main.S | 43 | ||||
| -rw-r--r-- | runtime/interpreter/mterp/x86_64/main.S | 39 | ||||
| -rw-r--r-- | runtime/oat.h | 4 | ||||
| -rw-r--r-- | runtime/thread.h | 35 | ||||
| -rw-r--r-- | tools/cpp-define-generator/thread.def | 4 |
12 files changed, 54 insertions, 171 deletions
diff --git a/runtime/entrypoints_order_test.cc b/runtime/entrypoints_order_test.cc index 50c65ea505..f45197834f 100644 --- a/runtime/entrypoints_order_test.cc +++ b/runtime/entrypoints_order_test.cc @@ -127,9 +127,7 @@ class EntrypointsOrderTest : public CommonRuntimeTest { EXPECT_OFFSET_DIFFP(Thread, tlsPtr_, thread_local_objects, jni_entrypoints, sizeof(size_t)); // Skip across the entrypoints structures. - EXPECT_OFFSET_DIFFP(Thread, tlsPtr_, mterp_current_ibase, mterp_default_ibase, sizeof(void*)); - EXPECT_OFFSET_DIFFP(Thread, tlsPtr_, mterp_default_ibase, mterp_alt_ibase, sizeof(void*)); - EXPECT_OFFSET_DIFFP(Thread, tlsPtr_, mterp_alt_ibase, rosalloc_runs, sizeof(void*)); + EXPECT_OFFSET_DIFFP(Thread, tlsPtr_, mterp_current_ibase, rosalloc_runs, sizeof(void*)); EXPECT_OFFSET_DIFFP(Thread, tlsPtr_, rosalloc_runs, thread_local_alloc_stack_top, sizeof(void*) * kNumRosAllocThreadLocalSizeBracketsInThread); EXPECT_OFFSET_DIFFP(Thread, tlsPtr_, thread_local_alloc_stack_top, thread_local_alloc_stack_end, diff --git a/runtime/interpreter/mterp/arm/main.S b/runtime/interpreter/mterp/arm/main.S index 62c38bfd96..f5fdf148d2 100644 --- a/runtime/interpreter/mterp/arm/main.S +++ b/runtime/interpreter/mterp/arm/main.S @@ -404,21 +404,20 @@ ENTRY ExecuteMterpImpl // cfi info continues, and covers the whole mterp implementation. END ExecuteMterpImpl -%def alt_stub(): -/* - * Inter-instruction transfer stub. Call out to MterpCheckBefore to handle - * any interesting requests and then jump to the real instruction - * handler. Note that the call to MterpCheckBefore is done as a tail call. - */ +%def dchecks_before_helper(): + // Call C++ to do debug checks and return to the handler using tail call. .extern MterpCheckBefore - ldr rIBASE, [rSELF, #THREAD_CURRENT_IBASE_OFFSET] @ refresh IBASE. - adr lr, .L_ALT_${opcode} - sub lr, lr, #(.L_ALT_${opcode} - .L_${opcode}) @ Addr of primary handler. mov r0, rSELF add r1, rFP, #OFF_FP_SHADOWFRAME mov r2, rPC b MterpCheckBefore @ (self, shadow_frame, dex_pc_ptr) @ Tail call. +%def opcode_pre(): +% add_helper(dchecks_before_helper, "Mterp_dchecks_before_helper") + #if !defined(NDEBUG) + bl Mterp_dchecks_before_helper + #endif + %def fallback(): /* Transfer stub to alternate interpreter */ b MterpFallback @@ -733,13 +732,6 @@ MterpProfileActive: .global artMterpAsmInstructionEnd artMterpAsmInstructionEnd: -%def instruction_end_alt(): - - .type artMterpAsmAltInstructionEnd, #object - .hidden artMterpAsmAltInstructionEnd - .global artMterpAsmAltInstructionEnd -artMterpAsmAltInstructionEnd: - %def instruction_start(): .type artMterpAsmInstructionStart, #object @@ -748,14 +740,6 @@ artMterpAsmAltInstructionEnd: artMterpAsmInstructionStart = .L_op_nop .text -%def instruction_start_alt(): - - .type artMterpAsmAltInstructionStart, #object - .hidden artMterpAsmAltInstructionStart - .global artMterpAsmAltInstructionStart -artMterpAsmAltInstructionStart = .L_ALT_op_nop - .text - %def opcode_start(): ENTRY Mterp_${opcode} %def opcode_end(): diff --git a/runtime/interpreter/mterp/arm64/main.S b/runtime/interpreter/mterp/arm64/main.S index f248265579..1b72e79f68 100644 --- a/runtime/interpreter/mterp/arm64/main.S +++ b/runtime/interpreter/mterp/arm64/main.S @@ -429,20 +429,20 @@ ENTRY ExecuteMterpImpl // cfi info continues, and covers the whole mterp implementation. END ExecuteMterpImpl -%def alt_stub(): -/* - * Inter-instruction transfer stub. Call out to MterpCheckBefore to handle - * any interesting requests and then jump to the real instruction - * handler. Note that the call to MterpCheckBefore is done as a tail call. - */ +%def dchecks_before_helper(): + // Call C++ to do debug checks and return to the handler using tail call. .extern MterpCheckBefore - ldr xIBASE, [xSELF, #THREAD_CURRENT_IBASE_OFFSET] // refresh IBASE. - adr lr, artMterpAsmInstructionStart + (${opnum} * 128) // Addr of primary handler. mov x0, xSELF add x1, xFP, #OFF_FP_SHADOWFRAME mov x2, xPC b MterpCheckBefore // (self, shadow_frame, dex_pc_ptr) Note: tail call. +%def opcode_pre(): +% add_helper(dchecks_before_helper, "Mterp_dchecks_before_helper") + #if !defined(NDEBUG) + bl Mterp_dchecks_before_helper + #endif + %def footer(): .cfi_endproc END MterpHelpers @@ -766,13 +766,6 @@ MterpProfileActive: .global artMterpAsmInstructionEnd artMterpAsmInstructionEnd: -%def instruction_end_alt(): - - .type artMterpAsmAltInstructionEnd, #object - .hidden artMterpAsmAltInstructionEnd - .global artMterpAsmAltInstructionEnd -artMterpAsmAltInstructionEnd: - %def instruction_start(): .type artMterpAsmInstructionStart, #object @@ -781,14 +774,6 @@ artMterpAsmAltInstructionEnd: artMterpAsmInstructionStart = .L_op_nop .text -%def instruction_start_alt(): - - .type artMterpAsmAltInstructionStart, #object - .hidden artMterpAsmAltInstructionStart - .global artMterpAsmAltInstructionStart -artMterpAsmAltInstructionStart = .L_ALT_op_nop - .text - %def opcode_start(): ENTRY Mterp_${opcode} %def opcode_end(): diff --git a/runtime/interpreter/mterp/common/gen_setup.py b/runtime/interpreter/mterp/common/gen_setup.py index d2a6376255..cfa5e2e2ef 100644 --- a/runtime/interpreter/mterp/common/gen_setup.py +++ b/runtime/interpreter/mterp/common/gen_setup.py @@ -33,20 +33,16 @@ def write_line(line): def balign(): write_line(" .balign {}".format(handler_size_bytes)) -def write_opcode(num, name, write_method, is_alt): +def write_opcode(num, name, write_method): global opnum, opcode opnum, opcode = str(num), name - if is_alt: - name = "ALT_" + name write_line("/* ------------------------------ */") balign() write_line(".L_{1}: /* {0:#04x} */".format(num, name)) - if is_alt: - alt_stub() - else: - opcode_start() - write_method() - opcode_end() + opcode_start() + opcode_pre() + write_method() + opcode_end() write_line("") opnum, opcode = None, None @@ -76,7 +72,7 @@ def generate(output_filename): entry() instruction_start() - opcodes(is_alt = False) + opcodes() balign() instruction_end() @@ -84,11 +80,6 @@ def generate(output_filename): out.write(helper) helpers() - instruction_start_alt() - opcodes(is_alt = True) - balign() - instruction_end_alt() - footer() out.seek(0) diff --git a/runtime/interpreter/mterp/gen_mterp.py b/runtime/interpreter/mterp/gen_mterp.py index ad6e836177..5d25955701 100755 --- a/runtime/interpreter/mterp/gen_mterp.py +++ b/runtime/interpreter/mterp/gen_mterp.py @@ -58,9 +58,9 @@ def generate_script(output_filename, input_filenames): script = StringIO() # File-like in-memory buffer. script.write("# DO NOT EDIT: This file was generated by gen-mterp.py.\n") script.write(open(SCRIPT_SETUP_CODE, "r").read()) - script.write("def opcodes(is_alt):\n") + script.write("def opcodes():\n") for i, opcode in enumerate(getOpcodeList()): - script.write(' write_opcode({0}, "{1}", {1}, is_alt)\n'.format(i, opcode)) + script.write(' write_opcode({0}, "{1}", {1})\n'.format(i, opcode)) # Read all template files and translate them into python code. for input_filename in sorted(input_filenames): diff --git a/runtime/interpreter/mterp/mterp.cc b/runtime/interpreter/mterp/mterp.cc index 5cd9e5d851..633a51337c 100644 --- a/runtime/interpreter/mterp/mterp.cc +++ b/runtime/interpreter/mterp/mterp.cc @@ -48,11 +48,7 @@ void CheckMterpAsmConstants() { } void InitMterpTls(Thread* self) { - self->SetMterpDefaultIBase(artMterpAsmInstructionStart); - self->SetMterpAltIBase(artMterpAsmAltInstructionStart); - self->SetMterpCurrentIBase((kTraceExecutionEnabled || kTestExportPC) ? - artMterpAsmAltInstructionStart : - artMterpAsmInstructionStart); + self->SetMterpCurrentIBase(artMterpAsmInstructionStart); } /* diff --git a/runtime/interpreter/mterp/mterp.h b/runtime/interpreter/mterp/mterp.h index adde7c652a..81a53c84fb 100644 --- a/runtime/interpreter/mterp/mterp.h +++ b/runtime/interpreter/mterp/mterp.h @@ -25,8 +25,6 @@ */ extern "C" void* artMterpAsmInstructionStart[]; extern "C" void* artMterpAsmInstructionEnd[]; -extern "C" void* artMterpAsmAltInstructionStart[]; -extern "C" void* artMterpAsmAltInstructionEnd[]; namespace art { diff --git a/runtime/interpreter/mterp/x86/main.S b/runtime/interpreter/mterp/x86/main.S index b44f168686..a7451426ff 100644 --- a/runtime/interpreter/mterp/x86/main.S +++ b/runtime/interpreter/mterp/x86/main.S @@ -410,26 +410,24 @@ ENTRY ExecuteMterpImpl // cfi info continues, and covers the whole mterp implementation. END ExecuteMterpImpl -%def alt_stub(): -/* - * Inter-instruction transfer stub. Call out to MterpCheckBefore to handle - * any interesting requests and then jump to the real instruction - * handler. Unlike the Arm handler, we can't do this as a tail call - * because rIBASE is caller save and we need to reload it. - * - * Note that unlike in the Arm implementation, we should never arrive - * here with a zero breakFlag because we always refresh rIBASE on - * return. - */ +%def dchecks_before_helper(): + // Call C++ to do debug checks and return to the handler using tail call. .extern MterpCheckBefore + popl %eax # Return address (the instuction handler). movl rSELF, %ecx movl %ecx, OUT_ARG0(%esp) - leal OFF_FP_SHADOWFRAME(rFP), %eax - movl %eax, OUT_ARG1(%esp) + leal OFF_FP_SHADOWFRAME(rFP), %ecx + movl %ecx, OUT_ARG1(%esp) movl rPC, OUT_ARG2(%esp) - call SYMBOL(MterpCheckBefore) # (self, shadow_frame, dex_pc_ptr) + pushl %eax # Return address for the tail call. + jmp SYMBOL(MterpCheckBefore) # (self, shadow_frame, dex_pc_ptr) + +%def opcode_pre(): +% add_helper(dchecks_before_helper, "Mterp_dchecks_before_helper") + #if !defined(NDEBUG) + call SYMBOL(Mterp_dchecks_before_helper) REFRESH_IBASE - jmp .L_op_nop+(${opnum}*${handler_size_bytes}) + #endif %def fallback(): /* Transfer stub to alternate interpreter */ @@ -773,13 +771,6 @@ MRestoreFrame: .global SYMBOL(artMterpAsmInstructionEnd) SYMBOL(artMterpAsmInstructionEnd): -%def instruction_end_alt(): - - OBJECT_TYPE(artMterpAsmAltInstructionEnd) - ASM_HIDDEN SYMBOL(artMterpAsmAltInstructionEnd) - .global SYMBOL(artMterpAsmAltInstructionEnd) -SYMBOL(artMterpAsmAltInstructionEnd): - %def instruction_start(): OBJECT_TYPE(artMterpAsmInstructionStart) @@ -788,14 +779,6 @@ SYMBOL(artMterpAsmAltInstructionEnd): SYMBOL(artMterpAsmInstructionStart) = .L_op_nop .text -%def instruction_start_alt(): - - OBJECT_TYPE(artMterpAsmAltInstructionStart) - ASM_HIDDEN SYMBOL(artMterpAsmAltInstructionStart) - .global SYMBOL(artMterpAsmAltInstructionStart) - .text -SYMBOL(artMterpAsmAltInstructionStart) = .L_ALT_op_nop - %def opcode_start(): ENTRY Mterp_${opcode} %def opcode_end(): diff --git a/runtime/interpreter/mterp/x86_64/main.S b/runtime/interpreter/mterp/x86_64/main.S index 900923da6d..53a993429e 100644 --- a/runtime/interpreter/mterp/x86_64/main.S +++ b/runtime/interpreter/mterp/x86_64/main.S @@ -393,24 +393,22 @@ ENTRY ExecuteMterpImpl // cfi info continues, and covers the whole mterp implementation. END ExecuteMterpImpl -%def alt_stub(): -/* - * Inter-instruction transfer stub. Call out to MterpCheckBefore to handle - * any interesting requests and then jump to the real instruction - * handler. Unlike the Arm handler, we can't do this as a tail call - * because rIBASE is caller save and we need to reload it. - * - * Note that unlike in the Arm implementation, we should never arrive - * here with a zero breakFlag because we always refresh rIBASE on - * return. - */ +%def dchecks_before_helper(): + // Call C++ to do debug checks and return to the handler using tail call. .extern MterpCheckBefore + popq %rax # Return address (the instuction handler). REFRESH_IBASE movq rSELF, OUT_ARG0 leaq OFF_FP_SHADOWFRAME(rFP), OUT_ARG1 movq rPC, OUT_ARG2 - call SYMBOL(MterpCheckBefore) # (self, shadow_frame, dex_pc_ptr) - jmp .L_op_nop+(${opnum}*${handler_size_bytes}) + pushq %rax # Return address for the tail call. + jmp SYMBOL(MterpCheckBefore) # (self, shadow_frame, dex_pc_ptr) + +%def opcode_pre(): +% add_helper(dchecks_before_helper, "Mterp_dchecks_before_helper") + #if !defined(NDEBUG) + call SYMBOL(Mterp_dchecks_before_helper) + #endif %def fallback(): /* Transfer stub to alternate interpreter */ @@ -726,13 +724,6 @@ MRestoreFrame: .global SYMBOL(artMterpAsmInstructionEnd) SYMBOL(artMterpAsmInstructionEnd): -%def instruction_end_alt(): - - OBJECT_TYPE(artMterpAsmAltInstructionEnd) - ASM_HIDDEN SYMBOL(artMterpAsmAltInstructionEnd) - .global SYMBOL(artMterpAsmAltInstructionEnd) -SYMBOL(artMterpAsmAltInstructionEnd): - %def instruction_start(): OBJECT_TYPE(artMterpAsmInstructionStart) @@ -741,14 +732,6 @@ SYMBOL(artMterpAsmAltInstructionEnd): SYMBOL(artMterpAsmInstructionStart) = .L_op_nop .text -%def instruction_start_alt(): - - OBJECT_TYPE(artMterpAsmAltInstructionStart) - ASM_HIDDEN SYMBOL(artMterpAsmAltInstructionStart) - .global SYMBOL(artMterpAsmAltInstructionStart) - .text -SYMBOL(artMterpAsmAltInstructionStart) = .L_ALT_op_nop - %def opcode_start(): ENTRY Mterp_${opcode} %def opcode_end(): diff --git a/runtime/oat.h b/runtime/oat.h index 963725a050..5c5a02dff5 100644 --- a/runtime/oat.h +++ b/runtime/oat.h @@ -32,8 +32,8 @@ class InstructionSetFeatures; class PACKED(4) OatHeader { public: static constexpr uint8_t kOatMagic[] = { 'o', 'a', 't', '\n' }; - // Last oat version changed reason: Remove PIC option from oat files. - static constexpr uint8_t kOatVersion[] = { '1', '6', '2', '\0' }; + // Last oat version changed reason: Remove interpreter alt tables. + static constexpr uint8_t kOatVersion[] = { '1', '6', '3', '\0' }; static constexpr const char* kImageLocationKey = "image-location"; static constexpr const char* kDex2OatCmdLineKey = "dex2oat-cmdline"; diff --git a/runtime/thread.h b/runtime/thread.h index 47a3af2564..d7dc5aeacb 100644 --- a/runtime/thread.h +++ b/runtime/thread.h @@ -743,18 +743,6 @@ class Thread { } template<PointerSize pointer_size> - static constexpr ThreadOffset<pointer_size> MterpDefaultIBaseOffset() { - return ThreadOffsetFromTlsPtr<pointer_size>( - OFFSETOF_MEMBER(tls_ptr_sized_values, mterp_default_ibase)); - } - - template<PointerSize pointer_size> - static constexpr ThreadOffset<pointer_size> MterpAltIBaseOffset() { - return ThreadOffsetFromTlsPtr<pointer_size>( - OFFSETOF_MEMBER(tls_ptr_sized_values, mterp_alt_ibase)); - } - - template<PointerSize pointer_size> static constexpr ThreadOffset<pointer_size> ExceptionOffset() { return ThreadOffsetFromTlsPtr<pointer_size>(OFFSETOF_MEMBER(tls_ptr_sized_values, exception)); } @@ -1199,30 +1187,14 @@ class Thread { bool ProtectStack(bool fatal_on_error = true); bool UnprotectStack(); - void SetMterpDefaultIBase(void* ibase) { - tlsPtr_.mterp_default_ibase = ibase; - } - void SetMterpCurrentIBase(void* ibase) { tlsPtr_.mterp_current_ibase = ibase; } - void SetMterpAltIBase(void* ibase) { - tlsPtr_.mterp_alt_ibase = ibase; - } - - const void* GetMterpDefaultIBase() const { - return tlsPtr_.mterp_default_ibase; - } - const void* GetMterpCurrentIBase() const { return tlsPtr_.mterp_current_ibase; } - const void* GetMterpAltIBase() const { - return tlsPtr_.mterp_alt_ibase; - } - bool HandlingSignal() const { return tls32_.handling_signal_; } @@ -1599,8 +1571,7 @@ class Thread { last_no_thread_suspension_cause(nullptr), checkpoint_function(nullptr), thread_local_start(nullptr), thread_local_pos(nullptr), thread_local_end(nullptr), thread_local_limit(nullptr), - thread_local_objects(0), mterp_current_ibase(nullptr), mterp_default_ibase(nullptr), - mterp_alt_ibase(nullptr), thread_local_alloc_stack_top(nullptr), + thread_local_objects(0), mterp_current_ibase(nullptr), thread_local_alloc_stack_top(nullptr), thread_local_alloc_stack_end(nullptr), flip_function(nullptr), method_verifier(nullptr), thread_local_mark_stack(nullptr), async_exception(nullptr) { @@ -1737,10 +1708,8 @@ class Thread { JniEntryPoints jni_entrypoints; QuickEntryPoints quick_entrypoints; - // Mterp jump table bases. + // Mterp jump table base. void* mterp_current_ibase; - void* mterp_default_ibase; - void* mterp_alt_ibase; // There are RosAlloc::kNumThreadLocalSizeBrackets thread-local size brackets per thread. void* rosalloc_runs[kNumRosAllocThreadLocalSizeBracketsInThread]; diff --git a/tools/cpp-define-generator/thread.def b/tools/cpp-define-generator/thread.def index 2dd90fae3f..7b19076828 100644 --- a/tools/cpp-define-generator/thread.def +++ b/tools/cpp-define-generator/thread.def @@ -18,16 +18,12 @@ #include "thread.h" #endif -ASM_DEFINE(THREAD_ALT_IBASE_OFFSET, - art::Thread::MterpAltIBaseOffset<art::kRuntimePointerSize>().Int32Value()) ASM_DEFINE(THREAD_CARD_TABLE_OFFSET, art::Thread::CardTableOffset<art::kRuntimePointerSize>().Int32Value()) ASM_DEFINE(THREAD_CHECKPOINT_REQUEST, art::kCheckpointRequest) ASM_DEFINE(THREAD_CURRENT_IBASE_OFFSET, art::Thread::MterpCurrentIBaseOffset<art::kRuntimePointerSize>().Int32Value()) -ASM_DEFINE(THREAD_DEFAULT_IBASE_OFFSET, - art::Thread::MterpDefaultIBaseOffset<art::kRuntimePointerSize>().Int32Value()) ASM_DEFINE(THREAD_EMPTY_CHECKPOINT_REQUEST, art::kEmptyCheckpointRequest) ASM_DEFINE(THREAD_EXCEPTION_OFFSET, |