Implement new-instance instruction.
Change-Id: I67e6a4e0256c098f48f2aa92dec37dd95dc65ec1
diff --git a/src/compiler_llvm/method_compiler.cc b/src/compiler_llvm/method_compiler.cc
index 64ebeb1..1912ad0 100644
--- a/src/compiler_llvm/method_compiler.cc
+++ b/src/compiler_llvm/method_compiler.cc
@@ -1514,7 +1514,28 @@
void MethodCompiler::EmitInsn_NewInstance(uint32_t dex_pc,
Instruction const* insn) {
- // UNIMPLEMENTED(WARNING);
+
+ Instruction::DecodedInstruction dec_insn(insn);
+
+ llvm::Function* runtime_func;
+ if (compiler_->CanAccessTypeWithoutChecks(method_idx_, dex_cache_,
+ *dex_file_, dec_insn.vB_)) {
+ runtime_func = irb_.GetRuntime(AllocObject);
+ } else {
+ runtime_func = irb_.GetRuntime(AllocObjectWithAccessCheck);
+ }
+
+ llvm::Constant* type_index_value = irb_.getInt32(dec_insn.vB_);
+
+ llvm::Value* method_object_addr = EmitLoadMethodObjectAddr();
+
+ llvm::Value* object_addr =
+ irb_.CreateCall2(runtime_func, type_index_value, method_object_addr);
+
+ EmitGuard_ExceptionLandingPad(dex_pc);
+
+ EmitStoreDalvikReg(dec_insn.vA_, kObject, kAccurate, object_addr);
+
irb_.CreateBr(GetNextBasicBlock(dex_pc));
}