// interpret.cc - Code for the interpreter
-/* Copyright (C) 1999, 2000 Free Software Foundation
+/* Copyright (C) 1999, 2000, 2001 Free Software Foundation
This file is part of libgcj.
#ifdef INTERPRETER
-#define ClassError _CL_Q34java4lang5Error
-extern java::lang::Class ClassError;
+#include <stdlib.h>
static _Jv_Utf8Const *init_name = _Jv_makeUtf8Const ("<init>", 6);
__attribute__ ((__noreturn__));
#endif
-extern "C" double __ieee754_fmod __P((double,double));
+extern "C" double __ieee754_fmod (double,double);
static inline void dupx (_Jv_word *sp, int n, int x)
{
// "run" ro be inlined. Otherwise gcc will ignore the inline directive.
int storage_size = _this->max_stack+_this->max_locals;
_Jv_InterpMethodInvocation* inv = (_Jv_InterpMethodInvocation*)
- alloca (sizeof (_Jv_InterpMethodInvocation)
- + storage_size * sizeof (_Jv_word));
+ __builtin_alloca (sizeof (_Jv_InterpMethodInvocation)
+ + storage_size * sizeof (_Jv_word));
jobject ex = _this->run (cif, ret, args, inv);
- if (ex != 0) _Jv_Throw (ex);
+ if (ex != 0) throw static_cast<jthrowable>(ex);
}
void _Jv_InterpMethod::run_synch_object (ffi_cif* cif,
int storage_size = _this->max_stack+_this->max_locals;
_Jv_InterpMethodInvocation* inv = (_Jv_InterpMethodInvocation*)
- alloca (sizeof (_Jv_InterpMethodInvocation)
- + storage_size * sizeof (_Jv_word));
+ __builtin_alloca (sizeof (_Jv_InterpMethodInvocation)
+ + storage_size * sizeof (_Jv_word));
_Jv_MonitorEnter (rcv);
jobject ex = _this->run (cif, ret, args, inv);
_Jv_MonitorExit (rcv);
- if (ex != 0) _Jv_Throw (ex);
+ if (ex != 0) throw static_cast<jthrowable>(ex);
}
void _Jv_InterpMethod::run_synch_class (ffi_cif* cif,
int storage_size = _this->max_stack+_this->max_locals;
_Jv_InterpMethodInvocation* inv = (_Jv_InterpMethodInvocation*)
- alloca (sizeof (_Jv_InterpMethodInvocation)
- + storage_size * sizeof (_Jv_word));
+ __builtin_alloca (sizeof (_Jv_InterpMethodInvocation)
+ + storage_size * sizeof (_Jv_word));
_Jv_MonitorEnter (sync);
jobject ex = _this->run (cif, ret, args, inv);
_Jv_MonitorExit (sync);
- if (ex != 0) _Jv_Throw (ex);
+ if (ex != 0) throw static_cast<jthrowable>(ex);
}
/*
_Jv_word *pool_data = defining_class->constants.data;
/* these two are used in the invokeXXX instructions */
- void (*fun)(...);
+ void (*fun)();
_Jv_ResolvedMethod* rmeth;
#define INSN_LABEL(op) &&insn_##op
rmeth = (_Jv_ResolvePoolEntry (defining_class, index)).rmethod;
sp -= rmeth->stack_item_count;
- NULLCHECK(sp[0]);
+ // We don't use NULLCHECK here because we can't rely on that
+ // working if the method is final. So instead we do an
+ // explicit test.
+ if (! sp[0].o)
+ throw new java::lang::NullPointerException;
if (rmeth->vtable_index == -1)
{
// final methods do not appear in the vtable,
// if it does not appear in the superclass.
- fun = (void (*) (...)) rmeth->method->ncode;
+ fun = (void (*)()) rmeth->method->ncode;
}
else
{
jobject rcv = sp[0].o;
_Jv_VTable *table = *(_Jv_VTable**)rcv;
- fun = (void (*) (...))table->method[rmeth->vtable_index];
+ fun = (void (*)()) table->method[rmeth->vtable_index];
}
}
goto perform_invoke;
{
case 1:
PUSHI (*(jbyte*) (field->u.addr));
+ break;
case 2:
if (type == JvPrimClass (char))
jclass type = field->type;
jint field_offset = field->u.boffset;
if (field_offset > 0xffff)
- JvThrow (new java::lang::VirtualMachineError);
+ throw new java::lang::VirtualMachineError;
jobject obj = POPA();
NULLCHECK(obj);
jint field_offset = field->u.boffset;
if (field_offset > 0xffff)
- JvThrow (new java::lang::VirtualMachineError);
+ throw new java::lang::VirtualMachineError;
if (type->isPrimitive ())
{
sp -= rmeth->stack_item_count;
- NULLCHECK(sp[0]);
+ NULLCHECK (sp[0].o);
- fun = (void (*) (...))rmeth->method->ncode;
+ fun = (void (*)()) rmeth->method->ncode;
}
goto perform_invoke;
sp -= rmeth->stack_item_count;
_Jv_InitClass (rmeth->klass);
- fun = (void (*) (...))rmeth->method->ncode;
+ fun = (void (*)()) rmeth->method->ncode;
}
goto perform_invoke;
rmeth = (_Jv_ResolvePoolEntry (defining_class, index)).rmethod;
sp -= rmeth->stack_item_count;
- NULLCHECK(sp[0]);
jobject rcv = sp[0].o;
- fun = (void (*) (...))
+ NULLCHECK (rcv);
+
+ fun = (void (*)())
_Jv_LookupInterfaceMethod (rcv->getClass (),
rmeth->method->name,
rmeth->method->signature);
SAVE_PC;
{
jobject value = POPA();
- JvThrow (value);
+ throw static_cast<jthrowable>(value);
}
NEXT_INSN;
if (value != NULL && ! to->isInstance (value))
{
- JvThrow (new java::lang::ClassCastException
- (to->getName()));
+ throw new java::lang::ClassCastException (to->getName());
}
PUSHA (value);
jclass type
= (_Jv_ResolvePoolEntry (defining_class, kind_index)).clazz;
_Jv_InitClass (type);
- jint *sizes = (jint*) alloca (sizeof (jint)*dim);
+ jint *sizes = (jint*) __builtin_alloca (sizeof (jint)*dim);
for (int i = dim - 1; i >= 0; i--)
{
static void
throw_internal_error (char *msg)
{
- JvThrow (new java::lang::InternalError (JvNewStringLatin1 (msg)));
+ throw new java::lang::InternalError (JvNewStringLatin1 (msg));
}
static void
throw_incompatible_class_change_error (jstring msg)
{
- JvThrow (new java::lang::IncompatibleClassChangeError (msg));
+ throw new java::lang::IncompatibleClassChangeError (msg);
}
#ifndef HANDLE_SEGV
if (null_pointer_exc == NULL)
null_pointer_exc = new java::lang::NullPointerException;
- JvThrow (null_pointer_exc);
+ throw null_pointer_exc;
}
#endif