diff options
| -rw-r--r-- | src/compiler_llvm/method_compiler.cc | 72 | ||||
| -rw-r--r-- | src/compiler_llvm/method_compiler.h | 15 | ||||
| -rw-r--r-- | src/dex_cache.h | 14 |
3 files changed, 94 insertions, 7 deletions
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(); diff --git a/src/compiler_llvm/method_compiler.h b/src/compiler_llvm/method_compiler.h index f86d740cc9..6a6768b42b 100644 --- a/src/compiler_llvm/method_compiler.h +++ b/src/compiler_llvm/method_compiler.h @@ -264,6 +264,21 @@ class MethodCompiler { #undef GEN_INSN_ARGS + // Dex cache code generation helper function + llvm::Value* EmitLoadDexCacheAddr(MemberOffset dex_cache_offset); + + void EmitLoadDexCacheCodeAndDirectMethodFieldAddr( + llvm::Value*& code_addr_field_addr, + llvm::Value*& method_field_addr, + uint32_t method_idx); + + llvm::Value* EmitLoadDexCacheStaticStorageFieldAddr(uint32_t type_idx); + + llvm::Value* EmitLoadDexCacheResolvedTypeFieldAddr(uint32_t type_idx); + + llvm::Value* EmitLoadDexCacheStringFieldAddr(uint32_t string_idx); + + // Code generation helper function llvm::Value* EmitLoadMethodObjectAddr(); diff --git a/src/dex_cache.h b/src/dex_cache.h index d87d8de6ce..f748e572fc 100644 --- a/src/dex_cache.h +++ b/src/dex_cache.h @@ -69,13 +69,6 @@ class MANAGED CodeAndDirectMethods : public IntArray { return GetLength() / kMax; } - private: - enum TupleIndex { - kCode = 0, - kMethod = 1, - kMax = 2, - }; - static size_t CodeIndex(uint32_t method_idx) { return method_idx * kMax + kCode; } @@ -83,6 +76,13 @@ class MANAGED CodeAndDirectMethods : public IntArray { return method_idx * kMax + kMethod; } + private: + enum TupleIndex { + kCode = 0, + kMethod = 1, + kMax = 2, + }; + // grant friend status to ImageWriter fixup code that needs to know internal layout friend class ImageWriter; |