summaryrefslogtreecommitdiff
path: root/src/compiler_llvm/ir_builder.cc
diff options
context:
space:
mode:
author Logan Chien <loganchien@google.com> 2012-02-17 18:50:32 +0800
committer Shih-wei Liao <sliao@google.com> 2012-02-20 23:14:10 -0800
commit8dfcbea64ef8c9279329119e42a626771669044d (patch)
tree06245a171b2983b5234b7bd60bef585ddd7e163e /src/compiler_llvm/ir_builder.cc
parentdd110694e0edc27a588a68609c678751593f667f (diff)
Add shadow stack support to Dex compiler.
Change-Id: I8e188be3fb30c81e2a9e6e466264074ddf7b1624
Diffstat (limited to 'src/compiler_llvm/ir_builder.cc')
-rw-r--r--src/compiler_llvm/ir_builder.cc24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/compiler_llvm/ir_builder.cc b/src/compiler_llvm/ir_builder.cc
index 582af65a41..30ed6ecee4 100644
--- a/src/compiler_llvm/ir_builder.cc
+++ b/src/compiler_llvm/ir_builder.cc
@@ -16,6 +16,7 @@
#include "ir_builder.h"
#include "runtime_support_func.h"
+#include "stringprintf.h"
#include <llvm/Module.h>
@@ -39,6 +40,10 @@ IRBuilder::IRBuilder(llvm::LLVMContext& context, llvm::Module& module)
llvm::Type* jenv_struct_type = llvm::StructType::create(context, "JEnv");
jenv_type_ = jenv_struct_type->getPointerTo();
+ // Get Art shadow frame struct type from module
+ art_frame_type_ = module.getTypeByName("ArtFrame");
+ CHECK_NE(art_frame_type_, static_cast<llvm::StructType*>(NULL));
+
// Load the runtime support function declaration from module
InitRuntimeSupportFuncDecl();
}
@@ -179,5 +184,24 @@ llvm::Type* IRBuilder::getJTypeInArraySpace(JType jty) {
}
+llvm::StructType* IRBuilder::getShadowFrameTy(uint32_t sirt_size) {
+ std::string name(StringPrintf("ArtFrame%u", sirt_size));
+
+ // Try to find the existing struct type definition
+ if (llvm::Type* type = module_->getTypeByName(name)) {
+ CHECK(llvm::isa<llvm::StructType>(type));
+ return static_cast<llvm::StructType*>(type);
+ }
+
+ // Create new struct type definition
+ llvm::Type* elem_types[] = {
+ art_frame_type_,
+ llvm::ArrayType::get(jobject_type_, sirt_size),
+ };
+
+ return llvm::StructType::create(elem_types, name);
+}
+
+
} // namespace compiler_llvm
} // namespace art