Class.h (Class): Made _Jv_BytecodeVerifier a friend.

* java/lang/Class.h (Class): Made _Jv_BytecodeVerifier a friend.
	* Makefile.in: Rebuilt.
	* Makefile.am (libgcj_la_SOURCES): Added verify.cc.
	* verify.cc: New file.
	* include/java-interp.h (_Jv_count_arguments): Declare.
	(_Jv_VerifyMethod): Likewise.
	(class _Jv_InterpMethod): Made _Jv_BytecodeVerifier a friend.
	(class _Jv_InterpException): Likewise.
	* resolve.cc (_Jv_count_arguments): Renamed from count_arguments.
	No longer static.  Updated callers.
	* defineclass.cc (int_bits_to_float): Removed.
	(long_bits_to_double): Likewise.
	(prepare_pool_entry): Updated.
	(handleCodeAttribute): Verify method (commented out for now).

From-SVN: r46796
This commit is contained in:
Tom Tromey 2001-11-05 23:39:54 +00:00 committed by Tom Tromey
parent e6ec164c8d
commit a12fe13ddb
8 changed files with 2513 additions and 47 deletions

View File

@ -1,3 +1,20 @@
2001-11-05 Tom Tromey <tromey@redhat.com>
* java/lang/Class.h (Class): Made _Jv_BytecodeVerifier a friend.
* Makefile.in: Rebuilt.
* Makefile.am (libgcj_la_SOURCES): Added verify.cc.
* verify.cc: New file.
* include/java-interp.h (_Jv_count_arguments): Declare.
(_Jv_VerifyMethod): Likewise.
(class _Jv_InterpMethod): Made _Jv_BytecodeVerifier a friend.
(class _Jv_InterpException): Likewise.
* resolve.cc (_Jv_count_arguments): Renamed from count_arguments.
No longer static. Updated callers.
* defineclass.cc (int_bits_to_float): Removed.
(long_bits_to_double): Likewise.
(prepare_pool_entry): Updated.
(handleCodeAttribute): Verify method (commented out for now).
2001-11-05 Bryce McKinlay <bryce@waitaki.otago.ac.nz>
* java/util/ResourceBundle.java (class Security): Now static.

View File

@ -124,7 +124,7 @@ javao_files = $(java_source_files:.java=.lo) \
x_javao_files = $(x_java_source_files:.java=.lo)
libgcj_la_SOURCES = prims.cc posix.cc jni.cc exception.cc \
resolve.cc defineclass.cc interpret.cc name-finder.cc \
resolve.cc defineclass.cc interpret.cc name-finder.cc verify.cc \
$(nat_source_files)
EXTRA_libgcj_la_SOURCES = boehm.cc nogc.cc posix-threads.cc no-threads.cc \
$(c_source_files) $(java_source_files) $(built_java_source_files)

View File

