From 63f712f54ac01871b66907452e045d7a5eb4d608 Mon Sep 17 00:00:00 2001 From: David Srbecky Date: Fri, 12 Jul 2019 15:01:46 +0100 Subject: Switch interpreter: Split the method in ASAN to avoid huge frames Bug: 117341496 Test: "./art/test.py -b -r --interpreter --host --64" in ASAN Change-Id: I6945bf78789588058b1668bf16da9ee1b3ff26b5 --- runtime/interpreter/interpreter_switch_impl-inl.h | 35 +++++++++++++++++++---- 1 file changed, 29 insertions(+), 6 deletions(-) (limited to 'runtime/interpreter/interpreter_switch_impl-inl.h') diff --git a/runtime/interpreter/interpreter_switch_impl-inl.h b/runtime/interpreter/interpreter_switch_impl-inl.h index be4b807267..8afaed5cde 100644 --- a/runtime/interpreter/interpreter_switch_impl-inl.h +++ b/runtime/interpreter/interpreter_switch_impl-inl.h @@ -1901,11 +1901,34 @@ class InstructionHandler { bool& exit_interpreter_loop; }; -// TODO On ASAN builds this function gets a huge stack frame. Since normally we run in the mterp -// this shouldn't cause any problems for stack overflow detection. Remove this once b/117341496 is -// fixed. +// Don't inline in ASAN. It would create massive stack frame. +#ifdef ADDRESS_SANITIZER +#define ASAN_NO_INLINE NO_INLINE +#else +#define ASAN_NO_INLINE ALWAYS_INLINE +#endif + +#define OPCODE_CASE(OPCODE, OPCODE_NAME, NAME, FORMAT, i, a, e, v) \ +template \ +ASAN_NO_INLINE static bool OP_##OPCODE_NAME( \ + SwitchImplContext* ctx, \ + const instrumentation::Instrumentation* instrumentation, \ + Thread* self, \ + ShadowFrame& shadow_frame, \ + uint16_t dex_pc, \ + const Instruction* inst, \ + uint16_t inst_data, \ + const Instruction*& next, \ + bool& exit) REQUIRES_SHARED(Locks::mutator_lock_) { \ + InstructionHandler handler( \ + ctx, instrumentation, self, shadow_frame, dex_pc, inst, inst_data, next, exit); \ + return LIKELY(handler.OPCODE_NAME()); \ +} +DEX_INSTRUCTION_LIST(OPCODE_CASE) +#undef OPCODE_CASE + template -ATTRIBUTE_NO_SANITIZE_ADDRESS void ExecuteSwitchImplCpp(SwitchImplContext* ctx) { +void ExecuteSwitchImplCpp(SwitchImplContext* ctx) { Thread* self = ctx->self; const CodeItemDataAccessor& accessor = ctx->accessor; ShadowFrame& shadow_frame = ctx->shadow_frame; @@ -1935,9 +1958,9 @@ ATTRIBUTE_NO_SANITIZE_ADDRESS void ExecuteSwitchImplCpp(SwitchImplContext* ctx) case OPCODE: { \ DCHECK_EQ(self->IsExceptionPending(), (OPCODE == Instruction::MOVE_EXCEPTION)); \ next = inst->RelativeAt(Instruction::SizeInCodeUnits(Instruction::FORMAT)); \ - InstructionHandler handler( \ + bool success = OP_##OPCODE_NAME( \ ctx, instrumentation, self, shadow_frame, dex_pc, inst, inst_data, next, exit); \ - if (handler.OPCODE_NAME() && LIKELY(!interpret_one_instruction)) { \ + if (success && LIKELY(!interpret_one_instruction)) { \ DCHECK(!exit) << NAME; \ continue; \ } \ -- cgit v1.2.3-59-g8ed1b