Skip to content

Commit

Permalink
explicitly specify classinfo type in llvm
Browse files Browse the repository at this point in the history
  • Loading branch information
guoyiteng committed Dec 18, 2019
1 parent 3b1fec0 commit 6f2f47c
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion compiler/src/jlang/extension/JLangClassDeclExt.java
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,22 @@ public static void buildClassLoadingFunc(LLVMTranslator v, ClassType ct, ClassBo
.map(intf -> v.utils.getClassObjectGlobal(intf))
.toArray(LLVMValueRef[]::new);

LLVMTypeRef classInfoType = v.utils.structType(
v.utils.i8Ptr(), // char* name
v.utils.ptrTypeRef(classType), // jclass*
v.utils.i8Ptr(), // void*
v.utils.i64(), // obj_size
v.utils.i8() , // jboolean
v.utils.i32(), // int32_t
v.utils.ptrTypeRef(v.utils.ptrTypeRef(classType)), // jclass **
v.utils.i32(), // int32_t
v.utils.ptrTypeRef(fieldInfoType), // JavaFieldInfo*
v.utils.i32(), // int32_t
v.utils.ptrTypeRef(staticFieldType), // JavaStaticFieldInfo*
v.utils.i32(), // int32_t
v.utils.ptrTypeRef(methodInfoType) // JavaMethodInfo*
);

// This layout must precisely mirror the layout defined in the runtime (class.cpp).
LLVMValueRef classInfo = v.utils.buildConstStruct(

Expand Down Expand Up @@ -182,7 +198,7 @@ public static void buildClassLoadingFunc(LLVMTranslator v, ClassType ct, ClassBo

// Emit class info as a global variable.
String classInfoMangled = v.mangler.classInfoGlobal(ct);
LLVMValueRef classInfoGlobal = v.utils.getGlobal(classInfoMangled, LLVMTypeOf(classInfo));
LLVMValueRef classInfoGlobal = v.utils.getGlobal(classInfoMangled, classInfoType);
LLVMSetInitializer(classInfoGlobal, classInfo);
LLVMSetGlobalConstant(classInfoGlobal, 1);
LLVMSetLinkage(classInfoGlobal, LLVMPrivateLinkage);
Expand Down

0 comments on commit 6f2f47c

Please sign in to comment.