[llvm-commits] CVS: llvm-java/runtime/runtime.c Makefile

Alkis Evlogimenos alkis at cs.uiuc.edu
Mon Sep 13 12:54:22 PDT 2004



Changes in directory llvm-java/runtime:

runtime.c added (r1.1)
Makefile updated: 1.2 -> 1.3
---
Log message:

Modify the vtable struct to reflect the object-layout doc.


---
Diffs of the changes:  (+53 -6)

Index: llvm-java/runtime/runtime.c
diff -c /dev/null llvm-java/runtime/runtime.c:1.1
*** /dev/null	Mon Sep 13 14:54:21 2004
--- llvm-java/runtime/runtime.c	Mon Sep 13 14:54:11 2004
***************
*** 0 ****
--- 1,51 ----
+ struct llvm_java_object_base;
+ struct llvm_java_object_header;
+ struct llvm_java_object_vtable;
+ struct llvm_java_object_typeinfo;
+ 
+ struct llvm_java_object_header {
+   // gc info, hash info, locking
+ };
+ 
+ struct llvm_java_object_base {
+   struct llvm_java_object_header header;
+   struct llvm_java_object_vtable* vtable;
+ };
+ 
+ struct llvm_java_object_typeinfo {
+   unsigned depth;
+   struct llvm_java_object_vtable** vtables;
+   unsigned lastIface;
+   union {
+     struct llvm_java_object_vtable** interfaces;
+     unsigned interfaceFlag;
+   };
+ };
+ 
+ struct llvm_java_object_vtable {
+   struct llvm_java_object_typeinfo typeinfo;
+ };
+ 
+ int llvm_java_IsInstanceOf(struct llvm_java_object_base* obj,
+                            struct llvm_java_object_vtable* clazz) {
+   struct llvm_java_object_vtable* objClazz = obj->vtable;
+   if (objClazz == clazz)
+     return 1;
+   // we are checking against a class' typeinfo
+   if (clazz->typeinfo.interfaceFlag != (unsigned)-1)
+     return objClazz->typeinfo.depth > clazz->typeinfo.depth &&
+            objClazz->typeinfo.vtables[objClazz->typeinfo.depth - clazz->typeinfo.depth - 1] == clazz;
+   // otherwise we are checking against an interface's typeinfo
+   else
+     return objClazz->typeinfo.lastIface >= clazz->typeinfo.lastIface &&
+            objClazz->typeinfo.interfaces[clazz->typeinfo.lastIface];
+ }
+ 
+ extern void llvm_java_static_init(void);
+ extern void llvm_java_main(int, char**);
+ 
+ int main(int argc, char** argv) {
+   llvm_java_static_init();
+   llvm_java_main(argc, argv);
+   return 0;
+ }


Index: llvm-java/runtime/Makefile
diff -u llvm-java/runtime/Makefile:1.2 llvm-java/runtime/Makefile:1.3
--- llvm-java/runtime/Makefile:1.2	Wed Jul 28 05:09:30 2004
+++ llvm-java/runtime/Makefile	Mon Sep 13 14:54:11 2004
@@ -7,11 +7,7 @@
 #
 ##===----------------------------------------------------------------------===##
 LEVEL := ..
+BYTECODE_LIBRARY=1
+LIBRARYNAME=jrt
 
 include $(LEVEL)/Makefile.common
-
-all:: runtime.bc
-
-clean::
-	rm -f *.bc
-






More information about the llvm-commits mailing list