From bb4d12ac1024f5333e59bc1413f5b05250c4d8c6 Mon Sep 17 00:00:00 2001 From: Logan Chien Date: Fri, 17 Feb 2012 14:10:01 +0800 Subject: Add dex cache codegen helper function. Change-Id: I02b0d3538dbbee03fb8837761b00ae1220d6902e --- src/compiler_llvm/method_compiler.cc | 72 ++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) (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 7ddae88791..7253cada70 100644 --- a/src/compiler_llvm/method_compiler.cc +++ b/src/compiler_llvm/method_compiler.cc @@ -2324,6 +2324,78 @@ void MethodCompiler::EmitGuard_NullPointerException(uint32_t dex_pc, } +llvm::Value* MethodCompiler::EmitLoadDexCacheAddr(MemberOffset offset) { + llvm::Value* method_object_addr = EmitLoadMethodObjectAddr(); + + llvm::Value* dex_cache_offset_value = + irb_.getPtrEquivInt(offset.Int32Value()); + + llvm::Value* dex_cache_field_addr = + irb_.CreatePtrDisp(method_object_addr, dex_cache_offset_value, + irb_.getJObjectTy()->getPointerTo()); + + return irb_.CreateLoad(dex_cache_field_addr); +} + + +void MethodCompiler:: +EmitLoadDexCacheCodeAndDirectMethodFieldAddr(llvm::Value*& code_field_addr, + llvm::Value*& method_field_addr, + uint32_t method_idx) { + llvm::Value* cadms_dex_cache_addr = + EmitLoadDexCacheAddr(Method::GetDexCacheCodeAndDirectMethodsOffset()); + + llvm::Value* code_index_value = + irb_.getPtrEquivInt(CodeAndDirectMethods::CodeIndex(method_idx)); + + llvm::Value* method_index_value = + irb_.getPtrEquivInt(CodeAndDirectMethods::MethodIndex(method_idx)); + + // Return the field address + code_field_addr = EmitArrayGEP(cadms_dex_cache_addr, code_index_value, + irb_.getJIntTy()); + + method_field_addr = EmitArrayGEP(cadms_dex_cache_addr, method_index_value, + irb_.getJIntTy()); +} + + +llvm::Value* MethodCompiler:: +EmitLoadDexCacheStaticStorageFieldAddr(uint32_t type_idx) { + llvm::Value* static_storage_dex_cache_addr = + EmitLoadDexCacheAddr(Method::DexCacheInitializedStaticStorageOffset()); + + llvm::Value* type_idx_value = irb_.getPtrEquivInt(type_idx); + + return EmitArrayGEP(static_storage_dex_cache_addr, type_idx_value, + irb_.getJObjectTy()); +} + + +llvm::Value* MethodCompiler:: +EmitLoadDexCacheResolvedTypeFieldAddr(uint32_t type_idx) { + llvm::Value* resolved_type_dex_cache_addr = + EmitLoadDexCacheAddr(Method::DexCacheResolvedTypesOffset()); + + llvm::Value* type_idx_value = irb_.getPtrEquivInt(type_idx); + + return EmitArrayGEP(resolved_type_dex_cache_addr, type_idx_value, + irb_.getJObjectTy()); +} + + +llvm::Value* MethodCompiler:: +EmitLoadDexCacheStringFieldAddr(uint32_t string_idx) { + llvm::Value* string_dex_cache_addr = + EmitLoadDexCacheAddr(Method::DexCacheStringsOffset()); + + llvm::Value* string_idx_value = irb_.getPtrEquivInt(string_idx); + + return EmitArrayGEP(string_dex_cache_addr, string_idx_value, + irb_.getJObjectTy()); +} + + CompiledMethod *MethodCompiler::Compile() { // Code generation CreateFunction(); -- cgit v1.2.3-59-g8ed1b