@ -123,13 +123,19 @@ libgcj_basedir = @libgcj_basedir@
mkinstalldirs = @mkinstalldirs@
AUTOMAKE_OPTIONS = foreign
@TESTSUBDIR_TRUE@SUBDIRS = @TESTSUBDIR_TRUE@$(DIRLTDL) testsuite gcj include
@TESTSUBDIR_FALSE@SUBDIRS = @TESTSUBDIR_FALSE@$(DIRLTDL) gcj include
@USE_LIBDIR_TRUE@toolexeclibdir = @USE_LIBDIR_TRUE@$(libdir)$(MULTISUBDIR)
@USE_LIBDIR_FALSE@toolexeclibdir = @USE_LIBDIR_FALSE@$(toolexecdir)/lib$(MULTISUBDIR)
@USE_LIBDIR_FALSE@toolexecdir = @USE_LIBDIR_FALSE@$(exec_prefix)/$(target_alias)
@XLIB_AWT_TRUE@cond_x_ltlibrary = @XLIB_AWT_TRUE@libgcjx.la
@XLIB_AWT_FALSE@cond_x_ltlibrary =
@TESTSUBDIR_TRUE@SUBDIRS = \
@TESTSUBDIR_TRUE@$(DIRLTDL) testsuite gcj include
@TESTSUBDIR_FALSE@SUBDIRS = \
@TESTSUBDIR_FALSE@$(DIRLTDL) gcj include
@USE_LIBDIR_TRUE@toolexeclibdir = \
@USE_LIBDIR_TRUE@$(libdir)$(MULTISUBDIR)
@USE_LIBDIR_FALSE@toolexeclibdir = \
@USE_LIBDIR_FALSE@$(toolexecdir)/lib$(MULTISUBDIR)
@USE_LIBDIR_FALSE@toolexecdir = \
@USE_LIBDIR_FALSE@$(exec_prefix)/$(target_alias)
@XLIB_AWT_TRUE@cond_x_ltlibrary = \
@XLIB_AWT_TRUE@libgcjx.la
@XLIB_AWT_FALSE@cond_x_ltlibrary = \
toolexeclib_LTLIBRARIES = libgcj.la $(cond_x_ltlibrary)
toolexeclib_DATA = libgcj.spec
@ -137,14 +143,20 @@ data_DATA = libgcj.jar
secdir = $(libdir)/security
@NATIVE_TRUE@bin_PROGRAMS = @NATIVE_TRUE@jv-convert gij rmic rmiregistry
@NATIVE_TRUE@bin_PROGRAMS = \
@NATIVE_TRUE@jv-convert gij rmic rmiregistry
bin_SCRIPTS = addr2name.awk
@CANADIAN_TRUE@@NULL_TARGET_TRUE@ZIP = @CANADIAN_TRUE@@NULL_TARGET_TRUE@$(MULTIBUILDTOP)../$(COMPPATH)/fastjar/jar$(EXEEXT)
@CANADIAN_TRUE@@NULL_TARGET_FALSE@ZIP = @CANADIAN_TRUE@@NULL_TARGET_FALSE@jar
@CANADIAN_FALSE@ZIP = @CANADIAN_FALSE@$(MULTIBUILDTOP)../$(COMPPATH)/fastjar/jar$(EXEEXT)
@CANADIAN_TRUE@GCJH = @CANADIAN_TRUE@gcjh
@CANADIAN_FALSE@GCJH = @CANADIAN_FALSE@$(MULTIBUILDTOP)../$(COMPPATH)/gcc/gcjh$(EXEEXT)
@CANADIAN_TRUE@@NULL_TARGET_TRUE@ZIP = \
@CANADIAN_TRUE@@NULL_TARGET_TRUE@$(MULTIBUILDTOP)../$(COMPPATH)/fastjar/jar$(EXEEXT)
@CANADIAN_TRUE@@NULL_TARGET_FALSE@ZIP = \
@CANADIAN_TRUE@@NULL_TARGET_FALSE@jar
@CANADIAN_FALSE@ZIP = \
@CANADIAN_FALSE@$(MULTIBUILDTOP)../$(COMPPATH)/fastjar/jar$(EXEEXT)
@CANADIAN_TRUE@GCJH = \
@CANADIAN_TRUE@gcjh
@CANADIAN_FALSE@GCJH = \
@CANADIAN_FALSE@$(MULTIBUILDTOP)../$(COMPPATH)/gcc/gcjh$(EXEEXT)
GCJ_WITH_FLAGS = $(GCJ) --encoding=UTF-8
@ -164,8 +176,10 @@ AM_CXXFLAGS = -fno-rtti -fnon-call-exceptions \
@LIBGCJ_CXXFLAGS@ @X_CFLAGS@ $(WARNINGS) -D_GNU_SOURCE \
-DPREFIX="\"$(prefix)\""
@USING_GCC_TRUE@AM_CFLAGS = @USING_GCC_TRUE@@LIBGCJ_CFLAGS@ $(WARNINGS)
@USING_GCC_FALSE@AM_CFLAGS = @USING_GCC_FALSE@@LIBGCJ_CFLAGS@
@USING_GCC_TRUE@AM_CFLAGS = \
@USING_GCC_TRUE@@LIBGCJ_CFLAGS@ $(WARNINGS)
@USING_GCC_FALSE@AM_CFLAGS = \
@USING_GCC_FALSE@@LIBGCJ_CFLAGS@
JCFLAGS = -g
JC1FLAGS = @LIBGCJ_JAVAFLAGS@ $(GCJFLAGS)
@ -186,7 +200,7 @@ javao_files = $(java_source_files:.java=.lo) \
x_javao_files = $(x_java_source_files:.java=.lo)
libgcj_la_SOURCES = prims.cc posix.cc jni.cc exception.cc \
resolve.cc defineclass.cc interpret.cc name-finder.cc \
resolve.cc defineclass.cc interpret.cc name-finder.cc verify.cc \
$(nat_source_files)
EXTRA_libgcj_la_SOURCES = boehm.cc nogc.cc posix-threads.cc no-threads.cc \
@ -234,7 +248,8 @@ extra_headers = java/lang/Object.h java/lang/Class.h
NM = nm
@NATIVE_TRUE@@MAINTAINER_MODE_TRUE@noinst_PROGRAMS = @NATIVE_TRUE@@MAINTAINER_MODE_TRUE@gen-from-JIS
@NATIVE_TRUE@@MAINTAINER_MODE_TRUE@noinst_PROGRAMS = \
@NATIVE_TRUE@@MAINTAINER_MODE_TRUE@gen-from-JIS
CONVERT_DIR = gnu/gcj/convert
@ -1496,7 +1511,7 @@ X_LIBS = @X_LIBS@
X_EXTRA_LIBS = @X_EXTRA_LIBS@
X_PRE_LIBS = @X_PRE_LIBS@
libgcj_la_OBJECTS = prims.lo posix.lo jni.lo exception.lo resolve.lo \
defineclass.lo interpret.lo name-finder.lo gnu/gcj/natCore.lo \
defineclass.lo interpret.lo name-finder.lo verify.lo gnu/gcj/natCore.lo \
gnu/gcj/convert/JIS0208_to_Unicode.lo \
gnu/gcj/convert/JIS0212_to_Unicode.lo gnu/gcj/convert/Unicode_to_JIS.lo \
gnu/gcj/convert/natIconv.lo gnu/gcj/convert/natInput_EUCJIS.lo \
@ -1562,7 +1577,7 @@ libgcj-test.spec.in libgcj.spec.in
DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
TAR = gtar
TAR = tar
GZIP_ENV = --best
DIST_SUBDIRS = @DIRLTDL@ testsuite gcj include @DIRLTDL@ gcj include
DEP_FILES = .deps/$(srcdir)/$(CONVERT_DIR)/gen-from-JIS.P \
@ -2369,7 +2384,7 @@ DEP_FILES = .deps/$(srcdir)/$(CONVERT_DIR)/gen-from-JIS.P \
.deps/org/xml/sax/helpers/XMLFilterImpl.P \
.deps/org/xml/sax/helpers/XMLReaderAdapter.P \
.deps/org/xml/sax/helpers/XMLReaderFactory.P .deps/posix-threads.P \
.deps/posix.P .deps/prims.P .deps/resolve.P
.deps/posix.P .deps/prims.P .deps/resolve.P .deps/verify.P
SOURCES = $(libgcj_la_SOURCES) $(EXTRA_libgcj_la_SOURCES) $(libgcjx_la_SOURCES) $(EXTRA_libgcjx_la_SOURCES) $(jv_convert_SOURCES) $(EXTRA_jv_convert_SOURCES) $(gij_SOURCES) $(rmic_SOURCES) $(EXTRA_rmic_SOURCES) $(rmiregistry_SOURCES) $(EXTRA_rmiregistry_SOURCES) $(gen_from_JIS_SOURCES) $(EXTRA_gen_from_JIS_SOURCES)
OBJECTS = $(libgcj_la_OBJECTS) $(libgcjx_la_OBJECTS) $(jv_convert_OBJECTS) $(gij_OBJECTS) $(rmic_OBJECTS) $(rmiregistry_OBJECTS) $(gen_from_JIS_OBJECTS)
@ -2710,7 +2725,7 @@ distdir: $(DISTFILES)
@for file in $(DISTFILES); do \
d=$(srcdir); \
if test -d $$d/$$file; then \
cp -pr $$d/$$file $(distdir)/$$file; \
cp -pr $$/$$file $(distdir)/$$file; \
else \
test -f $(distdir)/$$file \
|| ln $$d/$$file $(distdir)/$$file 2> /dev/null \

