summaryrefslogtreecommitdiff
path: root/src/compiler_llvm/method_compiler.cc
diff options
context:
space:
mode:
author Shih-wei Liao <sliao@google.com> 2012-02-17 23:50:08 -0800
committer Android (Google) Code Review <android-gerrit@google.com> 2012-02-17 23:50:08 -0800
commit5ca0351b9e9ca60f851ac3a7d65cfdc26d616ab1 (patch)
tree26f8aae1613e471edb91f227ce7b0201030f6a53 /src/compiler_llvm/method_compiler.cc
parent133a0a6d603e5cbe5b4e1a0336dcf756ab5f3fff (diff)
parentbb4d12ac1024f5333e59bc1413f5b05250c4d8c6 (diff)
Merge "Add dex cache codegen helper function." into dalvik-dev
Diffstat (limited to 'src/compiler_llvm/method_compiler.cc')
-rw-r--r--src/compiler_llvm/method_compiler.cc72
1 files changed, 72 insertions, 0 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();