From 3354cec8828abd98ce18baaad199d7d9bc47bdd2 Mon Sep 17 00:00:00 2001 From: Logan Chien Date: Fri, 13 Jan 2012 14:29:03 +0800 Subject: Implement move-exception instruction. Change-Id: I85ce1b59fcf9e5e29ff78c6fba150a5a5d69d8cd --- src/compiler_llvm/method_compiler.cc | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'src/compiler_llvm/method_compiler.cc') diff --git a/src/compiler_llvm/method_compiler.cc b/src/compiler_llvm/method_compiler.cc index 3bd79c7ed9..54e9decddb 100644 --- a/src/compiler_llvm/method_compiler.cc +++ b/src/compiler_llvm/method_compiler.cc @@ -1108,7 +1108,29 @@ void MethodCompiler::EmitInsn_MoveResult(uint32_t dex_pc, void MethodCompiler::EmitInsn_MoveException(uint32_t dex_pc, Instruction const* insn) { - // UNIMPLEMENTED(WARNING); + + Instruction::DecodedInstruction dec_insn(insn); + + // Get thread-local exception field address + llvm::Constant* exception_field_offset = + irb_.getPtrEquivInt(Thread::ExceptionOffset().Int32Value()); + + llvm::Value* thread_object_addr = + irb_.CreateCall(irb_.GetRuntime(GetCurrentThread)); + + llvm::Value* exception_field_addr = + irb_.CreatePtrDisp(thread_object_addr, exception_field_offset, + irb_.getJObjectTy()->getPointerTo()); + + // Get exception object address + llvm::Value* exception_object_addr = irb_.CreateLoad(exception_field_addr); + + // Set thread-local exception field address to NULL + irb_.CreateStore(irb_.getJNull(), exception_field_addr); + + // Keep the exception object in the Dalvik register + EmitStoreDalvikReg(dec_insn.vA_, kObject, kAccurate, exception_object_addr); + irb_.CreateBr(GetNextBasicBlock(dex_pc)); } -- cgit v1.2.3-59-g8ed1b