diff options
author | green <green@138bc75d-0d04-0410-961f-82ee72b054a4> | 1999-08-08 14:06:23 +0000 |
---|---|---|
committer | green <green@138bc75d-0d04-0410-961f-82ee72b054a4> | 1999-08-08 14:06:23 +0000 |
commit | 9a6624c49770e9b5e630a7c51eb0a13002d9df83 (patch) | |
tree | 277498eeeff558237a9cd88b0ea8b3788b31d645 /libjava/include | |
parent | 47c5fab6136c7525f4abe013644d7d20570d1b94 (diff) | |
download | gcc-9a6624c49770e9b5e630a7c51eb0a13002d9df83.tar.gz |
1999-08-09 Anthony Green <green@cygnus.com>
* gij.cc: New file.
* include/config.h.in: Rebuilt.
* acconfig.h: Add INTERPRETER.
* configure: Rebuilt.
* Makefile.in: Rebuilt.
* Makefile.am (libffi_files): Identify the libffi object files for
inclusion in libgcj.
(LIBFFIINCS): Define.
* interpret.cc (gnu::gcj::runtime::MethodInvocation::continue1):
Dummy definition for configurations without an interpreter.
* java/net/natPlainSocketImpl.cc (getOption): Disamiguate call to
java::lang::Boolean constructor.
* include/java-interp.h: Always include java-cpool.h.
* java/lang/natClassLoader.cc (getVMClassLoader0): Always return 0
when INTERPRETER not defined.
* java/lang/Class.h (finalize): Define.
* gnu/gcj/util/path/DirectoryPathEntry.java (getURL): Catch
IOException from File.getCanonicalPath.
(getStream): Likewise.
* NEWS: More news.
* THANKS: More thanks.
1999-08-09 Kresten Krab Thorup <krab@gnu.org>
* resolve.cc (get_ffi_type_from_signature): Generate uint16 for
jchar type.
(_Jv_PrepareClass): Allow non-abstract classes to
have abstract subclasses.
(_Jv_ResolvePoolEntry): Revert subclass check for protected
fields and methods.
* interpret.cc (continue1/perform_invoke): Don't sign extend
uint16 return val.
(continue1/lshl,lshr): Push long, not int.
(continue1/ulshr): Use UINT64, not long long.
* defineclass.cc (handleFieldsEnd): Handle case when all fields
are static.
* java/lang/natClass.cc (forName): Add call to _Jv_InitClass.
* java/lang/FirstThread.java (run): Add top-level exception
handler.
(run0): Renamed from run.
1999-08-08 Kresten Krab Thorup <krab@gnu.org>
* configure.in (--with-interpreter): Added.
* include/config.h.in (INTERPRETER): Added.
* java/lang/ClassLoader.java: File replaced.
* java/lang/VMClassLoader.java: New file.
* java/lang/natClassLoader.cc: New file.
* gnu/gcj/runtime/MethodInvocation.java: New file.
* gnu/gcj/util/path/SearchPath.java: New file.
* gnu/gcj/util/path/PathEntry.java: New file.
* gnu/gcj/util/path/DirectoryPathEntry.java: New file.
* gnu/gcj/util/path/ZipPathEntry.java: New file.
* gnu/gcj/util/path/URLPathEntry.java: New file.
* gnu/gcj/util/path/CacheEntry.java: New file.
* include/java-interp.h: New file.
* include/java-cpool.h: New file.
* include/java-insns.h: New file.
* defineclass.cc: New file.
* interpret.cc: New file.
* resolve.cc: New file.
* java/lang/natClass.cc (loaded_classes, _Jv_RegisterClass,
_Jv_RegisterClasses, _Jv_FindClassInCache, _Jv_FindClass,
_Jv_NewClass, _Jv_FindArrayClass): Moved to natClassLoader.cc.
(finalize): New.
(STATE_NOTHING, STATE_RESOLVED, STATE_IN_PROGRESS, STATE_DONE,
STATE_ERROR): Moved to java/lang/Class.h and renamed with JV_
prefix.
(initializeClass): Use new JV_ prefixed names. Also, call
ClassLoader::resolveClass instead of _Jv_ResolveClass.
* java/lang/Class.h (JV_STATE_PRELOADING, JV_STATE_LOADING,
JV_STATE_LOADED, JV_STATE_COMPILED, JV_STATE_PREPARED,
JV_STATE_LINKED): New.
(_Jv_WaitForState, _Jv_RegisterInitiatingLoader,
_Jv_UnregisterClass, _Jv_InternClassStrings): New friends.
(_Jv_IsInterpretedClass, _Jv_InitField, _Jv_LookupDeclaredMethod,
_Jv_DetermineVTableIndex, _Jv_ResolvePoolEntry, _Jv_PrepareClass,
_Jv_ClassReader, _Jv_InterpClass, _Jv_InterpMethod,
_Jv_InterpMethodInvocation): New friends for interpreter.
(finalize): New.
(CONSTANT_Class, CONSTANT_String, etc.): Moved to
include/java-cpool.h and renamed with JV_ prefix.
* include/jvm.h (_Jv_makeUtf8Const, _Jv_makeUtf8TypeConst): New
decls.
(_Jv_UnregisterClass): New decl.
* java/lang/natClassLoader.cc (_Jv_FindArrayClass): Added
class loader argument.
(_Jv_FindClass): Use class loader.
* prims.cc (_Jv_makeUtf8Const): New function.
(_Jv_NewObjectArray): Change use of _Jv_FindArrayClass.
(_Jv_NewPrimArray): Ditto.
(_Jv_FindClassFromSignature): Ditto.
* java/lang/reflect/natArray.cc (newInstance): Ditto.
* java/lang/reflect/natMethod.cc (getType): Ditto.
* include/java-field.h (_Jv_Field::isRef): Make robust for
non-resolved contexts.
* boehm.cc (_Jv_MarkObj): Mark interpreter-related fields.
Also, don't mark class->next field.
* java/lang/VirtualMachineError.java: Added FIXME note.
* configure.in (INTERPSPEC): New spec.
* libgcj.spec.in: Added INTERPSPEC.
* Makefile.am: Added gcjh friends for java/lang/VMClassLoader and
gnu/gcj/runtime/MethodInvocation.
(libgcj_la_SOURCES): Added resolve.cc defineclass.cc interpret.cc.
(ordinary_java_source_files): Added above mentioned java classes.
* configure: Rebuilt.
* Makefile.in: Rebuilt.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@28597 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libjava/include')
-rw-r--r-- | libjava/include/config.h.in | 3 | ||||
-rw-r--r-- | libjava/include/java-cpool.h | 173 | ||||
-rw-r--r-- | libjava/include/java-field.h | 13 | ||||
-rw-r--r-- | libjava/include/java-insns.h | 247 | ||||
-rw-r--r-- | libjava/include/java-interp.h | 172 | ||||
-rw-r--r-- | libjava/include/javaprims.h | 1 | ||||
-rw-r--r-- | libjava/include/jvm.h | 4 |
7 files changed, 612 insertions, 1 deletions
diff --git a/libjava/include/config.h.in b/libjava/include/config.h.in index d9b9a0a9cf8..03f51baca78 100644 --- a/libjava/include/config.h.in +++ b/libjava/include/config.h.in @@ -106,6 +106,9 @@ #undef HAVE_GETHOSTBYNAME_R #undef HAVE_GETHOSTBYADDR_R +/* Define if you want a bytecode interpreter. */ +#undef INTERPRETER + /* Define if you have the access function. */ #undef HAVE_ACCESS diff --git a/libjava/include/java-cpool.h b/libjava/include/java-cpool.h new file mode 100644 index 00000000000..f4d7ef9910a --- /dev/null +++ b/libjava/include/java-cpool.h @@ -0,0 +1,173 @@ +// java-cpool.h - Constant pool parsing header. -*- c++ -*- + +/* Copyright (C) 1999 Cygnus Solutions + + This file is part of libgcj. + +This software is copyrighted work licensed under the terms of the +Libgcj License. Please consult the file "LIBGCJ_LICENSE" for +details. */ + +#ifndef __JAVA_CPOOL_H__ +#define __JAVA_CPOOL_H__ + +#include <javaprims.h> + +// we rename these, to avoid polluting the name space +#define JV_CONSTANT_Undefined (0L) +#define JV_CONSTANT_Utf8 (1L) +#define JV_CONSTANT_Unicode (2L) +#define JV_CONSTANT_Integer (3L) +#define JV_CONSTANT_Float (4L) +#define JV_CONSTANT_Long (5L) +#define JV_CONSTANT_Double (6L) +#define JV_CONSTANT_Class (7L) +#define JV_CONSTANT_String (8L) +#define JV_CONSTANT_Fieldref (9L) +#define JV_CONSTANT_Methodref (10L) +#define JV_CONSTANT_InterfaceMethodref (11L) +#define JV_CONSTANT_NameAndType (12L) +#define JV_CONSTANT_ResolvedFlag (16L) +#define JV_CONSTANT_ResolvedString (16L | 8L) +#define JV_CONSTANT_ResolvedClass (16L | 7L) + +/* We use the following two operations uniformly for all put/get operations + * in the runtime system (constant pool & stack), to assure that we keep + * everything in the same format. The idea is, that these should be inlined + * away, into just a simple store (for small data types, and a pair of stores + * if double or long has alignment greater than void *. On an 64-bit + * architecture, all operations should be simple stores; on a 32-bit + * architecture it depends on the alignment requirement for the specific + * type. */ + +template <class T> +static inline void _Jv_put (void *dst, T value) +{ +#if 0 + if (sizeof (T) == 8 && __alignof__ (T) > __alignof__ (void*)) + { + jint *v_dst = (jint*)(dst); + jint *v_src = (jint*)&value; + + v_dst[0] = v_src[0]; + v_dst[1] = v_src[1]; + } + else +#endif + { + *((T*) (dst)) = value; + } +} + +template <class T> +static inline T _Jv_get (void *src) +{ +#if 0 + if (sizeof (T) == 8 && __alignof__ (T) > __alignof__ (void*)) + { + T value; + jint *v_dst = (jint*)&value; + jint *v_src = (jint*)src; + + v_dst[0] = v_src[0]; + v_dst[1] = v_src[1]; + + return value; + } + else +#endif + { + return *((T*) (src)); + } +} + +/** needed to keep the CONSTANT_XXXRef & CONSTANT_NameAndType entries */ +extern inline void +_Jv_storeIndexes (void **data, + _Jv_ushort index0, + _Jv_ushort index1) +{ + // accomodate 64bit machines... + if (sizeof (void*) == (2 * sizeof (jint))) + { + ((jint*)data)[0] = index0; + ((jint*)data)[1] = index0; + } + else + { + _Jv_put<jint>(data, ((jint)index0 << 16) | (jint)index1); + } +} + +extern inline void +_Jv_loadIndexes (const void **data, + _Jv_ushort& index0, + _Jv_ushort& index1) +{ + if (sizeof (void*) == (2*sizeof (jint))) + { + index0 = ((jint*)data)[0]; + index0 = ((jint*)data)[1]; + } + else + { + jint udata = _Jv_get<jint>(data); + + _Jv_uint uindex0 = ((udata >> 16) & 0xffff); + _Jv_uint uindex1 = udata & 0xffff; + + index0 = uindex0; + index1 = uindex1; + } +} + +extern inline void +_Jv_storeFloat (void **data, jfloat f) +{ + _Jv_put<jfloat>(data, f); +} + +extern inline jfloat +_Jv_loadFloat (void **data) +{ + return _Jv_get<jfloat>(data); +} + +extern inline void +_Jv_storeInt (void **data, jint i) +{ + _Jv_put<jint>(data, i); +} + +extern inline jint +_Jv_loadInt (void **data) +{ + return _Jv_get<jint>(data); +} + +extern inline void +_Jv_storeLong (void **data, jlong l) +{ + return _Jv_put<jlong>(data, l); +} + +extern inline jlong +_Jv_loadLong (void **data) +{ + return _Jv_get<jlong>(data); +} + +extern inline void +_Jv_storeDouble (void **data, jdouble d) +{ + _Jv_put<jdouble>(data, d); +} + +extern inline jdouble +_Jv_loadDouble (void **data) +{ + return _Jv_get<jdouble> (data); +} + + +#endif /* __JAVA_CPOOL_H__ */ diff --git a/libjava/include/java-field.h b/libjava/include/java-field.h index b4529fca30a..d00d9ce7726 100644 --- a/libjava/include/java-field.h +++ b/libjava/include/java-field.h @@ -53,7 +53,18 @@ struct _Jv_Field jfieldID getNextInstanceField () { return this + 1; } - jboolean isRef () { return ! isResolved () || ! type->isPrimitive (); } + jboolean isRef () + { + if (!isResolved ()) + { + char first = ((_Jv_Utf8Const*)type)->data[0]; + return first == '[' || first == 'L'; + } + else + { + return ! type->isPrimitive (); + } + } // FIXME - may need to mask off internal flags. int getModifiers() { return flags; } diff --git a/libjava/include/java-insns.h b/libjava/include/java-insns.h new file mode 100644 index 00000000000..8b19abd58ad --- /dev/null +++ b/libjava/include/java-insns.h @@ -0,0 +1,247 @@ +// java-insns.h - Instruction encodings. This is -*- c++ -*- + +/* Copyright (C) 1999 Cygnus Solutions + + This file is part of libgcj. + +This software is copyrighted work licensed under the terms of the +Libgcj License. Please consult the file "LIBGCJ_LICENSE" for +details. */ + +static const int op_nop = 0x00; +static const int op_aconst_null = 0x01; +static const int op_iconst_m1 = 0x02; +static const int op_iconst_0 = 0x03; +static const int op_iconst_1 = 0x04; +static const int op_iconst_2 = 0x05; +static const int op_iconst_3 = 0x06; +static const int op_iconst_4 = 0x07; +static const int op_iconst_5 = 0x08; +static const int op_lconst_0 = 0x09; +static const int op_lconst_1 = 0x0a; +static const int op_fconst_0 = 0x0b; +static const int op_fconst_1 = 0x0c; +static const int op_fconst_2 = 0x0d; +static const int op_dconst_0 = 0x0e; +static const int op_dconst_1 = 0x0f; +static const int op_bipush = 0x10; +static const int op_sipush = 0x11; +static const int op_ldc = 0x12; +static const int op_ldc_w = 0x13; +static const int op_ldc2_w = 0x14; +static const int op_iload = 0x15; +static const int op_lload = 0x16; +static const int op_fload = 0x17; +static const int op_dload = 0x18; +static const int op_aload = 0x19; +static const int op_iload_0 = 0x1a; +static const int op_iload_1 = 0x1b; +static const int op_iload_2 = 0x1c; +static const int op_iload_3 = 0x1d; +static const int op_lload_0 = 0x1e; +static const int op_lload_1 = 0x1f; +static const int op_lload_2 = 0x20; +static const int op_lload_3 = 0x21; +static const int op_fload_0 = 0x22; +static const int op_fload_1 = 0x23; +static const int op_fload_2 = 0x24; +static const int op_fload_3 = 0x25; +static const int op_dload_0 = 0x26; +static const int op_dload_1 = 0x27; +static const int op_dload_2 = 0x28; +static const int op_dload_3 = 0x29; +static const int op_aload_0 = 0x2a; +static const int op_aload_1 = 0x2b; +static const int op_aload_2 = 0x2c; +static const int op_aload_3 = 0x2d; +static const int op_iaload = 0x2e; +static const int op_laload = 0x2f; +static const int op_faload = 0x30; +static const int op_daload = 0x31; +static const int op_aaload = 0x32; +static const int op_baload = 0x33; +static const int op_caload = 0x34; +static const int op_saload = 0x35; +static const int op_istore = 0x36; +static const int op_lstore = 0x37; +static const int op_fstore = 0x38; +static const int op_dstore = 0x39; +static const int op_astore = 0x3a; +static const int op_istore_0 = 0x3b; +static const int op_istore_1 = 0x3c; +static const int op_istore_2 = 0x3d; +static const int op_istore_3 = 0x3e; +static const int op_lstore_0 = 0x3f; +static const int op_lstore_1 = 0x40; +static const int op_lstore_2 = 0x41; +static const int op_lstore_3 = 0x42; +static const int op_fstore_0 = 0x43; +static const int op_fstore_1 = 0x44; +static const int op_fstore_2 = 0x45; +static const int op_fstore_3 = 0x46; +static const int op_dstore_0 = 0x47; +static const int op_dstore_1 = 0x48; +static const int op_dstore_2 = 0x49; +static const int op_dstore_3 = 0x4a; +static const int op_astore_0 = 0x4b; +static const int op_astore_1 = 0x4c; +static const int op_astore_2 = 0x4d; +static const int op_astore_3 = 0x4e; +static const int op_iastore = 0x4f; +static const int op_lastore = 0x50; +static const int op_fastore = 0x51; +static const int op_dastore = 0x52; +static const int op_aastore = 0x53; +static const int op_bastore = 0x54; +static const int op_castore = 0x55; +static const int op_sastore = 0x56; +static const int op_pop = 0x57; +static const int op_pop2 = 0x58; +static const int op_dup = 0x59; +static const int op_dup_x1 = 0x5a; +static const int op_dup_x2 = 0x5b; +static const int op_dup2 = 0x5c; +static const int op_dup2_x1 = 0x5d; +static const int op_dup2_x2 = 0x5e; +static const int op_swap = 0x5f; +static const int op_iadd = 0x60; +static const int op_ladd = 0x61; +static const int op_fadd = 0x62; +static const int op_dadd = 0x63; +static const int op_isub = 0x64; +static const int op_lsub = 0x65; +static const int op_fsub = 0x66; +static const int op_dsub = 0x67; +static const int op_imul = 0x68; +static const int op_lmul = 0x69; +static const int op_fmul = 0x6a; +static const int op_dmul = 0x6b; +static const int op_idiv = 0x6c; +static const int op_ldiv = 0x6d; +static const int op_fdiv = 0x6e; +static const int op_ddiv = 0x6f; +static const int op_irem = 0x70; +static const int op_lrem = 0x71; +static const int op_frem = 0x72; +static const int op_drem = 0x73; +static const int op_ineg = 0x74; +static const int op_lneg = 0x75; +static const int op_fneg = 0x76; +static const int op_dneg = 0x77; +static const int op_ishl = 0x78; +static const int op_lshl = 0x79; +static const int op_ishr = 0x7a; +static const int op_lshr = 0x7b; +static const int op_iushr = 0x7c; +static const int op_lushr = 0x7d; +static const int op_iand = 0x7e; +static const int op_land = 0x7f; +static const int op_ior = 0x80; +static const int op_lor = 0x81; +static const int op_ixor = 0x82; +static const int op_lxor = 0x83; +static const int op_iinc = 0x84; +static const int op_i2l = 0x85; +static const int op_i2f = 0x86; +static const int op_i2d = 0x87; +static const int op_l2i = 0x88; +static const int op_l2f = 0x89; +static const int op_l2d = 0x8a; +static const int op_f2i = 0x8b; +static const int op_f2l = 0x8c; +static const int op_f2d = 0x8d; +static const int op_d2i = 0x8e; +static const int op_d2l = 0x8f; +static const int op_d2f = 0x90; +static const int op_i2b = 0x91; +static const int op_i2c = 0x92; +static const int op_i2s = 0x93; +static const int op_lcmp = 0x94; +static const int op_fcmpl = 0x95; +static const int op_fcmpg = 0x96; +static const int op_dcmpl = 0x97; +static const int op_dcmpg = 0x98; +static const int op_ifeq = 0x99; +static const int op_ifne = 0x9a; +static const int op_iflt = 0x9b; +static const int op_ifge = 0x9c; +static const int op_ifgt = 0x9d; +static const int op_ifle = 0x9e; +static const int op_if_icmpeq = 0x9f; +static const int op_if_icmpne = 0xa0; +static const int op_if_icmplt = 0xa1; +static const int op_if_icmpge = 0xa2; +static const int op_if_icmpgt = 0xa3; +static const int op_if_icmple = 0xa4; +static const int op_if_acmpeq = 0xa5; +static const int op_if_acmpne = 0xa6; +static const int op_goto = 0xa7; +static const int op_jsr = 0xa8; +static const int op_ret = 0xa9; +static const int op_tableswitch = 0xaa; +static const int op_lookupswitch = 0xab; +static const int op_ireturn = 0xac; +static const int op_lreturn = 0xad; +static const int op_freturn = 0xae; +static const int op_dreturn = 0xaf; +static const int op_areturn = 0xb0; +static const int op_return = 0xb1; +static const int op_getstatic = 0xb2; +static const int op_putstatic = 0xb3; +static const int op_getfield = 0xb4; +static const int op_putfield = 0xb5; +static const int op_invokevirtual = 0xb6; +static const int op_invokespecial = 0xb7; +static const int op_invokestatic = 0xb8; +static const int op_invokeinterface = 0xb9; +static const int op_xxxunusedxxx1 = 0xba; +static const int op_new = 0xbb; +static const int op_newarray = 0xbc; +static const int op_anewarray = 0xbd; +static const int op_arraylength = 0xbe; +static const int op_athrow = 0xbf; +static const int op_checkcast = 0xc0; +static const int op_instanceof = 0xc1; +static const int op_monitorenter = 0xc2; +static const int op_monitorexit = 0xc3; +static const int op_wide = 0xc4; +static const int op_multianewarray = 0xc5; +static const int op_ifnull = 0xc6; +static const int op_ifnonnull = 0xc7; +static const int op_goto_w = 0xc8; +static const int op_jsr_w = 0xc9; + +// new opcodes + +static const int op_putfield_1 = 0xca; +static const int op_putfield_2 = 0xcb; +static const int op_putfield_4 = 0xcd; +static const int op_putfield_8 = 0xce; +static const int op_putfield_a = 0xcf; + +static const int op_putstatic_1 = 0xd0; +static const int op_putstatic_2 = 0xd1; +static const int op_putstatic_4 = 0xd2; +static const int op_putstatic_8 = 0xd3; +static const int op_putstatic_a = 0xd4; + +static const int op_getfield_1 = 0xd5; +static const int op_getfield_2s = 0xd6; +static const int op_getfield_2u = 0xd7; +static const int op_getfield_4 = 0xd8; +static const int op_getfield_8 = 0xd9; +static const int op_getfield_a = 0xda; + +static const int op_getstatic_1 = 0xdb; +static const int op_getstatic_2s = 0xdc; +static const int op_getstatic_2u = 0xdd; +static const int op_getstatic_4 = 0xde; +static const int op_getstatic_8 = 0xdf; +static const int op_getstatic_a = 0xe0; + +static const int op_invokefinal = 0xe1; +static const int op_invokevtable = 0xe2; + + + + diff --git a/libjava/include/java-interp.h b/libjava/include/java-interp.h new file mode 100644 index 00000000000..70feec19beb --- /dev/null +++ b/libjava/include/java-interp.h @@ -0,0 +1,172 @@ +// java-interp.h - Header file for the bytecode interpreter. -*- c++ -*- + +/* Copyright (C) 1999 Cygnus Solutions + + This file is part of libgcj. + +This software is copyrighted work licensed under the terms of the +Libgcj License. Please consult the file "LIBGCJ_LICENSE" for +details. */ + +#ifndef __JAVA_INTERP_H__ +#define __JAVA_INTERP_H__ + +#include <config.h> + +#include <jvm.h> +#include <java-cpool.h> + +#ifdef INTERPRETER + +#pragma interface + +#include <java/lang/Class.h> +#include <java/lang/ClassLoader.h> +#include <gnu/gcj/runtime/MethodInvocation.h> + +extern "C" { +#include <ffi.h> +} + +extern inline jboolean +_Jv_IsInterpretedClass (jclass c) +{ + return (c->loader != 0); +} + +struct _Jv_ResolvedMethod; + +void _Jv_VerifyFieldSignature (_Jv_Utf8Const*sig); +void _Jv_VerifyMethodSignature (_Jv_Utf8Const*sig); +void _Jv_VerifyClassName (unsigned char* ptr, _Jv_ushort length); +void _Jv_VerifyClassName (_Jv_Utf8Const *name); +void _Jv_VerifyIdentifier (_Jv_Utf8Const *); +bool _Jv_ClassNameSamePackage (_Jv_Utf8Const *name1, _Jv_Utf8Const *name2); +void _Jv_DefineClass (jclass, jbyteArray, jint, jint); +void _Jv_ResolveField (_Jv_Field *, java::lang::ClassLoader*); + +void _Jv_InitField (jobject, jclass, int); +void * _Jv_AllocMethodInvocation (jsize size); + +/* FIXME: this should really be defined in some more generic place */ +#define ROUND(V, A) (((((unsigned) (V))-1) | ((A)-1))+1) + +/* the interpreter is written in C++, primarily because it makes it easy for + * the entire thing to be "friend" with class Class. */ + +class _Jv_InterpClass; +class _Jv_InterpMethod; +class _Jv_InterpMethodInvocation; + +class _Jv_InterpException { + int start_pc; + int end_pc; + int handler_pc; + int handler_type; + + friend class _Jv_ClassReader; + friend class _Jv_InterpMethod; +}; + +class _Jv_InterpMethod { + + _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 () + { + return + ((unsigned char*)this) + + ROUND((sizeof (_Jv_InterpMethod) + + exc_count*sizeof (_Jv_InterpException)), 4); + } + + _Jv_InterpException * exceptions () + { + return (_Jv_InterpException*) (this+1); + } + + static size_t size (int exc_count, int code_length) + { + return + ROUND ((sizeof (_Jv_InterpMethod) + + (exc_count * sizeof (_Jv_InterpException))), 4) + + code_length; + } + + // return the method's invocation pointer (a stub). + void *ncode (); + void continue1 (_Jv_InterpMethodInvocation *inv); + + static void run_normal (ffi_cif*, void*, void**, void*); + static void run_synch_object (ffi_cif*, void*, void**, void*); + static void run_synch_class (ffi_cif*, void*, void**, void*); + + inline jobject run (ffi_cif*, void*, void**, + _Jv_InterpMethodInvocation*); + + bool find_exception (jobject ex, + _Jv_InterpMethodInvocation *inv); + + public: + static void dump_object(jobject o); + + friend class _Jv_ClassReader; + friend class _Jv_InterpMethodInvocation; + friend class gnu::gcj::runtime::MethodInvocation; + + friend void _Jv_PrepareClass(jclass); + + friend void _Jv_callInterpretedMethod (ffi_cif*, + void*, + void **, + void*); +}; + +class _Jv_InterpMethodInvocation { + _Jv_InterpMethod *running; + void **sp; + unsigned char *pc; + void* state[0]; + + void** stack_base () { return &state[0]; } + void** local_base () { return &state[running->max_stack]; } + + friend class _Jv_InterpMethod; +}; + +class _Jv_InterpClass : public java::lang::Class +{ + _Jv_InterpMethod **interpreted_methods; + _Jv_ushort *field_initializers; + + friend class _Jv_ClassReader; + friend class _Jv_InterpMethod; + friend void _Jv_PrepareClass(jclass); + friend void _Jv_InitField (jobject, jclass, int); + friend void* _Jv_MarkObj (void *, void *, void *, void *); +}; + +struct _Jv_ResolvedMethod { + jint stack_item_count; + jint vtable_index; + jclass klass; + _Jv_Method* method; + + // a resolved method holds the cif in-line, so that _Jv_MarkObj just needs + // to mark the resolved method to hold on to the cif. Some memory could be + // saved by keeping a cache of cif's, since many will be the same. + ffi_cif cif; + ffi_type * arg_types[0]; +}; + +#endif /* INTERPRETER */ + +#endif /* __JAVA_INTERP_H__ */ diff --git a/libjava/include/javaprims.h b/libjava/include/javaprims.h index 98781ad51f2..9d8c0a6eab5 100644 --- a/libjava/include/javaprims.h +++ b/libjava/include/javaprims.h @@ -162,6 +162,7 @@ extern "Java" class VerifyError; class VirtualMachineError; class Void; + class VMClassLoader; namespace reflect { class AccessibleObject; diff --git a/libjava/include/jvm.h b/libjava/include/jvm.h index 75ca8274c4d..34da0edbea9 100644 --- a/libjava/include/jvm.h +++ b/libjava/include/jvm.h @@ -40,6 +40,8 @@ extern int _Jv_strLengthUtf8(char* str, int len); typedef struct _Jv_Utf8Const Utf8Const; _Jv_Utf8Const *_Jv_makeUtf8Const (char *s, int len); +_Jv_Utf8Const *_Jv_makeUtf8TypeConst (char* s, int len); +_Jv_Utf8Const *_Jv_makeUtf8Const (jstring string); extern jboolean _Jv_equalUtf8Consts (_Jv_Utf8Const *, _Jv_Utf8Const *); extern jboolean _Jv_equal (_Jv_Utf8Const *, jstring, jint); @@ -91,6 +93,8 @@ extern "C" void *_Jv_LookupInterfaceMethod (jclass klass, Utf8Const *name, extern "C" void _Jv_CheckArrayStore (jobject array, jobject obj); extern "C" void _Jv_RegisterClass (jclass klass); extern "C" void _Jv_RegisterClasses (jclass *classes); +extern void _Jv_UnregisterClass (_Jv_Utf8Const*, java::lang::ClassLoader*); + extern jclass _Jv_FindClass (_Jv_Utf8Const *name, java::lang::ClassLoader *loader); extern jclass _Jv_FindClassFromSignature (char *, |