/* src/vm/jit/codegen-common.c - architecture independent code generator stuff
- Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel,
+ Copyright (C) 1996-2005, 2006, 2007 R. Grafl, A. Krall, C. Kruegel,
C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
J. Wenninger, Institut f. Computersprachen - TU Wien
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
- Contact: cacao@cacaojvm.org
-
- Authors: Reinhard Grafl
- Andreas Krall
- Christian Thalinger
- Joseph Wenninger
- Edwin Steiner
-
All functions assume the following code area / data area layout:
+-----------+
memory. All functions writing values into the data area return the offset
relative the begin of the code area (start of procedure).
- $Id: codegen-common.c 5951 2006-11-11 18:31:10Z twisti $
+ $Id: codegen-common.c 7246 2007-01-29 18:49:05Z twisti $
*/
#endif
#include "mm/memory.h"
+
#include "toolbox/avl.h"
#include "toolbox/list.h"
#include "toolbox/logging.h"
+
#include "native/jni.h"
#include "native/native.h"
#endif
#include "vm/exceptions.h"
-#include "vm/method.h"
-#include "vm/options.h"
-#include "vm/statistics.h"
#include "vm/stringlocal.h"
+
#include "vm/jit/asmpart.h"
#include "vm/jit/codegen-common.h"
#include "vm/jit/dseg.h"
#include "vm/jit/jit.h"
+#include "vm/jit/md.h"
#include "vm/jit/stacktrace.h"
#include "vm/jit/replace.h"
#include "vm/jit/intrp/intrp.h"
#endif
+#include "vmcore/method.h"
+#include "vmcore/options.h"
+
+#if defined(ENABLE_STATISTICS)
+# include "vmcore/statistics.h"
+#endif
+
/* in this tree we store all method addresses *********************************/
}
+/* codegen_set_replacement_point_notrap ****************************************
+
+ Record the position of a non-trappable replacement point.
+
+*******************************************************************************/
+
+#if defined(ENABLE_REPLACEMENT)
+#if !defined(NDEBUG)
+void codegen_set_replacement_point_notrap(codegendata *cd, s4 type)
+#else
+void codegen_set_replacement_point_notrap(codegendata *cd)
+#endif
+{
+ assert(cd->replacementpoint);
+ assert(cd->replacementpoint->type == type);
+ assert(cd->replacementpoint->flags & RPLPOINT_FLAG_NOTRAP);
+
+ cd->replacementpoint->pc = (u1*) (ptrint) (cd->mcodeptr - cd->mcodebase);
+
+ cd->replacementpoint++;
+}
+#endif /* defined(ENABLE_REPLACEMENT) */
+
+
+/* codegen_set_replacement_point ***********************************************
+
+ Record the position of a trappable replacement point.
+
+*******************************************************************************/
+
+#if defined(ENABLE_REPLACEMENT)
+#if !defined(NDEBUG)
+void codegen_set_replacement_point(codegendata *cd, s4 type)
+#else
+void codegen_set_replacement_point(codegendata *cd)
+#endif
+{
+ assert(cd->replacementpoint);
+ assert(cd->replacementpoint->type == type);
+ assert(!(cd->replacementpoint->flags & RPLPOINT_FLAG_NOTRAP));
+
+ cd->replacementpoint->pc = (u1*) (ptrint) (cd->mcodeptr - cd->mcodebase);
+
+ cd->replacementpoint++;
+
+ /* XXX assert(cd->lastmcodeptr <= cd->mcodeptr); */
+
+ cd->lastmcodeptr = cd->mcodeptr + PATCHER_CALL_SIZE;
+}
+#endif /* defined(ENABLE_REPLACEMENT) */
+
+
/* codegen_finish **************************************************************
Finishes the code generation. A new memory, large enough for both
*((ptrint *) ((ptrint) epoint + cd->linenumbertablesizepos)) = lrtlen;
}
+#if defined(ENABLE_REPLACEMENT)
/* replacement point resolving */
{
int i;
rplpoint *rp;
+ code->replacementstubs += (ptrint) epoint;
+
rp = code->rplpoints;
for (i=0; i<code->rplpointcount; ++i, ++rp) {
rp->pc = (u1*) ((ptrint) epoint + (ptrint) rp->pc);
- rp->outcode = (u1*) ((ptrint) epoint + (ptrint) rp->outcode);
}
}
+#endif /* defined(ENABLE_REPLACEMENT) */
/* add method into methodtree to find the entrypoint */
stacktrace_create_native_stackframeinfo(sfi, pv, sp, ra);
+#if defined(ENABLE_JAVASE)
/* add current JNI local references table to this thread */
lrt->capacity = LOCALREFTABLE_CAPACITY;
MSET(lrt->refs, 0, java_objectheader*, LOCALREFTABLE_CAPACITY);
LOCALREFTABLE = lrt;
+#endif
}
*psfi = sfi->prev;
+#if defined(ENABLE_JAVASE)
/* release JNI local references tables for this thread */
lrt = LOCALREFTABLE;
/* now store the previous local frames in the thread structure */
LOCALREFTABLE = lrt;
+#endif
/* get the exception and return it */