Merged revisions 7766-7796 via svnmerge from
[cacao.git] / src / vm / builtin.h
index 32c0bc834d7e68dda0f4c99aa67c10bdbb4ec414..e77ef882b0332c795a227b3bdc8d8707a867337c 100644 (file)
@@ -1,6 +1,6 @@
 /* src/vm/builtin.h - prototypes of builtin functions
 
-   Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel,
+   Copyright (C) 1996-2005, 2006, 2007 R. Grafl, A. Krall, C. Kruegel,
    C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
    E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
    J. Wenninger, Institut f. Computersprachen - TU Wien
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   Contact: cacao@cacaojvm.org
-
-   Authors: Reinhard Grafl
-
-   Changes: Edwin Steiner
-            Christian Thalinger
-
-   $Id: builtin.h 4357 2006-01-22 23:33:38Z twisti $
+   $Id: builtin.h 7797 2007-04-23 20:12:39Z michi $
 
 */
 
 #define _BUILTIN_H
 
 #include "config.h"
+#include "vm/types.h"
 
 #include "arch.h"
-#include "toolbox/logging.h"
+#include "md-abi.h"
 
-#if defined(USE_THREADS)
-# if defined(NATIVE_THREADS)
-#  include "threads/native/threads.h"
-# else
-#  include "threads/green/threads.h"
-# endif
-#endif
+#include "toolbox/logging.h"
 
-#include "vm/jit/stacktrace.h"
+#include "vmcore/utf8.h"
 
 
 /* define infinity for floating point numbers */
@@ -80,13 +68,25 @@ typedef struct builtintable_entry builtintable_entry;
 
 struct builtintable_entry {
        s4           opcode;                /* opcode which is replaced           */
+       u4           flags;                 /* e.g. check for exception           */
        functionptr  fp;                    /* function pointer of builtin        */
-       char        *descriptor;
-       char        *name;
+       u1          *stub;                  /* pointer to builtin stub code       */
+       char        *cclassname;            /* char name of the class             */
+       char        *cname;                 /* char name of the function          */
+       char        *cdescriptor;           /* char name of the descriptor        */
+       utf         *classname;             /* class of the function              */
+       utf         *name;                  /* name of the function               */
+       utf         *descriptor;            /* descriptor of the function         */
        methoddesc  *md;
 };
 
 
+/* builtin table flag defines *************************************************/
+
+#define BUILTINTABLE_FLAG_STUB         0x0001 /* builtin needs a stub         */
+#define BUILTINTABLE_FLAG_EXCEPTION    0x0002 /* check for excepion on return */
+
+
 /* function prototypes ********************************************************/
 
 bool builtin_init(void);
@@ -94,6 +94,8 @@ bool builtin_init(void);
 builtintable_entry *builtintable_get_internal(functionptr fp);
 builtintable_entry *builtintable_get_automatic(s4 opcode);
 
+bool builtintable_replace_function(void *iptr);
+
 
 /**********************************************************************/
 /* BUILTIN FUNCTIONS                                                  */
@@ -122,10 +124,6 @@ builtintable_entry *builtintable_get_automatic(s4 opcode);
 
 s4 builtin_instanceof(java_objectheader *obj, classinfo *class);
 #define BUILTIN_instanceof (functionptr) builtin_instanceof
-s4 builtin_isanysubclass (classinfo *sub, classinfo *super);
-/* NOT AN OP */
-s4 builtin_isanysubclass_vftbl (vftbl_t *sub, vftbl_t *super);
-/* NOT AN OP */
 s4 builtin_checkcast(java_objectheader *obj, classinfo *class);
 /* NOT AN OP */
 s4 builtin_arrayinstanceof(java_objectheader *o, classinfo *targetclass);
@@ -133,7 +131,7 @@ s4 builtin_arrayinstanceof(java_objectheader *o, classinfo *targetclass);
 s4 builtin_arraycheckcast(java_objectheader *o, classinfo *targetclass);
 #define BUILTIN_arraycheckcast (functionptr) builtin_arraycheckcast
 
