## Process this file with automake to produce Makefile.in
-# $Id: Makefile.am 1333 2004-07-21 15:48:46Z twisti $
+# $Id: Makefile.am 1429 2004-11-02 08:58:26Z jowenn $
@SET_MAKE@
$(BOEHM_LIBS) \
@THREAD_OBJ@ \
toolbox/libtoolbox.a \
- classpath/native/jni/java-io/.libs/libjavaio.a \
- classpath/native/jni/java-nio/.libs/libjavanio.a \
- classpath/native/jni/java-net/.libs/libjavanet.a \
- classpath/native/jni/java-util/.libs/libjavautil.a \
- classpath/native/jni/java-lang/.libs/libjavalang.a \
- classpath/native/jni/java-lang/.libs/libjavalangreflect.a \
+ classpath/native/fdlibm/.libs/libfdlibm.a \
+ @STATIC_CLASSPATH_LIBS@ \
+ @DYNAMIC_CLASSPATH_LIBS@ \
@AWT_OBJS@ \
@ZIP_LIBS@ \
@THREAD_LIB@
$(BOEHM_LIBS) \
@THREAD_OBJ@ \
toolbox/libtoolbox.a \
- classpath/native/jni/java-io/.libs/libjavaio.a \
- classpath/native/jni/java-nio/.libs/libjavanio.a \
- classpath/native/jni/java-net/.libs/libjavanet.a \
- classpath/native/jni/java-util/.libs/libjavautil.a \
- classpath/native/jni/java-lang/.libs/libjavalang.a \
- classpath/native/jni/java-lang/.libs/libjavalangreflect.a \
+ @STATIC_CLASSPATH_LIBS@ \
nativetable.inc \
@AWT_OBJS@ \
@ZIP_LIBS@
natheaders: cacaoh
CLASSPATH=$(top_srcdir)/classpath/lib/bootstrap.zip ./cacaoh $(CLASSES)
-nativetable.inc: gennativetable
+nativetable.inc: gennativetable nat/implementednatives.data
CLASSPATH=$(top_srcdir)/classpath/lib/bootstrap.zip $(top_srcdir)/gennativetable $(CLASSES) > nativetable.inc
native.c: nativetable.inc
case "$host_cpu" in
alpha* )
ARCH_DIR="alpha"
+ STATIC_CLASSPATH="1"
CFLAGS="-Wall -O2 -g3 -mieee -D__ALPHA__"
AC_DEFINE([TRACE_ARGS_NUM], 6, [Defines integer argument register count])
AC_DEFINE([USE_CODEMMAP], 1, [use code mmap])
i386* | i486* | i586* | i686* )
ARCH_DIR="i386"
+ STATIC_CLASSPATH="0"
CFLAGS="-Wall -O0 -g3 -D__I386__"
AC_DEFINE([TRACE_ARGS_NUM], 8, [Defines integer argument register count])
AC_DEFINE([USE_CODEMMAP], 1, [use code mmap])
mips* )
ARCH_DIR="mips"
+ STATIC_CLASSPATH="1"
CFLAGS="-64 -O2 -OPT:Olimit=0 -g -DMAP_ANONYMOUS=0 -woff 1110,1164,1515 -D__MIPS__"
LIBS="-lelfutil"
AC_DEFINE([TRACE_ARGS_NUM], 8, [Defines integer argument register count])
powerpc* | ppc* )
ARCH_DIR="powerpc"
+ STATIC_CLASSPATH="1"
CFLAGS="-Wall -O2 -g -DMAP_ANONYMOUS=0 -no-cpp-precomp -D__POWERPC__"
AC_DEFINE([TRACE_ARGS_NUM], 8, [Defines integer argument register count])
;;
x86_64* )
ARCH_DIR="x86_64"
+ STATIC_CLASSPATH="1"
CFLAGS="-Wall -O2 -g3 -D__X86_64__"
AC_DEFINE([TRACE_ARGS_NUM], 6, [Defines integer argument register count])
AC_DEFINE([USE_CODEMMAP], 1, [use code mmap])
AC_DEFINE_UNQUOTED([ARCH_DIR], "$ARCH_DIR", [Architecture directory])
AC_SUBST(ARCH_DIR)
+AC_ARG_ENABLE([dynamicclasspath], [AS_HELP_STRING(--disable-dynamicclasspath, link classpath native code static even on platforms supporting dynamic loading)], [use_dynamicclasspath=$enableval], [use_dynamicclasspath=yes])
+dnl force static classpath linking ??
+AC_MSG_CHECKING(Link classpath static)
+if test "xno" == "x$use_dynamicclasspath"; then
+ STATIC_CLASSPATH="1"
+fi
+
+if test "$STATIC_CLASSPATH" == "1"; then
+ AC_MSG_RESULT(yes)
+else
+ AC_MSG_RESULT(no)
+fi
+AC_SUBST(STATIC_CLASSPATH)
+
dnl Checks for programs.
AC_PROG_CC
AM_PROG_AS
fi
+if test "x1" == "x$STATIC_CLASSPATH"; then
+ STATIC_CLASSPATH_LIBS=" \
+ classpath/native/jni/java-io/.libs/libjavaio.a \
+ classpath/native/jni/java-nio/.libs/libjavanio.a \
+ classpath/native/jni/java-net/.libs/libjavanet.a \
+ classpath/native/jni/java-util/.libs/libjavautil.a \
+ classpath/native/jni/java-lang/.libs/libjavalang.a \
+ classpath/native/jni/java-lang/.libs/libjavalangreflect.a"
+ DYNAMIC_CLASSPATH_LIBS=""
+ AC_SUBST(STATIC_CLASSPATH_LIBS)
+ AC_SUBST(DYNAMIC_CLASSPATH_LIBS)
+ AC_DEFINE([STATIC_CLASSPATH], 1, [use classpath statically linked])
+
+else
+ DYNAMIC_CLASSPATH_LIBS="-ldl -Wl,--export-dynamic"
+ STATIC_CLASSPATH_LIBS=""
+ AC_SUBST(STATIC_CLASSPATH_LIBS)
+ AC_SUBST(DYNAMIC_CLASSPATH_LIBS)
+fi
+
+
+
+
dnl now configure boehm gc and gnu classpath
dnl the export is not my favorite (is there another way?)
export CFLAGS
--- /dev/null
+export LD_LIBRARY_PATH=$PWD/classpath/native/jni/java-lang/.libs:$PWD/classpath/native/jni/java-io/.libs:$PWD/classpath/native/jni/java-nio/.libs:\
+$PWD/classpath/native/jni/java-util/.libs:$PWD/classpath/native/jni/java-awt/.libs:$PWD/classpath/native/jni/gtk-peer/.libs:\
+$PWD/classpath/native/jni/java-io/.libs:$PWD/classpath/native/jni/classpath/.libs:\
+$PWD/classpath/native/jni/java-net/.libs:$LD_LIBRARY_PATH
+export CLASSPATH=.:$PWD/classpath/lib/glibj.zip:$CLASSPATH
+export PATH=$PWD:$PATH
+
Authors: Christian Thalinger
- $Id: exceptions.c 1410 2004-08-17 13:01:24Z twisti $
+ $Id: exceptions.c 1429 2004-11-02 08:58:26Z jowenn $
*/
s4 len;
len = strlen(exception);
- tmp = MNEW(char, len);
+ tmp = MNEW(char, len+1);
strncpy(tmp, exception, len);
+ tmp[len]='\0';
/* convert to classname */
Changes:
- $Id: gennativetable.c 1405 2004-08-17 09:25:01Z twisti $
+ $Id: gennativetable.c 1429 2004-11-02 08:58:26Z jowenn $
*/
if (!file)
panic("Can not open file 'nativetable' to store native-link-table");
- fprintf(file, "/* Table of native methods: nativetables.hh */\n");
+ fprintf(file, "/* Table of native methods: nativetables.inc */\n");
fprintf(file, "/* This file is machine generated, don't edit it !*/\n\n");
+ fprintf(file, "#include \"config.h\"\n");
+
c = chain_first(nativeclass_chain);
while (c) {
gen_header_filename(classname, c->name);
chain_free(nativeclass_chain);
fprintf(file, "\n\n#include \"native.h\"\n\n");
+ fprintf(file, "#ifdef STATIC_CLASSPATH\n\n");
fprintf(file, "static nativeref nativetable[] = {\n");
m = chain_first(nativemethod_chain);
chain_free(nativemethod_chain);
fprintf(file, "};\n");
-
+ fprintf(file,"\n#else\n");
+ fprintf(file, "/*ensure that symbols for functions implemented within cacao are used and exported to dlopen*/\n");
+ fprintf(file, "static functionptr dummynativetable[]={\n");
+ {
+ FILE *implData=fopen("nat/implementednatives.data","r");
+ if (!implData) {fclose(file); exit(3);}
+ while (!feof(implData)) {
+ char functionLine[1024];
+ functionLine[0]='\0';
+ fgets(functionLine,1024,implData);
+ if (strlen(functionLine)<2) continue;
+ if (functionLine[strlen(functionLine)-1]!='\n') { fclose(implData); fclose(file); exit(4);}
+ functionLine[strlen(functionLine)-1]=',';
+ fprintf(file,"\t(functionptr) %s\n",functionLine);
+ }
+ fprintf(file,"\t(functionptr)0");
+ fclose(implData);
+ }
+ fprintf(file, "};\n");
+ fprintf(file,"\n#endif\n");
fclose(file);
-
+
/* release all resources */
loader_close();
memory. All functions writing values into the data area return the offset
relative the begin of the code area (start of procedure).
- $Id: codegen.inc 1420 2004-10-27 16:05:14Z twisti $
+ $Id: codegen.inc 1429 2004-11-02 08:58:26Z jowenn $
*/
#include "toolbox/logging.h"
#include "toolbox/avl.h"
#include "threads/thread.h"
-
+#ifndef STATIC_CLASSPATH
+#include <dlfcn.h>
+#endif
/* in this tree we store all method addresses */
cd->exceptiontablelength=m->exceptiontablelength;
cd->exceptiontable = MNEW(exceptiontable, m->exceptiontablelength + 1);
}
-
+ if (e) {
+ cd->maxstack=e->cummaxstack;
+ cd->maxlocals=e->cumlocals;
+ } else {
+ cd->maxstack=m->maxstack;
+ cd->maxlocals=m->maxlocals;
+ }
#if defined(USE_THREADS) && defined(NATIVE_THREADS)
cd->threadcritcurrent.next = NULL;
cd->threadcritcount = 0;
}
#endif
+#ifndef STATIC_CLASSPATH
+static size_t codegen_overloadPartLen(utf *desc) {
+ char *utf_ptr=desc->text;
+ u2 c;
+ size_t len=2;
+ while ((c=utf_nextu2(&utf_ptr))!=')') {
+ switch (c) {
+ case 'I':
+ case 'S':
+ case 'B':
+ case 'C':
+ case 'Z':
+ case 'J':
+ case 'F':
+ case 'D':
+ len ++;
+ break;
+ case '[':
+ len = len+2;
+ break;
+ case 'L':
+ len++;
+ while ( (c=utf_nextu2(&utf_ptr)) != ';')
+ len++;
+ len=len+2;
+ break;
+ case '(':
+ break;
+ default: panic ("invalid method descriptor");
+ }
+ }
+ return len;
+
+}
+
+static void codegen_fillInOverloadPart(char *target,utf *desc) {
+ char *utf_ptr=desc->text;
+ u2 c;
+ char* insertpos=&target[strlen(target)];
+ *(insertpos++)='_';
+ *(insertpos++)='_';
+ while ((c=utf_nextu2(&utf_ptr))!=')') {
+ switch (c) {
+ case 'I':
+ case 'S':
+ case 'B':
+ case 'C':
+ case 'Z':
+ case 'J':
+ case 'F':
+ case 'D':
+ *(insertpos++)=c;
+ break;
+ case '[':
+ *(insertpos++)='_';
+ *(insertpos++)='3';
+ break;
+ case 'L':
+ *(insertpos++)='L';
+ while ( (c=utf_nextu2(&utf_ptr)) != ';')
+ if ( ((c>='a') && (c<='z')) ||
+ ((c>='A') && (c<='Z')) ||
+ ((c>='0') && (c<='9')) )
+ *(insertpos++)=c;
+ else *(insertpos++)='_';
+ *(insertpos++)='_';
+ *(insertpos++)='2';
+ break;
+ case '(':
+ break;
+ default: panic ("invalid method descriptor");
+ }
+ }
+ *insertpos='\0';
+
+}
+
+static void codegen_resolve_native(methodinfo *m,void **insertionPoint,void *jmpTarget,void **jmpPatchTarget) {
+ char *nativeName;
+ size_t nativeLen;
+ size_t i;
+
+ builtin_monitorenter((java_objectheader*) m);
+ if ((*jmpPatchTarget)==jmpTarget) {
+ builtin_monitorexit((java_objectheader*) m);
+ return;
+ }
+ log_text("trying to resolve a native method");
+ utf_display(m->class->name);
+ utf_display(m->name);
+
+ void *lib=dlopen(0,RTLD_NOW | RTLD_GLOBAL);
+ if (lib) {
+ int ok=0;
+ /*generate the name of the native function in the form Java_package1_package2...._classname_methodname*/
+ nativeLen=/*Java_*/5+strlen(m->class->name->text)+/*_*/1+strlen(m->name->text)+/*\0*/1;
+ nativeName=MNEW(char,nativeLen);
+ sprintf(nativeName,"Java_%s_%s",m->class->name->text,m->name->text);
+ for (i=0;i<nativeLen;i++) {
+ if (nativeName[i]=='/') nativeName[i]='_';
+ }
+
+
+ void *sym=dlsym(lib,nativeName);
+ if (sym) {
+ ok=1;
+ log_text("resolved");
+ MFREE(nativeName,char,nativeLen);
+ } else {
+ size_t overloadedNativeLen=nativeLen+codegen_overloadPartLen(m->descriptor);
+ char *overloadedNative=MNEW(char,overloadedNativeLen);
+ sprintf(overloadedNative,"%s",nativeName);
+ MFREE(nativeName,char,nativeLen);
+ codegen_fillInOverloadPart(overloadedNative,m->descriptor);
+ log_text("symbol not found,trying harder (overloaded member ?)");
+ sym=dlsym(lib,overloadedNative);
+ if (sym) {
+ MFREE(overloadedNative,char,overloadedNativeLen);
+ ok=1;
+ log_text("resolved");
+ } else {
+ MFREE(overloadedNative,char,overloadedNativeLen);
+ log_text("It was not possible to find the native function implementation. Not even in overloading case");
+ }
+ }
+ if (ok) {
+ (*insertionPoint)=sym;
+ (*jmpPatchTarget)=jmpTarget;
+ builtin_monitorexit((java_objectheader *) m );
+ return;
+ }
+
+ } else log_text("library not found");
+
+
+ {
+ char *info;
+ size_t slen;
+ slen=2+strlen(m->class->name->text)+strlen(m->name->text)+strlen(m->descriptor->text);
+ info=(char*)MNEW(char,slen);
+ sprintf(info,"%s.%s%s",m->class->name->text,m->name->text,m->descriptor->text);
+
+ builtin_monitorexit((java_objectheader *) m );
+ throw_cacao_exception_exit(string_java_lang_LinkageError,
+ info);
+ }
+
+}
+#endif
+
/*
* These are local overrides for various environment variables in Emacs.
* Please do not remove this and leave it at the end of the file, where
Authors: Christian Thalinger
- $Id: codegen.inc.h 1415 2004-10-11 20:12:08Z jowenn $
+ $Id: codegen.inc.h 1429 2004-11-02 08:58:26Z jowenn $
*/
threadcritnodetemp *threadcrit; /* List of critical code regions */
threadcritnodetemp threadcritcurrent;
s4 threadcritcount; /* Number of critical regions */
+ int maxstack;
+ int maxlocals;
};
Authors: Andreas Krall
Christian Thalinger
- $Id: codegen.c 1415 2004-10-11 20:12:08Z jowenn $
+ $Id: codegen.c 1429 2004-11-02 08:58:26Z jowenn $
*/
#define _GNU_SOURCE
+#include "config.h"
#include "global.h"
#include <stdio.h>
#include <signal.h>
#include "jit/reg.h"
#include "jit/i386/codegen.h"
#include "jit/i386/emitfuncs.h"
-
/* include independent code generation stuff */
#include "jit/codegen.inc"
#include "jit/reg.inc"
int p, t;
codegendata *cd;
+ void** callAddrPatchPos=0;
+ u1* jmpInstrPos=0;
+ void** jmpInstrPatchPos=0;
/* setup codegendata structure */
codegen_setup(m,0);
/* CREATE DYNAMIC STACK INFO -- END*/
+/* RESOLVE NATIVE METHOD -- BEGIN*/
+#ifndef STATIC_CLASSPATH
+ if (f==0) {
+ log_text("Dynamic classpath: preparing for delayed native function resolving");
+ i386_jmp_imm(cd,0);
+ jmpInstrPos=cd->mcodeptr-4;
+ /*patchposition*/
+ i386_mov_imm_reg(cd,jmpInstrPos,REG_ITMP1);
+ i386_push_reg(cd,REG_ITMP1);
+ /*jmp offset*/
+ i386_mov_imm_reg(cd,0,REG_ITMP1);
+ jmpInstrPatchPos=cd->mcodeptr-4;
+ i386_push_reg(cd,REG_ITMP1);
+ /*position of call address to patch*/
+ i386_mov_imm_reg(cd,0,REG_ITMP1);
+ callAddrPatchPos=(cd->mcodeptr-4);
+ i386_push_reg(cd,REG_ITMP1);
+ /*method info structure*/
+ i386_mov_imm_reg(cd,(s4) m, REG_ITMP1);
+ i386_push_reg(cd,REG_ITMP1);
+ /*call resolve functions*/
+ i386_mov_imm_reg(cd, (s4)codegen_resolve_native,REG_ITMP1);
+ i386_call_reg(cd,REG_ITMP1);
+ /*cleanup*/
+ i386_pop_reg(cd,REG_ITMP1);
+ i386_pop_reg(cd,REG_ITMP1);
+ i386_pop_reg(cd,REG_ITMP1);
+ i386_pop_reg(cd,REG_ITMP1);
+ /*fix jmp offset replacement*/
+ (*jmpInstrPatchPos)=cd->mcodeptr-jmpInstrPos-4;
+ } else log_text("Dynamic classpath: immediate native function resolution possible");
+#endif
+/* RESOLVE NATIVE METHOD -- END*/
+
+
tptr = m->paramtypes;
for (i = 0; i < m->paramcount; i++) {
i386_mov_imm_membase(cd, (s4) &env, REG_SP, 0);
i386_mov_imm_reg(cd, (s4) f, REG_ITMP1);
+#ifndef STATIC_CLASSPATH
+ if (f==0)
+ (*callAddrPatchPos)=(cd->mcodeptr-4);
+#endif
i386_call_reg(cd, REG_ITMP1);
+
/*REMOVE DYNAMIC STACK INFO -BEGIN */
i386_push_reg(cd, REG_RESULT2);
i386_mov_membase_reg(cd, REG_SP,stackframesize-8,REG_ITMP2); /*old value*/
Authors: Dieter Thuernbeck
- $Id: inline.c 1415 2004-10-11 20:12:08Z jowenn $
+ $Id: inline.c 1429 2004-11-02 08:58:26Z jowenn $
*/
inlining_set_compiler_variables_fun(m, inline_env);
inline_env->isinlinedmethod = 0;
inline_env->cumjcodelength = m->jcodelength; /* for not inlining */
- inline_env->cummaxstack = 0;
+ inline_env->cummaxstack = m->maxstack; /*why has here been 0 ? */
inline_env->cumextablelength = 0;
inline_env->cumlocals = m->maxlocals;
inline_env->cummethods = 0;//co not global or static-used only here?
m->maxlocals, inline_env->cumlocals,
m->maxstack, inline_env->cummaxstack); fflush(stdout);
}
+#if 0
+/*This looks wrong*/
m->maxlocals = inline_env->cumlocals; //orig not used
m->maxstack = inline_env->cummaxstack; //orig global maxstack var!!
-
+#endif
//panic("TEMP so can test just inline init\n");
}
return inline_env;
Changes: Edwin Steiner
- $Id: jit.c 1420 2004-10-27 16:05:14Z twisti $
+ $Id: jit.c 1429 2004-11-02 08:58:26Z jowenn $
*/
EXTABLEN
- reg_setup(m);
+ reg_setup(inline_env);
/* setup the codegendata memory */
codegen_setup(m,inline_env);
Changes: Carolyn Oates
Edwin Steiner
- $Id: parse.c 1421 2004-10-28 14:39:49Z stefan $
+ $Id: parse.c 1429 2004-11-02 08:58:26Z jowenn $
*/
if ((useinlining) && (gp == nextgp)) {
u1 *tptr;
bool *readonly = NULL;
-
+ int argBlockIdx=0;
opcode = code_get_u1(p,inline_env->method);
nextp = p += jcommandsize[opcode];
label_index = tmpinlinf->label_index;
readonly = tmpinlinf->readonly;
+ for (i=0,tptr=tmpinlinf->method->paramtypes;i<tmpinlinf->method->paramcount;i++,tptr++) {
+ if ( ((*tptr)==TYPE_LNG) ||
+ ((*tptr)==TYPE_DBL) )
+ argBlockIdx+=2;
+ else
+ argBlockIdx++;
+ }
for (i = 0, tptr = tmpinlinf->method->paramtypes + tmpinlinf->method->paramcount - 1; i < tmpinlinf->method->paramcount; i++, tptr--) {
int op;
}
op += *tptr;
- OP1(op, firstlocal + tmpinlinf->method->paramcount - 1 - i);
-
+ if ( ((*tptr)==TYPE_LNG) ||
+ ((*tptr)==TYPE_DBL) )
+ argBlockIdx-=2;
+ else
+ argBlockIdx--;
+
+ OP1(op, firstlocal + argBlockIdx);
+ //OP1(op, firstlocal + tmpinlinf->method->paramcount - 1 - i);
+ //printf("inline argument load operation for local: %ld\n",firstlocal + tmpinlinf->method->paramcount - 1 - i);
/*m->basicblockindex[gp] |= (ipc << 1);*/ /*FIXME: necessary ? */
}
if (DEBUG==true) {
/* OP(ICMD_NOP); */
/* break; */
/* } */
+ if (nextp>inline_env->method->jcodelength-1) {
+ //OP1(ICMD_GOTO, inlinfo->stopgp);
+ //OP(ICMD_NOP);
+ //OP(ICMD_NOP);
+ blockend=true;
+ break;
+ }//JJJJJJJ
blockend = true;
OP1(ICMD_GOTO, inlinfo->stopgp);
break;
/* INLINING */
- if (inline_env->isinlinedmethod && p == inline_env->method->jcodelength - 1) { /* end of an inlined method */
+// if (inline_env->isinlinedmethod && p == inline_env->method->jcodelength - 1) { /* end of an inlined method */
+ if (inline_env->isinlinedmethod && (nextp >= inline_env->method->jcodelength) ) { /* end of an inlined method */
/* printf("setting gp from %d to %d\n",gp, inlinfo->stopgp); */
gp = inlinfo->stopgp;
inlining_restore_compiler_variables();
} /* end for */
- if (p != m->jcodelength)
+ if (p != m->jcodelength) {
+ printf("p (%ld) != m->jcodelength (%ld)\n",p,m->jcodelength);
panic("Command-sequence crosses code-boundary");
-
+ }
if (!blockend) {
*exceptionptr = new_verifyerror(m, "Falling off the end of the code");
return NULL;
Authors: Christian Thalinger
- $Id: reg.h 1234 2004-06-30 19:49:37Z twisti $
+ $Id: reg.h 1429 2004-11-02 08:58:26Z jowenn $
*/
typedef struct registerdata registerdata;
typedef varinfo varinfo5[5];
+struct t_inlining_globals;
+
struct registerdata {
varinfo5 *locals;
/* function prototypes */
void reg_init(methodinfo *m);
-void reg_setup(methodinfo *m);
+void reg_setup(struct t_inlining_globals *e);
void reg_close(methodinfo *m);
void regalloc(methodinfo *m);
Changes: Stefan Ring
Christian Thalinger
- $Id: reg.inc 1342 2004-07-21 16:10:17Z twisti $
+ $Id: reg.inc 1429 2004-11-02 08:58:26Z jowenn $
*/
}
-void reg_setup(methodinfo *m)
+void reg_setup(t_inlining_globals *e)
{
s4 i;
varinfo5 *v;
+ methodinfo *m=e->method;
+ m->registerdata->freemem = MNEW(s4, e->cummaxstack);
+ m->registerdata->locals = MNEW(varinfo5, e->cumlocals);
+ m->registerdata->interfaces = MNEW(varinfo5, e->cummaxstack);
- m->registerdata->freemem = MNEW(s4, m->maxstack);
- m->registerdata->locals = MNEW(varinfo5, m->maxlocals);
- m->registerdata->interfaces = MNEW(varinfo5, m->maxstack);
-
- for (v = m->registerdata->locals, i = m->maxlocals; i > 0; v++, i--) {
+ for (v = m->registerdata->locals, i = e->cumlocals; i > 0; v++, i--) {
v[0][TYPE_INT].type = -1;
v[0][TYPE_LNG].type = -1;
v[0][TYPE_FLT].type = -1;
v[0][TYPE_ADR].type = -1;
}
- for (v = m->registerdata->interfaces, i = m->maxstack; i > 0; v++, i--) {
+ for (v = m->registerdata->interfaces, i = e->cummaxstack; i > 0; v++, i--) {
v[0][TYPE_INT].type = -1;
v[0][TYPE_INT].flags = 0;
v[0][TYPE_LNG].type = -1;
if (r->secondregs) MFREE(r->secondregs, s4, r->intregsnum);
#endif
- if (r->freemem) MFREE(r->freemem, s4, m->maxstack);
- if (r->locals) MFREE(r->locals, varinfo5, m->maxlocals);
- if (r->interfaces) MFREE(r->interfaces, varinfo5, m->maxstack);
+ if (r->freemem) MFREE(r->freemem, s4, m->codegendata->maxstack);
+ if (r->locals) MFREE(r->locals, varinfo5, m->codegendata->maxlocals);
+ if (r->interfaces) MFREE(r->interfaces, varinfo5, m->codegendata->maxstack);
FREE(m->registerdata, registerdata);
m->registerdata = NULL;
r->iftmpfltregcnt = r->tmpfltregcnt;
r->ifsavfltregcnt = r->savfltregcnt;
- for (s = 0; s < m->maxstack; s++) {
+ for (s = 0; s < m->codegendata->maxstack; s++) {
intalloc = -1; fltalloc = -1;
saved = (r->interfaces[s][TYPE_INT].flags |
r->interfaces[s][TYPE_LNG].flags |
arg = 0, iargcnt = 0, fargcnt = 0;
doublewordarg = 0;
- for (s = 0; s < m->maxlocals; s++) {
+ for (s = 0; s < m->codegendata->maxlocals; s++) {
intalloc = -1; fltalloc = -1;
for (tt = 0; tt <= 4; tt++) {
t = typeloop[tt];
return;
}
- for (s = 0; s < m->maxlocals; s++) {
+ for (s = 0; s < m->codegendata->maxlocals; s++) {
intalloc = -1; fltalloc = -1;
for (tt=0; tt<=4; tt++) {
t = typeloop[tt];
Changes: Edwin Steiner
- $Id: stack.c 1415 2004-10-11 20:12:08Z jowenn $
+ $Id: stack.c 1429 2004-11-02 08:58:26Z jowenn $
*/
s4 *argren;
methodinfo *m=codegendata->method;
- argren = DMNEW(s4, m->maxlocals); /* table for argument renaming */
- for (i = 0; i < m->maxlocals; i++)
+ argren = DMNEW(s4, m->codegendata->maxlocals); /* table for argument renaming */
+ for (i = 0; i < m->codegendata->maxlocals; i++)
argren[i] = i;
m->registerdata->arguments_num = 0;
}
else if (bptr->indepth != stackdepth) {
show_icmd_method(m);
+ printf("Block: %ld, required depth:%ld, current depth:%ld\n",bptr->debug_nr,bptr->indepth,stackdepth);
panic("Stack depth mismatch");
}
break;
case ICMD_CLEAR_ARGREN:
- for (i = iptr->op1; i<m->maxlocals; i++)
+ for (i = iptr->op1; i<m->codegendata->maxlocals; i++)
argren[i] = i;
iptr->opc = opcode = ICMD_NOP;
SETDST;
int i, j;
stackptr t;
- i = m->maxstack;
+ i = m->codegendata->maxstack;
t = s;
while (t) {
i--;
t = t->prev;
}
- j = m->maxstack - i;
+ j = m->codegendata->maxstack - i;
while (--i >= 0)
printf(" ");
while (s) {
printf(".");
utf_fprint(stdout, m->name);
utf_fprint_classname(stdout, m->descriptor);
- printf ("\n\nMax locals: %d\n", (int) m->maxlocals);
- printf ("Max stack: %d\n", (int) m->maxstack);
+ printf ("\n\nMax locals: %d\n", (int) m->codegendata->maxlocals);
+ printf ("Max stack: %d\n", (int) m->codegendata->maxstack);
printf ("Line number table length: %d\n", m->linenumbercount);
}
printf ("Local Table:\n");
- for (i = 0; i < m->maxlocals; i++) {
+ for (i = 0; i < m->codegendata->maxlocals; i++) {
printf(" %3d: ", i);
for (j = TYPE_INT; j <= TYPE_ADR; j++)
if (m->registerdata->locals[i][j].type >= 0) {
printf("\n");
printf ("Interface Table:\n");
- for (i = 0; i < m->maxstack; i++) {
+ for (i = 0; i < m->codegendata->maxstack; i++) {
if ((m->registerdata->interfaces[i][0].type >= 0) ||
(m->registerdata->interfaces[i][1].type >= 0) ||
(m->registerdata->interfaces[i][2].type >= 0) ||
deadcode = bptr->flags <= BBREACHED;
printf("[");
if (deadcode)
- for (j = m->maxstack; j > 0; j--)
+ for (j = m->codegendata->maxstack; j > 0; j--)
printf(" ? ");
else
icmd_print_stack(m, bptr->instack);
for (i = 0; i < bptr->icount; i++, iptr++) {
printf("[");
if (deadcode) {
- for (j = m->maxstack; j > 0; j--)
+ for (j = m->codegendata->maxstack; j > 0; j--)
printf(" ? ");
}
else
break;
}
/* printf(" Line number: %d, method:",iptr->line); */
-/* utf_display(iptr->method->class->name); */
-/* printf("."); */
-/* utf_display(iptr->method->name); */
+ printf("\t\t");
+ utf_display(iptr->method->class->name);
+ printf(".");
+ utf_display(iptr->method->name);
}
Authors: Edwin Steiner
- $Id: typecheck.c 1415 2004-10-11 20:12:08Z jowenn $
+ $Id: typecheck.c 1429 2004-11-02 08:58:26Z jowenn $
*/
#define STORE_TWOWORD(num,type) \
do {typevectorset_store_twoword(localset,num,type);} while(0)
+
+#define WORDCHECKFAULT \
+ do { \
+ show_icmd_method(m); \
+ dolog("localset->td index: %ld\ninstruction belongs to:%s.%s, outermethod:%s.%s\n", \
+ iptr->op1,iptr->method->class->name->text, \
+ iptr->method->name->text,m->class->name->text,m->name->text); \
+ show_icmd(iptr++, false); \
+ show_icmd(iptr, false); \
+ } while (0)
+
+
#define CHECK_ONEWORD(num,tp) \
do {TYPECHECK_COUNT(stat_ins_primload); \
if (jsrencountered) { \
- if (!typevectorset_checktype(localset,num,tp)) \
+ if (!typevectorset_checktype(localset,num,tp)) { \
+ WORDCHECKFAULT; \
panic("Variable type mismatch"); \
+ } \
} \
else { \
- if (localset->td[num].type != tp) \
+ if (localset->td[num].type != tp) { \
panic("Variable type mismatch"); \
+ WORDCHECKFAULT; \
+ } \
} \
} while(0)
#define CHECK_TWOWORD(num,type) \
do {TYPECHECK_COUNT(stat_ins_primload); \
- if (!typevectorset_checktype(localset,num,type)) \
- panic("Variable type mismatch"); \
- } while(0)
+ if (!typevectorset_checktype(localset,num,type)) { \
+ WORDCHECKFAULT; \
+ panic("Variable type mismatch"); \
+ } \
+ } while(0)
/****************************************************************************/
/* MACROS FOR STACK TYPE CHECKING */
#ifdef TYPECHECK_STATISTICS
int count_iterations = 0;
TYPECHECK_COUNT(stat_typechecked);
- TYPECHECK_COUNT_FREQ(stat_locals,m->maxlocals,STAT_LOCALS);
+ TYPECHECK_COUNT_FREQ(stat_locals,m->codegendata->maxlocals,STAT_LOCALS);
TYPECHECK_COUNT_FREQ(stat_blocks,m->basicblockcount/10,STAT_BLOCKS);
#endif
/* In <init> methods we use an extra local variable to signal if
* the 'this' reference has been initialized. */
- numlocals = m->maxlocals;
+ numlocals = m->codegendata->maxlocals;
validlocals = numlocals;
if (initmethod) numlocals++;
typevectorset_copymergedtype(localset,iptr->op1,&(dst->typeinfo));
}
else {
- if (!TYPEDESC_IS_REFERENCE(localset->td[iptr->op1]))
+ if (!TYPEDESC_IS_REFERENCE(localset->td[iptr->op1])) {
+ show_icmd_method(m);
+ dolog("localset->td index: %ld\ninstruction belongs to:%s.%s, outermethod:%s.%s\n",
+ iptr->op1,iptr->method->class->name->text,
+ iptr->method->name->text,m->class->name->text,m->name->text);
+ show_icmd(iptr, false);
panic("illegal instruction: ALOAD loading non-reference");
+ }
TYPEINFO_COPY(localset->td[iptr->op1].info,dst->typeinfo);
}
break;
LOG("saving input stack types");
if (!savedstackbuf) {
LOG("allocating savedstack buffer");
- savedstackbuf = DMNEW(stackelement,m->maxstack);
+ savedstackbuf = DMNEW(stackelement,m->codegendata->maxstack);
savedstackbuf->prev = NULL;
- for (i=1; i<m->maxstack; ++i)
+ for (i=1; i<m->codegendata->maxstack; ++i)
savedstackbuf[i].prev = savedstackbuf+(i-1);
}
sp = savedstack = bptr->instack;
Edwin Steiner
Christian Thalinger
- $Id: loader.c 1415 2004-10-11 20:12:08Z jowenn $
+ $Id: loader.c 1429 2004-11-02 08:58:26Z jowenn $
*/
method_display(m);
}*/
functionptr f = native_findfunction(c->name, m->name, m->descriptor,
- (m->flags & ACC_STATIC) != 0);
- if (f) {
+ (m->flags & ACC_STATIC) != 0);
+#ifdef STATIC_CLASSPATH
+ if (f)
+#endif
+ {
m->stubroutine = createnativestub(f, m);
}
}
## Process this file with automake to produce Makefile.in
-# $Id: Makefile.am 1173 2004-06-16 14:56:18Z jowenn $
+# $Id: Makefile.am 1429 2004-11-02 08:58:26Z jowenn $
INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/jit/@ARCH_DIR@
GtkLabelPeer.c \
GtkScrollPanePeer.c
+implementedNatives:
+ echo "">implementednatives.data
+ grep "JNICALL Java_" *.c | perl -p -i -e "s/.*JNICALL\s//" | perl -p -i -e"s/\(.*//" | (\
+ while read line; do \
+ grep $$line *.h >/dev/null ; \
+ if test $$? == 0; then \
+ echo $$line >>implementednatives.data ;\
+ fi ;\
+ done )
## Local variables:
## mode: Makefile
Changes: Joseph Wenninger
Christian Thalinger
- $Id: Runtime.c 1344 2004-07-21 17:12:53Z twisti $
+ $Id: Runtime.c 1429 2004-11-02 08:58:26Z jowenn $
*/
#include "java_util_Properties.h" /* needed for java_lang_Runtime.h */
#include "java_lang_VMRuntime.h"
+#include "config.h"
+#ifndef STATIC_CLASSPATH
+#include <dlfcn.h>
+#endif
#define JOWENN_DEBUG
#define MAXPROPS 100
static bool shouldFinalizersBeRunOnExit=false;
-static int activeprops = 19;
+static int activeprops = 20;
static char *proplist[MAXPROPS][2] = {
{ "java.class.path", NULL },
{ "os.arch", NULL },
{ "os.name", NULL },
{ "os.version", NULL },
+ { "java.library.path",NULL},
{ "java.class.version", "45.3" },
{ "java.version", PACKAGE":"VERSION },
char *buffer;
int buffer_len;
utf *data;
-
+ int retVal=0;
+
data = javastring_toutf(par1, 0);
if (!data) {
buffer = MNEW(char, buffer_len);
-
+#ifndef STATIC_CLASSPATH
+ /*here it could be interesting to store the references in a list eg for nicely cleaning up or for certain platforms*/
+ if (dlopen(data->text,RTLD_NOW | RTLD_GLOBAL)) {
+ log_text("LIBLOADED");
+ retVal=1;
+ }
+#else
+ retVal=1;
+#endif
strcpy(buffer, "Java_java_lang_VMRuntime_nativeLoad:");
utf_sprint(buffer + strlen((char *) data), data);
log_text(buffer);
-
+
+
MFREE(buffer, char, buffer_len);
#endif
log_text("Java_java_lang_VMRuntime_nativeLoad");
- return 1;
+ return retVal;
}
return 0;;
}
- buffer_len = utf_strlen(data) + 6/*lib .so*/ +1 /*0*/;
+ buffer_len = utf_strlen(data) + 3 /*lib*/ /*6 lib .so */ +1 /*0*/;
buffer = MNEW(char, buffer_len);
sprintf(buffer,"lib");
utf_sprint(buffer+3,data);
- strcat(buffer,".so");
-
+ /*strcat(buffer,".so");*/
+ log_text("nativeGetLibName:");
log_text(buffer);
resultString=javastring_new_char(buffer);
proplist[6][1] = utsnamebuf.sysname;
proplist[7][1] = utsnamebuf.release;
+ proplist[8][1]=getenv("LD_LIBRARY_PATH");
+
if (!p) {
*exceptionptr = new_exception(string_java_lang_NullPointerException);
return;
s4 unhandledWakeup;
} gnu_java_nio_SelectorImpl;
-
-/*
- * Class: gnu/java/nio/SelectorImpl
- * Method: implSelect
- * Signature: ([I[I[IJ)I
- */
-JNIEXPORT s4 JNICALL Java_gnu_java_nio_SelectorImpl_implSelect(JNIEnv *env, jclass clazz, java_intarray* par1, java_intarray* par2, java_intarray* par3, s8 par4);
-
#endif
--- /dev/null
+Java_java_lang_reflect_Constructor_constructNative
+Java_java_lang_reflect_Constructor_getModifiers
+Java_java_lang_reflect_Field_get
+Java_java_lang_reflect_Field_getBoolean
+Java_java_lang_reflect_Field_getByte
+Java_java_lang_reflect_Field_getChar
+Java_java_lang_reflect_Field_getDouble
+Java_java_lang_reflect_Field_getFloat
+Java_java_lang_reflect_Field_getInt
+Java_java_lang_reflect_Field_getLong
+Java_java_lang_reflect_Field_getShort
+Java_java_lang_reflect_Field_set
+Java_java_lang_reflect_Field_setBoolean
+Java_java_lang_reflect_Field_setByte
+Java_java_lang_reflect_Field_setChar
+Java_java_lang_reflect_Field_setDouble
+Java_java_lang_reflect_Field_setFloat
+Java_java_lang_reflect_Field_setInt
+Java_java_lang_reflect_Field_setLong
+Java_java_lang_reflect_Field_setShort
+Java_java_lang_reflect_Field_getType
+Java_java_lang_reflect_Field_getModifiers
+Java_java_lang_JOWENNTest1_f1
+Java_java_lang_JOWENNTest1_f2
+Java_java_lang_JOWENNTest1_f3
+Java_java_lang_JOWENNTest1_f4
+Java_java_lang_JOWENNTest1_f5
+Java_java_lang_JOWENNTest1_f6
+Java_java_lang_JOWENNTest1_f7
+Java_java_lang_JOWENNTest1_f8
+Java_java_lang_JOWENNTest1_f9
+Java_java_lang_reflect_Method_getModifiers
+Java_java_lang_reflect_Method_getReturnType
+Java_java_lang_reflect_Method_getParameterTypes
+Java_java_lang_reflect_Method_getExceptionTypes
+Java_java_lang_reflect_Method_invokeNative
+Java_java_lang_reflect_Proxy_getProxyClass0
+Java_java_lang_reflect_Proxy_getProxyData0
+Java_java_lang_reflect_Proxy_generateProxyClass0
+Java_java_lang_VMRuntime_exit
+Java_java_lang_VMRuntime_freeMemory
+Java_java_lang_VMRuntime_gc
+Java_java_lang_VMRuntime_runFinalization
+Java_java_lang_VMRuntime_runFinalizersOnExit
+Java_java_lang_VMRuntime_runFinalizationForExit
+Java_java_lang_VMRuntime_totalMemory
+Java_java_lang_VMRuntime_traceInstructions
+Java_java_lang_VMRuntime_traceMethodCalls
+Java_java_lang_VMRuntime_availableProcessors
+Java_java_lang_VMRuntime_nativeLoad
+Java_java_lang_VMRuntime_nativeGetLibname
+Java_java_lang_VMRuntime_insertSystemProperties
+Java_java_lang_VMRuntime_maxMemory
+Java_java_lang_VMThread_currentThread
+Java_java_lang_VMThread_interrupt
+Java_java_lang_VMThread_isInterrupted
+Java_java_lang_VMThread_resume
+Java_java_lang_VMThread_nativeSetPriority
+Java_java_lang_VMThread_sleep
+Java_java_lang_VMThread_start
+Java_java_lang_VMThread_nativeStop
+Java_java_lang_VMThread_suspend
+Java_java_lang_VMThread_yield
+Java_java_lang_VMThread_interrupted
+Java_java_lang_VMThread_holdsLock
+Java_java_lang_VMClass_forName
+Java_java_lang_VMClass_getClassLoader
+Java_java_lang_VMClass_getComponentType
+Java_java_lang_VMClass_getDeclaredConstructors
+Java_java_lang_VMClass_getDeclaredClasses
+Java_java_lang_VMClass_getDeclaringClass
+Java_java_lang_VMClass_getDeclaredFields
+Java_java_lang_VMClass_getInterfaces
+Java_java_lang_VMClass_getDeclaredMethods
+Java_java_lang_VMClass_getModifiers
+Java_java_lang_VMClass_getName
+Java_java_lang_VMClass_getSuperclass
+Java_java_lang_VMClass_isArray
+Java_java_lang_VMClass_isAssignableFrom
+Java_java_lang_VMClass_isInstance
+Java_java_lang_VMClass_isInterface
+Java_java_lang_VMClass_isPrimitive
+Java_java_lang_VMClass_initialize
+Java_java_lang_VMClass_loadArrayClass
+Java_java_lang_VMClass_throwException
+Java_java_lang_VMClassLoader_defineClass
+Java_java_lang_VMClassLoader_getPrimitiveClass
+Java_java_lang_VMClassLoader_resolveClass
+Java_java_lang_VMClassLoader_loadClass
+Java_java_lang_VMObject_clone
+Java_java_lang_VMObject_notify
+Java_java_lang_VMObject_notifyAll
+Java_java_lang_VMObject_wait
+Java_java_lang_VMSecurityManager_currentClassLoader
+Java_java_lang_VMSecurityManager_getClassContext
+Java_java_lang_VMString_intern
+Java_java_lang_VMSystem_arraycopy
+Java_java_lang_VMSystem_identityHashCode
+Java_java_lang_VMThrowable_fillInStackTrace
+Java_java_lang_VMThrowable_getStackTrace
struct java_util_Vector* validators;
struct java_util_Hashtable* classLookupTable;
struct java_io_ObjectInputStream_GetField* prereadFields;
+ s4 depth;
} java_io_ObjectInputStream;
*/
JNIEXPORT s8 JNICALL Java_java_lang_VMSystem_currentTimeMillis(JNIEnv *env, jclass clazz);
+
+/*
+ * Class: java/lang/VMSystem
+ * Method: getenv
+ * Signature: (Ljava/lang/String;)Ljava/lang/String;
+ */
+JNIEXPORT struct java_lang_String* JNICALL Java_java_lang_VMSystem_getenv(JNIEnv *env, jclass clazz, struct java_lang_String* par1);
+
#endif
struct java_lang_String* ID;
} java_util_TimeZone;
-
-/*
- * Class: java/util/TimeZone
- * Method: getDefaultTimeZoneId
- * Signature: ()Ljava/lang/String;
- */
-JNIEXPORT struct java_lang_String* JNICALL Java_java_util_TimeZone_getDefaultTimeZoneId(JNIEnv *env, jclass clazz);
-
#endif
The .hh files created with the header file generator are all
included here as are the C functions implementing these methods.
- $Id: native.c 1383 2004-08-02 07:27:00Z stefan $
+ $Id: native.c 1429 2004-11-02 08:58:26Z jowenn $
*/
#undef JOWENN_DEBUG
#undef JOWENN_DEBUG1
+#ifdef STATIC_CLASSPATH
#define NATIVETABLESIZE (sizeof(nativetable)/sizeof(struct nativeref))
/* table for fast string comparison */
/* string comparsion table initialized */
static bool nativecompdone = false;
-
+#endif
/******************************************************************************/
functionptr native_findfunction(utf *cname, utf *mname,
utf *desc, bool isstatic)
{
+#ifdef STATIC_CLASSPATH
int i;
/* entry of table for fast string comparison */
struct nativecompref *n;
/* keep compiler happy */
return NULL;
+#else
+/* dynamic classpath */
+ return 0;
+#endif
}
The .hh files created with the header file generator are all
included here as are the C functions implementing these methods.
- $Id: native.c 1383 2004-08-02 07:27:00Z stefan $
+ $Id: native.c 1429 2004-11-02 08:58:26Z jowenn $
*/
#undef JOWENN_DEBUG
#undef JOWENN_DEBUG1
+#ifdef STATIC_CLASSPATH
#define NATIVETABLESIZE (sizeof(nativetable)/sizeof(struct nativeref))
/* table for fast string comparison */
/* string comparsion table initialized */
static bool nativecompdone = false;
-
+#endif
/******************************************************************************/
functionptr native_findfunction(utf *cname, utf *mname,
utf *desc, bool isstatic)
{
+#ifdef STATIC_CLASSPATH
int i;
/* entry of table for fast string comparison */
struct nativecompref *n;
/* keep compiler happy */
return NULL;
+#else
+/* dynamic classpath */
+ return 0;
+#endif
}
Changes:
- $Id: gennativetable.c 1405 2004-08-17 09:25:01Z twisti $
+ $Id: gennativetable.c 1429 2004-11-02 08:58:26Z jowenn $
*/
if (!file)
panic("Can not open file 'nativetable' to store native-link-table");
- fprintf(file, "/* Table of native methods: nativetables.hh */\n");
+ fprintf(file, "/* Table of native methods: nativetables.inc */\n");
fprintf(file, "/* This file is machine generated, don't edit it !*/\n\n");
+ fprintf(file, "#include \"config.h\"\n");
+
c = chain_first(nativeclass_chain);
while (c) {
gen_header_filename(classname, c->name);
chain_free(nativeclass_chain);
fprintf(file, "\n\n#include \"native.h\"\n\n");
+ fprintf(file, "#ifdef STATIC_CLASSPATH\n\n");
fprintf(file, "static nativeref nativetable[] = {\n");
m = chain_first(nativemethod_chain);
chain_free(nativemethod_chain);
fprintf(file, "};\n");
-
+ fprintf(file,"\n#else\n");
+ fprintf(file, "/*ensure that symbols for functions implemented within cacao are used and exported to dlopen*/\n");
+ fprintf(file, "static functionptr dummynativetable[]={\n");
+ {
+ FILE *implData=fopen("nat/implementednatives.data","r");
+ if (!implData) {fclose(file); exit(3);}
+ while (!feof(implData)) {
+ char functionLine[1024];
+ functionLine[0]='\0';
+ fgets(functionLine,1024,implData);
+ if (strlen(functionLine)<2) continue;
+ if (functionLine[strlen(functionLine)-1]!='\n') { fclose(implData); fclose(file); exit(4);}
+ functionLine[strlen(functionLine)-1]=',';
+ fprintf(file,"\t(functionptr) %s\n",functionLine);
+ }
+ fprintf(file,"\t(functionptr)0");
+ fclose(implData);
+ }
+ fprintf(file, "};\n");
+ fprintf(file,"\n#endif\n");
fclose(file);
-
+
/* release all resources */
loader_close();
## Process this file with automake to produce Makefile.in
-# $Id: Makefile.am 1173 2004-06-16 14:56:18Z jowenn $
+# $Id: Makefile.am 1429 2004-11-02 08:58:26Z jowenn $
INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/jit/@ARCH_DIR@
GtkLabelPeer.c \
GtkScrollPanePeer.c
+implementedNatives:
+ echo "">implementednatives.data
+ grep "JNICALL Java_" *.c | perl -p -i -e "s/.*JNICALL\s//" | perl -p -i -e"s/\(.*//" | (\
+ while read line; do \
+ grep $$line *.h >/dev/null ; \
+ if test $$? == 0; then \
+ echo $$line >>implementednatives.data ;\
+ fi ;\
+ done )
## Local variables:
## mode: Makefile
Changes: Joseph Wenninger
Christian Thalinger
- $Id: VMRuntime.c 1344 2004-07-21 17:12:53Z twisti $
+ $Id: VMRuntime.c 1429 2004-11-02 08:58:26Z jowenn $
*/
#include "java_util_Properties.h" /* needed for java_lang_Runtime.h */
#include "java_lang_VMRuntime.h"
+#include "config.h"
+#ifndef STATIC_CLASSPATH
+#include <dlfcn.h>
+#endif
#define JOWENN_DEBUG
#define MAXPROPS 100
static bool shouldFinalizersBeRunOnExit=false;
-static int activeprops = 19;
+static int activeprops = 20;
static char *proplist[MAXPROPS][2] = {
{ "java.class.path", NULL },
{ "os.arch", NULL },
{ "os.name", NULL },
{ "os.version", NULL },
+ { "java.library.path",NULL},
{ "java.class.version", "45.3" },
{ "java.version", PACKAGE":"VERSION },
char *buffer;
int buffer_len;
utf *data;
-
+ int retVal=0;
+
data = javastring_toutf(par1, 0);
if (!data) {
buffer = MNEW(char, buffer_len);
-
+#ifndef STATIC_CLASSPATH
+ /*here it could be interesting to store the references in a list eg for nicely cleaning up or for certain platforms*/
+ if (dlopen(data->text,RTLD_NOW | RTLD_GLOBAL)) {
+ log_text("LIBLOADED");
+ retVal=1;
+ }
+#else
+ retVal=1;
+#endif
strcpy(buffer, "Java_java_lang_VMRuntime_nativeLoad:");
utf_sprint(buffer + strlen((char *) data), data);
log_text(buffer);
-
+
+
MFREE(buffer, char, buffer_len);
#endif
log_text("Java_java_lang_VMRuntime_nativeLoad");
- return 1;
+ return retVal;
}
return 0;;
}
- buffer_len = utf_strlen(data) + 6/*lib .so*/ +1 /*0*/;
+ buffer_len = utf_strlen(data) + 3 /*lib*/ /*6 lib .so */ +1 /*0*/;
buffer = MNEW(char, buffer_len);
sprintf(buffer,"lib");
utf_sprint(buffer+3,data);
- strcat(buffer,".so");
-
+ /*strcat(buffer,".so");*/
+ log_text("nativeGetLibName:");
log_text(buffer);
resultString=javastring_new_char(buffer);
proplist[6][1] = utsnamebuf.sysname;
proplist[7][1] = utsnamebuf.release;
+ proplist[8][1]=getenv("LD_LIBRARY_PATH");
+
if (!p) {
*exceptionptr = new_exception(string_java_lang_NullPointerException);
return;
Authors: Christian Thalinger
- $Id: exceptions.c 1410 2004-08-17 13:01:24Z twisti $
+ $Id: exceptions.c 1429 2004-11-02 08:58:26Z jowenn $
*/
s4 len;
len = strlen(exception);
- tmp = MNEW(char, len);
+ tmp = MNEW(char, len+1);
strncpy(tmp, exception, len);
+ tmp[len]='\0';
/* convert to classname */
memory. All functions writing values into the data area return the offset
relative the begin of the code area (start of procedure).
- $Id: codegen.inc 1420 2004-10-27 16:05:14Z twisti $
+ $Id: codegen.inc 1429 2004-11-02 08:58:26Z jowenn $
*/
#include "toolbox/logging.h"
#include "toolbox/avl.h"
#include "threads/thread.h"
-
+#ifndef STATIC_CLASSPATH
+#include <dlfcn.h>
+#endif
/* in this tree we store all method addresses */
cd->exceptiontablelength=m->exceptiontablelength;
cd->exceptiontable = MNEW(exceptiontable, m->exceptiontablelength + 1);
}
-
+ if (e) {
+ cd->maxstack=e->cummaxstack;
+ cd->maxlocals=e->cumlocals;
+ } else {
+ cd->maxstack=m->maxstack;
+ cd->maxlocals=m->maxlocals;
+ }
#if defined(USE_THREADS) && defined(NATIVE_THREADS)
cd->threadcritcurrent.next = NULL;
cd->threadcritcount = 0;
}
#endif
+#ifndef STATIC_CLASSPATH
+static size_t codegen_overloadPartLen(utf *desc) {
+ char *utf_ptr=desc->text;
+ u2 c;
+ size_t len=2;
+ while ((c=utf_nextu2(&utf_ptr))!=')') {
+ switch (c) {
+ case 'I':
+ case 'S':
+ case 'B':
+ case 'C':
+ case 'Z':
+ case 'J':
+ case 'F':
+ case 'D':
+ len ++;
+ break;
+ case '[':
+ len = len+2;
+ break;
+ case 'L':
+ len++;
+ while ( (c=utf_nextu2(&utf_ptr)) != ';')
+ len++;
+ len=len+2;
+ break;
+ case '(':
+ break;
+ default: panic ("invalid method descriptor");
+ }
+ }
+ return len;
+
+}
+
+static void codegen_fillInOverloadPart(char *target,utf *desc) {
+ char *utf_ptr=desc->text;
+ u2 c;
+ char* insertpos=&target[strlen(target)];
+ *(insertpos++)='_';
+ *(insertpos++)='_';
+ while ((c=utf_nextu2(&utf_ptr))!=')') {
+ switch (c) {
+ case 'I':
+ case 'S':
+ case 'B':
+ case 'C':
+ case 'Z':
+ case 'J':
+ case 'F':
+ case 'D':
+ *(insertpos++)=c;
+ break;
+ case '[':
+ *(insertpos++)='_';
+ *(insertpos++)='3';
+ break;
+ case 'L':
+ *(insertpos++)='L';
+ while ( (c=utf_nextu2(&utf_ptr)) != ';')
+ if ( ((c>='a') && (c<='z')) ||
+ ((c>='A') && (c<='Z')) ||
+ ((c>='0') && (c<='9')) )
+ *(insertpos++)=c;
+ else *(insertpos++)='_';
+ *(insertpos++)='_';
+ *(insertpos++)='2';
+ break;
+ case '(':
+ break;
+ default: panic ("invalid method descriptor");
+ }
+ }
+ *insertpos='\0';
+
+}
+
+static void codegen_resolve_native(methodinfo *m,void **insertionPoint,void *jmpTarget,void **jmpPatchTarget) {
+ char *nativeName;
+ size_t nativeLen;
+ size_t i;
+
+ builtin_monitorenter((java_objectheader*) m);
+ if ((*jmpPatchTarget)==jmpTarget) {
+ builtin_monitorexit((java_objectheader*) m);
+ return;
+ }
+ log_text("trying to resolve a native method");
+ utf_display(m->class->name);
+ utf_display(m->name);
+
+ void *lib=dlopen(0,RTLD_NOW | RTLD_GLOBAL);
+ if (lib) {
+ int ok=0;
+ /*generate the name of the native function in the form Java_package1_package2...._classname_methodname*/
+ nativeLen=/*Java_*/5+strlen(m->class->name->text)+/*_*/1+strlen(m->name->text)+/*\0*/1;
+ nativeName=MNEW(char,nativeLen);
+ sprintf(nativeName,"Java_%s_%s",m->class->name->text,m->name->text);
+ for (i=0;i<nativeLen;i++) {
+ if (nativeName[i]=='/') nativeName[i]='_';
+ }
+
+
+ void *sym=dlsym(lib,nativeName);
+ if (sym) {
+ ok=1;
+ log_text("resolved");
+ MFREE(nativeName,char,nativeLen);
+ } else {
+ size_t overloadedNativeLen=nativeLen+codegen_overloadPartLen(m->descriptor);
+ char *overloadedNative=MNEW(char,overloadedNativeLen);
+ sprintf(overloadedNative,"%s",nativeName);
+ MFREE(nativeName,char,nativeLen);
+ codegen_fillInOverloadPart(overloadedNative,m->descriptor);
+ log_text("symbol not found,trying harder (overloaded member ?)");
+ sym=dlsym(lib,overloadedNative);
+ if (sym) {
+ MFREE(overloadedNative,char,overloadedNativeLen);
+ ok=1;
+ log_text("resolved");
+ } else {
+ MFREE(overloadedNative,char,overloadedNativeLen);
+ log_text("It was not possible to find the native function implementation. Not even in overloading case");
+ }
+ }
+ if (ok) {
+ (*insertionPoint)=sym;
+ (*jmpPatchTarget)=jmpTarget;
+ builtin_monitorexit((java_objectheader *) m );
+ return;
+ }
+
+ } else log_text("library not found");
+
+
+ {
+ char *info;
+ size_t slen;
+ slen=2+strlen(m->class->name->text)+strlen(m->name->text)+strlen(m->descriptor->text);
+ info=(char*)MNEW(char,slen);
+ sprintf(info,"%s.%s%s",m->class->name->text,m->name->text,m->descriptor->text);
+
+ builtin_monitorexit((java_objectheader *) m );
+ throw_cacao_exception_exit(string_java_lang_LinkageError,
+ info);
+ }
+
+}
+#endif
+
/*
* These are local overrides for various environment variables in Emacs.
* Please do not remove this and leave it at the end of the file, where
Authors: Christian Thalinger
- $Id: codegen.inc.h 1415 2004-10-11 20:12:08Z jowenn $
+ $Id: codegen.inc.h 1429 2004-11-02 08:58:26Z jowenn $
*/
threadcritnodetemp *threadcrit; /* List of critical code regions */
threadcritnodetemp threadcritcurrent;
s4 threadcritcount; /* Number of critical regions */
+ int maxstack;
+ int maxlocals;
};
Authors: Andreas Krall
Christian Thalinger
- $Id: codegen.c 1415 2004-10-11 20:12:08Z jowenn $
+ $Id: codegen.c 1429 2004-11-02 08:58:26Z jowenn $
*/
#define _GNU_SOURCE
+#include "config.h"
#include "global.h"
#include <stdio.h>
#include <signal.h>
#include "jit/reg.h"
#include "jit/i386/codegen.h"
#include "jit/i386/emitfuncs.h"
-
/* include independent code generation stuff */
#include "jit/codegen.inc"
#include "jit/reg.inc"
int p, t;
codegendata *cd;
+ void** callAddrPatchPos=0;
+ u1* jmpInstrPos=0;
+ void** jmpInstrPatchPos=0;
/* setup codegendata structure */
codegen_setup(m,0);
/* CREATE DYNAMIC STACK INFO -- END*/
+/* RESOLVE NATIVE METHOD -- BEGIN*/
+#ifndef STATIC_CLASSPATH
+ if (f==0) {
+ log_text("Dynamic classpath: preparing for delayed native function resolving");
+ i386_jmp_imm(cd,0);
+ jmpInstrPos=cd->mcodeptr-4;
+ /*patchposition*/
+ i386_mov_imm_reg(cd,jmpInstrPos,REG_ITMP1);
+ i386_push_reg(cd,REG_ITMP1);
+ /*jmp offset*/
+ i386_mov_imm_reg(cd,0,REG_ITMP1);
+ jmpInstrPatchPos=cd->mcodeptr-4;
+ i386_push_reg(cd,REG_ITMP1);
+ /*position of call address to patch*/
+ i386_mov_imm_reg(cd,0,REG_ITMP1);
+ callAddrPatchPos=(cd->mcodeptr-4);
+ i386_push_reg(cd,REG_ITMP1);
+ /*method info structure*/
+ i386_mov_imm_reg(cd,(s4) m, REG_ITMP1);
+ i386_push_reg(cd,REG_ITMP1);
+ /*call resolve functions*/
+ i386_mov_imm_reg(cd, (s4)codegen_resolve_native,REG_ITMP1);
+ i386_call_reg(cd,REG_ITMP1);
+ /*cleanup*/
+ i386_pop_reg(cd,REG_ITMP1);
+ i386_pop_reg(cd,REG_ITMP1);
+ i386_pop_reg(cd,REG_ITMP1);
+ i386_pop_reg(cd,REG_ITMP1);
+ /*fix jmp offset replacement*/
+ (*jmpInstrPatchPos)=cd->mcodeptr-jmpInstrPos-4;
+ } else log_text("Dynamic classpath: immediate native function resolution possible");
+#endif
+/* RESOLVE NATIVE METHOD -- END*/
+
+
tptr = m->paramtypes;
for (i = 0; i < m->paramcount; i++) {
i386_mov_imm_membase(cd, (s4) &env, REG_SP, 0);
i386_mov_imm_reg(cd, (s4) f, REG_ITMP1);
+#ifndef STATIC_CLASSPATH
+ if (f==0)
+ (*callAddrPatchPos)=(cd->mcodeptr-4);
+#endif
i386_call_reg(cd, REG_ITMP1);
+
/*REMOVE DYNAMIC STACK INFO -BEGIN */
i386_push_reg(cd, REG_RESULT2);
i386_mov_membase_reg(cd, REG_SP,stackframesize-8,REG_ITMP2); /*old value*/
Authors: Dieter Thuernbeck
- $Id: inline.c 1415 2004-10-11 20:12:08Z jowenn $
+ $Id: inline.c 1429 2004-11-02 08:58:26Z jowenn $
*/
inlining_set_compiler_variables_fun(m, inline_env);
inline_env->isinlinedmethod = 0;
inline_env->cumjcodelength = m->jcodelength; /* for not inlining */
- inline_env->cummaxstack = 0;
+ inline_env->cummaxstack = m->maxstack; /*why has here been 0 ? */
inline_env->cumextablelength = 0;
inline_env->cumlocals = m->maxlocals;
inline_env->cummethods = 0;//co not global or static-used only here?
m->maxlocals, inline_env->cumlocals,
m->maxstack, inline_env->cummaxstack); fflush(stdout);
}
+#if 0
+/*This looks wrong*/
m->maxlocals = inline_env->cumlocals; //orig not used
m->maxstack = inline_env->cummaxstack; //orig global maxstack var!!
-
+#endif
//panic("TEMP so can test just inline init\n");
}
return inline_env;
Changes: Edwin Steiner
- $Id: jit.c 1420 2004-10-27 16:05:14Z twisti $
+ $Id: jit.c 1429 2004-11-02 08:58:26Z jowenn $
*/
EXTABLEN
- reg_setup(m);
+ reg_setup(inline_env);
/* setup the codegendata memory */
codegen_setup(m,inline_env);
Changes: Carolyn Oates
Edwin Steiner
- $Id: parse.c 1421 2004-10-28 14:39:49Z stefan $
+ $Id: parse.c 1429 2004-11-02 08:58:26Z jowenn $
*/
if ((useinlining) && (gp == nextgp)) {
u1 *tptr;
bool *readonly = NULL;
-
+ int argBlockIdx=0;
opcode = code_get_u1(p,inline_env->method);
nextp = p += jcommandsize[opcode];
label_index = tmpinlinf->label_index;
readonly = tmpinlinf->readonly;
+ for (i=0,tptr=tmpinlinf->method->paramtypes;i<tmpinlinf->method->paramcount;i++,tptr++) {
+ if ( ((*tptr)==TYPE_LNG) ||
+ ((*tptr)==TYPE_DBL) )
+ argBlockIdx+=2;
+ else
+ argBlockIdx++;
+ }
for (i = 0, tptr = tmpinlinf->method->paramtypes + tmpinlinf->method->paramcount - 1; i < tmpinlinf->method->paramcount; i++, tptr--) {
int op;
}
op += *tptr;
- OP1(op, firstlocal + tmpinlinf->method->paramcount - 1 - i);
-
+ if ( ((*tptr)==TYPE_LNG) ||
+ ((*tptr)==TYPE_DBL) )
+ argBlockIdx-=2;
+ else
+ argBlockIdx--;
+
+ OP1(op, firstlocal + argBlockIdx);
+ //OP1(op, firstlocal + tmpinlinf->method->paramcount - 1 - i);
+ //printf("inline argument load operation for local: %ld\n",firstlocal + tmpinlinf->method->paramcount - 1 - i);
/*m->basicblockindex[gp] |= (ipc << 1);*/ /*FIXME: necessary ? */
}
if (DEBUG==true) {
/* OP(ICMD_NOP); */
/* break; */
/* } */
+ if (nextp>inline_env->method->jcodelength-1) {
+ //OP1(ICMD_GOTO, inlinfo->stopgp);
+ //OP(ICMD_NOP);
+ //OP(ICMD_NOP);
+ blockend=true;
+ break;
+ }//JJJJJJJ
blockend = true;
OP1(ICMD_GOTO, inlinfo->stopgp);
break;
/* INLINING */
- if (inline_env->isinlinedmethod && p == inline_env->method->jcodelength - 1) { /* end of an inlined method */
+// if (inline_env->isinlinedmethod && p == inline_env->method->jcodelength - 1) { /* end of an inlined method */
+ if (inline_env->isinlinedmethod && (nextp >= inline_env->method->jcodelength) ) { /* end of an inlined method */
/* printf("setting gp from %d to %d\n",gp, inlinfo->stopgp); */
gp = inlinfo->stopgp;
inlining_restore_compiler_variables();
} /* end for */
- if (p != m->jcodelength)
+ if (p != m->jcodelength) {
+ printf("p (%ld) != m->jcodelength (%ld)\n",p,m->jcodelength);
panic("Command-sequence crosses code-boundary");
-
+ }
if (!blockend) {
*exceptionptr = new_verifyerror(m, "Falling off the end of the code");
return NULL;
Authors: Christian Thalinger
- $Id: reg.h 1234 2004-06-30 19:49:37Z twisti $
+ $Id: reg.h 1429 2004-11-02 08:58:26Z jowenn $
*/
typedef struct registerdata registerdata;
typedef varinfo varinfo5[5];
+struct t_inlining_globals;
+
struct registerdata {
varinfo5 *locals;
/* function prototypes */
void reg_init(methodinfo *m);
-void reg_setup(methodinfo *m);
+void reg_setup(struct t_inlining_globals *e);
void reg_close(methodinfo *m);
void regalloc(methodinfo *m);
Changes: Stefan Ring
Christian Thalinger
- $Id: reg.inc 1342 2004-07-21 16:10:17Z twisti $
+ $Id: reg.inc 1429 2004-11-02 08:58:26Z jowenn $
*/
}
-void reg_setup(methodinfo *m)
+void reg_setup(t_inlining_globals *e)
{
s4 i;
varinfo5 *v;
+ methodinfo *m=e->method;
+ m->registerdata->freemem = MNEW(s4, e->cummaxstack);
+ m->registerdata->locals = MNEW(varinfo5, e->cumlocals);
+ m->registerdata->interfaces = MNEW(varinfo5, e->cummaxstack);
- m->registerdata->freemem = MNEW(s4, m->maxstack);
- m->registerdata->locals = MNEW(varinfo5, m->maxlocals);
- m->registerdata->interfaces = MNEW(varinfo5, m->maxstack);
-
- for (v = m->registerdata->locals, i = m->maxlocals; i > 0; v++, i--) {
+ for (v = m->registerdata->locals, i = e->cumlocals; i > 0; v++, i--) {
v[0][TYPE_INT].type = -1;
v[0][TYPE_LNG].type = -1;
v[0][TYPE_FLT].type = -1;
v[0][TYPE_ADR].type = -1;
}
- for (v = m->registerdata->interfaces, i = m->maxstack; i > 0; v++, i--) {
+ for (v = m->registerdata->interfaces, i = e->cummaxstack; i > 0; v++, i--) {
v[0][TYPE_INT].type = -1;
v[0][TYPE_INT].flags = 0;
v[0][TYPE_LNG].type = -1;
if (r->secondregs) MFREE(r->secondregs, s4, r->intregsnum);
#endif
- if (r->freemem) MFREE(r->freemem, s4, m->maxstack);
- if (r->locals) MFREE(r->locals, varinfo5, m->maxlocals);
- if (r->interfaces) MFREE(r->interfaces, varinfo5, m->maxstack);
+ if (r->freemem) MFREE(r->freemem, s4, m->codegendata->maxstack);
+ if (r->locals) MFREE(r->locals, varinfo5, m->codegendata->maxlocals);
+ if (r->interfaces) MFREE(r->interfaces, varinfo5, m->codegendata->maxstack);
FREE(m->registerdata, registerdata);
m->registerdata = NULL;
r->iftmpfltregcnt = r->tmpfltregcnt;
r->ifsavfltregcnt = r->savfltregcnt;
- for (s = 0; s < m->maxstack; s++) {
+ for (s = 0; s < m->codegendata->maxstack; s++) {
intalloc = -1; fltalloc = -1;
saved = (r->interfaces[s][TYPE_INT].flags |
r->interfaces[s][TYPE_LNG].flags |
arg = 0, iargcnt = 0, fargcnt = 0;
doublewordarg = 0;
- for (s = 0; s < m->maxlocals; s++) {
+ for (s = 0; s < m->codegendata->maxlocals; s++) {
intalloc = -1; fltalloc = -1;
for (tt = 0; tt <= 4; tt++) {
t = typeloop[tt];
return;
}
- for (s = 0; s < m->maxlocals; s++) {
+ for (s = 0; s < m->codegendata->maxlocals; s++) {
intalloc = -1; fltalloc = -1;
for (tt=0; tt<=4; tt++) {
t = typeloop[tt];
Changes: Edwin Steiner
- $Id: stack.c 1415 2004-10-11 20:12:08Z jowenn $
+ $Id: stack.c 1429 2004-11-02 08:58:26Z jowenn $
*/
s4 *argren;
methodinfo *m=codegendata->method;
- argren = DMNEW(s4, m->maxlocals); /* table for argument renaming */
- for (i = 0; i < m->maxlocals; i++)
+ argren = DMNEW(s4, m->codegendata->maxlocals); /* table for argument renaming */
+ for (i = 0; i < m->codegendata->maxlocals; i++)
argren[i] = i;
m->registerdata->arguments_num = 0;
}
else if (bptr->indepth != stackdepth) {
show_icmd_method(m);
+ printf("Block: %ld, required depth:%ld, current depth:%ld\n",bptr->debug_nr,bptr->indepth,stackdepth);
panic("Stack depth mismatch");
}
break;
case ICMD_CLEAR_ARGREN:
- for (i = iptr->op1; i<m->maxlocals; i++)
+ for (i = iptr->op1; i<m->codegendata->maxlocals; i++)
argren[i] = i;
iptr->opc = opcode = ICMD_NOP;
SETDST;
int i, j;
stackptr t;
- i = m->maxstack;
+ i = m->codegendata->maxstack;
t = s;
while (t) {
i--;
t = t->prev;
}
- j = m->maxstack - i;
+ j = m->codegendata->maxstack - i;
while (--i >= 0)
printf(" ");
while (s) {
printf(".");
utf_fprint(stdout, m->name);
utf_fprint_classname(stdout, m->descriptor);
- printf ("\n\nMax locals: %d\n", (int) m->maxlocals);
- printf ("Max stack: %d\n", (int) m->maxstack);
+ printf ("\n\nMax locals: %d\n", (int) m->codegendata->maxlocals);
+ printf ("Max stack: %d\n", (int) m->codegendata->maxstack);
printf ("Line number table length: %d\n", m->linenumbercount);
}
printf ("Local Table:\n");
- for (i = 0; i < m->maxlocals; i++) {
+ for (i = 0; i < m->codegendata->maxlocals; i++) {
printf(" %3d: ", i);
for (j = TYPE_INT; j <= TYPE_ADR; j++)
if (m->registerdata->locals[i][j].type >= 0) {
printf("\n");
printf ("Interface Table:\n");
- for (i = 0; i < m->maxstack; i++) {
+ for (i = 0; i < m->codegendata->maxstack; i++) {
if ((m->registerdata->interfaces[i][0].type >= 0) ||
(m->registerdata->interfaces[i][1].type >= 0) ||
(m->registerdata->interfaces[i][2].type >= 0) ||
deadcode = bptr->flags <= BBREACHED;
printf("[");
if (deadcode)
- for (j = m->maxstack; j > 0; j--)
+ for (j = m->codegendata->maxstack; j > 0; j--)
printf(" ? ");
else
icmd_print_stack(m, bptr->instack);
for (i = 0; i < bptr->icount; i++, iptr++) {
printf("[");
if (deadcode) {
- for (j = m->maxstack; j > 0; j--)
+ for (j = m->codegendata->maxstack; j > 0; j--)
printf(" ? ");
}
else
break;
}
/* printf(" Line number: %d, method:",iptr->line); */
-/* utf_display(iptr->method->class->name); */
-/* printf("."); */
-/* utf_display(iptr->method->name); */
+ printf("\t\t");
+ utf_display(iptr->method->class->name);
+ printf(".");
+ utf_display(iptr->method->name);
}
Authors: Edwin Steiner
- $Id: typecheck.c 1415 2004-10-11 20:12:08Z jowenn $
+ $Id: typecheck.c 1429 2004-11-02 08:58:26Z jowenn $
*/
#define STORE_TWOWORD(num,type) \
do {typevectorset_store_twoword(localset,num,type);} while(0)
+
+#define WORDCHECKFAULT \
+ do { \
+ show_icmd_method(m); \
+ dolog("localset->td index: %ld\ninstruction belongs to:%s.%s, outermethod:%s.%s\n", \
+ iptr->op1,iptr->method->class->name->text, \
+ iptr->method->name->text,m->class->name->text,m->name->text); \
+ show_icmd(iptr++, false); \
+ show_icmd(iptr, false); \
+ } while (0)
+
+
#define CHECK_ONEWORD(num,tp) \
do {TYPECHECK_COUNT(stat_ins_primload); \
if (jsrencountered) { \
- if (!typevectorset_checktype(localset,num,tp)) \
+ if (!typevectorset_checktype(localset,num,tp)) { \
+ WORDCHECKFAULT; \
panic("Variable type mismatch"); \
+ } \
} \
else { \
- if (localset->td[num].type != tp) \
+ if (localset->td[num].type != tp) { \
panic("Variable type mismatch"); \
+ WORDCHECKFAULT; \
+ } \
} \
} while(0)
#define CHECK_TWOWORD(num,type) \
do {TYPECHECK_COUNT(stat_ins_primload); \
- if (!typevectorset_checktype(localset,num,type)) \
- panic("Variable type mismatch"); \
- } while(0)
+ if (!typevectorset_checktype(localset,num,type)) { \
+ WORDCHECKFAULT; \
+ panic("Variable type mismatch"); \
+ } \
+ } while(0)
/****************************************************************************/
/* MACROS FOR STACK TYPE CHECKING */
#ifdef TYPECHECK_STATISTICS
int count_iterations = 0;
TYPECHECK_COUNT(stat_typechecked);
- TYPECHECK_COUNT_FREQ(stat_locals,m->maxlocals,STAT_LOCALS);
+ TYPECHECK_COUNT_FREQ(stat_locals,m->codegendata->maxlocals,STAT_LOCALS);
TYPECHECK_COUNT_FREQ(stat_blocks,m->basicblockcount/10,STAT_BLOCKS);
#endif
/* In <init> methods we use an extra local variable to signal if
* the 'this' reference has been initialized. */
- numlocals = m->maxlocals;
+ numlocals = m->codegendata->maxlocals;
validlocals = numlocals;
if (initmethod) numlocals++;
typevectorset_copymergedtype(localset,iptr->op1,&(dst->typeinfo));
}
else {
- if (!TYPEDESC_IS_REFERENCE(localset->td[iptr->op1]))
+ if (!TYPEDESC_IS_REFERENCE(localset->td[iptr->op1])) {
+ show_icmd_method(m);
+ dolog("localset->td index: %ld\ninstruction belongs to:%s.%s, outermethod:%s.%s\n",
+ iptr->op1,iptr->method->class->name->text,
+ iptr->method->name->text,m->class->name->text,m->name->text);
+ show_icmd(iptr, false);
panic("illegal instruction: ALOAD loading non-reference");
+ }
TYPEINFO_COPY(localset->td[iptr->op1].info,dst->typeinfo);
}
break;
LOG("saving input stack types");
if (!savedstackbuf) {
LOG("allocating savedstack buffer");
- savedstackbuf = DMNEW(stackelement,m->maxstack);
+ savedstackbuf = DMNEW(stackelement,m->codegendata->maxstack);
savedstackbuf->prev = NULL;
- for (i=1; i<m->maxstack; ++i)
+ for (i=1; i<m->codegendata->maxstack; ++i)
savedstackbuf[i].prev = savedstackbuf+(i-1);
}
sp = savedstack = bptr->instack;
Edwin Steiner
Christian Thalinger
- $Id: loader.c 1415 2004-10-11 20:12:08Z jowenn $
+ $Id: loader.c 1429 2004-11-02 08:58:26Z jowenn $
*/
method_display(m);
}*/
functionptr f = native_findfunction(c->name, m->name, m->descriptor,
- (m->flags & ACC_STATIC) != 0);
- if (f) {
+ (m->flags & ACC_STATIC) != 0);
+#ifdef STATIC_CLASSPATH
+ if (f)
+#endif
+ {
m->stubroutine = createnativestub(f, m);
}
}