From 6f2f47c40cd8695beee26e98e1aa913e47bd6530 Mon Sep 17 00:00:00 2001 From: Yiteng Guo Date: Tue, 17 Dec 2019 03:08:36 -0500 Subject: [PATCH] explicitly specify classinfo type in llvm --- .../src/jlang/extension/JLangClassDeclExt.java | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/compiler/src/jlang/extension/JLangClassDeclExt.java b/compiler/src/jlang/extension/JLangClassDeclExt.java index ed58d895..6ceee55d 100644 --- a/compiler/src/jlang/extension/JLangClassDeclExt.java +++ b/compiler/src/jlang/extension/JLangClassDeclExt.java @@ -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( @@ -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);