// java-interp.h - Header file for the bytecode interpreter. -*- c++ -*-
-/* Copyright (C) 1999 Cygnus Solutions
+/* Copyright (C) 1999, 2000 Red Hat, Inc.
This file is part of libgcj.
#ifndef __JAVA_INTERP_H__
#define __JAVA_INTERP_H__
-#include <config.h>
-
#include <jvm.h>
#include <java-cpool.h>
friend class _Jv_InterpMethod;
};
-class _Jv_InterpMethod {
+// Base class for method representations. Subclasses are interpreted
+// and JNI methods.
+class _Jv_MethodBase
+{
+protected:
+ // The class which defined this method.
+ _Jv_InterpClass *defining_class;
+
+ // The method description.
+ _Jv_Method *self;
+ // Size of raw arguments.
+ _Jv_ushort args_raw_size;
+
+public:
+ _Jv_Method *get_method ()
+ {
+ return self;
+ }
+};
+
+class _Jv_InterpMethod : public _Jv_MethodBase
+{
_Jv_ushort max_stack;
_Jv_ushort max_locals;
int code_length;
_Jv_ushort exc_count;
- _Jv_ushort args_raw_size;
-
- _Jv_InterpClass *defining_class;
- _Jv_Method *self;
unsigned char* bytecode ()
{
class _Jv_InterpClass : public java::lang::Class
{
- _Jv_InterpMethod **interpreted_methods;
+ _Jv_MethodBase **interpreted_methods;
_Jv_ushort *field_initializers;
friend class _Jv_ClassReader;
friend void _Jv_PrepareClass(jclass);
friend void _Jv_InitField (jobject, jclass, int);
friend void* _Jv_MarkObj (void *, void *, void *, void *);
+
+ friend _Jv_MethodBase ** _Jv_GetFirstMethod (_Jv_InterpClass *klass);
};
+extern inline _Jv_MethodBase **
+_Jv_GetFirstMethod (_Jv_InterpClass *klass)
+{
+ return klass->interpreted_methods;
+}
+
struct _Jv_ResolvedMethod {
jint stack_item_count;
jint vtable_index;
ffi_type * arg_types[0];
};
+class _Jv_JNIMethod : public _Jv_MethodBase
+{
+ // The underlying function. If NULL we have to look for the
+ // function.
+ void *function;
+
+ // This is the CIF used by the JNI function.
+ ffi_cif jni_cif;
+
+ // These are the argument types used by the JNI function.
+ ffi_type **jni_arg_types;
+
+ // This function is used when making a JNI call from the interpreter.
+ static void call (ffi_cif *, void *, ffi_raw *, void *);
+
+ void *ncode ();
+
+ friend class _Jv_ClassReader;
+ friend void _Jv_PrepareClass(jclass);
+
+public:
+ // FIXME: this is ugly.
+ void set_function (void *f)
+ {
+ function = f;
+ }
+};
+
#endif /* INTERPRETER */
#endif /* __JAVA_INTERP_H__ */