-java_objectheader *builtin_throw_exception(java_objectheader *exception);
+void *builtin_throw_exception(java_objectheader *exception);
 /* NOT AN OP */
 java_objectheader *builtin_trace_exception(java_objectheader *xptr,
                                                                                   methodinfo *m,
@@ -143,6 +141,8 @@ java_objectheader *builtin_trace_exception(java_objectheader *xptr,
 
 java_objectheader *builtin_new(classinfo *c);
 #define BUILTIN_new (functionptr) builtin_new
+java_objectheader *builtin_fast_new(classinfo *c);
+#define BUILTIN_FAST_new (functionptr) builtin_fast_new
 
 java_arrayheader *builtin_newarray(s4 size, classinfo *arrayclass);
 #define BUILTIN_newarray (functionptr) builtin_newarray
@@ -175,32 +175,23 @@ s4 builtin_canstore(java_objectarray *oa, java_objectheader *o);
 #define BUILTIN_canstore (functionptr) builtin_canstore
 
 #if defined(TRACE_ARGS_NUM)
-void builtin_trace_args(s8 a0, s8 a1,
-#if TRACE_ARGS_NUM >= 4
-                                               s8 a2, s8 a3,
-#endif /* TRACE_ARGS_NUM >= 4 */
-#if TRACE_ARGS_NUM >= 6
-                                               s8 a4, s8 a5,
-#endif /* TRACE_ARGS_NUM >= 6 */
-#if TRACE_ARGS_NUM == 8
-                                               s8 a6, s8 a7,
-#endif /* TRACE_ARGS_NUM == 8 */
-                                               methodinfo *m);
+void builtin_verbosecall_enter(s8 a0, s8 a1,
+# if TRACE_ARGS_NUM >= 4
+                                                          s8 a2, s8 a3,
+# endif
+# if TRACE_ARGS_NUM >= 6
+                                                          s8 a4, s8 a5,
+# endif
+# if TRACE_ARGS_NUM == 8
+                                                          s8 a6, s8 a7,
+# endif
+                                                          methodinfo *m);
 /* NOT AN OP */
 #endif /* defined(TRACE_ARGS_NUM) */
 
-void builtin_displaymethodstop(methodinfo *m, s8 l, double d, float f);
+void builtin_verbosecall_exit(s8 l, double d, float f, methodinfo *m);
 /* NOT AN OP */
 
-#if defined(USE_THREADS)
-void builtin_monitorenter(java_objectheader *o);
-#define BUILTIN_monitorenter (functionptr) builtin_monitorenter
-void builtin_staticmonitorenter(classinfo *c);
-#define BUILTIN_staticmonitorenter (functionptr) builtin_staticmonitorenter
-void builtin_monitorexit(java_objectheader *o);
-#define BUILTIN_monitorexit (functionptr) builtin_monitorexit
-#endif
-
 s4 builtin_idiv(s4 a, s4 b);
 #define BUILTIN_idiv (functionptr) builtin_idiv
 s4 builtin_irem(s4 a, s4 b);
@@ -306,19 +297,18 @@ s8       asm_builtin_d2l(double a);
 float    builtin_d2f(double a);
 #define BUILTIN_d2f (functionptr) builtin_d2f
 
-java_arrayheader *builtin_clone_array(void *env, java_arrayheader *o);
-/* NOT AN OP */
+java_objectheader *builtin_clone(void *env, java_objectheader *o);
+#define BUILTIN_clone (functionptr) builtin_clone
 
-/* this is a wrapper for calls from asmpart */
-java_objectheader **builtin_asm_get_exceptionptrptr(void);
+bool builtin_arraycopy(java_arrayheader *src, s4 srcStart,
+                                          java_arrayheader *dest, s4 destStart, s4 len);
+#define BUILTIN_arraycopy (functionptr) builtin_arraycopy
 
-#if defined(USE_THREADS) && defined(NATIVE_THREADS)
-static inline java_objectheader **builtin_get_exceptionptrptr(void);
+s8 builtin_currenttimemillis(void);
+#define BUILTIN_currenttimemillis (functionptr) builtin_currenttimemillis
 
-inline java_objectheader **builtin_get_exceptionptrptr(void)
-{
-       return &THREADINFO->_exceptionptr;
-}
+#if defined(ENABLE_CYCLES_STATS)
+void builtin_print_cycles_stats(FILE *file);
 #endif
 
 #endif /* _BUILTIN_H */