View File

@ -58,9 +58,6 @@ static void throw_incompatible_class_change_error (jstring msg)
static void throw_class_circularity_error (jstring msg)
__attribute__ ((__noreturn__));
static jdouble long_bits_to_double (jlong);
static jfloat int_bits_to_float (jint);
/**
* We define class reading using a class. It is practical, since then
* the entire class-reader can be a friend of class Class (it needs to
@ -826,7 +823,7 @@ _Jv_ClassReader::prepare_pool_entry (int index, unsigned char this_tag)
case JV_CONSTANT_Float:
{
jfloat f = int_bits_to_float ((jint) get4 (this_data));
jfloat f = java::lang::Float::intBitsToFloat ((jint) get4 (this_data));
_Jv_storeFloat (&pool_data[index], f);
pool_tags[index] = JV_CONSTANT_Float;
}
@ -842,7 +839,8 @@ _Jv_ClassReader::prepare_pool_entry (int index, unsigned char this_tag)
case JV_CONSTANT_Double:
{
jdouble d = long_bits_to_double ((jlong) get8 (this_data));
jdouble d
= java::lang::Double::longBitsToDouble ((jlong) get8 (this_data));
_Jv_storeDouble (&pool_data[index], d);
pool_tags[index] = JV_CONSTANT_Double;
}
@ -1282,10 +1280,12 @@ void _Jv_ClassReader::handleCodeAttribute
memcpy ((void*) method->bytecode (),
(void*) (bytes+code_start),
code_length);
def->interpreted_methods[method_index] = method;
/* that's all we do for now */
// FIXME: Shouldn't this be done after loading completes?
// if (verify)
// _Jv_VerifyMethod (method);
}
void _Jv_ClassReader::handleExceptionTableEntry
@ -1635,16 +1635,6 @@ throw_internal_error (char *msg)
throw new java::lang::InternalError (JvNewStringLatin1 (msg));
}
static jfloat int_bits_to_float (jint value)
{
return java::lang::Float::intBitsToFloat (value);
}
static jdouble long_bits_to_double (jlong value)
{
return java::lang::Double::longBitsToDouble (value);
}
static void throw_incompatible_class_change_error (jstring msg)
{
throw new java::lang::IncompatibleClassChangeError (msg);

View File

@ -43,6 +43,9 @@ void _Jv_DefineClass (jclass, jbyteArray, jint, jint);
void _Jv_InitField (jobject, jclass, int);
void * _Jv_AllocMethodInvocation (jsize size);
int _Jv_count_arguments (_Jv_Utf8Const *signature,
jboolean staticp = true);
void _Jv_VerifyMethod (_Jv_InterpMethod *method);
/* FIXME: this should really be defined in some more generic place */
#define ROUND(V, A) (((((unsigned) (V))-1) | ((A)-1))+1)
@ -54,7 +57,8 @@ class _Jv_InterpClass;
class _Jv_InterpMethod;
class _Jv_InterpMethodInvocation;
class _Jv_InterpException {
class _Jv_InterpException
{
int start_pc;
int end_pc;
int handler_pc;
@ -62,6 +66,7 @@ class _Jv_InterpException {
friend class _Jv_ClassReader;
friend class _Jv_InterpMethod;
friend class _Jv_BytecodeVerifier;
};
// Base class for method representations. Subclasses are interpreted
@ -133,6 +138,7 @@ class _Jv_InterpMethod : public _Jv_MethodBase
friend class _Jv_ClassReader;
friend class _Jv_InterpMethodInvocation;
friend class _Jv_BytecodeVerifier;
friend void _Jv_PrepareClass(jclass);
};

View File

@ -337,6 +337,8 @@ private:
friend JV_MARKOBJ_DECL;
#endif
friend class _Jv_BytecodeVerifier;
// Chain for class pool.
jclass next;
// Name of class.

View File

@ -958,9 +958,9 @@ get_ffi_type_from_signature (unsigned char* ptr)
* function is non-static, then one is added to the number of elements
* found in the signature */
static int
count_arguments (_Jv_Utf8Const *signature,
jboolean staticp)
int
_Jv_count_arguments (_Jv_Utf8Const *signature,
jboolean staticp)
{
unsigned char *ptr = (unsigned char*) signature->data;
int arg_count = staticp ? 0 : 1;
@ -1048,7 +1048,7 @@ init_cif (_Jv_Utf8Const* signature,
#endif
/* we put this one here, and not in interpret.cc because it
* calls the utility routines count_arguments
* calls the utility routines _Jv_count_arguments
* which are static to this module. The following struct defines the
* layout we use for the stubs, it's only used in the ncode method. */
@ -1069,7 +1069,7 @@ _Jv_InterpMethod::ncode ()
return self->ncode;
jboolean staticp = (self->accflags & Modifier::STATIC) != 0;
int arg_count = count_arguments (self->signature, staticp);
int arg_count = _Jv_count_arguments (self->signature, staticp);
ncode_closure *closure =
(ncode_closure*)_Jv_AllocBytes (sizeof (ncode_closure)
@ -1119,7 +1119,7 @@ _Jv_JNIMethod::ncode ()
return self->ncode;
jboolean staticp = (self->accflags & Modifier::STATIC) != 0;
int arg_count = count_arguments (self->signature, staticp);
int arg_count = _Jv_count_arguments (self->signature, staticp);
ncode_closure *closure =
(ncode_closure*)_Jv_AllocBytes (sizeof (ncode_closure)
@ -1180,7 +1180,7 @@ _Jv_BuildResolvedMethod (_Jv_Method* method,
jboolean staticp,
jint vtable_index)
{
int arg_count = count_arguments (method->signature, staticp);
int arg_count = _Jv_count_arguments (method->signature, staticp);
_Jv_ResolvedMethod* result = (_Jv_ResolvedMethod*)
_Jv_AllocBytes (sizeof (_Jv_ResolvedMethod)

2436
libjava/verify.cc Normal file

File diff suppressed because it is too large Load Diff