again with the 'real' upstream (http://www.netlib.org/fdlibm/readme).
-* src/lib/classes/*
+* src/lib/gnu/*
GNU Classpath is licensed under the terms of the GNU General Public
License with the following clarification and special exception:
See contrib/vmlog/COPYING for the full text of the license.
+
+* contrib/mapfile-vers-product, src/lib/gnu/sun/misc/Unsafe.java
+
+Copyright 2000-2006 Sun Microsystems, Inc. All Rights Reserved.
+DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+
+This code is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License version 2 only, as
+published by the Free Software Foundation. Sun designates this
+particular file as subject to the "Classpath" exception as provided
+by Sun in the LICENSE file that accompanied this code.
+
+This code is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+version 2 for more details (a copy is included in the LICENSE file that
+accompanied this code).
+
+You should have received a copy of the GNU General Public License version
+2 along with this work; if not, write to the Free Software Foundation,
+Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+
+Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+CA 95054 USA or visit www.sun.com if you need additional information or
+have any questions.
AC_DEFUN([AC_PROG_JAVAC],[
AC_REQUIRE([AC_EXEEXT])dnl
if test "x$JAVAPREFIX" = x; then
- test "x$JAVAC" = x && AC_CHECK_PROGS(JAVAC, "ecj$EXEEXT -bootclasspath ${CLASSPATH_CLASSES} -1.5" "gcj$EXEEXT -C -bootclasspath ${CLASSPATH_CLASSES}" "jikes$EXEEXT -bootclasspath ${CLASSPATH_CLASSES}" "javac$EXEEXT -bootclasspath ${CLASSPATH_CLASSES}")
+ test "x$JAVAC" = x && AC_CHECK_PROGS(JAVAC, "javac$EXEEXT -bootclasspath ${CLASSPATH_CLASSES}" "ecj$EXEEXT -bootclasspath ${CLASSPATH_CLASSES} -1.5" "gcj$EXEEXT -C -bootclasspath ${CLASSPATH_CLASSES}" "jikes$EXEEXT -bootclasspath ${CLASSPATH_CLASSES}")
else
- test "x$JAVAC" = x && AC_CHECK_PROGS(JAVAC, "ecj$EXEEXT -bootclasspath ${CLASSPATH_CLASSES} -1.5" "gcj$EXEEXT -C -bootclasspath ${CLASSPATH_CLASSES}" "jikes$EXEEXT -bootclasspath ${CLASSPATH_CLASSES}" "javac$EXEEXT -bootclasspath ${CLASSPATH_CLASSES}", $JAVAPREFIX)
+ test "x$JAVAC" = x && AC_CHECK_PROGS(JAVAC, "javac$EXEEXT -bootclasspath ${CLASSPATH_CLASSES}" "ecj$EXEEXT -bootclasspath ${CLASSPATH_CLASSES} -1.5" "gcj$EXEEXT -C -bootclasspath ${CLASSPATH_CLASSES}" "jikes$EXEEXT -bootclasspath ${CLASSPATH_CLASSES}", $JAVAPREFIX)
fi
test "x$JAVAC" = x && AC_MSG_ERROR([no acceptable Java compiler found in \$PATH])
AC_PROG_JAVAC_WORKS
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
- $Id: dummy.c 8123 2007-06-20 23:50:55Z michi $
+ $Id: dummy.c 8245 2007-07-31 09:55:04Z michi $
*/
{
}
+void md_param_alloc_native(methoddesc *md)
+{
+}
+
/* memory *********************************************************************/
/* properties *****************************************************************/
+void properties_add(char *key, char *value)
+{
+}
+
char *properties_get(char *key)
{
return NULL;
/* vm *************************************************************************/
+void vm_printconfig(void)
+{
+}
+
void vm_abort(const char *text, ...)
{
va_list ap;
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
- $Id: boehm.c 8179 2007-07-05 11:21:08Z michi $
+ $Id: boehm.c 8245 2007-07-31 09:55:04Z michi $
*/
return NULL;
if (finalizer != NULL)
- GC_REGISTER_FINALIZER(p, finalizer_run, 0, 0, 0);
+ GC_REGISTER_FINALIZER_NO_ORDER(p, finalizer_run, 0, 0, 0);
/* clear allocated memory region */
## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
## 02110-1301, USA.
##
-## $Id: Makefile.am 8132 2007-06-22 11:15:47Z twisti $
+## $Id: Makefile.am 8202 2007-07-15 12:08:18Z twisti $
## Process this file with automake to produce Makefile.in
if WITH_CLASSPATH_SUN
JAVASE_HEADER_FILES += \
java_lang_AssertionStatusDirectives.h \
- java_nio_ByteBuffer.h
+ java_nio_ByteBuffer.h \
+ sun_reflect_ConstantPool.h
endif
JAVAME_CLDC1_1_HEADER_FILES = \
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
- $Id: jni.c 8179 2007-07-05 11:21:08Z michi $
+ $Id: jni.c 8245 2007-07-31 09:55:04Z michi $
*/
#include "vmcore/statistics.h"
+/* debug **********************************************************************/
+
+#if !defined(NDEBUG)
+# define TRACEJNICALLS(format, ...) \
+ do { \
+ if (opt_TraceJNICalls) { \
+ log_println((format), __VA_ARGS__); \
+ } \
+ } while (0)
+#else
+# define TRACEJNICALLS(format, ...)
+#endif
+
+
/* global variables ***********************************************************/
/* global reference table *****************************************************/
*******************************************************************************/
-#if !defined(__MIPS__) && !defined(__X86_64__) && !defined(__POWERPC64__) \
- && !defined(__M68K__) && !defined(__ARM__) && !defined(__SPARC_64__)
+#if !defined(__MIPS__) && !defined(__X86_64__) && !defined(__POWERPC64__) && !defined(__SPARC_64__) && !defined(__M68K__) && !defined(__ARM__) && !defined(__ALPHA__) && !defined(__I386__)
java_objectheader *_Jv_jni_invokeNative(methodinfo *m, java_objectheader *o,
java_objectarray *params)
{
dumpsize = dump_size();
- /* fill the argument array from a object-array */
+ /* Fill the argument array from a object-array. */
array = vm_array_from_objectarray(resm, o, params);
- if (array == NULL) {
+ /* The array can be NULL if we don't have any arguments to pass
+ and the architecture does not have any argument registers
+ (e.g. i386). In that case we additionally check for an
+ exception thrown. */
+
+ if ((array == NULL) && (exceptions_get_exception() != NULL)) {
/* release dump area */
dump_release(dumpsize);
const jbyte *buf, jsize bufLen)
{
#if defined(ENABLE_JAVASE)
- java_lang_ClassLoader *cl;
- java_lang_String *s;
- java_bytearray *ba;
- jclass c;
+ utf *u;
+ java_objectheader *cl;
+ classinfo *c;
- STATISTICS(jniinvokation());
+ TRACEJNICALLS("_Jv_JNI_DefineClass(env=%p, name=%s, loader=%p, buf=%p, bufLen=%d", env, name, loader, buf, bufLen);
- cl = (java_lang_ClassLoader *) loader;
- s = (java_lang_String *) javastring_new_from_utf_string(name);
- ba = (java_bytearray *) buf;
+ u = utf_new_char(name);
+ cl = (java_objectheader *) loader;
- c = (jclass) _Jv_java_lang_ClassLoader_defineClass(cl, s, ba, 0, bufLen,
- NULL);
+ c = class_define(u, cl, bufLen, (const uint8_t *) buf);
return (jclass) _Jv_JNI_NewLocalRef(env, (jobject) c);
#else
jclass _Jv_JNI_GetSuperclass(JNIEnv *env, jclass sub)
{
classinfo *c;
+ classinfo *super;
- STATISTICS(jniinvokation());
+ TRACEJNICALLS("_Jv_JNI_GetSuperclass(env=%p, sub=%p)", env, sub);
- c = ((classinfo *) sub)->super.cls;
+ c = (classinfo *) sub;
- if (!c)
+ if (c == NULL)
return NULL;
- return (jclass) _Jv_JNI_NewLocalRef(env, (jobject) c);
+ super = class_get_superclass(c);
+
+ return (jclass) _Jv_JNI_NewLocalRef(env, (jobject) super);
}
{
java_lang_String *s;
+ TRACEJNICALLS("_Jv_JNI_GetStringLength(env=%p, str=%p)", env, str);
+
s = (java_lang_String *) str;
return s->count;
{
java_lang_String *s;
- STATISTICS(jniinvokation());
+ TRACEJNICALLS("_Jv_JNI_NewStringUTF(env=%p, bytes=%s)", env, bytes);
s = (java_lang_String *) javastring_safe_new_from_utf8(bytes);
java_lang_String *s;
s4 length;
- STATISTICS(jniinvokation());
+ TRACEJNICALLS("_Jv_JNI_GetStringUTFLength(env=%p, string=%p)", env, string);
s = (java_lang_String *) string;
java_chararray *ca;
s4 i;
- STATISTICS(jniinvokation());
+ TRACEJNICALLS("_Jv_JNI_GetStringUTFRegion(env=%p, str=%p, start=%d, len=%d, buf=%p)", env, str, start, len, buf);
s = (java_lang_String *) str;
ca = s->value;
return;
}
- /* XXX not sure if this is correct */
-
for (i = 0; i < len; i++)
- buf[i] = ca->data[start + i];
+ buf[i] = ca->data[s->offset + start + i];
buf[i] = '\0';
}
jint JNI_GetCreatedJavaVMs(JavaVM **vmBuf, jsize bufLen, jsize *nVMs)
{
- log_text("JNI_GetCreatedJavaVMs: IMPLEMENT ME!!!");
+ TRACEJNICALLS("JNI_GetCreatedJavaVMs(vmBuf=%p, jsize=%d, jsize=%p)", vmBuf, bufLen, nVMs);
- return 0;
+ if (bufLen <= 0)
+ return JNI_ERR;
+
+ /* We currently only support 1 VM running. */
+
+ vmBuf[0] = (JavaVM *) _Jv_jvm;
+ *nVMs = 1;
+
+ return JNI_OK;
}
jint JNI_CreateJavaVM(JavaVM **p_vm, void **p_env, void *vm_args)
{
+ TRACEJNICALLS("JNI_CreateJavaVM(p_vm=%p, p_env=%p, vm_args=%p)", p_vm, p_env, vm_args);
+
/* actually create the JVM */
if (!vm_createjvm(p_vm, p_env, vm_args))
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
- $Id: java_lang_Class.c 8179 2007-07-05 11:21:08Z michi $
+ $Id: java_lang_Class.c 8245 2007-07-31 09:55:04Z michi $
*/
s4 _Jv_java_lang_Class_isPrimitive(java_lang_Class *klass)
{
classinfo *c;
- bool result;
c = (classinfo *) klass;
- result = primitive_class_is_primitive(c);
-
- return result;
+ return class_is_primitive(c);
}
java_lang_Class *_Jv_java_lang_Class_getSuperclass(java_lang_Class *klass)
{
classinfo *c;
- classinfo *sc;
+ classinfo *super;
c = (classinfo *) klass;
- /* for java.lang.Object, primitive and Void classes we return NULL */
-
- if (!c->super.any)
- return NULL;
-
- /* for interfaces we also return NULL */
-
- if (c->flags & ACC_INTERFACE)
- return NULL;
-
- /* we may have to resolve the super class reference */
-
- if ((sc = resolve_classref_or_classinfo_eager(c->super, true)) == NULL)
- return NULL;
-
- /* store the resolution */
-
- c->super.cls = sc;
+ super = class_get_superclass(c);
- return (java_lang_Class *) sc;
+ return super;
}
*/
java_lang_Class *_Jv_java_lang_Class_getDeclaringClass(java_lang_Class *klass)
{
- classinfo *c;
- classref_or_classinfo inner;
- utf *innername;
- classinfo *outer;
- s4 i;
+ classinfo *c;
c = (classinfo *) klass;
- if (!primitive_class_is_primitive(c) && (c->name->text[0] != '[')) {
- if (c->innerclasscount == 0) /* no innerclasses exist */
- return NULL;
-
- for (i = 0; i < c->innerclasscount; i++) {
- inner = c->innerclass[i].inner_class;
-
- /* check if inner_class is a classref or a real class and
- get the class name from the structure */
-
- innername = IS_CLASSREF(inner) ? inner.ref->name : inner.cls->name;
-
- /* innerclass is this class */
-
- if (innername == c->name) {
- /* maybe the outer class is not loaded yet */
-
- if ((outer = resolve_classref_or_classinfo_eager(
- c->innerclass[i].outer_class,
- false)) == NULL)
- return NULL;
-
- if (!(outer->state & CLASS_LINKED))
- if (!link_class(outer))
- return NULL;
-
- return (java_lang_Class *) outer;
- }
- }
- }
-
- /* return NULL for arrayclasses and primitive classes */
-
- return NULL;
+ return (java_lang_Class *) class_get_declaringclass(c);
}
c = (classinfo *) klass;
declaredclasscount = 0;
- if (!primitive_class_is_primitive(c) && (c->name->text[0] != '[')) {
+ if (!class_is_primitive(c) && (c->name->text[0] != '[')) {
/* determine number of declared classes */
for (i = 0; i < c->innerclasscount; i++) {
c = class_define(utfname, loader, new_class_data_len, new_class_data);
else
#endif
- c = class_define(utfname, loader, len, (u1 *) &data->data[offset]);
+ c = class_define(utfname, loader, len, (const uint8_t *) &data->data[offset]);
if (c == NULL)
return NULL;
#include "native/include/java_lang_Thread.h" /* required by s.m.U */
#include "native/include/java_lang_Throwable.h"
-#if defined(WITH_CLASSPATH_SUN)
-# include "native/include/java_security_ProtectionDomain.h" /* required by smU*/
-#endif
+#include "native/include/java_security_ProtectionDomain.h" /* required by smU */
#include "native/include/sun_misc_Unsafe.h"
#include "vm/exceptions.h"
#include "vm/initialize.h"
+#include "vm/stringlocal.h"
#include "vmcore/utf8.h"
static JNINativeMethod methods[] = {
{ "registerNatives", "()V", (void *) (intptr_t) &Java_sun_misc_Unsafe_registerNatives },
{ "getInt", "(Ljava/lang/Object;J)I", (void *) (intptr_t) &Java_sun_misc_Unsafe_getInt__Ljava_lang_Object_2J },
+ { "putInt", "(Ljava/lang/Object;JI)V", (void *) (intptr_t) &Java_sun_misc_Unsafe_putInt__Ljava_lang_Object_2JI },
+ { "getObject", "(Ljava/lang/Object;J)Ljava/lang/Object;", (void *) (intptr_t) &Java_sun_misc_Unsafe_getObject },
{ "putObject", "(Ljava/lang/Object;JLjava/lang/Object;)V", (void *) (intptr_t) &Java_sun_misc_Unsafe_putObject },
{ "getBoolean", "(Ljava/lang/Object;J)Z", (void *) (intptr_t) &Java_sun_misc_Unsafe_getBoolean },
{ "putBoolean", "(Ljava/lang/Object;JZ)V", (void *) (intptr_t) &Java_sun_misc_Unsafe_putBoolean },
{ "arrayBaseOffset", "(Ljava/lang/Class;)I", (void *) (intptr_t) &Java_sun_misc_Unsafe_arrayBaseOffset },
{ "arrayIndexScale", "(Ljava/lang/Class;)I", (void *) (intptr_t) &Java_sun_misc_Unsafe_arrayIndexScale },
{ "addressSize", "()I", (void *) (intptr_t) &Java_sun_misc_Unsafe_addressSize },
+ { "defineClass", "(Ljava/lang/String;[BIILjava/lang/ClassLoader;Ljava/security/ProtectionDomain;)Ljava/lang/Class;", (void *) (intptr_t) &Java_sun_misc_Unsafe_defineClass__Ljava_lang_String_2_3BIILjava_lang_ClassLoader_2Ljava_security_ProtectionDomain_2 },
{ "throwException", "(Ljava/lang/Throwable;)V", (void *) (intptr_t) &Java_sun_misc_Unsafe_throwException },
{ "compareAndSwapObject", "(Ljava/lang/Object;JLjava/lang/Object;Ljava/lang/Object;)Z", (void *) (intptr_t) &Java_sun_misc_Unsafe_compareAndSwapObject },
{ "compareAndSwapInt", "(Ljava/lang/Object;JII)Z", (void *) (intptr_t) &Java_sun_misc_Unsafe_compareAndSwapInt },
}
+/*
+ * Class: sun/misc/Unsafe
+ * Method: putInt
+ * Signature: (Ljava/lang/Object;JI)V
+ */
+JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putInt__Ljava_lang_Object_2JI(JNIEnv *env, sun_misc_Unsafe *this, java_lang_Object *o, int64_t offset, int32_t x)
+{
+ int32_t *p;
+
+ p = (int32_t *) (((uint8_t *) o) + offset);
+
+ *p = x;
+}
+
+
+/*
+ * Class: sun/misc/Unsafe
+ * Method: getObject
+ * Signature: (Ljava/lang/Object;J)Ljava/lang/Object;
+ */
+JNIEXPORT java_lang_Object* JNICALL Java_sun_misc_Unsafe_getObject(JNIEnv *env, sun_misc_Unsafe *this, java_lang_Object *o, int64_t offset)
+{
+ void **p;
+ void *value;
+
+ p = (void **) (((uint8_t *) o) + offset);
+
+ value = *p;
+
+ return value;
+}
+
+
/*
* Class: sun/misc/Unsafe
* Method: putObject
}
+/*
+ * Class: sun/misc/Unsafe
+ * Method: defineClass
+ * Signature: (Ljava/lang/String;[BIILjava/lang/ClassLoader;Ljava/security/ProtectionDomain;)Ljava/lang/Class;
+ */
+JNIEXPORT java_lang_Class* JNICALL Java_sun_misc_Unsafe_defineClass__Ljava_lang_String_2_3BIILjava_lang_ClassLoader_2Ljava_security_ProtectionDomain_2(JNIEnv *env, sun_misc_Unsafe *this, java_lang_String *name, java_bytearray *b, int32_t off, int32_t len, java_lang_ClassLoader *loader, java_security_ProtectionDomain *protectionDomain)
+{
+ java_objectheader *cl;
+ utf *utfname;
+ classinfo *c;
+ java_lang_Class *o;
+
+ cl = (java_objectheader *) loader;
+
+ /* check if data was passed */
+
+ if (b == NULL) {
+ exceptions_throw_nullpointerexception();
+ return NULL;
+ }
+
+ /* check the indexes passed */
+
+ if ((off < 0) || (len < 0) || ((off + len) > b->header.size)) {
+ exceptions_throw_arrayindexoutofboundsexception();
+ return NULL;
+ }
+
+ if (name != NULL) {
+ /* convert '.' to '/' in java string */
+
+ utfname = javastring_toutf((java_objectheader *) name, true);
+ }
+ else {
+ utfname = NULL;
+ }
+
+ /* define the class */
+
+ c = class_define(utfname, cl, len, (const uint8_t *) &b->data[off]);
+
+ if (c == NULL)
+ return NULL;
+
+ /* for convenience */
+
+ o = (java_lang_Class *) c;
+
+#if defined(WITH_CLASSPATH_GNU)
+ /* set ProtectionDomain */
+
+ o->pd = protectionDomain;
+#endif
+
+ return o;
+}
+
+
/*
* Class: sun/misc/Unsafe
* Method: throwException
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
- $Id: threads.h 8027 2007-06-07 10:30:33Z michi $
+ $Id: threads.h 8245 2007-07-31 09:55:04Z michi $
*/
void threads_join_all_threads(void);
void threads_sleep(s8 millis, s4 nanos);
-void threads_yield(void);
bool threads_wait_with_timeout_relative(threadobject *t, s8 millis, s4 nanos);
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
- $Id: threads-common.h 8003 2007-06-03 18:42:09Z twisti $
+ $Id: threads-common.h 8222 2007-07-22 20:07:55Z twisti $
*/
void threads_impl_thread_free(threadobject *t);
void threads_impl_thread_start(threadobject *thread, functionptr f);
+void threads_yield(void);
+
#endif /* ENABLE_THREADS */
#endif /* _THREADS_COMMON_H */
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
- $Id: access.c 7976 2007-05-29 12:22:55Z twisti $
+ $Id: access.c 8237 2007-07-27 16:15:29Z twisti $
*/
assert(referer);
assert(cls);
- /* public classes are always accessible */
+ /* Public classes are always accessible. */
if (cls->flags & ACC_PUBLIC)
return true;
- /* a class in the same package is always accessible */
+ /* A class in the same package is always accessible. */
if (SAME_PACKAGE(referer, cls))
return true;
- /* a non-public class in another package is not accessible */
+#if defined(WITH_CLASSPATH_SUN)
+ /* Code for Sun's OpenJDK (see
+ hotspot/src/share/vm/runtime/reflection.cpp
+ (Reflection::verify_class_access)): Allow all accesses from
+ sun/reflect/MagicAccessorImpl subclasses to succeed
+ trivially. */
+
+ /* NOTE: This check must be before checks that could return
+ false. */
+
+ if (class_issubclass(cls, class_sun_reflect_MagicAccessorImpl))
+ return true;
+#endif
+
+ /* A non-public class in another package is not accessible. */
return false;
}
{
assert(referer);
assert(declarer);
-
- /* public members are accessible */
+
+ /* Public members are accessible. */
if (memberflags & ACC_PUBLIC)
return true;
+#if defined(WITH_CLASSPATH_SUN)
+ /* Code for Sun's OpenJDK (see
+ hotspot/src/share/vm/runtime/reflection.cpp
+ (Reflection::verify_class_access)): Allow all accesses from
+ sun/reflect/MagicAccessorImpl subclasses to succeed
+ trivially. */
+
+ /* NOTE: This check must be before checks that could return
+ false. */
+
+ if (class_issubclass(declarer, class_sun_reflect_MagicAccessorImpl))
+ return true;
+#endif
+
/* {declarer is not an interface} */
/* private members are only accessible by the class itself */
calls instead of machine instructions, using the C calling
convention.
- $Id: builtin.c 8179 2007-07-05 11:21:08Z michi $
+ $Id: builtin.c 8245 2007-07-31 09:55:04Z michi $
*/
descriptor_pool_alloc_parsed_descriptors(descpool);
- /* now parse all descriptors */
+ /* Now parse all descriptors. NOTE: builtin-functions are treated
+ like static methods (no `this' pointer). */
for (bte = builtintable_internal; bte->fp != NULL; bte++) {
- /* parse the descriptor, builtin is always static (no `this' pointer) */
-
- bte->md = descriptor_pool_parse_method_descriptor(descpool,
- bte->descriptor,
- ACC_STATIC, NULL);
+ bte->md =
+ descriptor_pool_parse_method_descriptor(descpool,
+ bte->descriptor,
+ ACC_STATIC | ACC_METHOD_BUILTIN,
+ NULL);
/* generate a builtin stub if we need one */
}
for (bte = builtintable_automatic; bte->fp != NULL; bte++) {
- bte->md = descriptor_pool_parse_method_descriptor(descpool,
- bte->descriptor,
- ACC_STATIC, NULL);
+ bte->md =
+ descriptor_pool_parse_method_descriptor(descpool,
+ bte->descriptor,
+ ACC_STATIC | ACC_METHOD_BUILTIN,
+ NULL);
}
for (bte = builtintable_function; bte->fp != NULL; bte++) {
- bte->md = descriptor_pool_parse_method_descriptor(descpool,
- bte->descriptor,
- ACC_STATIC, NULL);
+ bte->md =
+ descriptor_pool_parse_method_descriptor(descpool,
+ bte->descriptor,
+ ACC_STATIC | ACC_METHOD_BUILTIN,
+ NULL);
}
/* release dump area */
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
- $Id: builtintable.inc 7936 2007-05-22 17:05:42Z michi $
+ $Id: builtintable.inc 8245 2007-07-31 09:55:04Z michi $
*/
/* java.lang.VMSystem.arraycopy(Ljava/lang/Object;ILjava/lang/Object;II)V STATIC NATIVE */
-#if defined(__MIPS__) && (SIZEOF_VOID_P != 4)
- /* We can't use this optimization on MIPS32, since it has only 4
- argument registers and we use 8-byte stack slots. The code
- generated does not access the correct 5th argument (hint: *8
- instead of *4). */
-
{
ICMD_BUILTIN,
BUILTINTABLE_FLAG_EXCEPTION,
NULL,
NULL
},
-#endif
/* java.lang.System.arraycopy(Ljava/lang/Object;ILjava/lang/Object;II)V PUBLIC STATIC */
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
- $Id: exceptions.c 8178 2007-07-05 11:13:20Z michi $
+ $Id: exceptions.c 8244 2007-07-31 09:30:28Z michi $
*/
*******************************************************************************/
-java_objectheader *exceptions_new_hardware_exception(u1 *pv, u1 *sp, u1 *ra, u1 *xpc, s4 type, ptrint val, stackframeinfo *sfi)
+java_objectheader *exceptions_new_hardware_exception(u1 *xpc, s4 type, ptrint val)
{
java_objectheader *e;
java_objectheader *o;
s4 index;
- /* create stackframeinfo */
-
- stacktrace_create_extern_stackframeinfo(sfi, pv, sp, ra, xpc);
-
switch (type) {
case EXCEPTION_HARDWARE_NULLPOINTER:
e = exceptions_new_nullpointerexception();
break;
case EXCEPTION_HARDWARE_PATCHER:
+#if defined(ENABLE_REPLACEMENT)
+ if (replace_me_wrapper(xpc)) {
+ e = NULL;
+ break;
+ }
+#endif
e = patcher_handler(xpc);
break;
e = NULL;
}
- /* remove stackframeinfo */
-
- stacktrace_remove_stackframeinfo(sfi);
-
/* return the exception object */
return e;
if (issync) {
/* get synchronization object */
-# if defined(__MIPS__) && (SIZEOF_VOID_P == 4)
+# if (defined(__MIPS__) && (SIZEOF_VOID_P == 4)) || defined(__I386__)
/* XXX change this if we ever want to use 4-byte stackslots */
o = *((java_objectheader **) (sp + issync - 8));
# else
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
- $Id: exceptions.h 8178 2007-07-05 11:13:20Z michi $
+ $Id: exceptions.h 8243 2007-07-31 08:57:54Z michi $
*/
java_objectheader *exceptions_fillinstacktrace(void);
-java_objectheader *exceptions_new_hardware_exception(u1 *pv, u1 *sp, u1 *ra, u1 *xpc, s4 type, ptrint val, stackframeinfo *sfi);
+java_objectheader *exceptions_new_hardware_exception(u1 *xpc, s4 type, ptrint val);
void exceptions_print_exception(java_objectheader *xptr);
void exceptions_print_current_exception(void);
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
- $Id: global.h 8179 2007-07-05 11:21:08Z michi $
+ $Id: global.h 8245 2007-07-31 09:55:04Z michi $
*/
/* alignment macros ***********************************************************/
-#define ALIGN_2(a) do { if ((a) & 0x1) (a)++; } while (0)
+#define ALIGN_EVEN(a) ((a) = (((a) + 1) & ~1))
+#define ALIGN_ODD(a) ((a) = (a) | 1 )
+
+#define ALIGN_2(a) ALIGN_EVEN(a)
/* forward typedefs ***********************************************************/
/* special flags used in methodinfo *******************************************/
-#define ACC_METHOD_IMPLEMENTED 0x00010000 /* there is an implementation */
-#define ACC_METHOD_MONOMORPHIC 0x00020000 /* currently monomorphic method */
+#define ACC_METHOD_BUILTIN 0x00010000 /* use for descriptor parsing */
+#define ACC_METHOD_IMPLEMENTED 0x00020000 /* there is an implementation */
+#define ACC_METHOD_MONOMORPHIC 0x00040000 /* currently monomorphic method */
/* data structures of the runtime system **************************************/
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
02111-1307, USA.
- $Id: simplereg.c 8123 2007-06-20 23:50:55Z michi $
+ $Id: simplereg.c 8210 2007-07-18 12:51:00Z twisti $
*/
fltalloc = s * 5 + t;
}
else { /* !IS_FLT_DBL_TYPE(t) */
-#if defined(HAS_4BYTE_STACKSLOT) && !defined(SUPPORT_COMBINE_INTEGER_REGISTERS)
+#if (SIZEOF_VOID_P == 4) && !defined(SUPPORT_COMBINE_INTEGER_REGISTERS)
/*
* for i386 put all longs in memory
*/
NEW_MEM_SLOT_INT_LNG(regoff);
}
else
-#endif /* defined(HAS_4BYTE_STACKSLOT) && !defined(SUPPORT_COMBINE...GISTERS) */
+#endif
if (intalloc >= 0) {
/* Reuse memory slot(s)/register(s) for shared interface slots */
flags |= jd->interface_map[intalloc].flags & ~SAVEDVAR;
fltalloc = s * 5 + t;
}
else { /* IS_INT_LNG */
-#if defined(HAS_4BYTE_STACKSLOT) && !defined(SUPPORT_COMBINE_INTEGER_REGISTERS)
+#if (SIZEOF_VOID_P == 4) && !defined(SUPPORT_COMBINE_INTEGER_REGISTERS)
/*
* for i386 put all longs in memory
*/
}
else {
-#if defined(HAS_4BYTE_STACKSLOT) && !defined(SUPPORT_COMBINE_INTEGER_REGISTERS)
+#if (SIZEOF_VOID_P == 4) && !defined(SUPPORT_COMBINE_INTEGER_REGISTERS)
/*
* for i386 put all longs in memory
*/
fltalloc = jd->local_map[s * 5 + t];
}
else {
-#if defined(HAS_4BYTE_STACKSLOT) && !defined(SUPPORT_COMBINE_INTEGER_REGISTERS)
+#if (SIZEOF_VOID_P == 4) && !defined(SUPPORT_COMBINE_INTEGER_REGISTERS)
/*
* for i386 put all longs in memory
*/
v->flags = INMEMORY;
NEW_MEM_SLOT_INT_LNG(v->vv.regoff);
}
-#if defined(HAS_4BYTE_STACKSLOT) && !defined(SUPPORT_COMBINE_INTEGER_REGISTERS)
+#if (SIZEOF_VOID_P == 4) && !defined(SUPPORT_COMBINE_INTEGER_REGISTERS)
}
#endif
intalloc = jd->local_map[s * 5 + t];
}
}
else {
-#if defined(HAS_4BYTE_STACKSLOT) && !defined(SUPPORT_COMBINE_INTEGER_REGISTERS)
+#if (SIZEOF_VOID_P == 4) && !defined(SUPPORT_COMBINE_INTEGER_REGISTERS)
/*
* for i386 put all longs in memory
*/
}
else {
-#if defined(HAS_4BYTE_STACKSLOT) && !defined(SUPPORT_COMBINE_INTEGER_REGISTERS)
+#if (SIZEOF_VOID_P == 4) && !defined(SUPPORT_COMBINE_INTEGER_REGISTERS)
/*
* for i386 put all longs in memory
*/
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
- $Id: asmpart.S 8186 2007-07-05 23:48:16Z michi $
+ $Id: asmpart.S 8198 2007-07-12 07:16:24Z twisti $
*/
asm_vm_call_method_float:
asm_vm_call_method_double:
ldgp gp,0(pv)
- lda sp,-5*8(sp) /* allocate stack space */
- stq ra,0*8(sp) /* save return address */
- stq gp,1*8(sp) /* save global pointer */
- stq s6,3*8(sp)
-
- stq a0,4*8(sp) /* save method pointer for compiler */
-
- mov a2,t0 /* pointer to arg block */
- mov a1,s6 /* arg count */
-
- ble s6,calljava_argsloaded
- lda s6,-1(s6)
- ldq a0,offvmargdata(t0)
- ldt $f16,offvmargdata(t0)
- ble s6,calljava_argsloaded
-
- lda s6,-1(s6)
- ldq a1,offvmargdata+sizevmarg*1(t0)
- ldt $f17,offvmargdata+sizevmarg*1(t0)
- ble s6,calljava_argsloaded
-
- lda s6,-1(s6)
- ldq a2,offvmargdata+sizevmarg*2(t0)
- ldt $f18,offvmargdata+sizevmarg*2(t0)
- ble s6,calljava_argsloaded
-
- lda s6,-1(s6)
- ldq a3,offvmargdata+sizevmarg*3(t0)
- ldt $f19,offvmargdata+sizevmarg*3(t0)
- ble s6,calljava_argsloaded
-
- lda s6,-1(s6)
- ldq a4,offvmargdata+sizevmarg*4(t0)
- ldt $f20,offvmargdata+sizevmarg*4(t0)
- ble s6,calljava_argsloaded
-
- lda s6,-1(s6)
- ldq a5,offvmargdata+sizevmarg*5(t0)
- ldt $f21,offvmargdata+sizevmarg*5(t0)
-calljava_argsloaded:
- mov sp,t4
- ble s6,calljava_nocopy
- negq s6,t1
- s8addq t1,sp,sp
- s8addq t1,t4,t2
-
-calljava_copyloop:
- ldq t3,offvmargdata+sizevmarg*6(t0)
- stq t3,0(t2)
- lda t1,1(t1)
- lda t0,sizevmarg(t0)
- lda t2,8(t2)
- bne t1,calljava_copyloop
-
-calljava_nocopy:
- ldq itmp1,4*8(t4) /* pass method pointer via itmp1 */
-
- lda mptr,asm_call_jit_compiler/* fake virtual function call (2 instr) */
- stq mptr,2*8(t4) /* store function address */
- lda mptr,1*8(t4) /* set method pointer */
-
- ldq pv,1*8(mptr) /* method call as in Java */
- jmp ra,(pv) /* call JIT compiler */
-calljava_jit2:
- lda pv,(asm_vm_call_method - calljava_jit2)(ra)
-
- s8addq s6,sp,sp
-calljava_return2:
- ldq ra,0*8(sp) /* restore return address */
- ldq gp,1*8(sp) /* restore global pointer */
- ldq s6,3*8(sp)
- lda sp,5*8(sp) /* free stack space */
-
-calljava_ret2:
+ lda sp,-5*8(sp) /* allocate stack space */
+ stq ra,0*8(sp) /* save return address */
+ stq gp,1*8(sp) /* save global pointer */
+
+ stq s0,3*8(sp)
+ stq a0,4*8(sp) /* save method PV */
+
+ mov a1,t0 /* address of argument array */
+ mov a2,t1 /* stack argument count */
+ mov sp,s0 /* save stack pointer */
+
+ ldq a0,0*8(t0)
+ ldq a1,1*8(t0)
+ ldq a2,2*8(t0)
+ ldq a3,3*8(t0)
+ ldq a4,4*8(t0)
+ ldq a5,5*8(t0)
+
+ ldt fa0,6*8(t0)
+ ldt fa1,7*8(t0)
+ ldt fa2,8*8(t0)
+ ldt fa3,9*8(t0)
+ ldt fa4,10*8(t0)
+ ldt fa5,11*8(t0)
+
+ beq t1,L_asm_vm_call_method_stack_copy_done
+
+ negq t1,t2 /* calculate stackframe size (* 8) */
+ s8addq t2,sp,sp /* create stackframe */
+ mov sp,t2 /* temporary stack pointer */
+
+L_asm_vm_call_method_stack_copy_loop:
+ ldq t3,12*8(t0) /* load argument */
+ stq t3,0(t2) /* store argument on stack */
+
+ subq t1,1,t1 /* subtract 1 argument */
+ addq t0,8,t0 /* load address of next argument */
+ addq t2,8,t2 /* increase stack pointer */
+
+ bgt t1,L_asm_vm_call_method_stack_copy_loop
+
+L_asm_vm_call_method_stack_copy_done:
+ lda mptr,4*8(s0) /* get address of PV */
+ ldq pv,0*8(mptr) /* load PV */
+ jmp ra,(pv)
+L_asm_vm_call_method_recompute_pv:
+ lda pv,(asm_vm_call_method - L_asm_vm_call_method_recompute_pv)(ra)
+
+ mov s0,sp /* restore stack pointer */
+
+L_asm_vm_call_method_recompute_return:
+ ldq ra,0*8(sp) /* restore RA */
+ ldq gp,1*8(sp) /* restore global pointer */
+ ldq s0,3*8(sp)
+
+ lda sp,5*8(sp) /* free stack space */
jmp zero,(ra)
asm_vm_call_method_exception_handler:
- s8addq s6,sp,sp
- ldq gp,1*8(sp) /* restore global pointer */
+ mov s0,sp /* restore stack pointer */
+ ldq gp,1*8(sp) /* restore global pointer */
mov itmp1,a0
jsr ra,builtin_throw_exception
- ldq ra,0*8(sp) /* restore return address */
- ldq s6,3*8(sp)
- lda sp,5*8(sp) /* free stack space */
+
asm_vm_call_method_end:
- jmp zero,(ra)
+ br L_asm_vm_call_method_recompute_return
.end asm_vm_call_method
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
- $Id: codegen.c 8188 2007-07-06 00:31:03Z michi $
+ $Id: codegen.c 8245 2007-07-31 09:55:04Z michi $
*/
dseg_createlinenumbertable(cd);
- /* generate stubs */
+ /* generate traps */
emit_patcher_traps(jd);
- REPLACEMENT_EMIT_STUBS(jd);
/* everything's ok */
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
- $Id: emit.c 8186 2007-07-05 23:48:16Z michi $
+ $Id: emit.c 8211 2007-07-18 19:52:23Z michi $
*/
}
-/* emit_replacement_stubs ******************************************************
-
- Generates the code for the replacement stubs.
-
-*******************************************************************************/
-
-#if defined(ENABLE_REPLACEMENT)
-void emit_replacement_stubs(jitdata *jd)
-{
- codegendata *cd;
- codeinfo *code;
- rplpoint *rplp;
- s4 disp;
- s4 i;
-#if !defined(NDEBUG)
- u1 *savedmcodeptr;
-#endif
-
- /* get required compiler data */
-
- cd = jd->cd;
- code = jd->code;
-
- rplp = code->rplpoints;
-
- /* store beginning of replacement stubs */
-
- code->replacementstubs = (u1*) (cd->mcodeptr - cd->mcodebase);
-
- for (i = 0; i < code->rplpointcount; ++i, ++rplp) {
- /* do not generate stubs for non-trappable points */
-
- if (rplp->flags & RPLPOINT_FLAG_NOTRAP)
- continue;
-
- /* check code segment size */
-
- MCODECHECK(100);
-
-#if !defined(NDEBUG)
- savedmcodeptr = cd->mcodeptr;
-#endif
-
- /* create stack frame - 16-byte aligned */
-
- M_LSUB_IMM(REG_SP, 2 * 8, REG_SP);
-
- /* push address of `rplpoint` struct */
-
- disp = dseg_add_address(cd, rplp);
- M_ALD(REG_ITMP3, REG_PV, disp);
- M_AST(REG_ITMP3, REG_SP, 0 * 8);
-
- /* jump to replacement function */
-
- disp = dseg_add_functionptr(cd, asm_replacement_out);
- M_ALD(REG_ITMP3, REG_PV, disp);
- M_JMP(REG_ZERO, REG_ITMP3);
-
- assert((cd->mcodeptr - savedmcodeptr) == 4*REPLACEMENT_STUB_SIZE);
- }
-}
-#endif /* defined(ENABLE_REPLACEMENT) */
-
-
/* emit_verbosecall_enter ******************************************************
Generates the code for the call trace.
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
- $Id: md-os.c 8188 2007-07-06 00:31:03Z michi $
+ $Id: md-os.c 8245 2007-07-31 09:55:04Z michi $
*/
type = (s4) addr;
}
+ /* create stackframeinfo */
+
+ stacktrace_create_extern_stackframeinfo(&sfi, pv, sp, ra, xpc);
+
/* generate appropriate exception */
- e = exceptions_new_hardware_exception(pv, sp, ra, xpc, type, val, &sfi);
+ e = exceptions_new_hardware_exception(xpc, type, val);
+
+ /* remove stackframeinfo */
+
+ stacktrace_remove_stackframeinfo(&sfi);
/* set registers */
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
- $Id: md-abi.c 8123 2007-06-20 23:50:55Z michi $
+ $Id: md-abi.c 8198 2007-07-12 07:16:24Z twisti $
*/
case TYPE_LNG:
if (i < INT_ARG_CNT) {
pd->inmemory = false;
+ pd->index = reguse;
pd->regoff = abi_registers_integer_argument[reguse];
reguse++;
md->argintreguse = reguse;
}
else {
pd->inmemory = true;
+ pd->index = stacksize;
pd->regoff = stacksize * 8;
stacksize++;
}
case TYPE_DBL:
if (i < FLT_ARG_CNT) {
pd->inmemory = false;
+ pd->index = reguse;
pd->regoff = abi_registers_float_argument[reguse];
reguse++;
md->argfltreguse = reguse;
}
else {
pd->inmemory = true;
+ pd->index = stacksize;
pd->regoff = stacksize * 8;
stacksize++;
}
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
- $Id: codegen.c 8183 2007-07-05 20:37:05Z michi $
+ $Id: codegen.c 8245 2007-07-31 09:55:04Z michi $
*/
dseg_createlinenumbertable(cd);
- /* generate stubs */
+ /* generate traps */
emit_patcher_traps(jd);
- REPLACEMENT_EMIT_STUBS(jd);
/* everything's ok */
}
-/* emit_replacement_stubs ******************************************************
-
- Generates the code for the replacement stubs.
-
-*******************************************************************************/
-
-#if defined(ENABLE_REPLACEMENT)
-void emit_replacement_stubs(jitdata *jd)
-{
- codegendata *cd;
- codeinfo *code;
- rplpoint *rplp;
- u1 *savedmcodeptr;
- s4 disp;
- s4 i;
-
- /* get required compiler data */
-
- cd = jd->cd;
- code = jd->code;
-}
-#endif /* defined(ENABLE_REPLACEMENT) */
-
-
/* emit_verbosecall_enter ******************************************************
Generates the code for the call trace.
ptrint addr;
s4 type;
ptrint val;
- java_objectheader *o;
+ java_objectheader *e;
_uc = (ucontext_t*) _p;
_sc = &_uc->uc_mcontext;
/* get exception-throwing instruction */
+ if (xpc == NULL)
+ vm_abort("md_signal_handler_sigsegv: the program counter is NULL");
+
mcode = *((s4 *) xpc);
/* this is a NullPointerException */
if (addr != 0)
vm_abort("md_signal_handler_sigsegv: faulting address is not NULL: addr=%p", addr);
+ /* create stackframeinfo */
+
+ stacktrace_create_extern_stackframeinfo(&sfi, pv, sp, ra, xpc);
+
/* generate appropriate exception */
- o = exceptions_new_hardware_exception(pv, sp, ra, xpc, type, val, &sfi);
+ e = exceptions_new_hardware_exception(xpc, type, val);
+
+ /* remove stackframeinfo */
+
+ stacktrace_remove_stackframeinfo(&sfi);
/* set registers */
- _sc->arm_r10 = (ptrint) o;
+ _sc->arm_r10 = (ptrint) e;
_sc->arm_fp = (ptrint) xpc;
_sc->arm_pc = (ptrint) asm_handle_exception;
}
u4 mcode;
s4 type;
ptrint val;
- java_objectheader *o;
+ java_objectheader *e;
_uc = (ucontext_t*) _p;
_sc = &_uc->uc_mcontext;
type = (mcode >> 8) & 0x0fff;
val = *((s4 *) _sc + OFFSET(scontext_t, arm_r0)/4 + (mcode & 0x0f));
+ /* create stackframeinfo */
+
+ stacktrace_create_extern_stackframeinfo(&sfi, pv, sp, ra, xpc);
+
/* generate appropriate exception */
- o = exceptions_new_hardware_exception(pv, sp, ra, xpc, type, val, &sfi);
+ e = exceptions_new_hardware_exception(xpc, type, val);
+
+ /* remove stackframeinfo */
+
+ stacktrace_remove_stackframeinfo(&sfi);
/* set registers if we have an exception, return continue execution
otherwise (this is needed for patchers to work) */
- if (o != NULL) {
- _sc->arm_r10 = (ptrint) o;
+ if (e != NULL) {
+ _sc->arm_r10 = (ptrint) e;
_sc->arm_fp = (ptrint) xpc;
_sc->arm_pc = (ptrint) asm_handle_exception;
}
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
- $Id: asmpart.h 8128 2007-06-21 16:29:53Z tbfg $
+ $Id: asmpart.h 8210 2007-07-18 12:51:00Z twisti $
*/
void asm_call_jit_compiler(void);
#if defined(ENABLE_JIT)
-#if !defined(__MIPS__) && !defined(__X86_64__) && !defined(__POWERPC64__) && !defined(__SPARC_64__) && !defined(__M68K__)
+#if !defined(__MIPS__) && !defined(__X86_64__) && !defined(__POWERPC64__) && !defined(__SPARC_64__) && !defined(__M68K__) && !defined(__ARM__) && !defined(__ALPHA__) && !defined(__I386__)
java_objectheader *asm_vm_call_method(methodinfo *m, s4 vmargscount,
vm_arg *vmargs);
s4 asm_vm_call_method_int(methodinfo *m, s4 vmargscount, vm_arg *vmargs);
#if defined(ENABLE_REPLACEMENT)
rplpoint *rplpoints; /* replacement points */
rplalloc *regalloc; /* register allocation info */
- u1 *replacementstubs; /* beginning of replacement stubs */
s4 rplpointcount; /* number of replacement points */
s4 globalcount; /* number of global allocations */
s4 regalloccount; /* number of total allocations */
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 8179 2007-07-05 11:21:08Z michi $
+ $Id: codegen-common.c 8245 2007-07-31 09:55:04Z michi $
*/
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);
void emit_patcher_stubs(jitdata *jd);
void emit_patcher_traps(jitdata *jd);
-#if defined(ENABLE_REPLACEMENT)
-void emit_replacement_stubs(jitdata *jd);
-#endif
void emit_verbosecall_enter(jitdata *jd);
void emit_verbosecall_exit(jitdata *jd);
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
- $Id: arch.h 7695 2007-04-12 19:49:34Z twisti $
+ $Id: arch.h 8210 2007-07-18 12:51:00Z twisti $
*/
#endif
-#define HAS_4BYTE_STACKSLOT
-#define ALIGN_LONGS_IN_MEMORY /* Align Longs and/or Doubles at */
-#define ALIGN_DOUBLES_IN_MEMORY /* 2*Stackslotsize relativ to stackframe */
-/* Memory Positions for not Interface Stackslots (allocate_scratch_registers)*/
-/* are not properly aligned in case HAS_4_BYTE_STACKSLOT is not defined! */
-/* For HAS_4_BYTE_STACKSLOT archs no distinction is made between long and dbl*/
/* define SUPPORT_COMBINE_INTEGER_REGISTERS */
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
- $Id: asmpart.S 7678 2007-04-09 17:23:55Z twisti $
+ $Id: asmpart.S 8210 2007-07-18 12:51:00Z twisti $
*/
mov s1,1*4(sp)
mov s2,2*4(sp)
- mov 4*4(bp),itmp1 /* pointer to arg block (4(push)+4(return)+4+4)*/
- mov 3*4(bp),itmp2 /* arg count (4(push)+4(return)+4 */
+ mov sp,s1 /* save stack pointer */
- mov sp,s1 /* save the stackpointer */
+ mov 3*4(bp),t0 /* address of data structure */
+ mov 4*4(bp),itmp1 /* number of stack arguments */
- test itmp2,itmp2 /* maybe we have no args */
- jle L_asm_vm_call_method_copy_done
+ cmp $0,itmp1
+ je L_asm_vm_call_method_stack_copy_done
- mov itmp2,itmp3 /* calculate stack size */
- mov itmp1,%edi /* save pointer to arg block */
+ mov itmp1,itmp2
+ add $1,itmp2 /* keep stack 16-byte aligned */
+ and $0xfffffffe,itmp2
+ shl $3,itmp2 /* calculate stack size */
+ sub itmp2,sp /* create stack frame */
+ mov sp,itmp2 /* temporary stack pointer */
-calljava_calcstacksize:
- mov offvmargtype(itmp1),t0
- test $1,t0 /* two word type? */
- jz calljava_onewordtype
+L_asm_vm_call_method_stack_copy_loop:
+ mov 0(t0),itmp3 /* load argument */
+ mov itmp3,0(itmp2) /* store argument on stack */
+ mov 4(t0),itmp3
+ mov itmp3,4(itmp2)
- sub $4,sp /* add 1 slot to stackframe size */
+ sub $1,itmp1 /* subtract 1 argument */
+ add $8,t0 /* set address of next argument */
+ add $8,itmp2 /* increase SP */
-calljava_onewordtype:
- sub $4,sp /* add 1 slot to stackframe size */
- sub $1,itmp3
- test itmp3,itmp3 /* any args left? */
- jz calljava_setstack
+ cmp $0,itmp1
+ jg L_asm_vm_call_method_stack_copy_loop
- add $sizevmarg,itmp1 /* goto next argument block */
- jmp calljava_calcstacksize
-
-calljava_setstack:
- mov %edi,itmp1 /* restore pointer to arg block */
- and $0xfffffff0,sp /* align stack to 16-byte */
- mov sp,itmp3 /* initialize pointer for copying */
-
-calljava_copyloop:
- mov offvmargdata(itmp1),t0 /* get 4-bytes of argument */
- mov t0,(itmp3) /* and store them on the stack */
- add $4,itmp3 /* increase sp to next argument */
-
- mov offvmargtype(itmp1),t0 /* get the argument type */
- test $1,t0 /* two word type? */
- jz calljava_copynext
-
- mov offvmargdata+4(itmp1),t0 /* get upper 4-bytes of 2 word type */
- mov t0,(itmp3)
- add $4,itmp3 /* increase sp to next argument */
-
-calljava_copynext:
- sub $1,itmp2 /* are there any args left? */
- test itmp2,itmp2
- jle L_asm_vm_call_method_copy_done
-
- add $sizevmarg,itmp1 /* goto next argument block */
- jmp calljava_copyloop
-
-L_asm_vm_call_method_copy_done:
- mov 2*4(bp),itmp1 /* move function pointer to itmp1 */
-
- lea L_asm_call_jit_compiler,mptr
- mov mptr,3*4(s1)
- lea (3*4-256)(s1),mptr /* We subtract 256 to force the next */
+L_asm_vm_call_method_stack_copy_done:
+ lea (2*4-256)(bp),mptr /* We subtract 256 to force the next */
/* move instruction to have a 32-bit */
/* offset. */
cmp $2,itmp1
je int2
- mov -3*4(itmp2),s0
+ mov -3*8(itmp2),s0
int2:
- mov -2*4(itmp2),s1
+ mov -2*8(itmp2),s1
int1:
- mov -1*4(itmp2),s2
+ mov -1*8(itmp2),s2
shl $2,itmp1 /* multiply by 4 bytes */
sub itmp1,itmp2
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
- $Id: codegen.c 8138 2007-06-22 20:01:51Z michi $
+ $Id: codegen.c 8245 2007-07-31 09:55:04Z michi $
*/
/* space to save used callee saved registers */
savedregs_num += (INT_SAV_CNT - rd->savintreguse);
-
- /* float register are saved on 2 4-byte stackslots */
- savedregs_num += (FLT_SAV_CNT - rd->savfltreguse) * 2;
+ savedregs_num += (FLT_SAV_CNT - rd->savfltreguse);
cd->stackframesize = rd->memuse + savedregs_num;
#if defined(ENABLE_THREADS)
/* space to save argument of monitor_enter */
- if (checksync && (m->flags & ACC_SYNCHRONIZED)) {
- /* reserve 2 slots for long/double return values for monitorexit */
-
- if (IS_2_WORD_TYPE(m->parseddesc->returntype.type))
- cd->stackframesize += 2;
- else
- cd->stackframesize++;
- }
+ if (checksync && (m->flags & ACC_SYNCHRONIZED))
+ cd->stackframesize++;
#endif
/* create method header */
/* Keep stack of non-leaf functions 16-byte aligned. */
- if (!jd->isleafmethod)
- cd->stackframesize |= 0x3;
+ if (!jd->isleafmethod) {
+ ALIGN_ODD(cd->stackframesize); /* XXX this is wrong, +4 is missing */
+ }
(void) dseg_add_unique_address(cd, code); /* CodeinfoPointer */
- (void) dseg_add_unique_s4(cd, cd->stackframesize * 4); /* FrameSize */
+ (void) dseg_add_unique_s4(cd, cd->stackframesize * 8); /* FrameSize */
#if defined(ENABLE_THREADS)
/* IsSync contains the offset relative to the stack pointer for the
*/
if (checksync && (m->flags & ACC_SYNCHRONIZED))
- (void) dseg_add_unique_s4(cd, (rd->memuse + 1) * 4); /* IsSync */
+ (void) dseg_add_unique_s4(cd, (rd->memuse + 1) * 8); /* IsSync */
else
#endif
(void) dseg_add_unique_s4(cd, 0); /* IsSync */
/* create stack frame (if necessary) */
if (cd->stackframesize)
- M_ASUB_IMM(cd->stackframesize * 4, REG_SP);
+ M_ASUB_IMM(cd->stackframesize * 8, REG_SP);
/* save return address and used callee saved registers */
p = cd->stackframesize;
for (i = INT_SAV_CNT - 1; i >= rd->savintreguse; i--) {
- p--; M_AST(rd->savintregs[i], REG_SP, p * 4);
+ p--; M_AST(rd->savintregs[i], REG_SP, p * 8);
}
for (i = FLT_SAV_CNT - 1; i >= rd->savfltreguse; i--) {
- p-=2; emit_fld_reg(cd, rd->savfltregs[i]); emit_fstpl_membase(cd, REG_SP, p * 4);
+ p--; emit_fld_reg(cd, rd->savfltregs[i]); emit_fstpl_membase(cd, REG_SP, p * 8);
}
/* take arguments out of register or stack frame */
continue;
var = VAR(varindex);
-
- s1 = md->params[p].regoff;
+ s1 = md->params[p].regoff;
+ d = var->vv.regoff;
if (IS_INT_LNG_TYPE(t)) { /* integer args */
if (!md->params[p].inmemory) { /* register arguments */
/* rd->argintregs[md->params[p].regoff -> var->vv.regoff * 4 */
}
}
- else { /* stack arguments */
- if (!(var->flags & INMEMORY)) { /* stack arg -> register */
- emit_mov_membase_reg( /* + 4 for return address */
- cd, REG_SP, cd->stackframesize * 4 + s1 + 4, var->vv.regoff);
- /* + 4 for return address */
+ else {
+ if (!(var->flags & INMEMORY)) {
+ M_ILD(d, REG_SP, cd->stackframesize * 8 + 4 + s1);
}
- else { /* stack arg -> spilled */
+ else {
if (!IS_2_WORD_TYPE(t)) {
#if defined(ENABLE_SSA)
/* no copy avoiding by now possible with SSA */
if (ls != NULL) {
emit_mov_membase_reg( /* + 4 for return address */
- cd, REG_SP, cd->stackframesize * 4 + s1 + 4,
+ cd, REG_SP, cd->stackframesize * 8 + s1 + 4,
REG_ITMP1);
emit_mov_reg_membase(
cd, REG_ITMP1, REG_SP, var->vv.regoff);
}
else
#endif /*defined(ENABLE_SSA)*/
- /* reuse Stackslotand avoid copying */
- var->vv.regoff = cd->stackframesize * 4 + s1 + 4;
+ /* reuse stackslot */
+ var->vv.regoff = cd->stackframesize * 8 + 4 + s1;
}
else {
/* no copy avoiding by now possible with SSA */
if (ls != NULL) {
emit_mov_membase_reg( /* + 4 for return address */
- cd, REG_SP, cd->stackframesize * 4 + s1 + 4,
+ cd, REG_SP, cd->stackframesize * 8 + s1 + 4,
REG_ITMP1);
emit_mov_reg_membase(
cd, REG_ITMP1, REG_SP, var->vv.regoff);
emit_mov_membase_reg( /* + 4 for return address */
- cd, REG_SP, cd->stackframesize * 4 + s1 + 4 + 4,
+ cd, REG_SP, cd->stackframesize * 8 + s1 + 4 + 4,
REG_ITMP1);
emit_mov_reg_membase(
cd, REG_ITMP1, REG_SP, var->vv.regoff + 4);
}
else
#endif /*defined(ENABLE_SSA)*/
- /* reuse Stackslotand avoid copying */
- var->vv.regoff = cd->stackframesize * 4 + s1 + 4;
+ /* reuse stackslot */
+ var->vv.regoff = cd->stackframesize * 8 + 4 + s1;
}
}
}
if (!(var->flags & INMEMORY)) { /* reg arg -> register */
/* rd->argfltregs[md->params[p].regoff -> var->vv.regoff */
} else { /* reg arg -> spilled */
- /* rd->argfltregs[md->params[p].regoff -> var->vv.regoff * 4 */
+ /* rd->argfltregs[md->params[p].regoff -> var->vv.regoff * 8 */
}
}
if (!(var->flags & INMEMORY)) { /* stack-arg -> register */
if (t == TYPE_FLT) {
emit_flds_membase(
- cd, REG_SP, cd->stackframesize * 4 + s1 + 4);
+ cd, REG_SP, cd->stackframesize * 8 + s1 + 4);
assert(0);
/* emit_fstp_reg(cd, var->vv.regoff + fpu_st_offset); */
}
else {
emit_fldl_membase(
- cd, REG_SP, cd->stackframesize * 4 + s1 + 4);
+ cd, REG_SP, cd->stackframesize * 8 + s1 + 4);
assert(0);
/* emit_fstp_reg(cd, var->vv.regoff + fpu_st_offset); */
}
/* no copy avoiding by now possible with SSA */
if (ls != NULL) {
emit_mov_membase_reg(
- cd, REG_SP, cd->stackframesize * 4 + s1 + 4, REG_ITMP1);
+ cd, REG_SP, cd->stackframesize * 8 + s1 + 4, REG_ITMP1);
emit_mov_reg_membase(
cd, REG_ITMP1, REG_SP, var->vv.regoff);
if (t == TYPE_FLT) {
emit_flds_membase(
- cd, REG_SP, cd->stackframesize * 4 + s1 + 4);
+ cd, REG_SP, cd->stackframesize * 8 + s1 + 4);
emit_fstps_membase(cd, REG_SP, var->vv.regoff);
}
else {
emit_fldl_membase(
- cd, REG_SP, cd->stackframesize * 4 + s1 + 4);
+ cd, REG_SP, cd->stackframesize * 8 + s1 + 4);
emit_fstpl_membase(cd, REG_SP, var->vv.regoff);
}
}
else
#endif /*defined(ENABLE_SSA)*/
- /* reuse Stackslotand avoid copying */
- var->vv.regoff = cd->stackframesize * 4 + s1 + 4;
+ /* reuse stackslot */
+ var->vv.regoff = cd->stackframesize * 8 + 4 + s1;
}
}
}
- } /* end for */
+ }
/* call monitorenter function */
M_MOV_IMM(&m->class->object.header, REG_ITMP1);
}
else {
- M_ALD(REG_ITMP1, REG_SP, cd->stackframesize * 4 + 4);
+ M_ALD(REG_ITMP1, REG_SP, cd->stackframesize * 8 + 4);
M_TEST(REG_ITMP1);
M_BNE(6);
M_ALD_MEM(REG_ITMP1, EXCEPTION_HARDWARE_NULLPOINTER);
}
- M_AST(REG_ITMP1, REG_SP, s1 * 4);
+ M_AST(REG_ITMP1, REG_SP, s1 * 8);
M_AST(REG_ITMP1, REG_SP, 0 * 4);
M_MOV_IMM(LOCK_monitor_enter, REG_ITMP3);
M_CALL(REG_ITMP3);
if (iptr->s1.var->flags & INMEMORY) {
/* Alpha algorithm */
disp = 3;
- CALCOFFSETBYTES(disp, REG_SP, iptr->s1.var->vv.regoff * 4);
+ CALCOFFSETBYTES(disp, REG_SP, iptr->s1.var->vv.regoff * 8);
disp += 3;
- CALCOFFSETBYTES(disp, REG_SP, iptr->s1.var->vv.regoff * 4 + 4);
+ CALCOFFSETBYTES(disp, REG_SP, iptr->s1.var->vv.regoff * 8 + 4);
disp += 2;
disp += 3;
disp += 3;
disp += 2;
- emit_mov_membase_reg(cd, REG_SP, iptr->s1.var->vv.regoff * 4, REG_ITMP1);
- emit_mov_membase_reg(cd, REG_SP, iptr->s1.var->vv.regoff * 4 + 4, REG_ITMP2);
+ emit_mov_membase_reg(cd, REG_SP, iptr->s1.var->vv.regoff * 8, REG_ITMP1);
+ emit_mov_membase_reg(cd, REG_SP, iptr->s1.var->vv.regoff * 8 + 4, REG_ITMP2);
emit_alu_imm_reg(cd, ALU_AND, iptr->sx.val.l, REG_ITMP1);
emit_alu_imm_reg(cd, ALU_AND, iptr->sx.val.l >> 32, REG_ITMP2);
- emit_alu_imm_membase(cd, ALU_CMP, 0, REG_SP, iptr->s1.var->vv.regoff * 4 + 4);
+ emit_alu_imm_membase(cd, ALU_CMP, 0, REG_SP, iptr->s1.var->vv.regoff * 8 + 4);
emit_jcc(cd, CC_GE, disp);
- emit_mov_membase_reg(cd, REG_SP, iptr->s1.var->vv.regoff * 4, REG_ITMP1);
- emit_mov_membase_reg(cd, REG_SP, iptr->s1.var->vv.regoff * 4 + 4, REG_ITMP2);
+ emit_mov_membase_reg(cd, REG_SP, iptr->s1.var->vv.regoff * 8, REG_ITMP1);
+ emit_mov_membase_reg(cd, REG_SP, iptr->s1.var->vv.regoff * 8 + 4, REG_ITMP2);
emit_neg_reg(cd, REG_ITMP1);
emit_alu_imm_reg(cd, ALU_ADC, 0, REG_ITMP2);
emit_alu_imm_reg(cd, ALU_ADC, 0, REG_ITMP2);
emit_neg_reg(cd, REG_ITMP2);
- emit_mov_reg_membase(cd, REG_ITMP1, REG_SP, iptr->dst.var->vv.regoff * 4);
- emit_mov_reg_membase(cd, REG_ITMP2, REG_SP, iptr->dst.var->vv.regoff * 4 + 4);
+ emit_mov_reg_membase(cd, REG_ITMP1, REG_SP, iptr->dst.var->vv.regoff * 8);
+ emit_mov_reg_membase(cd, REG_ITMP2, REG_SP, iptr->dst.var->vv.regoff * 8 + 4);
}
}
#if defined(ENABLE_THREADS)
if (checksync && (m->flags & ACC_SYNCHRONIZED)) {
- M_ALD(REG_ITMP2, REG_SP, rd->memuse * 4);
+ M_ALD(REG_ITMP2, REG_SP, rd->memuse * 8);
/* we need to save the proper return value */
switch (iptr->opc) {
case ICMD_IRETURN:
case ICMD_ARETURN:
- M_IST(REG_RESULT, REG_SP, rd->memuse * 4);
+ M_IST(REG_RESULT, REG_SP, rd->memuse * 8);
break;
case ICMD_LRETURN:
- M_LST(REG_RESULT_PACKED, REG_SP, rd->memuse * 4);
+ M_LST(REG_RESULT_PACKED, REG_SP, rd->memuse * 8);
break;
case ICMD_FRETURN:
- emit_fstps_membase(cd, REG_SP, rd->memuse * 4);
+ emit_fstps_membase(cd, REG_SP, rd->memuse * 8);
break;
case ICMD_DRETURN:
- emit_fstpl_membase(cd, REG_SP, rd->memuse * 4);
+ emit_fstpl_membase(cd, REG_SP, rd->memuse * 8);
break;
}
switch (iptr->opc) {
case ICMD_IRETURN:
case ICMD_ARETURN:
- M_ILD(REG_RESULT, REG_SP, rd->memuse * 4);
+ M_ILD(REG_RESULT, REG_SP, rd->memuse * 8);
break;
case ICMD_LRETURN:
- M_LLD(REG_RESULT_PACKED, REG_SP, rd->memuse * 4);
+ M_LLD(REG_RESULT_PACKED, REG_SP, rd->memuse * 8);
break;
case ICMD_FRETURN:
- emit_flds_membase(cd, REG_SP, rd->memuse * 4);
+ emit_flds_membase(cd, REG_SP, rd->memuse * 8);
break;
case ICMD_DRETURN:
- emit_fldl_membase(cd, REG_SP, rd->memuse * 4);
+ emit_fldl_membase(cd, REG_SP, rd->memuse * 8);
break;
}
}
/* restore saved registers */
for (i = INT_SAV_CNT - 1; i >= rd->savintreguse; i--) {
- p--; M_ALD(rd->savintregs[i], REG_SP, p * 4);
+ p--; M_ALD(rd->savintregs[i], REG_SP, p * 8);
}
for (i = FLT_SAV_CNT - 1; i >= rd->savfltreguse; i--) {
p--;
- emit_fldl_membase(cd, REG_SP, p * 4);
+ emit_fldl_membase(cd, REG_SP, p * 8);
if (iptr->opc == ICMD_FRETURN || iptr->opc == ICMD_DRETURN) {
assert(0);
/* emit_fstp_reg(cd, rd->savfltregs[i] + fpu_st_offset + 1); */
/* deallocate stack */
if (cd->stackframesize)
- M_AADD_IMM(cd->stackframesize * 4, REG_SP);
+ M_AADD_IMM(cd->stackframesize * 8, REG_SP);
emit_ret(cd);
}
break;
case ICMD_INVOKESPECIAL:
- M_ALD(REG_ITMP1, REG_SP, 0 * 4);
+ M_ALD(REG_ITMP1, REG_SP, 0 * 8);
emit_nullpointer_check(cd, iptr, REG_ITMP1);
/* fall through */
break;
case ICMD_INVOKEVIRTUAL:
- M_ALD(REG_ITMP1, REG_SP, 0 * 4);
+ M_ALD(REG_ITMP1, REG_SP, 0 * 8);
emit_nullpointer_check(cd, iptr, s1);
if (lm == NULL) {
break;
case ICMD_INVOKEINTERFACE:
- M_ALD(REG_ITMP1, REG_SP, 0 * 4);
+ M_ALD(REG_ITMP1, REG_SP, 0 * 8);
emit_nullpointer_check(cd, iptr, s1);
if (lm == NULL) {
/* generate stubs */
emit_patcher_stubs(jd);
- REPLACEMENT_EMIT_STUBS(jd);
/* everything's ok */
/* keep stack 16-byte aligned */
- cd->stackframesize |= 0x3;
+ ALIGN_ODD(cd->stackframesize); /* XXX this is wrong, +4 is missing */
/* create method header */
(void) dseg_add_unique_address(cd, code); /* CodeinfoPointer */
- (void) dseg_add_unique_s4(cd, cd->stackframesize * 4); /* FrameSize */
+ (void) dseg_add_unique_s4(cd, cd->stackframesize * 8); /* FrameSize */
(void) dseg_add_unique_s4(cd, 0); /* IsSync */
(void) dseg_add_unique_s4(cd, 0); /* IsLeaf */
(void) dseg_add_unique_s4(cd, 0); /* IntSave */
/* calculate stackframe size for native function */
- M_ASUB_IMM(cd->stackframesize * 4, REG_SP);
+ M_ASUB_IMM(cd->stackframesize * 8, REG_SP);
#if !defined(NDEBUG)
emit_verbosecall_enter(jd);
/* remember callee saved int registers in stackframeinfo (GC may need to */
/* recover them during a collection). */
- disp = cd->stackframesize * 4 - sizeof(stackframeinfo) +
+ disp = cd->stackframesize * 8 - sizeof(stackframeinfo) +
OFFSET(stackframeinfo, intregs);
for (i = 0; i < INT_SAV_CNT; i++)
/* prepare data structures for native function call */
M_MOV(REG_SP, REG_ITMP1);
- M_AADD_IMM(cd->stackframesize * 4, REG_ITMP1);
+ M_AADD_IMM(cd->stackframesize * 8, REG_ITMP1);
M_AST(REG_ITMP1, REG_SP, 0 * 4);
M_IST_IMM(0, REG_SP, 1 * 4);
dseg_adddata(cd);
M_MOV(REG_SP, REG_ITMP2);
- M_AADD_IMM(cd->stackframesize * 4 + SIZEOF_VOID_P, REG_ITMP2);
+ M_AADD_IMM(cd->stackframesize * 8 + SIZEOF_VOID_P, REG_ITMP2);
M_AST(REG_ITMP2, REG_SP, 2 * 4);
- M_ALD(REG_ITMP3, REG_SP, cd->stackframesize * 4);
+ M_ALD(REG_ITMP3, REG_SP, cd->stackframesize * 8);
M_AST(REG_ITMP3, REG_SP, 3 * 4);
M_MOV_IMM(codegen_start_native_call, REG_ITMP1);
M_CALL(REG_ITMP1);
if (!md->params[i].inmemory) {
/* no integer argument registers */
- } else { /* float/double in memory can be copied like int/longs */
- s1 = md->params[i].regoff + cd->stackframesize * 4 + 4;
+ }
+ else {
+ /* float/double in memory can be copied like int/longs */
+
+ s1 = md->params[i].regoff + cd->stackframesize * 8 + 4;
s2 = nmd->params[j].regoff;
M_ILD(REG_ITMP1, REG_SP, s1);
switch (md->returntype.type) {
case TYPE_INT:
case TYPE_ADR:
- M_IST(REG_RESULT, REG_SP, 1 * 4);
+ M_IST(REG_RESULT, REG_SP, 1 * 8);
break;
case TYPE_LNG:
- M_LST(REG_RESULT_PACKED, REG_SP, 1 * 4);
+ M_LST(REG_RESULT_PACKED, REG_SP, 1 * 8);
break;
case TYPE_FLT:
- emit_fsts_membase(cd, REG_SP, 1 * 4);
+ emit_fsts_membase(cd, REG_SP, 1 * 8);
break;
case TYPE_DBL:
- emit_fstl_membase(cd, REG_SP, 1 * 4);
+ emit_fstl_membase(cd, REG_SP, 1 * 8);
break;
case TYPE_VOID:
break;
/* remove native stackframe info */
M_MOV(REG_SP, REG_ITMP1);
- M_AADD_IMM(cd->stackframesize * 4, REG_ITMP1);
+ M_AADD_IMM(cd->stackframesize * 8, REG_ITMP1);
M_AST(REG_ITMP1, REG_SP, 0 * 4);
M_MOV_IMM(codegen_finish_native_call, REG_ITMP1);
switch (md->returntype.type) {
case TYPE_INT:
case TYPE_ADR:
- M_ILD(REG_RESULT, REG_SP, 1 * 4);
+ M_ILD(REG_RESULT, REG_SP, 1 * 8);
break;
case TYPE_LNG:
- M_LLD(REG_RESULT_PACKED, REG_SP, 1 * 4);
+ M_LLD(REG_RESULT_PACKED, REG_SP, 1 * 8);
break;
case TYPE_FLT:
- emit_flds_membase(cd, REG_SP, 1 * 4);
+ emit_flds_membase(cd, REG_SP, 1 * 8);
break;
case TYPE_DBL:
- emit_fldl_membase(cd, REG_SP, 1 * 4);
+ emit_fldl_membase(cd, REG_SP, 1 * 8);
break;
case TYPE_VOID:
break;
/* restore callee saved int registers from stackframeinfo (GC might have */
/* modified them during a collection). */
- disp = cd->stackframesize * 4 - sizeof(stackframeinfo) +
+ disp = cd->stackframesize * 8 - sizeof(stackframeinfo) +
OFFSET(stackframeinfo, intregs);
for (i = 0; i < INT_SAV_CNT; i++)
M_ALD(abi_registers_integer_saved[i], REG_SP, disp + i * 4);
#endif
- M_AADD_IMM(cd->stackframesize * 4, REG_SP);
+ M_AADD_IMM(cd->stackframesize * 8, REG_SP);
/* check for exception */
s4 disp;
ptrint val;
s4 type;
- java_objectheader *o;
+ java_objectheader *e;
_uc = (ucontext_t *) _p;
_mc = _uc->uc_mcontext;
type = EXCEPTION_HARDWARE_NULLPOINTER;
}
- /* generate appropriate exception */
+ /* create stackframeinfo */
- o = exceptions_new_hardware_exception(pv, sp, ra, xpc, type, val, &sfi);
+ stacktrace_create_extern_stackframeinfo(&sfi, pv, sp, ra, xpc);
+
+ /* generate appropriate exception */
+
+ e = exceptions_new_hardware_exception(xpc, type, val);
+
+ /* remove stackframeinfo */
+
+ stacktrace_remove_stackframeinfo(&sfi);
/* set registers */
- _ss->eax = (ptrint) o;
+ _ss->eax = (ptrint) e;
_ss->ecx = (ptrint) xpc;
_ss->eip = (ptrint) asm_handle_exception;
}
u1 *xpc;
s4 type;
ptrint val;
- java_objectheader *o;
+ java_objectheader *e;
_uc = (ucontext_t *) _p;
type = EXCEPTION_HARDWARE_ARITHMETIC;
val = 0;
- /* generate appropriate exception */
+ /* create stackframeinfo */
+
+ stacktrace_create_extern_stackframeinfo(&sfi, pv, sp, ra, xpc);
+
+ /* generate appropriate exception */
+
+ e = exceptions_new_hardware_exception(xpc, type, val);
+
+ /* remove stackframeinfo */
- o = exceptions_new_hardware_exception(pv, sp, ra, xpc, type, val, &sfi);
+ stacktrace_remove_stackframeinfo(&sfi);
- _ss->eax = (ptrint) o;
+ _ss->eax = (ptrint) e;
_ss->ecx = (ptrint) xpc;
_ss->eip = (ptrint) asm_handle_exception;
}
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
- $Id: emit.c 8123 2007-06-20 23:50:55Z michi $
+ $Id: emit.c 8211 2007-07-18 19:52:23Z michi $
*/
#include "vm/builtin.h"
#include "vm/exceptions.h"
+#include "vm/jit/abi.h"
#include "vm/jit/asmpart.h"
#include "vm/jit/dseg.h"
#include "vm/jit/emit-common.h"
}
-/* emit_replacement_stubs ******************************************************
-
- Generates the code for the replacement stubs.
-
-*******************************************************************************/
-
-#if defined(ENABLE_REPLACEMENT)
-void emit_replacement_stubs(jitdata *jd)
-{
- codegendata *cd;
- codeinfo *code;
- rplpoint *rplp;
- s4 i;
- s4 branchmpc;
- s4 outcode;
-
- /* get required compiler data */
-
- cd = jd->cd;
- code = jd->code;
-
- rplp = code->rplpoints;
-
- /* store beginning of replacement stubs */
-
- code->replacementstubs = (u1*) (cd->mcodeptr - cd->mcodebase);
-
- for (i = 0; i < code->rplpointcount; ++i, ++rplp) {
- /* do not generate stubs for non-trappable points */
-
- if (rplp->flags & RPLPOINT_FLAG_NOTRAP)
- continue;
-
- /* check code segment size */
-
- MCODECHECK(512);
-
- /* note start of stub code */
-
- outcode = (s4) (cd->mcodeptr - cd->mcodebase);
-
- /* push address of `rplpoint` struct */
-
- M_PUSH_IMM(rplp);
-
- /* jump to replacement function */
-
- M_PUSH_IMM(asm_replacement_out);
- M_RET;
-
- /* add jump reference for COUNTDOWN points */
-
- if (rplp->flags & RPLPOINT_FLAG_COUNTDOWN) {
-
- branchmpc = (s4)rplp->pc + (7 + 6);
-
- md_codegen_patch_branch(cd, branchmpc, (s4) outcode);
- }
-
- assert(((cd->mcodeptr - cd->mcodebase) - outcode) == REPLACEMENT_STUB_SIZE);
- }
-}
-#endif /* defined(ENABLE_REPLACEMENT) */
-
-
/* emit_verbosecall_enter ******************************************************
Generates the code for the call trace.
codegendata *cd;
registerdata *rd;
methoddesc *md;
- s4 disp;
- s4 i, t;
+ int32_t disp;
+ int i;
+ int d;
if (!JITDATA_HAS_FLAG_VERBOSECALL(jd))
return;
/* methodinfo* + arguments + return address */
- disp = TRACE_ARGS_NUM * 8 + 4 + INT_TMP_CNT * 4 +
- cd->stackframesize * 4 + 4;
+ disp = (TRACE_ARGS_NUM + 1 + TMP_CNT) * 8 + cd->stackframesize * 8 + 4;
- M_ASUB_IMM(TRACE_ARGS_NUM * 8 + 4 + INT_TMP_CNT * 4, REG_SP);
+ M_ASUB_IMM((TRACE_ARGS_NUM + 1 + TMP_CNT) * 8, REG_SP);
/* save temporary registers for leaf methods */
for (i = 0; i < INT_TMP_CNT; i++)
- M_IST(rd->tmpintregs[i], REG_SP, TRACE_ARGS_NUM * 8 + 4 + i * 4);
+ M_IST(rd->tmpintregs[i], REG_SP, (TRACE_ARGS_NUM + 1 + i) * 8);
- for (i = 0; i < md->paramcount && i < TRACE_ARGS_NUM; i++) {
- t = md->paramtypes[i].type;
+ /* save argument registers */
- if (IS_INT_LNG_TYPE(t)) {
- if (IS_2_WORD_TYPE(t)) {
- M_LLD(REG_ITMP12_PACKED, REG_SP, disp);
- M_LST(REG_ITMP12_PACKED, REG_SP, i * 8);
- }
- else if (IS_ADR_TYPE(t)) {
- M_ALD(REG_ITMP1, REG_SP, disp);
- M_AST(REG_ITMP1, REG_SP, i * 8);
- M_IST_IMM(0, REG_SP, i * 8 + 4);
- }
- else {
- M_ILD(EAX, REG_SP, disp);
- emit_cltd(cd);
- M_LST(EAX_EDX_PACKED, REG_SP, i * 8);
- }
- }
- else {
- if (IS_2_WORD_TYPE(t)) {
- M_DLD(REG_NULL, REG_SP, disp);
- M_DST(REG_NULL, REG_SP, i * 8);
- }
- else {
- M_FLD(REG_NULL, REG_SP, disp);
- M_FST(REG_NULL, REG_SP, i * 8);
- M_IST_IMM(0, REG_SP, i * 8 + 4);
- }
+ for (i = 0; i < md->paramcount; i++) {
+ d = i * 8;
+
+ switch (md->paramtypes[i].type) {
+ case TYPE_INT:
+ M_ILD(EAX, REG_SP, disp);
+ emit_cltd(cd);
+ M_LST(EAX_EDX_PACKED, REG_SP, d);
+ break;
+ case TYPE_LNG:
+ M_LLD(REG_ITMP12_PACKED, REG_SP, disp);
+ M_LST(REG_ITMP12_PACKED, REG_SP, d);
+ break;
+ case TYPE_ADR:
+ M_ALD(REG_ITMP1, REG_SP, disp);
+ M_AST(REG_ITMP1, REG_SP, d);
+ M_IST_IMM(0, REG_SP, d + 4); /* high-bits are zero */
+ break;
+ case TYPE_FLT:
+ M_FLD(REG_NULL, REG_SP, disp);
+ M_FST(REG_NULL, REG_SP, d);
+ M_IST_IMM(0, REG_SP, d + 4); /* high-bits are zero */
+ break;
+ case TYPE_DBL:
+ M_DLD(REG_NULL, REG_SP, disp);
+ M_DST(REG_NULL, REG_SP, d);
+ break;
}
- disp += (IS_2_WORD_TYPE(t)) ? 8 : 4;
+ disp += 8;
}
-
+
M_AST_IMM(m, REG_SP, TRACE_ARGS_NUM * 8);
M_MOV_IMM(builtin_verbosecall_enter, REG_ITMP1);
/* restore temporary registers for leaf methods */
for (i = 0; i < INT_TMP_CNT; i++)
- M_ILD(rd->tmpintregs[i], REG_SP, TRACE_ARGS_NUM * 8 + 4 + i * 4);
+ M_ILD(rd->tmpintregs[i], REG_SP, (TRACE_ARGS_NUM + 1 + i) * 8);
- M_AADD_IMM(TRACE_ARGS_NUM * 8 + 4 + INT_TMP_CNT * 4, REG_SP);
+ M_AADD_IMM((TRACE_ARGS_NUM + 1 + TMP_CNT) * 8, REG_SP);
/* mark trace code */
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
- $Id: md-os.c 8179 2007-07-05 11:21:08Z michi $
+ $Id: md-os.c 8245 2007-07-31 09:55:04Z michi $
*/
s4 disp;
ptrint val;
s4 type;
- java_objectheader *o;
+ java_objectheader *e;
_uc = (ucontext_t *) _p;
_mc = &_uc->uc_mcontext;
val = 0;
}
+ /* create stackframeinfo */
+
+ stacktrace_create_extern_stackframeinfo(&sfi, pv, sp, ra, xpc);
+
/* generate appropriate exception */
- o = exceptions_new_hardware_exception(pv, sp, ra, xpc, type, val, &sfi);
+ e = exceptions_new_hardware_exception(xpc, type, val);
+
+ /* remove stackframeinfo */
+
+ stacktrace_remove_stackframeinfo(&sfi);
/* set registers */
- _mc->gregs[REG_EAX] = (ptrint) o;
+ _mc->gregs[REG_EAX] = (ptrint) e;
_mc->gregs[REG_ECX] = (ptrint) xpc; /* REG_ITMP2_XPC */
_mc->gregs[REG_EIP] = (ptrint) asm_handle_exception;
}
u1 *xpc;
s4 type;
ptrint val;
- java_objectheader *o;
+ java_objectheader *e;
_uc = (ucontext_t *) _p;
_mc = &_uc->uc_mcontext;
type = EXCEPTION_HARDWARE_ARITHMETIC;
val = 0;
+ /* create stackframeinfo */
+
+ stacktrace_create_extern_stackframeinfo(&sfi, pv, sp, ra, xpc);
+
/* generate appropriate exception */
- o = exceptions_new_hardware_exception(pv, sp, ra, xpc, type, val, &sfi);
+ e = exceptions_new_hardware_exception(xpc, type, val);
+
+ /* remove stackframeinfo */
+
+ stacktrace_remove_stackframeinfo(&sfi);
- _mc->gregs[REG_EAX] = (ptrint) o;
+ _mc->gregs[REG_EAX] = (ptrint) e;
_mc->gregs[REG_ECX] = (ptrint) xpc; /* REG_ITMP2_XPC */
_mc->gregs[REG_EIP] = (ptrint) asm_handle_exception;
}
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
- $Id: md-abi.c 8123 2007-06-20 23:50:55Z michi $
+ $Id: md-abi.c 8210 2007-07-18 12:51:00Z twisti $
*/
void md_param_alloc(methoddesc *md)
{
paramdesc *pd;
- s4 stacksize;
- s4 i;
+ int stacksize;
+ int i;
pd = md->params;
stacksize = 0;
for (i = 0; i < md->paramcount; i++, pd++) {
pd->inmemory = true;
- pd->regoff = stacksize * 4;
- stacksize += IS_2_WORD_TYPE(md->paramtypes[i].type) ? 2 : 1;
+ pd->index = stacksize;
+ pd->regoff = stacksize * 8;
+ stacksize++;
}
- md->memuse = stacksize;
+ md->memuse = stacksize;
md->argintreguse = 0;
md->argfltreguse = 0;
}
void md_param_alloc_native(methoddesc *md)
{
- /* On i386 we use the same ABI for JIT method calls as for native
- method calls. */
+ paramdesc *pd;
+ int stacksize;
+ int i;
- md_param_alloc(md);
+ pd = md->params;
+ stacksize = 0;
+
+ for (i = 0; i < md->paramcount; i++, pd++) {
+ pd->inmemory = true;
+ pd->index = stacksize;
+ pd->regoff = stacksize * 4;
+ stacksize += IS_2_WORD_TYPE(md->paramtypes[i].type) ? 2 : 1;
+ }
+
+ md->memuse = stacksize;
+ md->argintreguse = 0;
+ md->argfltreguse = 0;
}
/* generate stubs */
emit_patcher_stubs(jd);
- REPLACEMENT_EMIT_STUBS(jd);
return true;
}
/*fprintf(stderr, "SEGV: sp=%x, xpc=%x, regval=%x\n", sp, xpc, regval);
*/
- e = exceptions_new_hardware_exception(0, sp, xpc, xpc, EXCEPTION_HARDWARE_NULLPOINTER, regval, &sfi);
+
+ /* create stackframeinfo */
+
+ stacktrace_create_extern_stackframeinfo(&sfi, NULL, sp, xpc, xpc);
+
+ /* generate appropriate exception */
+
+ e = exceptions_new_hardware_exception(xpc, EXCEPTION_HARDWARE_NULLPOINTER, regval);
+
+ /* remove stackframeinfo */
+
+ stacktrace_remove_stackframeinfo(&sfi);
_mc->gregs[GREGS_ADRREG_OFF + REG_ATMP1] = (ptrint) e;
_mc->gregs[GREGS_ADRREG_OFF + REG_ATMP2_XPC] = (ptrint) xpc;
/*fprintf(stderr, "NEW HWE: sp=%x, xpc=%x, tpye=%x, regval=%x\n", sp, xpc, type, regval);
*/
- e = exceptions_new_hardware_exception(0, sp, xpc, xpc, type, regval, &sfi);
+
+ /* create stackframeinfo */
+
+ stacktrace_create_extern_stackframeinfo(&sfi, NULL, sp, xpc, xpc);
+
+ /* generate appropriate exception */
+
+ e = exceptions_new_hardware_exception(xpc, type, regval);
+
+ /* remove stackframeinfo */
+
+ stacktrace_remove_stackframeinfo(&sfi);
_mc->gregs[GREGS_ADRREG_OFF + REG_ATMP1] = (ptrint) e;
_mc->gregs[GREGS_ADRREG_OFF + REG_ATMP2_XPC] = (ptrint) xpc;
/* found an invokevirtual */
/* get offset of load instruction 246b XXXX */
offset = *((s2*)(ra - 4));
+
+ /* return NULL if no mptr was specified (used for replacement) */
+
+ if (mptr == NULL)
+ return NULL;
+
pa = mptr + offset; /* mptr contains the magic we want */
} else {
/* we had a moveal XXX, %a3 which is a 3 word opcode */
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
- $Id: codegen.c 8123 2007-06-20 23:50:55Z michi $
+ $Id: codegen.c 8211 2007-07-18 19:52:23Z michi $
*/
/* generate stubs */
emit_patcher_stubs(jd);
- REPLACEMENT_EMIT_STUBS(jd);
/* everything's ok */
}
-/* emit_replacement_stubs ******************************************************
-
- Generates the code for the replacement stubs.
-
-*******************************************************************************/
-
-#if defined(ENABLE_REPLACEMENT)
-void emit_replacement_stubs(jitdata *jd)
-{
- codegendata *cd;
- codeinfo *code;
- rplpoint *rplp;
- s4 disp;
- s4 i;
-#if !defined(NDEBUG)
- u1 *savedmcodeptr;
-#endif
-
- /* get required compiler data */
-
- cd = jd->cd;
- code = jd->code;
-
- rplp = code->rplpoints;
-
- /* store beginning of replacement stubs */
-
- code->replacementstubs = (u1*) (cd->mcodeptr - cd->mcodebase);
-
- for (i = 0; i < code->rplpointcount; ++i, ++rplp) {
- /* do not generate stubs for non-trappable points */
-
- if (rplp->flags & RPLPOINT_FLAG_NOTRAP)
- continue;
-
- /* check code segment size */
-
- MCODECHECK(100);
-
-#if !defined(NDEBUG)
- savedmcodeptr = cd->mcodeptr;
-#endif
-
- /* create stack frame - 16-byte aligned */
-
- M_ASUB_IMM(REG_SP, 2 * 8, REG_SP);
-
- /* push address of `rplpoint` struct */
-
- disp = dseg_add_address(cd, rplp);
- M_ALD(REG_ITMP3, REG_PV, disp);
- M_AST(REG_ITMP3, REG_SP, 0 * 8);
-
- /* jump to replacement function */
-
- disp = dseg_add_functionptr(cd, asm_replacement_out);
- M_ALD(REG_ITMP3, REG_PV, disp);
- M_JMP(REG_ITMP3);
- M_NOP; /* delay slot */
-
- assert((cd->mcodeptr - savedmcodeptr) == 4*REPLACEMENT_STUB_SIZE);
- }
-}
-#endif /* defined(ENABLE_REPLACEMENT) */
-
-
/* emit_verbosecall_enter ******************************************************
Generates the code for the call trace.
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
- $Id: md-os.c 8179 2007-07-05 11:21:08Z michi $
+ $Id: md-os.c 8245 2007-07-31 09:55:04Z michi $
*/
ptrint val;
ptrint addr;
s4 type;
- java_objectheader *o;
+ java_objectheader *e;
_uc = (struct ucontext *) _p;
_mc = &_uc->uc_mcontext;
val = 0;
}
+ /* create stackframeinfo */
+
+ stacktrace_create_extern_stackframeinfo(&sfi, pv, sp, ra, xpc);
+
/* generate appropriate exception */
- o = exceptions_new_hardware_exception(pv, sp, ra, xpc, type, val, &sfi);
+ e = exceptions_new_hardware_exception(xpc, type, val);
+
+ /* remove stackframeinfo */
+
+ stacktrace_remove_stackframeinfo(&sfi);
/* set registers */
- _mc->gregs[REG_ITMP1_XPTR] = (ptrint) o;
+ _mc->gregs[REG_ITMP1_XPTR] = (ptrint) e;
_mc->gregs[REG_ITMP2_XPC] = (ptrint) xpc;
_mc->gregs[CTX_EPC] = (ptrint) asm_handle_exception;
}
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
- $Id: md-os.c 8179 2007-07-05 11:21:08Z michi $
+ $Id: md-os.c 8245 2007-07-31 09:55:04Z michi $
*/
ptrint val;
ptrint addr;
s4 type;
- java_objectheader *o;
+ java_objectheader *e;
_uc = (struct ucontext *) _p;
_mc = &_uc->uc_mcontext;
val = 0;
}
+ /* create stackframeinfo */
+
+ stacktrace_create_extern_stackframeinfo(&sfi, pv, sp, ra, xpc);
+
/* generate appropriate exception */
- o = exceptions_new_hardware_exception(pv, sp, ra, xpc, type, val, &sfi);
+ e = exceptions_new_hardware_exception(xpc, type, val);
+
+ /* remove stackframeinfo */
+
+ stacktrace_remove_stackframeinfo(&sfi);
/* set registers */
- _gregs[REG_ITMP1_XPTR] = (ptrint) o;
+ _gregs[REG_ITMP1_XPTR] = (ptrint) e;
_gregs[REG_ITMP2_XPC] = (ptrint) xpc;
#if defined(__UCLIBC__)
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
- $Id: patcher.h 8186 2007-07-05 23:48:16Z michi $
+ $Id: patcher.h 8216 2007-07-19 13:51:21Z michi $
*/
#include "vm/global.h"
-#if defined(__ALPHA__) || defined(__ARM__)
+#if defined(__ALPHA__) || defined(__ARM__) || defined(__POWERPC__)
# error "you should no longer include this file"
#else
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
- $Id: asmpart.S 7989 2007-05-30 21:04:42Z twisti $
+ $Id: asmpart.S 8216 2007-07-19 13:51:21Z michi $
*/
.globl asm_abstractmethoderror
- .globl asm_patcher_wrapper
-
#if defined(ENABLE_REPLACEMENT)
.globl asm_replacement_out
.globl asm_replacement_in
b L_asm_handle_nat_exception
-/* asm_patcher_wrapper *********************************************************
-
- XXX
-
- Stack layout:
- 20 return address into JIT code (patch position)
- 16 pointer to virtual java_objectheader
- 12 machine code (which is patched back later)
- 8 unresolved class/method/field reference
- 4 data segment displacement from load instructions
- 0 patcher function pointer to call (pv is saved here afterwards)
-
-*******************************************************************************/
-
-asm_patcher_wrapper:
- mflr r0 /* get Java return address (leaf) */
- stw r0,6*4(sp) /* store it in the stub stackframe */
- /* keep stack 16-bytes aligned: 6+1+37 = 44 */
- stwu sp,-(LA_SIZE+(5+58)*4)(sp)
-
-#if defined(__DARWIN__)
- stw a0,LA_SIZE+(5+0)*4(sp) /* save argument registers */
- stw a1,LA_SIZE+(5+1)*4(sp) /* preserve linkage area (24 bytes) */
- stw a2,LA_SIZE+(5+2)*4(sp) /* and 4 bytes for 4 argument */
- stw a3,LA_SIZE+(5+3)*4(sp)
- stw a4,LA_SIZE+(5+4)*4(sp)
- stw a5,LA_SIZE+(5+5)*4(sp)
- stw a6,LA_SIZE+(5+6)*4(sp)
- stw a7,LA_SIZE+(5+7)*4(sp)
-
- stfd fa0,LA_SIZE+(5+8)*4(sp)
- stfd fa1,LA_SIZE+(5+10)*4(sp)
- stfd fa2,LA_SIZE+(5+12)*4(sp)
- stfd fa3,LA_SIZE+(5+14)*4(sp)
- stfd fa4,LA_SIZE+(5+16)*4(sp)
- stfd fa5,LA_SIZE+(5+18)*4(sp)
- stfd fa6,LA_SIZE+(5+20)*4(sp)
- stfd fa7,LA_SIZE+(5+22)*4(sp)
- stfd fa8,LA_SIZE+(5+24)*4(sp)
- stfd fa9,LA_SIZE+(5+26)*4(sp)
- stfd fa10,LA_SIZE+(5+28)*4(sp)
- stfd fa11,LA_SIZE+(5+30)*4(sp)
- stfd fa12,LA_SIZE+(5+32)*4(sp)
-
- stw t0,LA_SIZE+(5+33)*4(sp)
- stw t1,LA_SIZE+(5+34)*4(sp)
- stw t2,LA_SIZE+(5+35)*4(sp)
- stw t3,LA_SIZE+(5+36)*4(sp)
- stw t4,LA_SIZE+(5+37)*4(sp)
- stw t5,LA_SIZE+(5+38)*4(sp)
- stw t6,LA_SIZE+(5+39)*4(sp)
- stw t7,LA_SIZE+(5+40)*4(sp)
-
- stfd ft0,LA_SIZE+(5+42)*4(sp)
- stfd ft1,LA_SIZE+(5+44)*4(sp)
- stfd ft2,LA_SIZE+(5+46)*4(sp)
- stfd ft3,LA_SIZE+(5+48)*4(sp)
- stfd ft4,LA_SIZE+(5+50)*4(sp)
- stfd ft5,LA_SIZE+(5+52)*4(sp)
-#else
- /* save 8 int/8 float arguments */
- SAVE_ARGUMENT_REGISTERS(LA_SIZE_IN_POINTERS+1)
- SAVE_TEMPORARY_REGISTERS(LA_SIZE_IN_POINTERS+1+24)
-#endif
-
- stw itmp1,LA_SIZE+(5+54)*4(sp)
- stw itmp2,LA_SIZE+(5+55)*4(sp)
- stw pv,LA_SIZE+(5+56)*4(sp)
-
- addi a0,sp,LA_SIZE+(5+58)*4 /* pass SP of patcher stub */
- mr a1,pv /* pass PV */
- mr a2,r0 /* pass RA (correct for leafs) */
- bl patcher_wrapper
- stw v0,LA_SIZE+(5+57)*4(sp) /* save return value */
-
-#if defined(__DARWIN__)
- lwz a0,LA_SIZE+(5+0)*4(sp)
- lwz a1,LA_SIZE+(5+1)*4(sp)
- lwz a2,LA_SIZE+(5+2)*4(sp)
- lwz a3,LA_SIZE+(5+3)*4(sp)
- lwz a4,LA_SIZE+(5+4)*4(sp)
- lwz a5,LA_SIZE+(5+5)*4(sp)
- lwz a6,LA_SIZE+(5+6)*4(sp)
- lwz a7,LA_SIZE+(5+7)*4(sp)
-
- lfd fa0,LA_SIZE+(5+8)*4(sp)
- lfd fa1,LA_SIZE+(5+10)*4(sp)
- lfd fa2,LA_SIZE+(5+12)*4(sp)
- lfd fa3,LA_SIZE+(5+14)*4(sp)
- lfd fa4,LA_SIZE+(5+16)*4(sp)
- lfd fa5,LA_SIZE+(5+18)*4(sp)
- lfd fa6,LA_SIZE+(5+20)*4(sp)
- lfd fa7,LA_SIZE+(5+22)*4(sp)
- lfd fa8,LA_SIZE+(5+24)*4(sp)
- lfd fa9,LA_SIZE+(5+26)*4(sp)
- lfd fa10,LA_SIZE+(5+28)*4(sp)
- lfd fa11,LA_SIZE+(5+30)*4(sp)
- lfd fa12,LA_SIZE+(5+32)*4(sp)
-
- lwz t0,LA_SIZE+(5+33)*4(sp)
- lwz t1,LA_SIZE+(5+34)*4(sp)
- lwz t2,LA_SIZE+(5+35)*4(sp)
- lwz t3,LA_SIZE+(5+36)*4(sp)
- lwz t4,LA_SIZE+(5+37)*4(sp)
- lwz t5,LA_SIZE+(5+38)*4(sp)
- lwz t6,LA_SIZE+(5+39)*4(sp)
- lwz t7,LA_SIZE+(5+40)*4(sp)
-
- lfd ft0,LA_SIZE+(5+42)*4(sp)
- lfd ft1,LA_SIZE+(5+44)*4(sp)
- lfd ft2,LA_SIZE+(5+46)*4(sp)
- lfd ft3,LA_SIZE+(5+48)*4(sp)
- lfd ft4,LA_SIZE+(5+50)*4(sp)
- lfd ft5,LA_SIZE+(5+52)*4(sp)
-#else
- /* restore 8 int/8 float arguments */
- RESTORE_ARGUMENT_REGISTERS(LA_SIZE_IN_POINTERS+1)
- RESTORE_TEMPORARY_REGISTERS(LA_SIZE_IN_POINTERS+1+24)
-#endif
-
- lwz itmp1,LA_SIZE+(5+54)*4(sp)
- lwz itmp2,LA_SIZE+(5+55)*4(sp)
- lwz pv,LA_SIZE+(5+56)*4(sp)
- lwz itmp3,LA_SIZE+(5+57)*4(sp) /* restore return value into temp reg.*/
-
- lwz r0,6*4+LA_SIZE+(5+58)*4(sp) /* restore RA */
- mtlr r0
-
- mr. itmp3,itmp3 /* check for an exception */
- bne L_asm_patcher_wrapper_exception
-
- /* get return address (into JIT code) */
- lwz itmp3,5*4+LA_SIZE+(5+58)*4(sp)
-
- /* remove stack frame + patcher stub stack */
- addi sp,sp,8*4+LA_SIZE+(5+58)*4
-
- mtctr itmp3
- bctr /* jump to new patched code */
-
-L_asm_patcher_wrapper_exception:
- mr xptr,itmp3 /* get exception */
- lwz xpc,5*4+LA_SIZE+(5+58)*4(sp)
- addi sp,sp,8*4+LA_SIZE+(5+58)*4
- b L_asm_handle_exception
-
#if defined(ENABLE_REPLACEMENT)
/* asm_replacement_out *********************************************************
.long dyld_stub_binding_helper
-.section __TEXT,__picsymbolstub1,symbol_stubs,pure_instructions,32
- .align 2
-L_patcher_wrapper$stub:
- .indirect_symbol _patcher_wrapper
- mflr r0
- bcl 20,31,L00$_patcher_wrapper
-L00$_patcher_wrapper:
- mflr r11
- addis r11,r11,ha16(L_patcher_wrapper$lazy_ptr - L00$_patcher_wrapper)
- mtlr r0
- lwzu r12,lo16(L_patcher_wrapper$lazy_ptr - L00$_patcher_wrapper)(r11)
- mtctr r12
- bctr
-.data
-.lazy_symbol_pointer
-L_patcher_wrapper$lazy_ptr:
- .indirect_symbol _patcher_wrapper
- .long dyld_stub_binding_helper
-
-
# if defined(ENABLE_REPLACEMENT)
.section __TEXT,__picsymbolstub1,symbol_stubs,pure_instructions,32
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
- $Id: codegen.c 8123 2007-06-20 23:50:55Z michi $
+ $Id: codegen.c 8245 2007-07-31 09:55:04Z michi $
*/
#include "vm/jit/md.h"
#include "vm/jit/methodheader.h"
#include "vm/jit/parse.h"
-#include "vm/jit/patcher.h"
+#include "vm/jit/patcher-common.h"
#include "vm/jit/reg.h"
#include "vm/jit/replace.h"
#include "vm/jit/stacktrace.h"
if (IS_2_WORD_TYPE(t)) {
M_DLD(REG_FTMP1, REG_SP, cd->stackframesize * 4 + s1);
M_DST(REG_FTMP1, REG_SP, var->vv.regoff);
- var->vv.regoff = cd->stackframesize + s1;
-
- } else {
+ }
+ else {
M_FLD(REG_FTMP1, REG_SP, cd->stackframesize * 4 + s1);
M_FST(REG_FTMP1, REG_SP, var->vv.regoff);
}
disp = dseg_add_unique_address(cd, cr);
- codegen_addpatchref(cd, PATCHER_resolve_classref_to_classinfo,
+ patcher_add_patch_ref(jd, PATCHER_resolve_classref_to_classinfo,
cr, disp);
}
else
fieldtype = uf->fieldref->parseddesc.fd->type;
disp = dseg_add_unique_address(cd, uf);
- codegen_addpatchref(cd, PATCHER_get_putstatic, uf, disp);
+ patcher_add_patch_ref(jd, PATCHER_get_putstatic, uf, disp);
}
else {
fi = iptr->sx.s23.s3.fmiref->p.field;
disp = dseg_add_address(cd, &(fi->value));
if (!CLASS_IS_OR_ALMOST_INITIALIZED(fi->class))
- codegen_addpatchref(cd, PATCHER_initialize_class,
+ patcher_add_patch_ref(jd, PATCHER_initialize_class,
fi->class, disp);
}
fieldtype = uf->fieldref->parseddesc.fd->type;
disp = dseg_add_unique_address(cd, uf);
- codegen_addpatchref(cd, PATCHER_get_putstatic, uf, disp);
+ patcher_add_patch_ref(jd, PATCHER_get_putstatic, uf, disp);
}
else {
fi = iptr->sx.s23.s3.fmiref->p.field;
disp = dseg_add_address(cd, &(fi->value));
if (!CLASS_IS_OR_ALMOST_INITIALIZED(fi->class))
- codegen_addpatchref(cd, PATCHER_initialize_class,
+ patcher_add_patch_ref(jd, PATCHER_initialize_class,
fi->class, disp);
}
fieldtype = uf->fieldref->parseddesc.fd->type;
disp = 0;
- codegen_addpatchref(cd, PATCHER_get_putfield, uf, 0);
+ patcher_add_patch_ref(jd, PATCHER_get_putfield, uf, 0);
}
else {
fi = iptr->sx.s23.s3.fmiref->p.field;
s2 = emit_load_s2(jd, iptr, REG_FTMP2);
if (INSTRUCTION_IS_UNRESOLVED(iptr))
- codegen_addpatchref(cd, PATCHER_get_putfield, uf, 0);
+ patcher_add_patch_ref(jd, PATCHER_get_putfield, uf, 0);
/* implicit null-pointer check */
switch (fieldtype) {
if (INSTRUCTION_IS_UNRESOLVED(iptr)) {
unresolved_class *uc = iptr->sx.s23.s2.uc;
- codegen_addpatchref(cd, PATCHER_resolve_class, uc, 0);
+ patcher_add_patch_ref(jd, PATCHER_resolve_class, uc, 0);
}
#endif /* ENABLE_VERIFIER */
if (INSTRUCTION_IS_UNRESOLVED(iptr)) {
unresolved_class *uc = iptr->sx.s23.s2.uc;
- codegen_addpatchref(cd, PATCHER_resolve_class, uc, 0);
+ patcher_add_patch_ref(jd, PATCHER_resolve_class, uc, 0);
}
#endif /* ENABLE_VERIFIER */
goto nowperformreturn;
if (lm == NULL) {
disp = dseg_add_unique_address(cd, um);
- codegen_addpatchref(cd, PATCHER_invokestatic_special,
+ patcher_add_patch_ref(jd, PATCHER_invokestatic_special,
um, disp);
}
else
case ICMD_INVOKEVIRTUAL:
if (lm == NULL) {
- codegen_addpatchref(cd, PATCHER_invokevirtual, um, 0);
+ patcher_add_patch_ref(jd, PATCHER_invokevirtual, um, 0);
s1 = 0;
}
case ICMD_INVOKEINTERFACE:
if (lm == NULL) {
- codegen_addpatchref(cd, PATCHER_invokeinterface, um, 0);
+ patcher_add_patch_ref(jd, PATCHER_invokeinterface, um, 0);
s1 = 0;
s2 = 0;
disp = dseg_add_unique_s4(cd, 0); /* super->flags */
- codegen_addpatchref(cd,
+ patcher_add_patch_ref(jd,
PATCHER_resolve_classref_to_flags,
iptr->sx.s23.s3.c.ref,
disp);
if ((super == NULL) || (super->flags & ACC_INTERFACE)) {
if (super == NULL) {
- codegen_addpatchref(cd,
+ patcher_add_patch_ref(jd,
PATCHER_checkcast_interface,
iptr->sx.s23.s3.c.ref,
0);
disp = dseg_add_unique_address(cd, NULL);
- codegen_addpatchref(cd, PATCHER_resolve_classref_to_vftbl,
+ patcher_add_patch_ref(jd, PATCHER_resolve_classref_to_vftbl,
iptr->sx.s23.s3.c.ref,
disp);
}
if (INSTRUCTION_IS_UNRESOLVED(iptr)) {
disp = dseg_add_unique_address(cd, NULL);
- codegen_addpatchref(cd, PATCHER_resolve_classref_to_classinfo,
+ patcher_add_patch_ref(jd, PATCHER_resolve_classref_to_classinfo,
iptr->sx.s23.s3.c.ref,
disp);
}
disp = dseg_add_unique_s4(cd, 0); /* super->flags */
- codegen_addpatchref(cd, PATCHER_resolve_classref_to_flags,
+ patcher_add_patch_ref(jd, PATCHER_resolve_classref_to_flags,
iptr->sx.s23.s3.c.ref, disp);
M_ILD(REG_ITMP3, REG_PV, disp);
if ((super == NULL) || (super->flags & ACC_INTERFACE)) {
if (super == NULL) {
- codegen_addpatchref(cd,
+ patcher_add_patch_ref(jd,
PATCHER_instanceof_interface,
iptr->sx.s23.s3.c.ref, 0);
}
disp = dseg_add_unique_address(cd, NULL);
- codegen_addpatchref(cd, PATCHER_resolve_classref_to_vftbl,
+ patcher_add_patch_ref(jd, PATCHER_resolve_classref_to_vftbl,
iptr->sx.s23.s3.c.ref,
disp);
}
if (INSTRUCTION_IS_UNRESOLVED(iptr)) {
disp = dseg_add_unique_address(cd, NULL);
- codegen_addpatchref(cd, PATCHER_resolve_classref_to_classinfo,
+ patcher_add_patch_ref(jd, PATCHER_resolve_classref_to_classinfo,
iptr->sx.s23.s3.c.ref, disp);
}
else
dseg_createlinenumbertable(cd);
- /* generate stubs */
+ /* generate traps */
- emit_patcher_stubs(jd);
- REPLACEMENT_EMIT_STUBS(jd);
+ emit_patcher_traps(jd);
/* everything's ok */
#if !defined(WITH_STATIC_CLASSPATH)
if (f == NULL)
- codegen_addpatchref(cd, PATCHER_resolve_native_function, m, funcdisp);
+ patcher_add_patch_ref(jd, PATCHER_resolve_native_function, m, funcdisp);
#endif
/* emit trace code */
/* save integer and float argument registers */
- j = 0;
-
for (i = 0; i < md->paramcount; i++) {
- t = md->paramtypes[i].type;
-
- if (IS_INT_LNG_TYPE(t)) {
- if (!md->params[i].inmemory) {
- s1 = md->params[i].regoff;
+ if (!md->params[i].inmemory) {
+ s1 = md->params[i].regoff;
- if (IS_2_WORD_TYPE(t)) {
- M_IST(GET_HIGH_REG(s1), REG_SP, LA_SIZE + 4 * 4 + j * 4);
- j++;
- M_IST(GET_LOW_REG(s1), REG_SP, LA_SIZE + 4 * 4 + j * 4);
- }
- else
- M_IST(s1, REG_SP, LA_SIZE + 4 * 4 + j * 4);
-
- j++;
- }
- }
- }
-
- for (i = 0; i < md->paramcount; i++) {
- if (IS_FLT_DBL_TYPE(md->paramtypes[i].type)) {
- if (!md->params[i].inmemory) {
- s1 = md->params[i].regoff;
- M_DST(s1, REG_SP, LA_SIZE + 4 * 4 + j * 8);
- j++;
+ switch (md->paramtypes[i].type) {
+ case TYPE_INT:
+ case TYPE_ADR:
+ M_IST(s1, REG_SP, LA_SIZE + 4*4 + i * 8);
+ break;
+ case TYPE_LNG:
+ M_LST(s1, REG_SP, LA_SIZE + 4*4 + i * 8);
+ break;
+ case TYPE_FLT:
+ case TYPE_DBL:
+ M_DST(s1, REG_SP, LA_SIZE + 4*4 + i * 8);
+ break;
}
}
}
/* restore integer and float argument registers */
- j = 0;
-
for (i = 0; i < md->paramcount; i++) {
- t = md->paramtypes[i].type;
-
- if (IS_INT_LNG_TYPE(t)) {
- if (!md->params[i].inmemory) {
- s1 = md->params[i].regoff;
+ if (!md->params[i].inmemory) {
+ s1 = md->params[i].regoff;
- if (IS_2_WORD_TYPE(t)) {
- M_ILD(GET_HIGH_REG(s1), REG_SP, LA_SIZE + 4 * 4 + j * 4);
- j++;
- M_ILD(GET_LOW_REG(s1), REG_SP, LA_SIZE + 4 * 4 + j * 4);
- }
- else
- M_ILD(s1, REG_SP, LA_SIZE + 4 * 4 + j * 4);
-
- j++;
+ switch (md->paramtypes[i].type) {
+ case TYPE_INT:
+ case TYPE_ADR:
+ M_ILD(s1, REG_SP, LA_SIZE + 4*4 + i * 8);
+ break;
+ case TYPE_LNG:
+ M_LLD(s1, REG_SP, LA_SIZE + 4*4 + i * 8);
+ break;
+ case TYPE_FLT:
+ case TYPE_DBL:
+ M_DLD(s1, REG_SP, LA_SIZE + 4*4 + i * 8);
+ break;
}
}
}
- for (i = 0; i < md->paramcount; i++) {
- if (IS_FLT_DBL_TYPE(md->paramtypes[i].type)) {
- if (!md->params[i].inmemory) {
- s1 = md->params[i].regoff;
- M_DLD(s1, REG_SP, LA_SIZE + 4 * 4 + j * 8);
- j++;
- }
- }
- }
-
/* copy or spill arguments to new locations */
for (i = md->paramcount - 1, j = i + nativeparams; i >= 0; i--, j--) {
M_MTCTR(REG_ITMP3);
M_RTS;
- /* generate patcher stubs */
+ /* generate patcher traps */
- emit_patcher_stubs(jd);
+ emit_patcher_traps(jd);
}
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
- $Id: md-abi.h 7988 2007-05-30 20:53:56Z twisti $
+ $Id: md-abi.h 8191 2007-07-08 15:15:53Z twisti $
*/
#define FLT_TMP_CNT 6 /* number of float temporary registers */
#define FLT_RES_CNT 3 /* number of float reserved registers */
-#define TRACE_ARGS_NUM 8
+#define TRACE_ARGS_NUM 4
/* packed register defines ****************************************************/
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
- $Id: md-os.c 8178 2007-07-05 11:13:20Z michi $
+ $Id: md-os.c 8243 2007-07-31 08:57:54Z michi $
*/
ptrint addr;
ptrint val;
s4 type;
- java_objectheader *o;
+ java_objectheader *e;
_uc = (ucontext_t *) _p;
_mc = _uc->uc_mcontext;
vm_abort("md_signal_handler_sigsegv: faulting address is not NULL: addr=%p", addr);
}
+ /* create stackframeinfo */
+
+ stacktrace_create_extern_stackframeinfo(&sfi, pv, sp, ra, xpc);
+
/* generate appropriate exception */
- o = exceptions_new_hardware_exception(pv, sp, ra, xpc, type, val, &sfi);
+ e = exceptions_new_hardware_exception(xpc, type, val);
- /* set registers */
+ /* remove stackframeinfo */
- _ss->r11 = (ptrint) o;
- _ss->r12 = (ptrint) xpc;
- _ss->srr0 = (ptrint) asm_handle_exception;
+ stacktrace_remove_stackframeinfo(&sfi);
+
+ /* set registers (only if exception object ready) */
+
+ if (e != NULL) {
+ _ss->r11 = (ptrint) e;
+ _ss->r12 = (ptrint) xpc;
+ _ss->srr0 = (ptrint) asm_handle_exception;
+ }
}
s4 s1;
ptrint val;
s4 type;
- java_objectheader *o;
+ java_objectheader *e;
_uc = (ucontext_t *) _p;
_mc = _uc->uc_mcontext;
type = EXCEPTION_HARDWARE_ARRAYINDEXOUTOFBOUNDS;
val = gregs[s1];
+ /* create stackframeinfo */
+
+ stacktrace_create_extern_stackframeinfo(&sfi, pv, sp, ra, xpc);
+
/* generate appropriate exception */
- o = exceptions_new_hardware_exception(pv, sp, ra, xpc, type, val, &sfi);
+ e = exceptions_new_hardware_exception(xpc, type, val);
+
+ /* remove stackframeinfo */
+
+ stacktrace_remove_stackframeinfo(&sfi);
/* set registers */
- _ss->r11 = (ptrint) o;
+ _ss->r11 = (ptrint) e;
_ss->r12 = (ptrint) xpc;
_ss->srr0 = (ptrint) asm_handle_exception;
}
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
- $Id: emit.c 8123 2007-06-20 23:50:55Z michi $
+ $Id: emit.c 8216 2007-07-19 13:51:21Z michi $
*/
#include "config.h"
#include <assert.h>
+#include <stdint.h>
#include "vm/types.h"
#include "vm/jit/dseg.h"
#include "vm/jit/emit-common.h"
#include "vm/jit/jit.h"
+#include "vm/jit/patcher-common.h"
#include "vm/jit/replace.h"
#include "vmcore/options.h"
}
-/* emit_patcher_stubs **********************************************************
+/* emit_patcher_traps **********************************************************
Generates the code for the patcher stubs.
*******************************************************************************/
-void emit_patcher_stubs(jitdata *jd)
+void emit_patcher_traps(jitdata *jd)
{
codegendata *cd;
- patchref *pref;
- u4 mcode;
+ codeinfo *code;
+ patchref_t *pr;
u1 *savedmcodeptr;
u1 *tmpmcodeptr;
- s4 targetdisp;
- s4 disp;
/* get required compiler data */
- cd = jd->cd;
+ cd = jd->cd;
+ code = jd->code;
/* generate code patching stub call code */
- targetdisp = 0;
-
- for (pref = cd->patchrefs; pref != NULL; pref = pref->next) {
- /* check code segment size */
-
- MCODECHECK(100);
+ for (pr = list_first_unsynced(code->patchers); pr != NULL; pr = list_next_unsynced(code->patchers, pr)) {
/* Get machine code which is patched back in later. The
- call is 1 instruction word long. */
+ trap is 1 instruction word long. */
- tmpmcodeptr = (u1 *) (cd->mcodebase + pref->branchpos);
+ tmpmcodeptr = (u1 *) (cd->mcodebase + pr->mpc);
- mcode = *((u4 *) tmpmcodeptr);
+ pr->mcode = *((u4 *) tmpmcodeptr);
- /* Patch in the call to call the following code (done at
+ /* Patch in the trap to call the signal handler (done at
compile time). */
savedmcodeptr = cd->mcodeptr; /* save current mcodeptr */
cd->mcodeptr = tmpmcodeptr; /* set mcodeptr to patch position */
- disp = ((u4 *) savedmcodeptr) - (((u4 *) tmpmcodeptr) + 1);
- M_BR(disp);
+ M_ALD_INTERN(REG_ZERO, REG_ZERO, EXCEPTION_HARDWARE_PATCHER);
cd->mcodeptr = savedmcodeptr; /* restore the current mcodeptr */
-
- /* create stack frame - keep stack 16-byte aligned */
-
- M_AADD_IMM(REG_SP, -8 * 4, REG_SP);
-
- /* calculate return address and move it onto the stack */
-
- M_LDA(REG_ITMP3, REG_PV, pref->branchpos);
- M_AST_INTERN(REG_ITMP3, REG_SP, 5 * 4);
-
- /* move pointer to java_objectheader onto stack */
-
-#if defined(ENABLE_THREADS)
- /* order reversed because of data segment layout */
-
- (void) dseg_add_unique_address(cd, NULL); /* flcword */
- (void) dseg_add_unique_address(cd, lock_get_initial_lock_word());
- disp = dseg_add_unique_address(cd, NULL); /* vftbl */
-
- M_LDA(REG_ITMP3, REG_PV, disp);
- M_AST_INTERN(REG_ITMP3, REG_SP, 4 * 4);
-#else
- /* do nothing */
-#endif
-
- /* move machine code onto stack */
-
- disp = dseg_add_s4(cd, mcode);
- M_ILD(REG_ITMP3, REG_PV, disp);
- M_IST_INTERN(REG_ITMP3, REG_SP, 3 * 4);
-
- /* move class/method/field reference onto stack */
-
- disp = dseg_add_address(cd, pref->ref);
- M_ALD(REG_ITMP3, REG_PV, disp);
- M_AST_INTERN(REG_ITMP3, REG_SP, 2 * 4);
-
- /* move data segment displacement onto stack */
-
- disp = dseg_add_s4(cd, pref->disp);
- M_ILD(REG_ITMP3, REG_PV, disp);
- M_IST_INTERN(REG_ITMP3, REG_SP, 1 * 4);
-
- /* move patcher function pointer onto stack */
-
- disp = dseg_add_functionptr(cd, pref->patcher);
- M_ALD(REG_ITMP3, REG_PV, disp);
- M_AST_INTERN(REG_ITMP3, REG_SP, 0 * 4);
-
- if (targetdisp == 0) {
- targetdisp = ((u4 *) cd->mcodeptr) - ((u4 *) cd->mcodebase);
-
- disp = dseg_add_functionptr(cd, asm_patcher_wrapper);
- M_ALD(REG_ITMP3, REG_PV, disp);
- M_MTCTR(REG_ITMP3);
- M_RTS;
- }
- else {
- disp = (((u4 *) cd->mcodebase) + targetdisp) -
- (((u4 *) cd->mcodeptr) + 1);
- M_BR(disp);
- }
}
}
-/* emit_replacement_stubs ******************************************************
-
- Generates the code for the replacement stubs.
-
-*******************************************************************************/
-
-#if defined(ENABLE_REPLACEMENT)
-void emit_replacement_stubs(jitdata *jd)
-{
- codegendata *cd;
- codeinfo *code;
- rplpoint *rplp;
- s4 disp;
- s4 i;
-#if !defined(NDEBUG)
- u1 *savedmcodeptr;
-#endif
-
- /* get required compiler data */
-
- cd = jd->cd;
- code = jd->code;
-
- rplp = code->rplpoints;
-
- /* store beginning of replacement stubs */
-
- code->replacementstubs = (u1*) (cd->mcodeptr - cd->mcodebase);
-
- for (i = 0; i < code->rplpointcount; ++i, ++rplp) {
- /* do not generate stubs for non-trappable points */
-
- if (rplp->flags & RPLPOINT_FLAG_NOTRAP)
- continue;
-
- /* check code segment size */
-
- MCODECHECK(100);
-
-#if !defined(NDEBUG)
- savedmcodeptr = cd->mcodeptr;
-#endif
-
- /* create stack frame - keep 16-byte aligned */
-
- M_AADD_IMM(REG_SP, -4 * 4, REG_SP);
-
- /* push address of `rplpoint` struct */
-
- disp = dseg_add_address(cd, rplp);
- M_ALD(REG_ITMP3, REG_PV, disp);
- M_AST_INTERN(REG_ITMP3, REG_SP, 0 * 4);
-
- /* jump to replacement function */
-
- disp = dseg_add_functionptr(cd, asm_replacement_out);
- M_ALD(REG_ITMP3, REG_PV, disp);
- M_MTCTR(REG_ITMP3);
- M_RTS;
-
- assert((cd->mcodeptr - savedmcodeptr) == 4*REPLACEMENT_STUB_SIZE);
- }
-}
-#endif /* defined(ENABLE_REPLACEMENT) */
-
-
/* emit_verbosecall_enter ******************************************************
Generates the code for the call trace.
methodinfo *m;
codegendata *cd;
registerdata *rd;
- s4 s1, p, t, d;
- int stack_off;
- int stack_size;
- methoddesc *md;
+ methoddesc *md;
+ int32_t disp;
+ int32_t i;
+ int32_t s, d;
+ int32_t x;
if (!JITDATA_HAS_FLAG_VERBOSECALL(jd))
return;
rd = jd->rd;
md = m->parseddesc;
-
- /* Build up Stackframe for builtin_trace_args call (a multiple of 16) */
- /* For Darwin: */
- /* LA + TRACE_ARGS_NUM u8 args + methodinfo + LR */
- /* LA_SIZE(=6*4) + 8*8 + 4 + 4 + 0(Padding) */
- /* 6 * 4 + 8 * 8 + 2 * 4 = 12 * 8 = 6 * 16 */
- /* For Linux: */
- /* LA + (TRACE_ARGS_NUM - INT_ARG_CNT/2) u8 args + methodinfo */
- /* + INT_ARG_CNT * 4 ( save integer registers) + LR + 8 + 8 (Padding) */
- /* LA_SIZE(=2*4) + 4 * 8 + 4 + 8 * 4 + 4 + 8 */
- /* 2 * 4 + 4 * 8 + 10 * 4 + 1 * 8 + 8= 12 * 8 = 6 * 16 */
-
- /* in nativestubs no Place to save the LR (Link Register) would be needed */
- /* but since the stack frame has to be aligned the 4 Bytes would have to */
- /* be padded again */
-
-#if defined(__DARWIN__)
- stack_size = LA_SIZE + (TRACE_ARGS_NUM + 1) * 8;
-#else
- stack_size = 6 * 16;
-#endif
/* mark trace code */
M_MFLR(REG_ZERO);
M_AST(REG_ZERO, REG_SP, LA_LR_OFFSET);
- M_STWU(REG_SP, REG_SP, -stack_size);
+ M_STWU(REG_SP, REG_SP, -(LA_SIZE + (1 + ARG_CNT + TMP_CNT) * 8));
- M_CLR(REG_ITMP1); /* clear help register */
+ M_CLR(REG_ITMP1); /* prepare a "zero" register */
- /* save up to TRACE_ARGS_NUM arguments into the reserved stack space */
-#if defined(__DARWIN__)
- /* Copy Params starting from first to Stack */
- /* since TRACE_ARGS == INT_ARG_CNT all used integer argument regs */
- /* are saved */
- p = 0;
-#else
- /* Copy Params starting from fifth to Stack (INT_ARG_CNT/2) are in */
- /* integer argument regs */
- /* all integer argument registers have to be saved */
- for (p = 0; p < 8; p++) {
- d = abi_registers_integer_argument[p];
- /* save integer argument registers */
- M_IST(d, REG_SP, LA_SIZE + 4 * 8 + 4 + p * 4);
- }
- p = 4;
-#endif
- stack_off = LA_SIZE;
-
- for (; p < md->paramcount && p < TRACE_ARGS_NUM; p++, stack_off += 8) {
- t = md->paramtypes[p].type;
-
- if (IS_INT_LNG_TYPE(t)) {
- if (!md->params[p].inmemory) {
- s1 = md->params[p].regoff;
-
- if (IS_2_WORD_TYPE(t)) {
- M_IST(GET_HIGH_REG(s1), REG_SP, stack_off);
- M_IST(GET_LOW_REG(s1), REG_SP, stack_off + 4);
- }
- else {
- M_IST(REG_ITMP1, REG_SP, stack_off);
- M_IST(s1, REG_SP, stack_off + 4);
- }
- }
- else {
- s1 = md->params[p].regoff + cd->stackframesize * 4
- + stack_size;
- if (IS_2_WORD_TYPE(t)) {
- M_ILD(REG_ITMP2, REG_SP, s1);
- M_IST(REG_ITMP2, REG_SP, stack_off);
- M_ILD(REG_ITMP2, REG_SP, s1 + 4);
- M_IST(REG_ITMP2, REG_SP, stack_off + 4);
- }
- else {
- M_IST(REG_ITMP1, REG_SP, stack_off);
- M_ILD(REG_ITMP2, REG_SP, s1);
- M_IST(REG_ITMP2, REG_SP, stack_off + 4);
- }
- }
- }
- else {
- if (!md->params[p].inmemory) {
- s1 = md->params[p].regoff;
-
- if (!IS_2_WORD_TYPE(t)) {
- M_IST(REG_ITMP1, REG_SP, stack_off);
- M_FST(s1, REG_SP, stack_off + 4);
- }
- else
- M_DST(s1, REG_SP, stack_off);
- }
- else {
- /* this should not happen */
+ /* save argument registers */
+
+ for (i = 0; i < md->paramcount; i++) {
+ if (!md->params[i].inmemory) {
+ s = md->params[i].regoff;
+ d = LA_SIZE + (1 + i) * 8;
+
+ switch (md->paramtypes[i].type) {
+ case TYPE_INT:
+ case TYPE_ADR:
+ M_IST(REG_ITMP1, REG_SP, d); /* high-bits are zero */
+ M_IST(s, REG_SP, d + 4);
+ break;
+ case TYPE_LNG:
+ M_LST(s, REG_SP, d);
+ break;
+ case TYPE_FLT:
+ M_IST(REG_ITMP1, REG_SP, d); /* high-bits are zero */
+ M_FST(s, REG_SP, d + 4);
+ break;
+ case TYPE_DBL:
+ M_DST(s, REG_SP, d);
+ break;
}
}
}
- /* load first 4 (==INT_ARG_CNT/2) arguments into integer registers */
-#if defined(__DARWIN__)
- for (p = 0; p < 8; p++) {
- d = abi_registers_integer_argument[p];
- M_ILD(d, REG_SP, LA_SIZE + p * 4);
- }
-#else
- /* LINUX */
- /* Set integer and float argument registers vor trace_args call */
- /* offset to saved integer argument registers */
+ /* load arguments as longs */
- stack_off = LA_SIZE + 4 * 8 + 4;
+ d = 0;
- for (p = 0; (p < 4) && (p < md->paramcount); p++) {
- t = md->paramtypes[p].type;
+ for (i = 0; i < md->paramcount && i < TRACE_ARGS_NUM; i++) {
+ s = LA_SIZE + (1 + i) * 8;
+ x = PACK_REGS(abi_registers_integer_argument[d + 1],
+ abi_registers_integer_argument[d]);
- if (IS_INT_LNG_TYPE(t)) {
- /* "stretch" int types */
- if (!IS_2_WORD_TYPE(t)) {
- M_CLR(abi_registers_integer_argument[2 * p]);
- M_ILD(abi_registers_integer_argument[2 * p + 1], REG_SP,stack_off);
- stack_off += 4;
- }
- else {
- M_ILD(abi_registers_integer_argument[2 * p + 1], REG_SP,stack_off + 4);
- M_ILD(abi_registers_integer_argument[2 * p], REG_SP,stack_off);
- stack_off += 8;
- }
- }
- else {
- if (!md->params[p].inmemory) {
- /* use reserved Place on Stack (sp + 5 * 16) to copy */
- /* float/double arg reg to int reg */
-
- s1 = md->params[p].regoff;
-
- if (!IS_2_WORD_TYPE(t)) {
- M_FST(s1, REG_SP, 5 * 16);
- M_ILD(abi_registers_integer_argument[2 * p + 1], REG_SP, 5 * 16);
- M_CLR(abi_registers_integer_argument[2 * p]);
- }
- else {
- M_DST(s1, REG_SP, 5 * 16);
- M_ILD(abi_registers_integer_argument[2 * p + 1], REG_SP, 5 * 16 + 4);
- M_ILD(abi_registers_integer_argument[2 * p], REG_SP, 5 * 16);
- }
- }
- }
+ M_LLD(x, REG_SP, s);
+
+ d += 2;
}
-#endif
- /* put methodinfo pointer on Stackframe */
- p = dseg_add_address(cd, m);
- M_ALD(REG_ITMP1, REG_PV, p);
+ /* put methodinfo pointer as last argument on the stack */
+
+ disp = dseg_add_address(cd, m);
+ M_ALD(REG_ITMP1, REG_PV, disp);
#if defined(__DARWIN__)
M_AST(REG_ITMP1, REG_SP, LA_SIZE + TRACE_ARGS_NUM * 8);
#else
- M_AST(REG_ITMP1, REG_SP, LA_SIZE + 4 * 8);
+ M_AST(REG_ITMP1, REG_SP, LA_SIZE);
#endif
- p = dseg_add_functionptr(cd, builtin_verbosecall_enter);
- M_ALD(REG_ITMP2, REG_PV, p);
+ disp = dseg_add_functionptr(cd, builtin_verbosecall_enter);
+ M_ALD(REG_ITMP2, REG_PV, disp);
M_MTCTR(REG_ITMP2);
M_JSR;
-#if defined(__DARWIN__)
- /* restore integer argument registers from the reserved stack space */
-
- stack_off = LA_SIZE;
+ /* restore argument registers */
- for (p = 0; p < md->paramcount && p < TRACE_ARGS_NUM; p++, stack_off += 8) {
- t = md->paramtypes[p].type;
+ for (i = 0; i < md->paramcount; i++) {
+ if (!md->params[i].inmemory) {
+ s = LA_SIZE + (1 + i) * 8;
+ d = md->params[i].regoff;
- if (IS_INT_LNG_TYPE(t)) {
- if (!md->params[p].inmemory) {
- s1 = md->params[p].regoff;
-
- if (IS_2_WORD_TYPE(t)) {
- M_ILD(GET_HIGH_REG(s1), REG_SP, stack_off);
- M_ILD(GET_LOW_REG(s1), REG_SP, stack_off + 4);
- }
- else
- M_ILD(s1, REG_SP, stack_off + 4);
+ switch (md->paramtypes[i].type) {
+ case TYPE_INT:
+ case TYPE_ADR:
+ M_ILD(d, REG_SP, s + 4); /* get low-bits */
+ break;
+ case TYPE_LNG:
+ M_LLD(d, REG_SP, s);
+ break;
+ case TYPE_FLT:
+ M_FLD(d, REG_SP, s + 4); /* get low-bits */
+ break;
+ case TYPE_DBL:
+ M_DLD(d, REG_SP, s);
+ break;
}
}
}
-#else
- /* LINUX */
- for (p = 0; p < 8; p++) {
- d = abi_registers_integer_argument[p];
- /* save integer argument registers */
- M_ILD(d, REG_SP, LA_SIZE + 4 * 8 + 4 + p * 4);
- }
-#endif
- M_ALD(REG_ZERO, REG_SP, stack_size + LA_LR_OFFSET);
+ M_ALD(REG_ZERO, REG_SP, LA_SIZE + (1 + ARG_CNT + TMP_CNT) * 8 + LA_LR_OFFSET);
M_MTLR(REG_ZERO);
- M_LDA(REG_SP, REG_SP, stack_size);
+ M_LDA(REG_SP, REG_SP, LA_SIZE + (1 + ARG_CNT + TMP_CNT) * 8);
/* mark trace code */
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
- $Id: md-abi.c 8123 2007-06-20 23:50:55Z michi $
+ $Id: md-abi.c 8190 2007-07-08 13:42:06Z twisti $
*/
#include "config.h"
#include <assert.h>
-
-#include "vm/types.h"
+#include <stdint.h>
#include "vm/jit/powerpc/linux/md-abi.h"
#include "vmcore/descriptor.h"
-#define _ALIGN(a) do { if ((a) & 1) (a)++; } while (0)
-
-
/* register descripton arrays *************************************************/
-s4 nregdescint[] = {
+int32_t nregdescint[] = {
/* zero, sp, NO(sys), a0/v0, a1/v1, a2, a3, a4, */
REG_RES, REG_RES, REG_RES, REG_ARG, REG_ARG, REG_ARG, REG_ARG, REG_ARG,
"r24", "r25", "r26", "r27", "r28", "r29", "r30", "r31",
};
-const s4 abi_registers_integer_argument[] = {
+const int32_t abi_registers_integer_argument[] = {
3, /* a0 */
4, /* a1 */
5, /* a2 */
10, /* a7 */
};
-const s4 abi_registers_integer_saved[] = {
+const int32_t abi_registers_integer_saved[] = {
14, /* s0 */
15, /* s1 */
24, /* s2 */
31, /* s9 */
};
-const s4 abi_registers_integer_temporary[] = {
+const int32_t abi_registers_integer_temporary[] = {
17, /* t0 */
18, /* t1 */
19, /* t2 */
};
-s4 nregdescfloat[] = {
+int32_t nregdescfloat[] = {
/*ftmp3, fa0/v0, fa1, fa2, fa3, fa4, fa5, fa6, */
REG_RES, REG_ARG, REG_ARG, REG_ARG, REG_ARG, REG_ARG, REG_ARG, REG_ARG,
};
-const s4 abi_registers_float_argument[] = {
+const int32_t abi_registers_float_argument[] = {
1, /* fa0 */
2, /* fa1 */
3, /* fa2 */
8, /* fa7 */
};
-const s4 abi_registers_float_saved[] = {
+const int32_t abi_registers_float_saved[] = {
14, /* fs0 */
15, /* fs1 */
24, /* fs2 */
31, /* fs9 */
};
-const s4 abi_registers_float_temporary[] = {
+const int32_t abi_registers_float_temporary[] = {
9, /* ft0 */
10, /* ft1 */
11, /* ft2 */
void md_param_alloc(methoddesc *md)
{
paramdesc *pd;
- s4 i;
- s4 iarg;
- s4 farg;
- s4 stacksize;
+ int32_t i;
+ int32_t iarg;
+ int32_t farg;
+ int32_t stacksize;
/* set default values */
case TYPE_LNG:
if (iarg < INT_ARG_CNT - 1) {
- _ALIGN(iarg);
+ ALIGN_2(iarg);
pd->inmemory = false;
pd->regoff =
PACK_REGS(abi_registers_integer_argument[iarg + 1],
iarg += 2;
}
else {
- _ALIGN(stacksize);
+ ALIGN_2(stacksize);
pd->inmemory = true;
pd->regoff = stacksize * 4;
iarg = INT_ARG_CNT;
farg++;
}
else {
- _ALIGN(stacksize);
+ ALIGN_2(stacksize);
pd->inmemory = true;
pd->regoff = stacksize * 4;
stacksize += 2;
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
- Contact: cacao@cacaojvm.org
-
- Authors: Christian Thalinger
-
- Changes:
-
- $Id: md-abi.h 7713 2007-04-15 21:49:48Z twisti $
+ $Id: md-abi.h 8191 2007-07-08 15:15:53Z twisti $
*/
#define FLT_TMP_CNT 11 /* number of float temporary registers */
#define FLT_RES_CNT 3 /* number of float reserved registers */
-#define TRACE_ARGS_NUM 8
+#define TRACE_ARGS_NUM 4
/* packed register defines ****************************************************/
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
- $Id: md-os.c 8178 2007-07-05 11:13:20Z michi $
+ $Id: md-os.c 8243 2007-07-31 08:57:54Z michi $
*/
ptrint addr;
ptrint val;
s4 type;
- java_objectheader *o;
+ java_objectheader *e;
_uc = (ucontext_t *) _p;
vm_abort("md_signal_handler_sigsegv: faulting address is not NULL: addr=%p", addr);
}
+ /* create stackframeinfo */
+
+ stacktrace_create_extern_stackframeinfo(&sfi, pv, sp, ra, xpc);
+
/* generate appropriate exception */
- o = exceptions_new_hardware_exception(pv, sp, ra, xpc, type, val, &sfi);
+ e = exceptions_new_hardware_exception(xpc, type, val);
- /* set registers */
+ /* remove stackframeinfo */
- _gregs[REG_ITMP1_XPTR] = (ptrint) o;
- _gregs[REG_ITMP2_XPC] = (ptrint) xpc;
- _gregs[PT_NIP] = (ptrint) asm_handle_exception;
+ stacktrace_remove_stackframeinfo(&sfi);
+
+ /* set registers (only if exception object ready) */
+
+ if (e != NULL) {
+ _gregs[REG_ITMP1_XPTR] = (ptrint) e;
+ _gregs[REG_ITMP2_XPC] = (ptrint) xpc;
+ _gregs[PT_NIP] = (ptrint) asm_handle_exception;
+ }
}
s4 s1;
ptrint val;
s4 type;
- java_objectheader *o;
+ java_objectheader *e;
_uc = (ucontext_t *) _p;
type = EXCEPTION_HARDWARE_ARRAYINDEXOUTOFBOUNDS;
val = _gregs[s1];
+ /* create stackframeinfo */
+
+ stacktrace_create_extern_stackframeinfo(&sfi, pv, sp, ra, xpc);
+
/* generate appropriate exception */
- o = exceptions_new_hardware_exception(pv, sp, ra, xpc, type, val, &sfi);
+ e = exceptions_new_hardware_exception(xpc, type, val);
+
+ /* remove stackframeinfo */
+
+ stacktrace_remove_stackframeinfo(&sfi);
/* set registers */
- _gregs[REG_ITMP1_XPTR] = (ptrint) o;
+ _gregs[REG_ITMP1_XPTR] = (ptrint) e;
_gregs[REG_ITMP2_XPC] = (ptrint) xpc;
_gregs[PT_NIP] = (ptrint) asm_handle_exception;
}
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
- $Id: patcher.c 7596 2007-03-28 21:05:53Z twisti $
+ $Id: patcher.c 8216 2007-07-19 13:51:21Z michi $
*/
#include "vm/initialize.h"
#include "vm/jit/asmpart.h"
-#include "vm/jit/patcher.h"
#include "vm/jit/md.h"
#include "vm/jit/methodheader.h"
+#include "vm/jit/patcher-common.h"
#include "vm/jit/stacktrace.h"
#include "vmcore/class.h"
#include "vmcore/references.h"
-/* patcher_wrapper *************************************************************
-
- Wrapper for all patchers. It also creates the stackframe info
- structure.
-
- If the return value of the patcher function is false, it gets the
- exception object, clears the exception pointer and returns the
- exception.
-
-*******************************************************************************/
-
-java_objectheader *patcher_wrapper(u1 *sp, u1 *pv, u1 *ra)
-{
- stackframeinfo sfi;
- u1 *xpc;
- java_objectheader *o;
- u4 mcode;
- functionptr f;
- bool result;
- java_objectheader *e;
-
- /* define the patcher function */
-
- bool (*patcher_function)(u1 *);
-
- assert(pv != NULL);
-
- /* get stuff from the stack */
-
- xpc = (u1 *) *((ptrint *) (sp + 5 * 4));
- o = (java_objectheader *) *((ptrint *) (sp + 4 * 4));
- f = (functionptr) *((ptrint *) (sp + 0 * 4));
-
- /* Correct RA is calculated in codegen.c and stored in the patcher
- stub stack. There's no need to adjust xpc. */
-
- /* store PV into the patcher function position */
-
- *((ptrint *) (sp + 0 * 4)) = (ptrint) pv;
-
- /* cast the passed function to a patcher function */
-
- patcher_function = (bool (*)(u1 *)) (ptrint) f;
-
- /* enter a monitor on the patching position */
-
- PATCHER_MONITORENTER;
-
- /* create the stackframeinfo */
-
- stacktrace_create_extern_stackframeinfo(&sfi, pv, sp + 8 * 4, ra, xpc);
-
- /* call the proper patcher function */
-
- result = (patcher_function)(sp);
-
- /* remove the stackframeinfo */
-
- stacktrace_remove_stackframeinfo(&sfi);
-
- /* check for return value and exit accordingly */
-
- if (result == false) {
- e = exceptions_get_and_clear_exception();
-
- PATCHER_MONITOREXIT;
-
- return e;
- }
-
- /* patch back original code */
-
- mcode = *((u4 *) (sp + 3 * 4));
-
- *((u4 *) xpc) = mcode;
-
- /* synchronize instruction cache */
-
- md_icacheflush(xpc, 4);
-
- PATCHER_MARK_PATCHED_MONITOREXIT;
-
- return NULL;
-}
+#define PATCH_BACK_ORIGINAL_MCODE \
+ *((u4 *) pr->mpc) = (u4) pr->mcode; \
+ md_icacheflush((u1 *) pr->mpc, 4);
/* patcher_initialize_class ****************************************************
*******************************************************************************/
-bool patcher_initialize_class(u1 *sp)
+bool patcher_initialize_class(patchref_t *pr)
{
classinfo *c;
/* get stuff from the stack */
- c = (classinfo *) *((ptrint *) (sp + 2 * 4));
+ c = (classinfo *) pr->ref;
/* check if the class is initialized */
if (!initialize_class(c))
return false;
+ PATCH_BACK_ORIGINAL_MCODE;
+
return true;
}
*******************************************************************************/
#ifdef ENABLE_VERIFIER
-bool patcher_resolve_class(u1 *sp)
+bool patcher_resolve_class(patchref_t *pr)
{
unresolved_class *uc;
/* get stuff from the stack */
- uc = (unresolved_class *) *((ptrint *) (sp + 2 * 4));
+ uc = (unresolved_class *) pr->ref;
/* resolve the class and check subtype constraints */
if (!resolve_class_eager_no_access_check(uc))
return false;
+ PATCH_BACK_ORIGINAL_MCODE;
+
return true;
}
#endif /* ENABLE_VERIFIER */
*******************************************************************************/
-bool patcher_resolve_classref_to_classinfo(u1 *sp)
+bool patcher_resolve_classref_to_classinfo(patchref_t *pr)
{
constant_classref *cr;
- s4 disp;
- u1 *pv;
+ u1 *datap;
classinfo *c;
/* get stuff from the stack */
- cr = (constant_classref *) *((ptrint *) (sp + 2 * 4));
- disp = *((s4 *) (sp + 1 * 4));
- pv = (u1 *) *((ptrint *) (sp + 0 * 4));
+ cr = (constant_classref *) pr->ref;
+ datap = (u1 *) pr->datap;
/* get the classinfo */
if (!(c = resolve_classref_eager(cr)))
return false;
+ PATCH_BACK_ORIGINAL_MCODE;
+
/* patch the classinfo pointer */
- *((ptrint *) (pv + disp)) = (ptrint) c;
+ *((ptrint *) datap) = (ptrint) c;
/* synchronize data cache */
- md_dcacheflush(pv + disp, SIZEOF_VOID_P);
+ md_dcacheflush(datap, SIZEOF_VOID_P);
return true;
}
*******************************************************************************/
-bool patcher_resolve_classref_to_vftbl(u1 *sp)
+bool patcher_resolve_classref_to_vftbl(patchref_t *pr)
{
constant_classref *cr;
- s4 disp;
- u1 *pv;
+ u1 *datap;
classinfo *c;
/* get stuff from the stack */
- cr = (constant_classref *) *((ptrint *) (sp + 2 * 4));
- disp = *((s4 *) (sp + 1 * 4));
- pv = (u1 *) *((ptrint *) (sp + 0 * 4));
+ cr = (constant_classref *) pr->ref;
+ datap = (u1 *) pr->datap;
/* get the fieldinfo */
if (!(c = resolve_classref_eager(cr)))
return false;
+ PATCH_BACK_ORIGINAL_MCODE;
+
/* patch super class' vftbl */
- *((ptrint *) (pv + disp)) = (ptrint) c->vftbl;
+ *((ptrint *) datap) = (ptrint) c->vftbl;
/* synchronize data cache */
- md_dcacheflush(pv + disp, SIZEOF_VOID_P);
+ md_dcacheflush(datap, SIZEOF_VOID_P);
return true;
}
*******************************************************************************/
-bool patcher_resolve_classref_to_flags(u1 *sp)
+bool patcher_resolve_classref_to_flags(patchref_t *pr)
{
constant_classref *cr;
- s4 disp;
- u1 *pv;
+ u1 *datap;
classinfo *c;
/* get stuff from the stack */
- cr = (constant_classref *) *((ptrint *) (sp + 2 * 4));
- disp = *((s4 *) (sp + 1 * 4));
- pv = (u1 *) *((ptrint *) (sp + 0 * 4));
+ cr = (constant_classref *) pr->ref;
+ datap = (u1 *) pr->datap;
/* get the fieldinfo */
if (!(c = resolve_classref_eager(cr)))
return false;
+ PATCH_BACK_ORIGINAL_MCODE;
+
/* patch class flags */
- *((s4 *) (pv + disp)) = (s4) c->flags;
+ *((s4 *) datap) = (s4) c->flags;
/* synchronize data cache */
- md_dcacheflush(pv + disp, SIZEOF_VOID_P);
+ md_dcacheflush(datap, SIZEOF_VOID_P);
return true;
}
*******************************************************************************/
#if !defined(WITH_STATIC_CLASSPATH)
-bool patcher_resolve_native_function(u1 *sp)
+bool patcher_resolve_native_function(patchref_t *pr)
{
methodinfo *m;
- s4 disp;
- u1 *pv;
+ u1 *datap;
functionptr f;
/* get stuff from the stack */
- m = (methodinfo *) *((ptrint *) (sp + 2 * 4));
- disp = *((s4 *) (sp + 1 * 4));
- pv = (u1 *) *((ptrint *) (sp + 0 * 4));
+ m = (methodinfo *) pr->ref;
+ datap = (u1 *) pr->datap;
/* resolve native function */
if (!(f = native_resolve_function(m)))
return false;
+ PATCH_BACK_ORIGINAL_MCODE;
+
/* patch native function pointer */
- *((ptrint *) (pv + disp)) = (ptrint) f;
+ *((ptrint *) datap) = (ptrint) f;
/* synchronize data cache */
- md_dcacheflush(pv + disp, SIZEOF_VOID_P);
+ md_dcacheflush(datap, SIZEOF_VOID_P);
return true;
}
*******************************************************************************/
-bool patcher_get_putstatic(u1 *sp)
+bool patcher_get_putstatic(patchref_t *pr)
{
u1 *ra;
- u4 mcode;
unresolved_field *uf;
- s4 disp;
- u1 *pv;
+ u1 *datap;
fieldinfo *fi;
/* get stuff from the stack */
- ra = (u1 *) *((ptrint *) (sp + 5 * 4));
- mcode = *((u4 *) (sp + 3 * 4));
- uf = (unresolved_field *) *((ptrint *) (sp + 2 * 4));
- disp = *((s4 *) (sp + 1 * 4));
- pv = (u1 *) *((ptrint *) (sp + 0 * 4));
+ ra = (u1 *) pr->mpc;
+ uf = (unresolved_field *) pr->ref;
+ datap = (u1 *) pr->datap;
/* get the fieldinfo */
if (!initialize_class(fi->class))
return false;
+ PATCH_BACK_ORIGINAL_MCODE;
+
/* patch the field value's address */
- *((ptrint *) (pv + disp)) = (ptrint) &(fi->value);
+ *((ptrint *) datap) = (ptrint) &(fi->value);
/* synchronize data cache */
- md_dcacheflush(pv + disp, SIZEOF_VOID_P);
+ md_dcacheflush(datap, SIZEOF_VOID_P);
return true;
}
*******************************************************************************/
-bool patcher_get_putfield(u1 *sp)
+bool patcher_get_putfield(patchref_t *pr)
{
u1 *ra;
unresolved_field *uf;
- u1 *pv;
fieldinfo *fi;
s2 disp;
- ra = (u1 *) *((ptrint *) (sp + 5 * 4));
- uf = (unresolved_field *) *((ptrint *) (sp + 2 * 4));
- pv = (u1 *) *((ptrint *) (sp + 1 * 4));
+ ra = (u1 *) pr->mpc;
+ uf = (unresolved_field *) pr->ref;
/* get the fieldinfo */
if (!(fi = resolve_field_eager(uf)))
return false;
+ PATCH_BACK_ORIGINAL_MCODE;
+
/* if we show NOPs, we have to skip them */
- if (opt_shownops) {
- /* patch the field's offset */
-
- if (IS_LNG_TYPE(fi->type)) {
- /* If the field has type long, we have to patch two
- instructions. But we have to check which instruction
- is first. We do that with the offset of the first
- instruction. */
-
- disp = *((u4 *) (ra + 1 * 4));
-
- if (disp == 4) {
- *((u4 *) (ra + 1 * 4)) |= (s2) ((fi->offset + 4) & 0x0000ffff);
- *((u4 *) (ra + 2 * 4)) |= (s2) ((fi->offset + 0) & 0x0000ffff);
- }
- else {
- *((u4 *) (ra + 1 * 4)) |= (s2) ((fi->offset + 0) & 0x0000ffff);
- *((u4 *) (ra + 2 * 4)) |= (s2) ((fi->offset + 4) & 0x0000ffff);
- }
+ if (opt_shownops)
+ ra = ra + 1 * 4;
+
+ /* patch the field's offset */
+
+ if (IS_LNG_TYPE(fi->type)) {
+ /* If the field has type long, we have to patch two
+ instructions. But we have to check which instruction
+ is first. We do that with the offset of the first
+ instruction. */
+
+ disp = *((u4 *) (ra + 0 * 4));
+
+ if (disp == 4) {
+ *((u4 *) (ra + 0 * 4)) |= (s2) ((fi->offset + 4) & 0x0000ffff);
+ *((u4 *) (ra + 1 * 4)) |= (s2) ((fi->offset + 0) & 0x0000ffff);
}
- else
- *((u4 *) (ra + 1 * 4)) |= (s2) (fi->offset & 0x0000ffff);
- }
- else {
- if (IS_LNG_TYPE(fi->type)) {
-
- disp = *((u4 *) (sp + 3 * 4));
-
- /* We patch the first instruction in the patcher stub
- stack and the second in the code. The first
- instruction is patched back later in
- patcher_wrapper. */
-
- if (disp == 4) {
- *((u4 *) (sp + 3 * 4)) |= (s2) ((fi->offset + 4) & 0x0000ffff);
- *((u4 *) (ra + 1 * 4)) |= (s2) ((fi->offset + 0) & 0x0000ffff);
- }
- else {
- *((u4 *) (sp + 3 * 4)) |= (s2) ((fi->offset + 0) & 0x0000ffff);
- *((u4 *) (ra + 1 * 4)) |= (s2) ((fi->offset + 4) & 0x0000ffff);
- }
+ else {
+ *((u4 *) (ra + 0 * 4)) |= (s2) ((fi->offset + 0) & 0x0000ffff);
+ *((u4 *) (ra + 1 * 4)) |= (s2) ((fi->offset + 4) & 0x0000ffff);
}
- else
- *((u4 *) (sp + 3 * 4)) |= (s2) (fi->offset & 0x0000ffff);
}
+ else
+ *((u4 *) (ra + 0 * 4)) |= (s2) (fi->offset & 0x0000ffff);
/* synchronize instruction cache */
- md_icacheflush(ra + 1 * 4, 2 * 4);
+ md_icacheflush(ra + 0 * 4, 2 * 4);
return true;
}
******************************************************************************/
-bool patcher_invokestatic_special(u1 *sp)
+bool patcher_invokestatic_special(patchref_t *pr)
{
unresolved_method *um;
- s4 disp;
- u1 *pv;
+ u1 *datap;
methodinfo *m;
/* get stuff from the stack */
- um = (unresolved_method *) *((ptrint *) (sp + 2 * 4));
- disp = *((s4 *) (sp + 1 * 4));
- pv = (u1 *) *((ptrint *) (sp + 0 * 4));
+ um = (unresolved_method *) pr->ref;
+ datap = (u1 *) pr->datap;
/* get the fieldinfo */
if (!(m = resolve_method_eager(um)))
return false;
+ PATCH_BACK_ORIGINAL_MCODE;
+
/* patch stubroutine */
- *((ptrint *) (pv + disp)) = (ptrint) m->stubroutine;
+ *((ptrint *) datap) = (ptrint) m->stubroutine;
/* synchronize data cache */
- md_dcacheflush(pv + disp, SIZEOF_VOID_P);
+ md_dcacheflush(datap, SIZEOF_VOID_P);
return true;
}
*******************************************************************************/
-bool patcher_invokevirtual(u1 *sp)
+bool patcher_invokevirtual(patchref_t *pr)
{
u1 *ra;
unresolved_method *um;
/* get stuff from the stack */
- ra = (u1 *) *((ptrint *) (sp + 5 * 4));
- um = (unresolved_method *) *((ptrint *) (sp + 2 * 4));
+ ra = (u1 *) pr->mpc;
+ um = (unresolved_method *) pr->ref;
/* get the fieldinfo */
if (!(m = resolve_method_eager(um)))
return false;
+ PATCH_BACK_ORIGINAL_MCODE;
+
/* if we show NOPs, we have to skip them */
if (opt_shownops)
*******************************************************************************/
-bool patcher_invokeinterface(u1 *sp)
+bool patcher_invokeinterface(patchref_t *pr)
{
u1 *ra;
unresolved_method *um;
/* get stuff from the stack */
- ra = (u1 *) *((ptrint *) (sp + 5 * 4));
- um = (unresolved_method *) *((ptrint *) (sp + 2 * 4));
+ ra = (u1 *) pr->mpc;
+ um = (unresolved_method *) pr->ref;
/* get the fieldinfo */
if (!(m = resolve_method_eager(um)))
return false;
+ PATCH_BACK_ORIGINAL_MCODE;
+
/* if we show NOPs, we have to skip them */
if (opt_shownops)
*******************************************************************************/
-bool patcher_checkcast_interface(u1 *sp)
+bool patcher_checkcast_interface(patchref_t *pr)
{
u1 *ra;
constant_classref *cr;
/* get stuff from the stack */
- ra = (u1 *) *((ptrint *) (sp + 5 * 4));
- cr = (constant_classref *) *((ptrint *) (sp + 2 * 4));
+ ra = (u1 *) pr->mpc;
+ cr = (constant_classref *) pr->ref;
/* get the fieldinfo */
if (!(c = resolve_classref_eager(cr)))
return false;
+ PATCH_BACK_ORIGINAL_MCODE;
+
/* if we show NOPs, we have to skip them */
if (opt_shownops)
*******************************************************************************/
-bool patcher_instanceof_interface(u1 *sp)
+bool patcher_instanceof_interface(patchref_t *pr)
{
u1 *ra;
constant_classref *cr;
/* get stuff from the stack */
- ra = (u1 *) *((ptrint *) (sp + 5 * 4));
- cr = (constant_classref *) *((ptrint *) (sp + 2 * 4));
+ ra = (u1 *) pr->mpc;
+ cr = (constant_classref *) pr->ref;
/* get the fieldinfo */
if (!(c = resolve_classref_eager(cr)))
return false;
+ PATCH_BACK_ORIGINAL_MCODE;
+
/* if we show NOPs, we have to skip them */
if (opt_shownops)
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
- $Id: codegen.c 8123 2007-06-20 23:50:55Z michi $
+ $Id: codegen.c 8211 2007-07-18 19:52:23Z michi $
*/
/* generate stubs */
emit_patcher_stubs(jd);
- REPLACEMENT_EMIT_STUBS(jd);
/* everything's ok */
}
-/* emit_replacement_stubs ******************************************************
-
- Generates the code for the replacement stubs.
-
-*******************************************************************************/
-
-#if defined(ENABLE_REPLACEMENT)
-void emit_replacement_stubs(jitdata *jd)
-{
- codegendata *cd;
- codeinfo *code;
- rplpoint *replacementpoint;
- s4 disp;
- s4 i;
-#if !defined(NDEBUG)
- u1 *savedmcodeptr;
-#endif
-
- /* get required compiler data */
-
- cd = jd->cd;
- code = jd->code;
-
- replacementpoint = jd->code->rplpoints;
-
- for (i = 0; i < code->rplpointcount; ++i, ++replacementpoint) {
- /* do not generate stubs for non-trappable points */
-
- if (replacementpoint->flags & RPLPOINT_FLAG_NOTRAP)
- continue;
-
-
- /* check code segment size */
-
- MCODECHECK(200);
-
-#if !defined(NDEBUG)
- savedmcodeptr = cd->mcodeptr;
-#endif
- /* create stack frame - keep 16-byte aligned */
-
- M_AADD_IMM(REG_SP, -4 * 8, REG_SP);
-
- /* push address of `rplpoint` struct */
-
- disp = dseg_add_address(cd, replacementpoint);
- M_ALD(REG_ITMP3, REG_PV, disp);
- M_AST_INTERN(REG_ITMP3, REG_SP, 0 * 8);
-
- /* jump to replacement function */
-
- disp = dseg_add_functionptr(cd, asm_replacement_out);
- M_ALD(REG_ITMP3, REG_PV, disp);
- M_MTCTR(REG_ITMP3);
- M_RTS;
-
- assert((cd->mcodeptr - savedmcodeptr) == 4*REPLACEMENT_STUB_SIZE);
-
-#if 0
- /* note start of stub code */
-
- replacementpoint->outcode = (u1 *) (cd->mcodeptr - cd->mcodebase);
-
- /* make machine code for patching */
-
- savedmcodeptr = cd->mcodeptr;
- cd->mcodeptr = (u1 *) &(replacementpoint->mcode) + 1 /* big-endian */;
-
- disp = (ptrint)((s4*)replacementpoint->outcode - (s4*)replacementpoint->pc) - 1;
- M_BR(disp);
-
- cd->mcodeptr = savedmcodeptr;
-
- /* create stack frame - keep 16-byte aligned */
-
- M_AADD_IMM(REG_SP, -4 * 4, REG_SP);
-
- /* push address of `rplpoint` struct */
-
- disp = dseg_add_unique_address(cd, replacementpoint);
- M_ALD(REG_ITMP3, REG_PV, disp);
- M_AST_INTERN(REG_ITMP3, REG_SP, 0 * 4);
-
- /* jump to replacement function */
-
- disp = dseg_add_functionptr(cd, asm_replacement_out);
- M_ALD(REG_ITMP3, REG_PV, disp);
- M_MTCTR(REG_ITMP3);
- M_RTS;
-#endif
- }
-}
-#endif /* define(ENABLE_REPLACEMENT) */
-
/*
* 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
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
- $Id: md-os.c 8178 2007-07-05 11:13:20Z michi $
+ $Id: md-os.c 8243 2007-07-31 08:57:54Z michi $
*/
addr = _mc->gp_regs[s1];
type = (s4) addr;
}
- e = exceptions_new_hardware_exception(pv, sp, ra, xpc, type, val, &sfi);
+
+ /* create stackframeinfo */
+
+ stacktrace_create_extern_stackframeinfo(&sfi, pv, sp, ra, xpc);
+
+ /* generate appropriate exception */
+
+ e = exceptions_new_hardware_exception(xpc, type, val);
+
+ /* remove stackframeinfo */
+
+ stacktrace_remove_stackframeinfo(&sfi);
_mc->gp_regs[REG_ITMP1] = (ptrint) e;
_mc->gp_regs[REG_ITMP2_XPC] = (ptrint) xpc;
#define REPLACE_RA_LINKAGE_AREA
#define REPLACE_LEAFMETHODS_RA_REGISTER
#define REPLACE_REG_RA REG_ITMP3 /* the execution state has the LR in itmp3 */
+/* s390 */
+#elif defined(__S390__)
+#define REPLACE_RA_TOP_OF_FRAME
+#define REPLACE_REG_RA REG_ITMP3
#endif
savedmcode -= REPLACEMENT_PATCH_SIZE;
-#if (defined(__I386__) || defined(__X86_64__) || defined(__ALPHA__) || defined(__POWERPC__) || defined(__MIPS__)) && defined(ENABLE_JIT)
+#if (defined(__I386__) || defined(__X86_64__) || defined(__ALPHA__) || defined(__POWERPC__) || defined(__MIPS__) || defined(__S390__)) && defined(ENABLE_JIT)
md_patch_replacement_point(code, index, rp, savedmcode);
#endif
rp->flags |= RPLPOINT_FLAG_ACTIVE;
DOLOG( printf("deactivate replacement point:\n");
replace_replacement_point_println(rp, 1); fflush(stdout); );
-#if (defined(__I386__) || defined(__X86_64__) || defined(__ALPHA__) || defined(__POWERPC__) || defined(__MIPS__)) && defined(ENABLE_JIT)
+#if (defined(__I386__) || defined(__X86_64__) || defined(__ALPHA__) || defined(__POWERPC__) || defined(__MIPS__) || defined(__S390__)) && defined(ENABLE_JIT)
md_patch_replacement_point(code, -1, rp, savedmcode);
#endif
}
+/* replace_me_wrapper **********************************************************
+
+ TODO: Document me!
+
+*******************************************************************************/
+
+bool replace_me_wrapper(u1 *pc)
+{
+ codeinfo *code;
+ rplpoint *rp;
+ executionstate_t es;
+
+ /* search the codeinfo for the given PC */
+
+ code = code_find_codeinfo_for_pc(pc);
+ assert(code);
+
+ /* search for a replacement point at the given PC */
+
+#if 0
+ rp = replace_find_replacement_point_for_pc(code, pc);
+ assert(rp == NULL || rp->pc == pc);
+#else
+ {
+ int i;
+ rplpoint *rp2;
+ rp = NULL;
+ for (i=0,rp2=code->rplpoints; i<code->rplpointcount; i++,rp2++) {
+ if (rp2->pc == pc)
+ rp = rp2;
+ }
+ }
+#endif
+
+ /* check if the replacement point is active */
+
+ if (rp != NULL && (rp->flags & RPLPOINT_FLAG_ACTIVE)) {
+
+ /*md_replace_executionstate_read(&es, context);*/
+
+ replace_me(rp, &es);
+
+ return true;
+ }
+ else
+ return false;
+}
+
+
/* replace_me ******************************************************************
This function is called by asm_replacement_out when a thread reaches
/* call the assembler code for the last phase of replacement */
-#if (defined(__I386__) || defined(__X86_64__) || defined(__ALPHA__) || defined(__POWERPC__) || defined(__MIPS__)) && defined(ENABLE_JIT)
+#if (defined(__I386__) || defined(__X86_64__) || defined(__ALPHA__) || defined(__POWERPC__) || defined(__MIPS__) || defined(__S390__)) && defined(ENABLE_JIT)
asm_replacement_in(&(safestack->es), safestack);
#endif
#define REPLACEMENT_POINT_RETURN(cd, iptr)
#define REPLACEMENT_POINT_INVOKE(cd, iptr)
#define REPLACEMENT_POINT_INVOKE_RETURN(cd, iptr)
-#define REPLACEMENT_EMIT_STUBS(jd)
#else /* defined(ENABLE_REPLACEMENT) */
cd->replacementpoint[-1].callsize = (cd->mcodeptr - cd->mcodebase)\
- (ptrint) cd->replacementpoint[-1].pc;
-#define REPLACEMENT_EMIT_STUBS(jd) \
- emit_replacement_stubs(jd);
/*** prototypes ********************************************************/
void replace_activate_replacement_points(codeinfo *code, bool mappable);
void replace_deactivate_replacement_points(codeinfo *code);
+bool replace_me_wrapper(u1 *pc);
+
void replace_me(rplpoint *rp,executionstate_t *es);
#if !defined(NDEBUG)
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
- $Id: arch.h 7839 2007-04-29 22:46:56Z pm $
+ $Id: arch.h 8240 2007-07-29 20:36:47Z pm $
*/
#define SUPPORT_HARDWARE_DIVIDE_BY_ZERO 1
+/* replacement ****************************************************************/
+
+#define REPLACEMENT_PATCH_SIZE 5 /* bytes */
+#define REPLACEMENT_STUB_SIZE (4+(4+4+4+4)+4+(4+4+4+4)+2) /* bytes */
+
/* misc ***********************************************************************/
#define HAS_4BYTE_STACKSLOT
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
- $Id: codegen.c 8152 2007-06-27 20:37:45Z pm $
+ $Id: codegen.c 8240 2007-07-29 20:36:47Z pm $
*/
ICONST(REG_ITMP2, 1);
N_AL(REG_ITMP2, OFFSET(codeinfo, frequency), RN, REG_ITMP1);
M_IST(REG_ITMP2, REG_ITMP1, OFFSET(codeinfo, frequency));
+
+ PROFILE_CYCLE_START;
}
#endif
}
/* end of header generation */
-#if 0
- replacementpoint = jd->code->rplpoints;
-#endif
+
+ /* create replacement points */
+
+ REPLACEMENT_POINTS_INIT(cd, jd);
/* walk through all basic blocks */
/* handle replacement points */
-#if 0
- if (bptr->bitflags & BBFLAG_REPLACEMENT) {
- replacementpoint->pc = (u1*)(ptrint)bptr->mpc; /* will be resolved later */
-
- replacementpoint++;
-
- assert(cd->lastmcodeptr <= cd->mcodeptr);
- cd->lastmcodeptr = cd->mcodeptr + 5; /* 5 byte jmp patch */
- }
-#endif
+ REPLACEMENT_POINT_BLOCK_START(cd, bptr);
/* copy interface registers to their destination */
len = bptr->indepth;
MCODECHECK(512);
+#if defined(ENABLE_PROFILING)
/* generate basicblock profiling code */
if (JITDATA_HAS_FLAG_INSTRUMENT(jd)) {
/* count frequency */
- M_MOV_IMM(code->bbfrequency, REG_ITMP3);
- M_IINC_MEMBASE(REG_ITMP3, bptr->nr * 4);
+ M_ALD_DSEG(REG_ITMP1, CodeinfoPointer);
+ M_ALD(REG_ITMP1, REG_ITMP1, OFFSET(codeinfo, bbfrequency));
+ ICONST(REG_ITMP2, 1);
+ N_AL(REG_ITMP2, bptr->nr * 4, RN, REG_ITMP1);
+ M_IST(REG_ITMP2, REG_ITMP1, bptr->nr * 4);
/* if this is an exception handler, start profiling again */
if (bptr->type == BBTYPE_EXH)
PROFILE_CYCLE_START;
}
+#endif
#if defined(ENABLE_LSRA)
if (opt_lsra) {
case ICMD_NOP: /* ... ==> ... */
case ICMD_POP: /* ..., value ==> ... */
case ICMD_POP2: /* ..., value, value ==> ... */
- case ICMD_INLINE_START: /* internal ICMDs */
+ break;
+
+ case ICMD_INLINE_START:
+
+ REPLACEMENT_POINT_INLINE_START(cd, iptr);
+ break;
+
+ case ICMD_INLINE_BODY:
+
+ REPLACEMENT_POINT_INLINE_BODY(cd, iptr);
+ dseg_addlinenumber_inline_start(cd, iptr);
+ dseg_addlinenumber(cd, iptr->line);
+ break;
+
case ICMD_INLINE_END:
+
+ dseg_addlinenumber_inline_end(cd, iptr);
+ dseg_addlinenumber(cd, iptr->line);
break;
case ICMD_CHECKNULL: /* ..., objectref ==> ..., objectref */
fieldtype = fi->type;
disp = dseg_add_address(cd, &(fi->value));
- if (!CLASS_IS_OR_ALMOST_INITIALIZED(fi->class))
- codegen_addpatchref(cd, PATCHER_clinit,
- fi->class, disp);
+ if (!CLASS_IS_OR_ALMOST_INITIALIZED(fi->class)) {
+ PROFILE_CYCLE_STOP;
+ codegen_addpatchref(cd, PATCHER_clinit, fi->class, disp);
+ PROFILE_CYCLE_START;
+ }
}
M_ALD_DSEG(REG_ITMP1, disp);
case ICMD_ATHROW: /* ..., objectref ==> ... (, objectref) */
+ /* PROFILE_CYCLE_STOP; */
+
s1 = emit_load_s1(jd, iptr, REG_ITMP1);
M_INTMOVE(s1, REG_ITMP1_XPTR);
- PROFILE_CYCLE_STOP;
-
#ifdef ENABLE_VERIFIER
if (INSTRUCTION_IS_UNRESOLVED(iptr)) {
uc = iptr->sx.s23.s2.uc;
if (INSTRUCTION_IS_UNRESOLVED(iptr)) {
unresolved_class *uc = iptr->sx.s23.s2.uc;
+ PROFILE_CYCLE_STOP;
codegen_addpatchref(cd, PATCHER_athrow_areturn, uc, 0);
+ PROFILE_CYCLE_START;
}
#endif /* ENABLE_VERIFIER */
goto nowperformreturn;
if (cd->stackframesize)
M_AADD_IMM(cd->stackframesize * 4, REG_SP);
+ /* generate method profiling code */
+
+ PROFILE_CYCLE_STOP;
M_RET;
ALIGNCODENOP;
}
}
}
+ /* generate method profiling code */
+
+ PROFILE_CYCLE_STOP;
+
switch (iptr->opc) {
case ICMD_BUILTIN:
disp = dseg_add_functionptr(cd, bte->fp);
* and -0xFFF in index register (itmp1)
*/
- N_LHI(REG_ITMP1, -N_DISP_MAX);
-
if (lm == NULL) {
codegen_addpatchref(cd, PATCHER_invokeinterface, um, 0);
}
else {
s1 = OFFSET(vftbl_t, interfacetable[0]) -
- sizeof(methodptr*) * lm->class->index +
- N_DISP_MAX;
+ sizeof(methodptr*) * lm->class->index;
s2 = sizeof(methodptr) * (lm - lm->class->methods);
}
/* Implicit null-pointer check */
M_ALD(REG_METHODPTR, REG_A0, OFFSET(java_objectheader, vftbl));
- N_L(REG_METHODPTR, s1, REG_ITMP1, REG_METHODPTR);
+ N_LHI(REG_ITMP1, s1);
+ N_L(REG_METHODPTR, 0, REG_ITMP1, REG_METHODPTR);
M_ALD(REG_PV, REG_METHODPTR, s2);
break;
}
/* generate the actual call */
M_CALL(REG_PV);
- REPLACEMENT_POINT_INVOKE_RETURN(cd, iptr);
emit_restore_pv(cd);
-
+
/* post call finalization */
switch (iptr->opc) {
break;
}
+ /* generate method profiling code */
+
+ PROFILE_CYCLE_START;
+
+ /* store size of call code in replacement point */
+
+ REPLACEMENT_POINT_INVOKE_RETURN(cd, iptr);
+
/* store return value */
d = md->returntype.type;
/* generate stubs */
emit_patcher_stubs(jd);
-#if 0
- emit_replacement_stubs(jd);
+#if defined(ENABLE_REPLACEMENT)
+ REPLACEMENT_EMIT_STUBS(jd);
#endif
/* everything's ok */
(void) dseg_addlinenumbertablesize(cd);
(void) dseg_add_unique_s4(cd, 0); /* ExTableSize */
+ /* generate stub code */
+
+ N_AHI(REG_SP, -(cd->stackframesize * SIZEOF_VOID_P));
+ N_AHI(REG_PV, N_PV_OFFSET);
+
/* generate native method profiling code */
-#if 0
+
+#if defined(ENABLE_PROFILING)
if (JITDATA_HAS_FLAG_INSTRUMENT(jd)) {
/* count frequency */
-
- M_MOV_IMM(code, REG_ITMP3);
- M_IINC_MEMBASE(REG_ITMP3, OFFSET(codeinfo, frequency));
+ M_ALD_DSEG(REG_ITMP1, CodeinfoPointer);
+ ICONST(REG_ITMP2, 1);
+ N_AL(REG_ITMP2, OFFSET(codeinfo, frequency), RN, REG_ITMP1);
+ M_IST(REG_ITMP2, REG_ITMP1, OFFSET(codeinfo, frequency));
}
#endif
- /* generate stub code */
-
- N_AHI(REG_SP, -(cd->stackframesize * SIZEOF_VOID_P));
- N_AHI(REG_PV, N_PV_OFFSET);
-
/* save return address */
N_ST(R14, (cd->stackframesize - 1) * SIZEOF_VOID_P, RN, REG_SP);
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
- $Id: codegen.h 8123 2007-06-20 23:50:55Z michi $
+ $Id: codegen.h 8240 2007-07-29 20:36:47Z pm $
*/
#define M_DSUB(a, dest) N_SDBR(dest, a)
#define M_DADD(a, dest) N_ADBR(dest, a)
#define M_DDIV(a, dest) N_DDBR(dest, a)
-#define M_CVTFI(src, dst) N_CFEBR(dst, 4, src)
-#define M_CVTDI(src, dst) N_CFDBR(dst, 4, src)
+#define M_CVTFI(src, dst) N_CFEBR(dst, 5, src)
+#define M_CVTDI(src, dst) N_CFDBR(dst, 5, src)
#define M_IADD(a, dest) N_AR(dest, a)
#define M_AADD(a, dest) N_AR(dest, a)
#define M_ISUB(a, dest) N_SR(dest, a)
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
- $Id: emit.c 8123 2007-06-20 23:50:55Z michi $
+ $Id: emit.c 8240 2007-07-29 20:36:47Z pm $
*/
Generates the code for the replacement stubs.
*******************************************************************************/
-
+#if defined(ENABLE_REPLACEMENT)
void emit_replacement_stubs(jitdata *jd)
{
-#if 0
codegendata *cd;
codeinfo *code;
rplpoint *rplp;
s4 disp;
- s4 i;
+ s4 i, remain;
+ u1 *savedmcodeptr;
/* get required compiler data */
rplp = code->rplpoints;
+ /* store beginning of replacement stubs */
+
+ code->replacementstubs = (u1*) (cd->mcodeptr - cd->mcodebase);
+
for (i = 0; i < code->rplpointcount; ++i, ++rplp) {
+ /* do not generate stubs for non-trappable points */
+
+ if (rplp->flags & RPLPOINT_FLAG_NOTRAP)
+ continue;
+
/* check code segment size */
MCODECHECK(512);
- /* note start of stub code */
-
- rplp->outcode = (u1 *) (ptrint) (cd->mcodeptr - cd->mcodebase);
+#if !defined(NDEBUG)
+ savedmcodeptr = cd->mcodeptr;
+#endif
- /* make machine code for patching */
+ /* create stack frame - 8-byte aligned */
- disp = (ptrint) (rplp->outcode - rplp->pc) - 5;
+ M_ASUB_IMM(REG_SP, 2 * 4);
- rplp->mcode = 0xe9 | ((u8) disp << 8);
+ /* push address of `rplpoint` struct, will be used in asm_replacement_out */
- /* push address of `rplpoint` struct */
-
- M_MOV_IMM(rplp, REG_ITMP3);
- M_PUSH(REG_ITMP3);
+ disp = dseg_add_address(cd, rplp);
+ M_ALD_DSEG(REG_ITMP3, disp);
+ M_AST(REG_ITMP3, REG_SP, 0 * 4);
/* jump to replacement function */
- M_MOV_IMM(asm_replacement_out, REG_ITMP3);
- M_JMP(REG_ITMP3);
+ disp = dseg_add_functionptr(cd, asm_replacement_out);
+ M_ALD_DSEG(REG_ITMP3, disp);
+ M_JMP(RN, REG_ITMP3);
+
+ assert((cd->mcodeptr - savedmcodeptr) <= REPLACEMENT_STUB_SIZE);
+
+ /* pad with NOPs */
+
+ for (remain = REPLACEMENT_STUB_SIZE - (cd->mcodeptr - savedmcodeptr); remain > 0;) {
+ if (remain >= 4) {
+ M_NOP;
+ remain -= 4;
+ } else {
+ M_NOP2;
+ remain -= 2;
+ }
+ }
+
+ assert((cd->mcodeptr - savedmcodeptr) == REPLACEMENT_STUB_SIZE);
}
-#endif
}
-
+#endif
/* emit_verbosecall_enter ******************************************************
Changes: Edwin Steiner
- $Id: md.c 8178 2007-07-05 11:13:20Z michi $
+ $Id: md.c 8243 2007-07-31 08:57:54Z michi $
*/
switch (xpc[0]) {
case 0x58: /* L */
case 0x50: /* ST */
+ case 0x55: /* CL (array size check on NULL array) */
base = (xpc[2] >> 4) & 0xF;
if (base == 0) {
is_null = 1;
type = EXCEPTION_HARDWARE_NULLPOINTER;
val = 0;
- e = exceptions_new_hardware_exception(pv, sp, ra, xpc, type, val, &sfi);
+ /* create stackframeinfo */
+
+ stacktrace_create_extern_stackframeinfo(&sfi, pv, sp, ra, xpc);
+
+ /* generate appropriate exception */
+
+ e = exceptions_new_hardware_exception(xpc, type, val);
+
+ /* remove stackframeinfo */
+
+ stacktrace_remove_stackframeinfo(&sfi);
_mc->gregs[REG_ITMP2_XPC] = (ptrint) xpc;
_mc->gregs[REG_ITMP1_XPTR] = (ptrint) e;
sp = (u1 *)_mc->gregs[REG_SP];
val = (ptrint)_mc->gregs[reg];
- e = exceptions_new_hardware_exception(pv, sp, ra, xpc, type, val, &sfi);
+ /* create stackframeinfo */
+
+ stacktrace_create_extern_stackframeinfo(&sfi, pv, sp, ra, xpc);
+
+ /* generate appropriate exception */
+
+ e = exceptions_new_hardware_exception(xpc, type, val);
+
+ /* remove stackframeinfo */
+
+ stacktrace_remove_stackframeinfo(&sfi);
_mc->gregs[REG_ITMP1_XPTR] = (ptrint)e;
_mc->gregs[REG_ITMP2_XPC] = (ptrint)xpc;
type = EXCEPTION_HARDWARE_ARITHMETIC;
val = 0;
- e = exceptions_new_hardware_exception(pv, sp, ra, xpc, type, val, &sfi);
+ /* create stackframeinfo */
+
+ stacktrace_create_extern_stackframeinfo(&sfi, pv, sp, ra, xpc);
+
+ /* generate appropriate exception */
+
+ e = exceptions_new_hardware_exception(xpc, type, val);
+
+ /* remove stackframeinfo */
+
+ stacktrace_remove_stackframeinfo(&sfi);
_mc->gregs[REG_ITMP1_XPTR] = (ptrint)e;
_mc->gregs[REG_ITMP2_XPC] = (ptrint)xpc;
offset = *((u2 *)(ra + 2)) & 0xFFF;
+ /* return NULL if no mptr was specified (used for replacement) */
+
+ if (mptr == NULL)
+ return NULL;
+
/* add offset to method pointer */
pa = mptr + offset;
Patch the given replacement point.
*******************************************************************************/
-#if 0
-void md_patch_replacement_point(rplpoint *rp)
+#if defined(ENABLE_REPLACEMENT)
+void md_patch_replacement_point(codeinfo *code, s4 index, rplpoint *rp, u1 *savedmcode)
{
- u8 mcode;
-
- /* XXX this is probably unsafe! */
-
- /* save the current machine code */
- mcode = *(u8*)rp->pc;
-
- /* write spinning instruction */
- *(u2*)(rp->pc) = 0xebfe;
-
- /* write 5th byte */
- rp->pc[4] = (rp->mcode >> 32);
-
- /* write first word */
- *(u4*)(rp->pc) = (u4) rp->mcode;
-
- /* store saved mcode */
- rp->mcode = mcode;
-
-#if !defined(NDEBUG) && defined(ENABLE_DISASSEMBLER)
- {
- u1* u1ptr = rp->pc;
- DISASSINSTR(u1ptr);
- fflush(stdout);
- }
-#endif
-
- /* XXX if required asm_cacheflush(rp->pc,8); */
+ assert(0);
}
#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
Changes:
- $Id: patcher.c 8123 2007-06-20 23:50:55Z michi $
+ $Id: patcher.c 8195 2007-07-11 11:27:55Z pm $
GENERATED PATCHER BRANCH AFTER PATCH
/* get interfacetable index */
idx = (s4) (OFFSET(vftbl_t, interfacetable[0]) -
- sizeof(methodptr) * m->class->index) +
- N_DISP_MAX;
+ sizeof(methodptr) * m->class->index);
- ASSERT_VALID_DISP(idx);
+ ASSERT_VALID_IMM(idx);
/* get method offset */
/* patch them */
- *((s4 *)(ra + 4)) |= idx;
- *((s4 *)(ra + 4 + 4)) |= off;
+ *((s4 *)(ra + 4)) |= (u2)idx;
+ *((s4 *)(ra + 4 + 4 + 4)) |= off;
return true;
}
/* generate stubs */
emit_patcher_stubs(jd);
- REPLACEMENT_EMIT_STUBS(jd);
/* everything's ok */
}
-/* emit_replacement_stubs ******************************************************
-
- Generates the code for the replacement stubs.
-
-*******************************************************************************/
-
-#if defined(ENABLE_REPLACEMENT)
-void emit_replacement_stubs(jitdata *jd)
-{
- codegendata *cd;
- codeinfo *code;
- rplpoint *rplp;
- s4 disp;
- s4 i;
-#if !defined(NDEBUG)
- u1 *savedmcodeptr;
-#endif
-
- /* get required compiler data */
-
- cd = jd->cd;
- code = jd->code;
-
- rplp = code->rplpoints;
-
- /* store beginning of replacement stubs */
-
- code->replacementstubs = (u1*) (cd->mcodeptr - cd->mcodebase);
-
- for (i = 0; i < code->rplpointcount; ++i, ++rplp) {
- /* do not generate stubs for non-trappable points */
-
- if (rplp->flags & RPLPOINT_FLAG_NOTRAP)
- continue;
-
- M_LDX(0,0,0);
-
-/* this is just a stub rpl point for the GC */
-#if 0
-
- /* check code segment size */
-
- MCODECHECK(100);
-
-#if !defined(NDEBUG)
- savedmcodeptr = cd->mcodeptr;
-#endif
-
- /* create stack frame - 16-byte aligned */
-
- M_ASUB_IMM(REG_SP, 2 * 8, REG_SP);
-
- /* push address of `rplpoint` struct */
-
- disp = dseg_add_address(cd, rplp);
- M_ALD(REG_ITMP3, REG_PV_CALLEE, disp);
- M_AST(REG_ITMP3, REG_SP, JITSTACK + 0 * 8);
-
- /* jump to replacement function */
-
- disp = dseg_add_functionptr(cd, asm_replacement_out);
- M_ALD(REG_ITMP3, REG_PV_CALLEE, disp);
- M_JMP(REG_ZERO, REG_ITMP3, REG_ZERO);
-
- assert((cd->mcodeptr - savedmcodeptr) == 4*REPLACEMENT_STUB_SIZE);
-#endif
- }
-}
-#endif /* defined(ENABLE_REPLACEMENT) */
-
/* emit_verbosecall_enter ******************************************************
Generates the code for the call trace.
type = (s4) addr;
}
+ /* create stackframeinfo */
- e = exceptions_new_hardware_exception(pv, sp, ra, xpc, type, val, &sfi);
+ stacktrace_create_extern_stackframeinfo(&sfi, pv, sp, ra, xpc);
+
+ /* generate appropriate exception */
+
+ e = exceptions_new_hardware_exception(xpc, type, val);
+
+ /* remove stackframeinfo */
+
+ stacktrace_remove_stackframeinfo(&sfi);
/* set registers */
#include <ucontext.h>
/* work around name clash */
-#define REG_SP_OS REG_SP
#undef REG_SP
#include "vm/types.h"
if (rindex <= 15) {
/* register is in global or out range, available in context */
+ val = _mc->gregs[rindex + 3];
}
else {
assert(rindex <= 31);
/* register is local or in, need to fetch from regsave area on stack */
- /*
- window = ctx->sigc_regs.u_regs[REG_SP] + BIAS;
+
+ window = (s8 *) (_mc->gregs[REG_O6] + BIAS);
val = window[rindex - 16];
- */
+
}
return val;
stackframeinfo sfi;
ucontext_t *_uc;
mcontext_t *_mc;
- u4 instr;
ptrint addr;
u1 *pv;
u1 *sp;
u1 *ra;
u1 *xpc;
+ u4 mcode;
s4 d;
s4 s1;
s4 disp;
_mc = &_uc->uc_mcontext;
pv = (u1 *) md_get_reg_from_context(_mc, REG_PV_CALLEE);
-#if 0
- sp = (u1 *) md_get_reg_from_context(ctx, REG_SP);
- ra = (u1 *) md_get_reg_from_context(ctx, REG_RA_CALLEE); /* this is correct for leafs */
- xpc = (u1 *) ctx->sigc_regs.tpc;
+ sp = (u1 *) _mc->gregs[REG_O6];
+ ra = (u1 *) md_get_reg_from_context(_mc, REG_RA_CALLEE);
+ xpc = (u1 *) _mc->gregs[REG_PC];
+
/* get exception-throwing instruction */
/* flush register windows? */
- val = md_get_reg_from_context(ctx, d);
+ val = md_get_reg_from_context(_mc, d);
/* check for special-load */
/* This is a normal NPE: addr must be NULL and the NPE-type
define is 0. */
- addr = md_get_reg_from_context(ctx, s1);
+ addr = md_get_reg_from_context(_mc, s1);
type = (s4) addr;
}
-#endif
- e = exceptions_new_hardware_exception(pv, sp, ra, xpc, type, val, &sfi);
+ /* create stackframeinfo */
+
+ stacktrace_create_extern_stackframeinfo(&sfi, pv, sp, ra, xpc);
+
+ /* generate appropriate exception */
+
+ e = exceptions_new_hardware_exception(xpc, type, val);
+
+ /* remove stackframeinfo */
+
+ stacktrace_remove_stackframeinfo(&sfi);
/* set registers */
_mc->gregs[REG_G3] = (ptrint) xpc; /* REG_ITMP3_XPC */
_mc->gregs[REG_PC] = (ptrint) asm_handle_exception;
_mc->gregs[REG_nPC] = (ptrint) asm_handle_exception + 4;
-#if 0
- if (addr == 0) {
-
- pv = (u1 *) _mc->gregs[REG_G3];
- sp = (u1 *) (_uc->uc_stack.ss_sp);
- /*ra = (u1 *) _mc->mc_i7;*/ /* this is correct for leafs */
- ra = 0;
- xpc = (u1 *) _mc->gregs[REG_PC];
-
- _mc->gregs[REG_G4] =
- (ptrint) stacktrace_hardware_nullpointerexception(pv, sp, ra, xpc);
-
- _mc->gregs[REG_G5] = (ptrint) xpc;
- _mc->gregs[REG_PC] = (ptrint) asm_handle_exception;
-
- } else {
- addr += (long) ((instr << 16) >> 16);
-
- /*
- throw_cacao_exception_exit(string_java_lang_InternalError,
- "Segmentation fault: 0x%016lx at 0x%016lx\n",
- addr, _mc->mc_gregs[MC_PC]);
- */
- assert(0);
- }
-#endif
}
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
- $Id: asmpart.S 8123 2007-06-20 23:50:55Z michi $
+ $Id: asmpart.S 8197 2007-07-11 19:17:04Z twisti $
*/
je L_asm_vm_call_method_stack_copy_done
mov itmp1,itmp2
- and $0xfffffffffffffffe,itmp2 /* keep stack 16-byte aligned */
+ add $1,itmp2 /* keep stack 16-byte aligned */
+ and $0xfffffffffffffffe,itmp2
shl $3,itmp2 /* calculate stack size */
sub itmp2,sp /* create stack frame */
mov sp,itmp2 /* temporary stack pointer */
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
- $Id: codegen.c 8123 2007-06-20 23:50:55Z michi $
+ $Id: codegen.c 8245 2007-07-31 09:55:04Z michi $
*/
/* generate stubs */
emit_patcher_stubs(jd);
- REPLACEMENT_EMIT_STUBS(jd);
/* everything's ok */
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
- $Id: emit.c 8123 2007-06-20 23:50:55Z michi $
+ $Id: emit.c 8211 2007-07-18 19:52:23Z michi $
*/
}
-/* emit_replacement_stubs ******************************************************
-
- Generates the code for the replacement stubs.
-
-*******************************************************************************/
-
-#if defined(ENABLE_REPLACEMENT)
-void emit_replacement_stubs(jitdata *jd)
-{
- codegendata *cd;
- codeinfo *code;
- rplpoint *rplp;
- s4 i;
-#if !defined(NDEBUG)
- u1 *savedmcodeptr;
-#endif
-
- /* get required compiler data */
-
- cd = jd->cd;
- code = jd->code;
-
- rplp = code->rplpoints;
-
- /* store beginning of replacement stubs */
-
- code->replacementstubs = (u1*) (cd->mcodeptr - cd->mcodebase);
-
- for (i = 0; i < code->rplpointcount; ++i, ++rplp) {
- /* do not generate stubs for non-trappable points */
-
- if (rplp->flags & RPLPOINT_FLAG_NOTRAP)
- continue;
-
- /* check code segment size */
-
- MCODECHECK(512);
-
- /* note start of stub code */
-
-#if !defined(NDEBUG)
- savedmcodeptr = cd->mcodeptr;
-#endif
-
- /* push address of `rplpoint` struct */
-
- M_MOV_IMM(rplp, REG_ITMP3);
- M_PUSH(REG_ITMP3);
-
- /* jump to replacement function */
-
- M_MOV_IMM(asm_replacement_out, REG_ITMP3);
- M_PUSH(REG_ITMP3);
- M_RET;
-
- assert((cd->mcodeptr - savedmcodeptr) == REPLACEMENT_STUB_SIZE);
- }
-}
-#endif /* defined(ENABLE_REPLACEMENT) */
-
-
/* emit_verbosecall_enter ******************************************************
Generates the code for the call trace.
s4 disp;
s4 type;
ptrint val;
- java_objectheader *o;
+ java_objectheader *e;
_uc = (ucontext_t *) _p;
_mc = &_uc->uc_mcontext;
val = 0;
}
+ /* create stackframeinfo */
+
+ stacktrace_create_extern_stackframeinfo(&sfi, NULL, sp, ra, xpc);
+
/* generate appropriate exception */
- o = exceptions_new_hardware_exception(NULL, sp, ra, xpc, type, vali, &sfi);
+ e = exceptions_new_hardware_exception(xpc, type, val);
+
+ /* remove stackframeinfo */
+
+ stacktrace_remove_stackframeinfo(&sfi);
/* set registers */
- _mc->gregs[REG_RAX] = (ptrint) o;
+ _mc->gregs[REG_RAX] = (ptrint) e;
_mc->gregs[REG_R10] = (ptrint) xpc; /* REG_ITMP2_XPC */
_mc->gregs[REG_RIP] = (ptrint) asm_handle_exception;
}
u1 *xpc;
s4 type;
ptrint val;
- java_objectheader *o;
+ java_objectheader *e;
_uc = (ucontext_t *) _p;
_mc = &_uc->uc_mcontext;
type = EXCEPTION_HARDWARE_ARITHMETIC;
val = 0;
+ /* create stackframeinfo */
+
+ stacktrace_create_extern_stackframeinfo(&sfi, pv, sp, ra, xpc);
+
/* generate appropriate exception */
- o = exceptions_new_hardware_exception(pv, sp, ra, xpc, type, val, &sfi);
+ e = exceptions_new_hardware_exception(xpc, type, val);
+
+ /* remove stackframeinfo */
+
+ stacktrace_remove_stackframeinfo(&sfi);
/* set registers */
- _mc->gregs[REG_RAX] = (ptrint) o;
+ _mc->gregs[REG_RAX] = (ptrint) e;
_mc->gregs[REG_R10] = (ptrint) xpc; /* REG_ITMP2_XPC */
_mc->gregs[REG_RIP] = (ptrint) asm_handle_exception;
}
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
- $Id: jit_interface.h 7692 2007-04-12 14:47:24Z twisti $
+ $Id: jit_interface.h 8210 2007-07-18 12:51:00Z twisti $
*/
void jit_invalidate_code(methodinfo *m);
void md_param_alloc(methoddesc *md);
+void md_param_alloc_native(methoddesc *md);
/* stub for throwing AbstractMethodError's */
#if defined(ENABLE_JIT)
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
- $Id: properties.c 8132 2007-06-22 11:15:47Z twisti $
+ $Id: properties.c 8236 2007-07-27 10:18:17Z twisti $
*/
properties_add("java.vm.vendor", "CACAO Team");
properties_add("java.vm.name", "CACAO");
+# if defined(ENABLE_INTRP)
+ if (opt_intrp) {
+ /* XXX We don't support java.lang.Compiler */
+/* properties_add("java.compiler", "cacao.intrp"); */
+ properties_add("java.vm.info", "interpreted mode");
+ }
+ else
+# endif
+ {
+ /* XXX We don't support java.lang.Compiler */
+/* properties_add("java.compiler", "cacao.jit"); */
+ properties_add("java.vm.info", "JIT mode");
+ }
+
# if defined(WITH_CLASSPATH_GNU)
/* get properties from system */
# if defined(ENABLE_INTRP)
if (opt_intrp) {
- /* XXX We don't support java.lang.Compiler */
-/* properties_add("java.compiler", "cacao.intrp"); */
- properties_add("java.vm.info", "interpreted mode");
properties_add("gnu.java.compiler.name", "cacao.intrp");
}
else
# endif
{
- /* XXX We don't support java.lang.Compiler */
-/* properties_add("java.compiler", "cacao.jit"); */
- properties_add("java.vm.info", "JIT mode");
properties_add("gnu.java.compiler.name", "cacao.jit");
}
}
-/* properties_postinit *********************************************************
-
- Re-set some properties that may have changed during command-line
- parsing.
-
-*******************************************************************************/
-
-bool properties_postinit(void)
-{
-#if defined(ENABLE_JAVASE)
- properties_add("java.class.path", _Jv_classpath);
- properties_add("java.boot.class.path", _Jv_bootclasspath);
- properties_add("sun.boot.class.path", _Jv_bootclasspath);
-#endif
-
- /* everything's ok */
-
- return true;
-}
-
-
/* properties_add **************************************************************
Adds a property entry to the internal property list. If there's
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
- $Id: properties.h 7246 2007-01-29 18:49:05Z twisti $
+ $Id: properties.h 8236 2007-07-27 10:18:17Z twisti $
*/
/* function prototypes ********************************************************/
bool properties_init(void);
-bool properties_postinit(void);
void properties_add(char *key, char *value);
char *properties_get(char *key);
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
- $Id: string.c 8123 2007-06-20 23:50:55Z michi $
+ $Id: string.c 8230 2007-07-25 08:23:10Z twisti $
*/
assert(class_java_lang_String);
assert(class_java_lang_String->state & CLASS_LOADED);
- /* if we use eager loading, we have to check loaded String class */
-
- if (opt_eager)
- list_add_first(&unlinkedclasses, class_java_lang_String);
-
/* create new javastring */
js = NEW(java_lang_String);
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
- $Id: vm.c 8179 2007-07-05 11:21:08Z michi $
+ $Id: vm.c 8245 2007-07-31 09:55:04Z michi $
*/
OPT_VERBOSETC,
#endif
#endif /* defined(ENABLE_VERIFIER) */
- OPT_EAGER,
/* optimization options */
OPT_INLINE_DEBUG_END,
OPT_INLINE_DEBUG_MIN,
OPT_INLINE_DEBUG_MAX,
- OPT_INLINE_REPLACE_VERBOSE,
- OPT_INLINE_REPLACE_VERBOSE2,
#endif /* defined(ENABLE_INLINING_DEBUG) */
#endif /* defined(ENABLE_INLINING) */
{ "?", false, OPT_HELP },
{ "X", false, OPT_X },
{ "XX:", true, OPT_XX },
+ { "XX", false, OPT_XX },
{ "ea:", true, OPT_EA },
{ "da:", true, OPT_DA },
{ "log", true, OPT_LOG },
{ "c", true, OPT_CHECK },
{ "l", false, OPT_LOAD },
- { "eager", false, OPT_EAGER },
#if !defined(NDEBUG)
{ "all", false, OPT_ALL },
{ "ii", true, OPT_INLINE_DEBUG_MIN },
{ "im", true, OPT_INLINE_DEBUG_MAX },
{ "ie", true, OPT_INLINE_DEBUG_END },
- { "ir", false, OPT_INLINE_REPLACE_VERBOSE },
- { "iR", false, OPT_INLINE_REPLACE_VERBOSE2 },
#endif /* defined(ENABLE_INLINING_DEBUG) */
#if !defined(NDEBUG)
{ "il", false, OPT_INLINE_LOG },
puts(" -showversion print product version and continue");
puts(" -help, -? print this help message");
puts(" -X print help on non-standard Java options");
- puts(" -XX print help on CACAO options");
+ puts(" -XX print help on debugging options");
puts(" -ea[:<packagename>...|:<classname>]");
puts(" -enableassertions[:<packagename>...|:<classname>]");
puts(" enable assertions with specified granularity");
{
puts(" -v write state-information");
#if !defined(NDEBUG)
- puts(" -verbose[:call|jit|threads]");
+ puts(" -verbose[:jit|threads]");
puts(" enable specific verbose output");
puts(" -debug-color colored output for ANSI terms");
#endif
puts(" -oloop optimize array accesses in loops");
#endif
puts(" -l don't start the class after loading");
- puts(" -eager perform eager class loading and linking");
#if !defined(NDEBUG)
puts(" -all compile all methods, no execution");
puts(" -m compile only a specific method");
puts(" -ii <size> set minimum size for inlined result");
puts(" -im <size> set maximum size for inlined result");
puts(" -ie <number> stop inlining after the given number of roots");
- puts(" -ir log on-stack replacement");
- puts(" -iR log on-stack replacement, more verbose");
#endif /* defined(ENABLE_INLINING_DEBUG) */
#endif /* defined(ENABLE_INLINING) */
puts("This program is distributed in the hope that it will be useful, but");
puts("WITHOUT ANY WARRANTY; without even the implied warranty of");
puts("MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU");
- puts("General Public License for more details.\n");
+ puts("General Public License for more details.");
+ /* exit normally, if requested */
+
+ if (opt_exit)
+ exit(0);
+}
+
+
+/* fullversion *****************************************************************
+
+ Prints a Sun compatible version information (required e.g. by
+ jpackage, www.jpackage.org).
+
+*******************************************************************************/
+
+static void fullversion(void)
+{
+ puts("java full version \"cacao-"JAVA_VERSION"\"");
+
+ /* exit normally */
+
+ exit(0);
+}
+
+
+void vm_printconfig(void)
+{
puts("Configure/Build options:\n");
puts(" ./configure: "VERSION_CONFIGURE_ARGS"");
#if defined(__VERSION__)
printf(" java.boot.class.path : %s\n", _Jv_bootclasspath);
printf(" gnu.classpath.boot.library.path: %s\n", classpath_libdir);
printf(" java.class.path : %s\n", _Jv_classpath);
-
- /* exit normally, if requested */
-
- if (opt_exit)
- exit(0);
-}
-
-
-/* fullversion *****************************************************************
-
- Prints a Sun compatible version information (required e.g. by
- jpackage, www.jpackage.org).
-
-*******************************************************************************/
-
-static void fullversion(void)
-{
- puts("java full version \"cacao-"JAVA_VERSION"\"");
-
- /* exit normally */
-
- exit(0);
}
strcat(_Jv_bootclasspath, cacao_prefix);
strcat(_Jv_bootclasspath, "/share/classpath/glibj.zip");
#else
- len =
# if defined(WITH_CLASSPATH_GNU)
+ len =
strlen(CACAO_VM_ZIP) +
strlen(":") +
-# endif
strlen(CLASSPATH_CLASSES) +
strlen("0");
+# elif defined(WITH_CLASSPATH_SUN)
+ /* This is the bootclasspath taken from HotSpot (see
+ hotspot/src/share/vm/runtime/os.cpp
+ (os::set_boot_path)). */
+
+ len =
+ strlen(CLASSPATH_PREFIX"/lib/resources.jar:"
+ CLASSPATH_PREFIX"/lib/rt.jar:"
+ CLASSPATH_PREFIX"/lib/sunrsasign.jar:"
+ CLASSPATH_PREFIX"/lib/jsse.jar:"
+ CLASSPATH_PREFIX"/lib/jce.jar:"
+ CLASSPATH_PREFIX"/lib/charsets.jar:"
+ CLASSPATH_PREFIX"/classes") +
+ strlen("0");
+# elif defined(WITH_CLASSPATH_CLDC1_1)
+ len =
+ strlen(CLASSPATH_CLASSES) +
+ strlen("0");
+# else
+# error unknown classpath configuration
+# endif
_Jv_bootclasspath = MNEW(char, len);
+
# if defined(WITH_CLASSPATH_GNU)
- strcat(_Jv_bootclasspath, CACAO_VM_ZIP);
+ strcpy(_Jv_bootclasspath, CACAO_VM_ZIP);
strcat(_Jv_bootclasspath, ":");
-# endif
strcat(_Jv_bootclasspath, CLASSPATH_CLASSES);
+# elif defined(WITH_CLASSPATH_SUN)
+ strcpy(_Jv_bootclasspath,
+ CLASSPATH_PREFIX"/lib/resources.jar:"
+ CLASSPATH_PREFIX"/lib/rt.jar:"
+ CLASSPATH_PREFIX"/lib/sunrsasign.jar:"
+ CLASSPATH_PREFIX"/lib/jsse.jar:"
+ CLASSPATH_PREFIX"/lib/jce.jar:"
+ CLASSPATH_PREFIX"/lib/charsets.jar:"
+ CLASSPATH_PREFIX"/classes");
+# elif defined(WITH_CLASSPATH_CLDC1_1)
+ strcat(_Jv_bootclasspath, CLASSPATH_CLASSES);
+# else
+# error unknown classpath configuration
+# endif
#endif
}
strcpy(_Jv_classpath, ".");
}
- /* get and set java.library.path */
+ /* Get and set java.library.path. */
_Jv_java_library_path = getenv("LD_LIBRARY_PATH");
jvmti = false;
#endif
- /* initialize and fill properties before command-line handling */
+ /* Initialize and fill properties before command-line handling. */
if (!properties_init())
- vm_abort("properties_init failed");
+ vm_abort("vm_create: properties_init failed");
+
+ /* Set the classpath properties. */
+
+#if defined(ENABLE_JAVASE)
+ properties_add("java.boot.class.path", _Jv_bootclasspath);
+ properties_add("sun.boot.class.path", _Jv_bootclasspath);
+ properties_add("java.class.path", _Jv_classpath);
+#endif
/* iterate over all passed options */
_Jv_classpath = MNEW(char, strlen(opt_arg) + strlen("0"));
strcpy(_Jv_classpath, opt_arg);
+
+#if defined(ENABLE_JAVASE)
+ properties_add("java.class.path", _Jv_classpath);
+#endif
break;
case OPT_D:
_Jv_bootclasspath = MNEW(char, strlen(opt_arg) + strlen("0"));
strcpy(_Jv_bootclasspath, opt_arg);
+
+#if defined(ENABLE_JAVASE)
+ properties_add("java.boot.class.path", _Jv_bootclasspath);
+ properties_add("sun.boot.class.path", _Jv_bootclasspath);
+#endif
break;
case OPT_BOOTCLASSPATH_A:
strcat(_Jv_bootclasspath, ":");
strcat(_Jv_bootclasspath, opt_arg);
+
+#if defined(ENABLE_JAVASE)
+ properties_add("java.boot.class.path", _Jv_bootclasspath);
+ properties_add("sun.boot.class.path", _Jv_bootclasspath);
+#endif
break;
case OPT_BOOTCLASSPATH_P:
strcat(_Jv_bootclasspath, cp);
MFREE(cp, char, len);
+
+#if defined(ENABLE_JAVASE)
+ properties_add("java.boot.class.path", _Jv_bootclasspath);
+ properties_add("sun.boot.class.path", _Jv_bootclasspath);
+#endif
break;
case OPT_BOOTCLASSPATH_C:
strcpy(_Jv_bootclasspath, CACAO_VM_ZIP);
strcat(_Jv_bootclasspath, ":");
strcat(_Jv_bootclasspath, opt_arg);
+
+#if defined(ENABLE_JAVASE)
+ properties_add("java.boot.class.path", _Jv_bootclasspath);
+ properties_add("sun.boot.class.path", _Jv_bootclasspath);
+#endif
break;
#if defined(ENABLE_JVMTI)
opt_verbosejni = true;
}
#if !defined(NDEBUG)
- else if (strcmp("call", opt_arg) == 0) {
- opt_verbosecall = true;
- }
else if (strcmp("jit", opt_arg) == 0) {
opt_verbose = true;
loadverbose = true;
makeinitializations = false;
break;
- case OPT_EAGER:
- opt_eager = true;
- break;
-
#if !defined(NDEBUG)
case OPT_ALL:
compileall = true;
case OPT_INLINE_DEBUG_MAX:
opt_inline_debug_max_size = atoi(opt_arg);
break;
- case OPT_INLINE_REPLACE_VERBOSE:
- opt_replace_verbose = 1;
- break;
- case OPT_INLINE_REPLACE_VERBOSE2:
- opt_replace_verbose = 2;
- break;
#endif /* defined(ENABLE_INLINING_DEBUG) */
#if !defined(NDEBUG)
case OPT_INLINE_LOG:
_Jv_classpath = MNEW(char, strlen(mainstring) + strlen("0"));
strcpy(_Jv_classpath, mainstring);
+
+#if defined(ENABLE_JAVASE)
+ properties_add("java.class.path", _Jv_classpath);
+#endif
}
else {
/* replace .'s with /'s in classname */
suck_add(_Jv_bootclasspath);
- /* Now re-set some of the properties that may have changed. This
- must be done after _all_ environment variables have been
- processes (e.g. -jar handling).
-
- AFTER: suck_add_from_property, since it may change the
- _Jv_bootclasspath pointer. */
-
- if (!properties_postinit())
- vm_abort("vm_create: properties_postinit failed");
-
/* initialize the classcache hashtable stuff: lock, hashtable
(must be done _after_ threads_preinit) */
*******************************************************************************/
-#if !defined(__MIPS__) && !defined(__X86_64__) && !defined(__POWERPC64__) && !defined(__SPARC_64__) && !defined(__M68K__) && !defined(__ARM__)
+#if !defined(__MIPS__) && !defined(__X86_64__) && !defined(__POWERPC64__) && !defined(__SPARC_64__) && !defined(__M68K__) && !defined(__ARM__) && !defined(__ALPHA__) && !defined(__I386__)
static void vm_vmargs_from_valist(methodinfo *m, java_objectheader *o,
vm_arg *vmargs, va_list ap)
{
*******************************************************************************/
-#if !defined(__MIPS__) && !defined(__X86_64__) && !defined(__POWERPC64__) && !defined(__SPARC_64__) && !defined(__M68K__) && !defined(__ARM__)
+#if !defined(__MIPS__) && !defined(__X86_64__) && !defined(__POWERPC64__) && !defined(__SPARC_64__) && !defined(__M68K__) && !defined(__ARM__) && !defined(__ALPHA__) && !defined(__I386__)
static void vm_vmargs_from_jvalue(methodinfo *m, java_objectheader *o,
vm_arg *vmargs, const jvalue *args)
{
*******************************************************************************/
-#if !defined(__MIPS__) && !defined(__X86_64__) && !defined(__POWERPC64__) && !defined(__SPARC_64__) && !defined(__M68K__) && !defined(__ARM__)
+#if !defined(__MIPS__) && !defined(__X86_64__) && !defined(__POWERPC64__) && !defined(__SPARC_64__) && !defined(__M68K__) && !defined(__ARM__) && !defined(__ALPHA__) && !defined(__I386__)
bool vm_vmargs_from_objectarray(methodinfo *m, java_objectheader *o,
vm_arg *vmargs, java_objectarray *params)
{
java_objectheader *vm_call_method_valist(methodinfo *m, java_objectheader *o,
va_list ap)
{
-#if !defined(__MIPS__) && !defined(__X86_64__) && !defined(__POWERPC64__) && !defined(__SPARC_64__) && !defined(__M68K__) && !defined(__ARM__)
+#if !defined(__MIPS__) && !defined(__X86_64__) && !defined(__POWERPC64__) && !defined(__SPARC_64__) && !defined(__M68K__) && !defined(__ARM__) && !defined(__ALPHA__) && !defined(__I386__)
s4 vmargscount;
vm_arg *vmargs;
java_objectheader *ro;
java_objectheader *vm_call_method_jvalue(methodinfo *m, java_objectheader *o,
const jvalue *args)
{
-#if !defined(__MIPS__) && !defined(__X86_64__) && !defined(__POWERPC64__) && !defined(__SPARC_64__) && !defined(__M68K__) && !defined(__ARM__)
+#if !defined(__MIPS__) && !defined(__X86_64__) && !defined(__POWERPC64__) && !defined(__SPARC_64__) && !defined(__M68K__) && !defined(__ARM__) && !defined(__ALPHA__) && !defined(__I386__)
s4 vmargscount;
vm_arg *vmargs;
java_objectheader *ro;
*******************************************************************************/
-#if !defined(__MIPS__) && !defined(__X86_64__) && !defined(__POWERPC64__) && !defined(__SPARC_64__) && !defined(__M68K__) && !defined(__ARM__)
+#if !defined(__MIPS__) && !defined(__X86_64__) && !defined(__POWERPC64__) && !defined(__SPARC_64__) && !defined(__M68K__) && !defined(__ARM__) && !defined(__ALPHA__) && !defined(__I386__)
java_objectheader *vm_call_method_vmarg(methodinfo *m, s4 vmargscount,
vm_arg *vmargs)
{
*******************************************************************************/
-#if !defined(__MIPS__) && !defined(__X86_64__) && !defined(__POWERPC64__) && !defined(__SPARC_64__) && !defined(__M68K__) && !defined(__ARM__)
+#if !defined(__MIPS__) && !defined(__X86_64__) && !defined(__POWERPC64__) && !defined(__SPARC_64__) && !defined(__M68K__) && !defined(__ARM__) && !defined(__ALPHA__) && !defined(__I386__)
s4 vm_call_method_int_vmarg(methodinfo *m, s4 vmargscount, vm_arg *vmargs)
{
s4 i;
*******************************************************************************/
-#if !defined(__MIPS__) && !defined(__X86_64__) && !defined(__POWERPC64__) && !defined(__SPARC_64__) && !defined(__M68K__) && !defined(__ARM__)
+#if !defined(__MIPS__) && !defined(__X86_64__) && !defined(__POWERPC64__) && !defined(__SPARC_64__) && !defined(__M68K__) && !defined(__ARM__) && !defined(__ALPHA__) && !defined(__I386__)
s4 vm_call_method_int_valist(methodinfo *m, java_objectheader *o, va_list ap)
{
s4 vmargscount;
*******************************************************************************/
-#if !defined(__MIPS__) && !defined(__X86_64__) && !defined(__POWERPC64__) && !defined(__SPARC_64__) && !defined(__M68K__) && !defined(__ARM__)
+#if !defined(__MIPS__) && !defined(__X86_64__) && !defined(__POWERPC64__) && !defined(__SPARC_64__) && !defined(__M68K__) && !defined(__ARM__) && !defined(__ALPHA__) && !defined(__I386__)
s4 vm_call_method_int_jvalue(methodinfo *m, java_objectheader *o,
const jvalue *args)
{
*******************************************************************************/
-#if !defined(__MIPS__) && !defined(__X86_64__) && !defined(__POWERPC64__) && !defined(__SPARC_64__) && !defined(__M68K__) && !defined(__ARM__)
+#if !defined(__MIPS__) && !defined(__X86_64__) && !defined(__POWERPC64__) && !defined(__SPARC_64__) && !defined(__M68K__) && !defined(__ARM__) && !defined(__ALPHA__) && !defined(__I386__)
s8 vm_call_method_long_vmarg(methodinfo *m, s4 vmargscount, vm_arg *vmargs)
{
s8 l;
*******************************************************************************/
-#if !defined(__MIPS__) && !defined(__X86_64__) && !defined(__POWERPC64__) && !defined(__SPARC_64__) && !defined(__M68K__) && !defined(__ARM__)
+#if !defined(__MIPS__) && !defined(__X86_64__) && !defined(__POWERPC64__) && !defined(__SPARC_64__) && !defined(__M68K__) && !defined(__ARM__) && !defined(__ALPHA__) && !defined(__I386__)
s8 vm_call_method_long_valist(methodinfo *m, java_objectheader *o, va_list ap)
{
s4 vmargscount;
*******************************************************************************/
-#if !defined(__MIPS__) && !defined(__X86_64__) && !defined(__POWERPC64__) && !defined(__SPARC_64__) && !defined(__M68K__) && !defined(__ARM__)
+#if !defined(__MIPS__) && !defined(__X86_64__) && !defined(__POWERPC64__) && !defined(__SPARC_64__) && !defined(__M68K__) && !defined(__ARM__) && !defined(__ALPHA__) && !defined(__I386__)
s8 vm_call_method_long_jvalue(methodinfo *m, java_objectheader *o,
const jvalue *args)
{
*******************************************************************************/
-#if !defined(__MIPS__) && !defined(__X86_64__) && !defined(__POWERPC64__) && !defined(__SPARC_64__) && !defined(__M68K__) && !defined(__ARM__)
+#if !defined(__MIPS__) && !defined(__X86_64__) && !defined(__POWERPC64__) && !defined(__SPARC_64__) && !defined(__M68K__) && !defined(__ARM__) && !defined(__ALPHA__) && !defined(__I386__)
float vm_call_method_float_vmarg(methodinfo *m, s4 vmargscount, vm_arg *vmargs)
{
float f;
*******************************************************************************/
-#if !defined(__MIPS__) && !defined(__X86_64__) && !defined(__POWERPC64__) && !defined(__SPARC_64__) && !defined(__M68K__) && !defined(__ARM__)
+#if !defined(__MIPS__) && !defined(__X86_64__) && !defined(__POWERPC64__) && !defined(__SPARC_64__) && !defined(__M68K__) && !defined(__ARM__) && !defined(__ALPHA__) && !defined(__I386__)
float vm_call_method_float_valist(methodinfo *m, java_objectheader *o,
va_list ap)
{
*******************************************************************************/
-#if !defined(__MIPS__) && !defined(__X86_64__) && !defined(__POWERPC64__) && !defined(__SPARC_64__) && !defined(__M68K__) && !defined(__ARM__)
+#if !defined(__MIPS__) && !defined(__X86_64__) && !defined(__POWERPC64__) && !defined(__SPARC_64__) && !defined(__M68K__) && !defined(__ARM__) && !defined(__ALPHA__) && !defined(__I386__)
float vm_call_method_float_jvalue(methodinfo *m, java_objectheader *o,
const jvalue *args)
{
*******************************************************************************/
-#if !defined(__MIPS__) && !defined(__X86_64__) && !defined(__POWERPC64__) && !defined(__SPARC_64__) && !defined(__M68K__) && !defined(__ARM__)
+#if !defined(__MIPS__) && !defined(__X86_64__) && !defined(__POWERPC64__) && !defined(__SPARC_64__) && !defined(__M68K__) && !defined(__ARM__) && !defined(__ALPHA__) && !defined(__I386__)
double vm_call_method_double_vmarg(methodinfo *m, s4 vmargscount,
vm_arg *vmargs)
{
*******************************************************************************/
-#if !defined(__MIPS__) && !defined(__X86_64__) && !defined(__POWERPC64__) && !defined(__SPARC_64__) && !defined(__M68K__) && !defined(__ARM__)
+#if !defined(__MIPS__) && !defined(__X86_64__) && !defined(__POWERPC64__) && !defined(__SPARC_64__) && !defined(__M68K__) && !defined(__ARM__) && !defined(__ALPHA__) && !defined(__I386__)
double vm_call_method_double_valist(methodinfo *m, java_objectheader *o,
va_list ap)
{
*******************************************************************************/
-#if !defined(__MIPS__) && !defined(__X86_64__) && !defined(__POWERPC64__) && !defined(__SPARC_64__) && !defined(__M68K__) && !defined(__ARM__)
+#if !defined(__MIPS__) && !defined(__X86_64__) && !defined(__POWERPC64__) && !defined(__SPARC_64__) && !defined(__M68K__) && !defined(__ARM__) && !defined(__ALPHA__) && !defined(__I386__)
double vm_call_method_double_jvalue(methodinfo *m, java_objectheader *o,
const jvalue *args)
{
/* function prototypes ********************************************************/
void usage(void);
+void vm_printconfig(void);
bool vm_createjvm(JavaVM **p_vm, void **p_env, void *vm_args);
bool vm_create(JavaVMInitArgs *vm_args);
void vm_abort(const char *text, ...);
/* Java method calling functions */
-#if !defined(__MIPS__) && !defined(__X86_64__) && !defined(__POWERPC64__) && !defined(__SPARC_64__) && !defined(__M68K__) && !defined(__ARM__)
+#if !defined(__MIPS__) && !defined(__X86_64__) && !defined(__POWERPC64__) && !defined(__SPARC_64__) && !defined(__M68K__) && !defined(__ARM__) && !defined(__ALPHA__) && !defined(__I386__)
bool vm_vmargs_from_objectarray(methodinfo *m, java_objectheader *o,
vm_arg *vmargs, java_objectarray *params);
#else
java_objectheader *vm_call_method_jvalue(methodinfo *m, java_objectheader *o,
const jvalue *args);
-#if !defined(__MIPS__) && !defined(__X86_64__) && !defined(__POWERPC64__) && !defined(__SPARC_64__) && !defined(__M68K__) && !defined(__ARM__)
+#if !defined(__MIPS__) && !defined(__X86_64__) && !defined(__POWERPC64__) && !defined(__SPARC_64__) && !defined(__M68K__) && !defined(__ARM__) && !defined(__ALPHA__) && !defined(__I386__)
java_objectheader *vm_call_method_vmarg(methodinfo *m, s4 vmargscount,
vm_arg *vmargs);
s4 vm_call_method_int_vmarg(methodinfo *m, s4 vmargscount, vm_arg *vmargs);
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
- $Id: class.c 8179 2007-07-05 11:21:08Z michi $
+ $Id: class.c 8245 2007-07-31 09:55:04Z michi $
*/
#include "vm/exceptions.h"
#include "vm/global.h"
+#include "vm/resolve.h"
#include "vm/jit/asmpart.h"
/* global variables ***********************************************************/
-list_t unlinkedclasses; /* this is only used for eager class */
- /* loading */
-
-
/* frequently used classes ****************************************************/
/* important system classes */
classinfo *class_java_lang_VMThread;
classinfo *class_java_io_Serializable;
+#if defined(WITH_CLASSPATH_SUN)
+classinfo *class_sun_reflect_MagicAccessorImpl;
+#endif
/* system exception classes required in cacao */
*******************************************************************************/
-classinfo *class_define(utf *name, classloader *cl, s4 length, u1 *data)
+classinfo *class_define(utf *name, classloader *cl, int32_t length, const uint8_t *data)
{
classinfo *c;
classinfo *r;
}
+/* class_resolve_superclass ****************************************************
+
+ Resolves the super class reference of the given class if necessary.
+
+*******************************************************************************/
+
+static classinfo *class_resolve_superclass(classinfo *c)
+{
+ classinfo *super;
+
+ if (c->super.any == NULL)
+ return NULL;
+
+ /* Do we have a super class reference or is it already
+ resolved? */
+
+ if (IS_CLASSREF(c->super)) {
+ super = resolve_classref_or_classinfo_eager(c->super, true);
+
+ if (super == NULL)
+ return NULL;
+
+ /* Store the resolved super class in the class structure. */
+
+ c->super.cls = super;
+ }
+
+ return c->super.cls;
+}
+
+
/* class_issubclass ************************************************************
Checks if sub is a descendant of super.
bool class_issubclass(classinfo *sub, classinfo *super)
{
for (;;) {
- if (!sub)
+ if (sub == NULL)
return false;
if (sub == super)
return true;
- sub = sub->super.cls;
+ sub = class_resolve_superclass(sub);
}
}
/* Primitive classes are only subclasses of themselves. */
- if ((sub->flags & ACC_CLASS_PRIMITIVE) ||
- (super->flags & ACC_CLASS_PRIMITIVE))
+ if (class_is_primitive(sub) || class_is_primitive(super))
return false;
/* Check for interfaces. */
}
+/* class_is_primitive **********************************************************
+
+ Checks if the given class is a primitive class.
+
+*******************************************************************************/
+
+bool class_is_primitive(classinfo *c)
+{
+ if (c->flags & ACC_CLASS_PRIMITIVE)
+ return true;
+
+ return false;
+}
+
+
/* class_is_array **************************************************************
Checks if the given class is an array class.
}
+/* class_get_superclass ********************************************************
+
+ Return the super class of the given class. If the super-field is a
+ class-reference, resolve it and store it in the classinfo.
+
+*******************************************************************************/
+
+classinfo *class_get_superclass(classinfo *c)
+{
+ classinfo *super;
+
+ /* For java.lang.Object, primitive and Void classes we return
+ NULL. */
+
+ if (c->super.any == NULL)
+ return NULL;
+
+ /* For interfaces we also return NULL. */
+
+ if (c->flags & ACC_INTERFACE)
+ return NULL;
+
+ /* We may have to resolve the super class reference. */
+
+ super = class_resolve_superclass(c);
+
+ return super;
+}
+
+
+/* class_get_declaringclass ****************************************************
+
+ If the class or interface given is a member of another class,
+ return the declaring class. For array and primitive classes return
+ NULL.
+
+*******************************************************************************/
+
+classinfo *class_get_declaringclass(classinfo *c)
+{
+ classref_or_classinfo innercr;
+ utf *innername;
+ classref_or_classinfo outercr;
+ classinfo *outer;
+ int16_t i;
+
+ /* return NULL for arrayclasses and primitive classes */
+
+ if (class_is_primitive(c) || (c->name->text[0] == '['))
+ return NULL;
+
+ /* no innerclasses exist */
+
+ if (c->innerclasscount == 0)
+ return NULL;
+
+ for (i = 0; i < c->innerclasscount; i++) {
+ /* Check if inner_class is a classref or a real class and get
+ the class name from the structure. */
+
+ innercr = c->innerclass[i].inner_class;
+
+ innername = IS_CLASSREF(innercr) ?
+ innercr.ref->name : innercr.cls->name;
+
+ /* Is the current innerclass this class? */
+
+ if (innername == c->name) {
+ /* Maybe the outer class is not loaded yet. */
+
+ outercr = c->innerclass[i].outer_class;
+
+ outer = resolve_classref_or_classinfo_eager(outercr, false);
+
+ if (outer == NULL)
+ return NULL;
+
+ if (!(outer->state & CLASS_LINKED))
+ if (!link_class(outer))
+ return NULL;
+
+ return outer;
+ }
+ }
+
+ return NULL;
+}
+
+
+/* class_get_signature *********************************************************
+
+ Return the signature of the given class. For array and primitive
+ classes return NULL.
+
+*******************************************************************************/
+
+#if defined(ENABLE_JAVASE)
+utf *class_get_signature(classinfo *c)
+{
+ /* For array and primitive classes return NULL. */
+
+ if (class_is_array(c) || class_is_primitive(c))
+ return NULL;
+
+ return c->signature;
+}
+#endif
+
+
/* class_printflags ************************************************************
Prints flags of a class.
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
- $Id: class.h 8179 2007-07-05 11:21:08Z michi $
+ $Id: class.h 8245 2007-07-31 09:55:04Z michi $
*/
/* classinfo ******************************************************************/
/* We define this dummy structure of java_lang_Class so we can
- bootstrap cacaoh without needing a java_lang_Class.h file. If the
- size is big enough, is checked during runtime in vm_create. */
+ bootstrap cacaoh without needing a java_lang_Class.h file. Whether
+ the size of the dummy structure is big enough is checked during
+ runtime in vm_create. */
typedef struct {
java_objectheader header;
s4 methodscount; /* number of methods */
methodinfo *methods; /* method table */
- listnode_t listnode; /* linkage */
-
s4 state; /* current class state */
s4 index; /* hierarchy depth (classes) or index */
/* (interfaces) */
/* global variables ***********************************************************/
-extern list_t unlinkedclasses; /* this is only used for eager class loading */
-
-
/* frequently used classes ****************************************************/
/* important system classes */
extern classinfo *class_java_lang_VMThread;
extern classinfo *class_java_io_Serializable;
+#if defined(WITH_CLASSPATH_SUN)
+extern classinfo *class_sun_reflect_MagicAccessorImpl;
+#endif
/* system exception classes required in cacao */
/* function prototypes ********************************************************/
-/* create a new classinfo struct */
classinfo *class_create_classinfo(utf *u);
+void class_postset_header_vftbl(void);
+classinfo *class_define(utf *name, classloader *cl, int32_t length, const uint8_t *data);
+void class_set_packagename(classinfo *c);
-/* postset's the header.vftbl */
-void class_postset_header_vftbl(void);
-
-classinfo *class_define(utf *name, classloader *cl, s4 length, u1 *data);
-
-/* set the package name after the name has been set */
-void class_set_packagename(classinfo *c);
-
-bool class_load_attributes(classbuffer *cb);
+bool class_load_attributes(classbuffer *cb);
/* retrieve constantpool element */
voidptr class_getconstant(classinfo *class, u4 pos, u4 ctype);
methodinfo *class_resolveclassmethod(classinfo *c, utf *name, utf *dest, classinfo *referer, bool throwexception);
methodinfo *class_resolveinterfacemethod(classinfo *c, utf *name, utf *dest, classinfo *referer, bool throwexception);
-bool class_issubclass(classinfo *sub, classinfo *super);
-bool class_isanysubclass(classinfo *sub, classinfo *super);
-bool class_is_array(classinfo *c);
-bool class_is_interface(classinfo *c);
+bool class_issubclass(classinfo *sub, classinfo *super);
+bool class_isanysubclass(classinfo *sub, classinfo *super);
+bool class_is_primitive(classinfo *c);
+bool class_is_array(classinfo *c);
+bool class_is_interface(classinfo *c);
+classinfo *class_get_superclass(classinfo *c);
+classinfo *class_get_declaringclass(classinfo *c);
+
+#if defined(ENABLE_JAVASE)
+utf *class_get_signature(classinfo *c);
+#endif
/* some debugging functions */
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
- $Id: descriptor.c 8123 2007-06-20 23:50:55Z michi $
+ $Id: descriptor.c 8233 2007-07-25 15:11:20Z twisti $
*/
#include "mm/memory.h"
#include "vm/exceptions.h"
-
#include "vm/jit_interface.h"
+#include "vm/vm.h"
#include "vmcore/descriptor.h"
#include "vmcore/primitive.h"
*******************************************************************************/
-u2 descriptor_to_basic_type(utf *descriptor)
+int descriptor_to_basic_type(utf *descriptor)
{
assert(descriptor->blength >= 1);
switch (descriptor->text[0]) {
- case 'B':
- case 'C':
- case 'I':
- case 'S':
- case 'Z': return TYPE_INT;
- case 'D': return TYPE_DBL;
- case 'F': return TYPE_FLT;
- case 'J': return TYPE_LNG;
- case 'L':
- case '[': return TYPE_ADR;
+ case 'Z':
+ case 'B':
+ case 'C':
+ case 'S':
+ case 'I':
+ return TYPE_INT;
+
+ case 'J':
+ return TYPE_LNG;
+
+ case 'F':
+ return TYPE_FLT;
+
+ case 'D':
+ return TYPE_DBL;
+
+ case 'L':
+ case '[':
+ return TYPE_ADR;
+
+ default:
+ vm_abort("descriptor_to_basic_type: invalid type %c",
+ descriptor->text[0]);
}
-
- assert(0);
- return 0; /* keep the compiler happy */
+ /* keep the compiler happy */
+
+ return 0;
}
-/* descriptor_typesize**** ****************************************************
+
+/* descriptor_typesize *********************************************************
Return the size in bytes needed for the given type.
*******************************************************************************/
-u2 descriptor_typesize(typedesc *td)
+int descriptor_typesize(typedesc *td)
{
assert(td);
switch (td->type) {
- case TYPE_INT: return 4;
- case TYPE_LNG: return 8;
- case TYPE_FLT: return 4;
- case TYPE_DBL: return 8;
- case TYPE_ADR: return sizeof(voidptr);
+ case TYPE_INT:
+ case TYPE_FLT:
+ return 4;
+
+ case TYPE_LNG:
+ case TYPE_DBL:
+ return 8;
+
+ case TYPE_ADR:
+ return SIZEOF_VOID_P;
+
+ default:
+ vm_abort("descriptor_typesize: invalid type %d", td->type);
}
- assert(0);
+ /* keep the compiler happy */
- return 0; /* keep the compiler happy */
+ return 0;
}
+
/* name_from_descriptor ********************************************************
Return the class name indicated by the given descriptor
md->paramcount = paramcount;
md->paramslots = paramslots;
- /* If m != ACC_UNDEF we parse a real loaded method, so do param prealloc. */
- /* Otherwise we do this in stack analysis. */
+ /* If mflags != ACC_UNDEF we parse a real loaded method, so do
+ param prealloc. Otherwise we do this in stack analysis. */
if (mflags != ACC_UNDEF) {
if (md->paramcount > 0) {
# if defined(ENABLE_INTRP)
if (!opt_intrp)
# endif
- md_param_alloc(md);
+ {
+ /* As builtin-functions are native functions, we have
+ to pre-allocate for the native ABI. */
+
+ if (mflags & ACC_METHOD_BUILTIN)
+ md_param_alloc_native(md);
+ else
+ md_param_alloc(md);
+ }
#endif
-
- } else {
+ }
+ else {
/* params will be allocated later by
descriptor_params_from_paramtypes if necessary */
# if defined(ENABLE_INTRP)
if (!opt_intrp)
# endif
- md_param_alloc(md);
+ {
+ /* As builtin-functions are native functions, we have to
+ pre-allocate for the native ABI. */
+
+ if (mflags & ACC_METHOD_BUILTIN)
+ md_param_alloc_native(md);
+ else
+ md_param_alloc(md);
+ }
#endif
return true;
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
- $Id: descriptor.h 8123 2007-06-20 23:50:55Z michi $
+ $Id: descriptor.h 8233 2007-07-25 15:11:20Z twisti $
*/
bool descriptor_pool_add_class(descriptor_pool *pool,utf *name);
bool descriptor_pool_add(descriptor_pool *pool,utf *desc,int *paramslots);
-u2 descriptor_to_basic_type(utf *desc);
-u2 descriptor_typesize(typedesc *td);
+int descriptor_to_basic_type(utf *desc);
+int descriptor_typesize(typedesc *td);
constant_classref * descriptor_pool_create_classrefs(descriptor_pool *pool,
s4 *count);
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
- $Id: field.c 8132 2007-06-22 11:15:47Z twisti $
+ $Id: field.c 8227 2007-07-24 11:55:07Z twisti $
*/
#include "config.h"
#include <assert.h>
+#include <stdint.h>
#include <stdio.h>
#include "vm/types.h"
+#include "vm/exceptions.h"
+#include "vm/stringlocal.h"
+#include "vm/vm.h"
+
#include "vmcore/class.h"
+#include "vmcore/descriptor.h"
#include "vmcore/field.h"
+#include "vmcore/loader.h"
+#include "vmcore/options.h"
#include "vmcore/primitive.h"
#include "vmcore/references.h"
+#include "vmcore/suck.h"
#include "vmcore/utf8.h"
+/* field_load ******************************************************************
+
+ Load everything about a class field from the class file and fill a
+ fieldinfo structure.
+
+*******************************************************************************/
+
+#define field_load_NOVALUE 0xffffffff /* must be bigger than any u2 value! */
+
+bool field_load(classbuffer *cb, fieldinfo *f, descriptor_pool *descpool)
+{
+ classinfo *c;
+ u4 attrnum, i;
+ u4 jtype;
+ u4 pindex = field_load_NOVALUE; /* constantvalue_index */
+ utf *u;
+
+ c = cb->class;
+
+ if (!suck_check_classbuffer_size(cb, 2 + 2 + 2))
+ return false;
+
+ f->flags = suck_u2(cb);
+
+ if (!(u = class_getconstant(c, suck_u2(cb), CONSTANT_Utf8)))
+ return false;
+
+ f->name = u;
+
+ if (!(u = class_getconstant(c, suck_u2(cb), CONSTANT_Utf8)))
+ return false;
+
+ f->descriptor = u;
+ f->parseddesc = NULL;
+
+ if (!descriptor_pool_add(descpool, u, NULL))
+ return false;
+
+ /* descriptor_pool_add accepts method descriptors, so we have to
+ check against them here before the call of
+ descriptor_to_basic_type below. */
+
+ if (u->text[0] == '(') {
+ exceptions_throw_classformaterror(c, "Method descriptor used for field");
+ return false;
+ }
+
+#ifdef ENABLE_VERIFIER
+ if (opt_verify) {
+ /* check name */
+ if (!is_valid_name_utf(f->name) || f->name->text[0] == '<') {
+ exceptions_throw_classformaterror(c,
+ "Illegal Field name \"%s\"",
+ f->name->text);
+ return false;
+ }
+
+ /* check flag consistency */
+ i = f->flags & (ACC_PUBLIC | ACC_PRIVATE | ACC_PROTECTED);
+
+ if ((i != 0 && i != ACC_PUBLIC && i != ACC_PRIVATE && i != ACC_PROTECTED) ||
+ ((f->flags & (ACC_FINAL | ACC_VOLATILE)) == (ACC_FINAL | ACC_VOLATILE))) {
+ exceptions_throw_classformaterror(c,
+ "Illegal field modifiers: 0x%X",
+ f->flags);
+ return false;
+ }
+
+ if (c->flags & ACC_INTERFACE) {
+ if (((f->flags & (ACC_STATIC | ACC_PUBLIC | ACC_FINAL))
+ != (ACC_STATIC | ACC_PUBLIC | ACC_FINAL)) ||
+ f->flags & ACC_TRANSIENT) {
+ exceptions_throw_classformaterror(c,
+ "Illegal field modifiers: 0x%X",
+ f->flags);
+ return false;
+ }
+ }
+ }
+#endif /* ENABLE_VERIFIER */
+
+ /* data type */
+
+ jtype = descriptor_to_basic_type(f->descriptor);
+
+ f->class = c;
+ f->type = jtype;
+ f->offset = 0; /* offset from start of object */
+
+ switch (f->type) {
+ case TYPE_INT:
+ f->value.i = 0;
+ break;
+
+ case TYPE_FLT:
+ f->value.f = 0.0;
+ break;
+
+ case TYPE_DBL:
+ f->value.d = 0.0;
+ break;
+
+ case TYPE_ADR:
+ f->value.a = NULL;
+ if (!(f->flags & ACC_STATIC))
+ c->flags |= ACC_CLASS_HAS_POINTERS;
+ break;
+
+ case TYPE_LNG:
+#if U8_AVAILABLE
+ f->value.l = 0;
+#else
+ f->value.l.low = 0;
+ f->value.l.high = 0;
+#endif
+ break;
+ }
+
+ /* read attributes */
+ if (!suck_check_classbuffer_size(cb, 2))
+ return false;
+
+ attrnum = suck_u2(cb);
+ for (i = 0; i < attrnum; i++) {
+ if (!suck_check_classbuffer_size(cb, 2))
+ return false;
+
+ if (!(u = class_getconstant(c, suck_u2(cb), CONSTANT_Utf8)))
+ return false;
+
+ if (u == utf_ConstantValue) {
+ if (!suck_check_classbuffer_size(cb, 4 + 2))
+ return false;
+
+ /* check attribute length */
+
+ if (suck_u4(cb) != 2) {
+ exceptions_throw_classformaterror(c, "Wrong size for VALUE attribute");
+ return false;
+ }
+
+ /* constant value attribute */
+
+ if (pindex != field_load_NOVALUE) {
+ exceptions_throw_classformaterror(c, "Multiple ConstantValue attributes");
+ return false;
+ }
+
+ /* index of value in constantpool */
+
+ pindex = suck_u2(cb);
+
+ /* initialize field with value from constantpool */
+
+ switch (jtype) {
+ case TYPE_INT: {
+ constant_integer *ci;
+
+ if (!(ci = class_getconstant(c, pindex, CONSTANT_Integer)))
+ return false;
+
+ f->value.i = ci->value;
+ }
+ break;
+
+ case TYPE_LNG: {
+ constant_long *cl;
+
+ if (!(cl = class_getconstant(c, pindex, CONSTANT_Long)))
+ return false;
+
+ f->value.l = cl->value;
+ }
+ break;
+
+ case TYPE_FLT: {
+ constant_float *cf;
+
+ if (!(cf = class_getconstant(c, pindex, CONSTANT_Float)))
+ return false;
+
+ f->value.f = cf->value;
+ }
+ break;
+
+ case TYPE_DBL: {
+ constant_double *cd;
+
+ if (!(cd = class_getconstant(c, pindex, CONSTANT_Double)))
+ return false;
+
+ f->value.d = cd->value;
+ }
+ break;
+
+ case TYPE_ADR:
+ if (!(u = class_getconstant(c, pindex, CONSTANT_String)))
+ return false;
+
+ /* create javastring from compressed utf8-string */
+ f->value.a = literalstring_new(u);
+ break;
+
+ default:
+ vm_abort("field_load: invalid field type %d", jtype);
+ }
+ }
+#if defined(ENABLE_JAVASE)
+ else if (u == utf_Signature) {
+ /* Signature */
+
+ if (!loader_load_attribute_signature(cb, &(f->signature)))
+ return false;
+ }
+#endif
+ else {
+ /* unknown attribute */
+
+ if (!loader_skip_attribute_body(cb))
+ return false;
+ }
+ }
+
+ /* everything was ok */
+
+ return true;
+}
+
+
/* field_get_type **************************************************************
Returns the type of the field as class.
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
- $Id: field.h 8132 2007-06-22 11:15:47Z twisti $
+ $Id: field.h 8229 2007-07-24 18:42:44Z twisti $
*/
#include "vmcore/descriptor.h"
#include "vmcore/class.h"
+#include "vmcore/loader.h"
#include "vmcore/references.h"
#include "vmcore/utf8.h"
/* function prototypes ********************************************************/
+bool field_load(classbuffer *cb, fieldinfo *f, descriptor_pool *descpool);
classinfo *field_get_type(fieldinfo *f);
void field_free(fieldinfo *f);
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
- $Id: linker.c 8179 2007-07-05 11:21:08Z michi $
+ $Id: linker.c 8245 2007-07-31 09:55:04Z michi $
*/
static s4 class_highestinterface(classinfo *c);
+/* dummy structures for alinment checks ***************************************/
+
+typedef struct dummy_alignment_long_t dummy_alignment_long_t;
+typedef struct dummy_alignment_double_t dummy_alignment_double_t;
+
+struct dummy_alignment_long_t {
+ int32_t i;
+ int64_t l;
+};
+
+struct dummy_alignment_double_t {
+ int32_t i;
+ double d;
+};
+
+
/* linker_init *****************************************************************
Initializes the linker subsystem.
bool linker_init(void)
{
+ /* Check for if alignment for long and double matches what we
+ assume for the current architecture. */
+
+#if defined(__I386__) || (defined(__ARM__) && !defined(__ARM_EABI__))
+ if (OFFSET(dummy_alignment_long_t, l) != 4)
+ vm_abort("linker_init: long alignment is different from what assumed: %d != %d",
+ OFFSET(dummy_alignment_long_t, l), 4);
+
+ if (OFFSET(dummy_alignment_double_t, d) != 4)
+ vm_abort("linker_init: double alignment is different from what assumed: %d != %d",
+ OFFSET(dummy_alignment_double_t, d), 4);
+#else
+ if (OFFSET(dummy_alignment_long_t, l) != 8)
+ vm_abort("linker_init: long alignment is different from what assumed: %d != %d",
+ OFFSET(dummy_alignment_long_t, l), 8);
+
+ if (OFFSET(dummy_alignment_double_t, d) != 8)
+ vm_abort("linker_init: double alignment is different from what assumed: %d != %d",
+ OFFSET(dummy_alignment_double_t, d), 8);
+#endif
+
/* reset interface index */
interfaceindex = 0;
return false;
#endif
-
/* link classes for wrapping primitive types */
#if defined(ENABLE_JAVASE)
if (!link_class(class_java_util_Vector))
return false;
+# if defined(WITH_CLASSPATH_SUN)
+ if (!link_class(class_sun_reflect_MagicAccessorImpl))
+ return false;
+# endif
+
if (!link_class(arrayclass_java_lang_Object))
return false;
#endif
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
- $Id: loader.c 8123 2007-06-20 23:50:55Z michi $
+ $Id: loader.c 8245 2007-07-31 09:55:04Z michi $
*/
#endif
#include "vmcore/classcache.h"
+#include "vmcore/field.h"
#include "vmcore/linker.h"
#include "vmcore/loader.h"
+#include "vmcore/method.h"
#include "vmcore/options.h"
#include "vmcore/primitive.h"
#include "vmcore/rt-timing.h"
if (!(class_java_util_Vector = load_class_bootstrap(utf_java_util_Vector)))
return false;
+# if defined(WITH_CLASSPATH_SUN)
+ if (!(class_sun_reflect_MagicAccessorImpl =
+ load_class_bootstrap(utf_new_char("sun/reflect/MagicAccessorImpl"))))
+ return false;
+# endif
+
if (!(arrayclass_java_lang_Object =
load_class_bootstrap(utf_new_char("[Ljava/lang/Object;"))))
return false;
cptags[forward_classes->thisindex] = CONSTANT_Class;
- if (opt_eager) {
- classinfo *tc;
-
- if (!(tc = load_class_bootstrap(name)))
- return false;
-
- /* link the class later, because we cannot link the class currently
- loading */
- list_add_first(&unlinkedclasses, tc);
- }
-
/* the classref is created later */
cpinfos[forward_classes->thisindex] = name;
#endif /* defined(ENABLE_JAVASE) */
-/* load_field ******************************************************************
-
- Load everything about a class field from the class file and fill a
- 'fieldinfo' structure. For static fields, space in the data segment
- is allocated.
-
-*******************************************************************************/
-
-#define field_load_NOVALUE 0xffffffff /* must be bigger than any u2 value! */
-
-static bool load_field(classbuffer *cb, fieldinfo *f, descriptor_pool *descpool)
-{
- classinfo *c;
- u4 attrnum, i;
- u4 jtype;
- u4 pindex = field_load_NOVALUE; /* constantvalue_index */
- utf *u;
-
- c = cb->class;
-
- if (!suck_check_classbuffer_size(cb, 2 + 2 + 2))
- return false;
-
- f->flags = suck_u2(cb);
-
- if (!(u = class_getconstant(c, suck_u2(cb), CONSTANT_Utf8)))
- return false;
-
- f->name = u;
-
- if (!(u = class_getconstant(c, suck_u2(cb), CONSTANT_Utf8)))
- return false;
-
- f->descriptor = u;
- f->parseddesc = NULL;
-
- if (!descriptor_pool_add(descpool, u, NULL))
- return false;
-
- /* descriptor_pool_add accepts method descriptors, so we have to check */
- /* against them here before the call of descriptor_to_basic_type below. */
- if (u->text[0] == '(') {
- exceptions_throw_classformaterror(c, "Method descriptor used for field");
- return false;
- }
-
-#ifdef ENABLE_VERIFIER
- if (opt_verify) {
- /* check name */
- if (!is_valid_name_utf(f->name) || f->name->text[0] == '<') {
- exceptions_throw_classformaterror(c,
- "Illegal Field name \"%s\"",
- f->name->text);
- return false;
- }
-
- /* check flag consistency */
- i = f->flags & (ACC_PUBLIC | ACC_PRIVATE | ACC_PROTECTED);
-
- if ((i != 0 && i != ACC_PUBLIC && i != ACC_PRIVATE && i != ACC_PROTECTED) ||
- ((f->flags & (ACC_FINAL | ACC_VOLATILE)) == (ACC_FINAL | ACC_VOLATILE))) {
- exceptions_throw_classformaterror(c,
- "Illegal field modifiers: 0x%X",
- f->flags);
- return false;
- }
-
- if (c->flags & ACC_INTERFACE) {
- if (((f->flags & (ACC_STATIC | ACC_PUBLIC | ACC_FINAL))
- != (ACC_STATIC | ACC_PUBLIC | ACC_FINAL)) ||
- f->flags & ACC_TRANSIENT) {
- exceptions_throw_classformaterror(c,
- "Illegal field modifiers: 0x%X",
- f->flags);
- return false;
- }
- }
- }
-#endif /* ENABLE_VERIFIER */
-
- f->type = jtype = descriptor_to_basic_type(f->descriptor); /* data type */
- f->offset = 0; /* offset from start of object */
- f->class = c;
-
- switch (f->type) {
- case TYPE_INT:
- f->value.i = 0;
- break;
-
- case TYPE_FLT:
- f->value.f = 0.0;
- break;
-
- case TYPE_DBL:
- f->value.d = 0.0;
- break;
-
- case TYPE_ADR:
- f->value.a = NULL;
- if (!(f->flags & ACC_STATIC))
- c->flags |= ACC_CLASS_HAS_POINTERS;
- break;
-
- case TYPE_LNG:
-#if U8_AVAILABLE
- f->value.l = 0;
-#else
- f->value.l.low = 0;
- f->value.l.high = 0;
-#endif
- break;
- }
-
- /* read attributes */
- if (!suck_check_classbuffer_size(cb, 2))
- return false;
-
- attrnum = suck_u2(cb);
- for (i = 0; i < attrnum; i++) {
- if (!suck_check_classbuffer_size(cb, 2))
- return false;
-
- if (!(u = class_getconstant(c, suck_u2(cb), CONSTANT_Utf8)))
- return false;
-
- if (u == utf_ConstantValue) {
- if (!suck_check_classbuffer_size(cb, 4 + 2))
- return false;
-
- /* check attribute length */
-
- if (suck_u4(cb) != 2) {
- exceptions_throw_classformaterror(c, "Wrong size for VALUE attribute");
- return false;
- }
-
- /* constant value attribute */
-
- if (pindex != field_load_NOVALUE) {
- exceptions_throw_classformaterror(c, "Multiple ConstantValue attributes");
- return false;
- }
-
- /* index of value in constantpool */
-
- pindex = suck_u2(cb);
-
- /* initialize field with value from constantpool */
- switch (jtype) {
- case TYPE_INT: {
- constant_integer *ci;
-
- if (!(ci = class_getconstant(c, pindex, CONSTANT_Integer)))
- return false;
-
- f->value.i = ci->value;
- }
- break;
-
- case TYPE_LNG: {
- constant_long *cl;
-
- if (!(cl = class_getconstant(c, pindex, CONSTANT_Long)))
- return false;
-
- f->value.l = cl->value;
- }
- break;
-
- case TYPE_FLT: {
- constant_float *cf;
-
- if (!(cf = class_getconstant(c, pindex, CONSTANT_Float)))
- return false;
-
- f->value.f = cf->value;
- }
- break;
-
- case TYPE_DBL: {
- constant_double *cd;
-
- if (!(cd = class_getconstant(c, pindex, CONSTANT_Double)))
- return false;
-
- f->value.d = cd->value;
- }
- break;
-
- case TYPE_ADR:
- if (!(u = class_getconstant(c, pindex, CONSTANT_String)))
- return false;
-
- /* create javastring from compressed utf8-string */
- f->value.a = literalstring_new(u);
- break;
-
- default:
- log_text("Invalid Constant - Type");
- }
- }
-#if defined(ENABLE_JAVASE)
- else if (u == utf_Signature) {
- /* Signature */
-
- if (!loader_load_attribute_signature(cb, &(f->signature)))
- return false;
- }
-#endif
- else {
- /* unknown attribute */
-
- if (!loader_skip_attribute_body(cb))
- return false;
- }
- }
-
- /* everything was ok */
-
- return true;
-}
-
-
-/* loader_load_method **********************************************************
-
- Loads a method from the class file and fills an existing
- 'methodinfo' structure. For native methods, the function pointer
- field is set to the real function pointer, for JavaVM methods a
- pointer to the compiler is used preliminarily.
-
- method_info {
- u2 access_flags;
- u2 name_index;
- u2 descriptor_index;
- u2 attributes_count;
- attribute_info attributes[attribute_count];
- }
-
- attribute_info {
- u2 attribute_name_index;
- u4 attribute_length;
- u1 info[attribute_length];
- }
-
- LineNumberTable_attribute {
- u2 attribute_name_index;
- u4 attribute_length;
- u2 line_number_table_length;
- {
- u2 start_pc;
- u2 line_number;
- } line_number_table[line_number_table_length];
- }
-
-*******************************************************************************/
-
-static bool loader_load_method(classbuffer *cb, methodinfo *m,
- descriptor_pool *descpool)
-{
- classinfo *c;
- int argcount;
- s4 i, j, k, l;
- utf *u;
- u2 name_index;
- u2 descriptor_index;
- u2 attributes_count;
- u2 attribute_name_index;
- utf *attribute_name;
- u2 code_attributes_count;
- u2 code_attribute_name_index;
- utf *code_attribute_name;
-
- /* get classinfo */
-
- c = cb->class;
-
-#if defined(ENABLE_THREADS)
- lock_init_object_lock(&m->header);
-#endif
-
-#if defined(ENABLE_STATISTICS)
- if (opt_stat)
- count_all_methods++;
-#endif
-
- /* all fields of m have been zeroed in load_class_from_classbuffer */
-
- m->class = c;
-
- if (!suck_check_classbuffer_size(cb, 2 + 2 + 2))
- return false;
-
- /* access flags */
-
- m->flags = suck_u2(cb);
-
- /* name */
-
- name_index = suck_u2(cb);
-
- if (!(u = class_getconstant(c, name_index, CONSTANT_Utf8)))
- return false;
-
- m->name = u;
-
- /* descriptor */
-
- descriptor_index = suck_u2(cb);
-
- if (!(u = class_getconstant(c, descriptor_index, CONSTANT_Utf8)))
- return false;
-
- m->descriptor = u;
-
- if (!descriptor_pool_add(descpool, u, &argcount))
- return false;
-
-#ifdef ENABLE_VERIFIER
- if (opt_verify) {
- if (!is_valid_name_utf(m->name)) {
- exceptions_throw_classformaterror(c, "Method with invalid name");
- return false;
- }
-
- if (m->name->text[0] == '<' &&
- m->name != utf_init && m->name != utf_clinit) {
- exceptions_throw_classformaterror(c, "Method with invalid special name");
- return false;
- }
- }
-#endif /* ENABLE_VERIFIER */
-
- if (!(m->flags & ACC_STATIC))
- argcount++; /* count the 'this' argument */
-
-#ifdef ENABLE_VERIFIER
- if (opt_verify) {
- if (argcount > 255) {
- exceptions_throw_classformaterror(c, "Too many arguments in signature");
- return false;
- }
-
- /* check flag consistency */
- if (m->name != utf_clinit) {
- i = (m->flags & (ACC_PUBLIC | ACC_PRIVATE | ACC_PROTECTED));
-
- if (i != 0 && i != ACC_PUBLIC && i != ACC_PRIVATE && i != ACC_PROTECTED) {
- exceptions_throw_classformaterror(c,
- "Illegal method modifiers: 0x%X",
- m->flags);
- return false;
- }
-
- if (m->flags & ACC_ABSTRACT) {
- if ((m->flags & (ACC_FINAL | ACC_NATIVE | ACC_PRIVATE |
- ACC_STATIC | ACC_STRICT | ACC_SYNCHRONIZED))) {
- exceptions_throw_classformaterror(c,
- "Illegal method modifiers: 0x%X",
- m->flags);
- return false;
- }
- }
-
- if (c->flags & ACC_INTERFACE) {
- if ((m->flags & (ACC_ABSTRACT | ACC_PUBLIC)) != (ACC_ABSTRACT | ACC_PUBLIC)) {
- exceptions_throw_classformaterror(c,
- "Illegal method modifiers: 0x%X",
- m->flags);
- return false;
- }
- }
-
- if (m->name == utf_init) {
- if (m->flags & (ACC_STATIC | ACC_FINAL | ACC_SYNCHRONIZED |
- ACC_NATIVE | ACC_ABSTRACT)) {
- exceptions_throw_classformaterror(c, "Instance initialization method has invalid flags set");
- return false;
- }
- }
- }
- }
-#endif /* ENABLE_VERIFIER */
-
- /* mark the method as monomorphic until further notice */
-
- m->flags |= ACC_METHOD_MONOMORPHIC;
-
- /* non-abstract methods have an implementation in this class */
-
- if (!(m->flags & ACC_ABSTRACT))
- m->flags |= ACC_METHOD_IMPLEMENTED;
-
- if (!suck_check_classbuffer_size(cb, 2))
- return false;
-
- /* attributes count */
-
- attributes_count = suck_u2(cb);
-
- for (i = 0; i < attributes_count; i++) {
- if (!suck_check_classbuffer_size(cb, 2))
- return false;
-
- /* attribute name index */
-
- attribute_name_index = suck_u2(cb);
-
- if (!(attribute_name = class_getconstant(c, attribute_name_index, CONSTANT_Utf8)))
- return false;
-
- if (attribute_name == utf_Code) {
- /* Code */
- if (m->flags & (ACC_ABSTRACT | ACC_NATIVE)) {
- exceptions_throw_classformaterror(c, "Code attribute in native or abstract methods");
- return false;
- }
-
- if (m->jcode) {
- exceptions_throw_classformaterror(c, "Multiple Code attributes");
- return false;
- }
-
- if (!suck_check_classbuffer_size(cb, 4 + 2 + 2))
- return false;
-
- suck_u4(cb);
- m->maxstack = suck_u2(cb);
- m->maxlocals = suck_u2(cb);
-
- if (m->maxlocals < argcount) {
- exceptions_throw_classformaterror(c, "Arguments can't fit into locals");
- return false;
- }
-
- if (!suck_check_classbuffer_size(cb, 4))
- return false;
-
- m->jcodelength = suck_u4(cb);
-
- if (m->jcodelength == 0) {
- exceptions_throw_classformaterror(c, "Code of a method has length 0");
- return false;
- }
-
- if (m->jcodelength > 65535) {
- exceptions_throw_classformaterror(c, "Code of a method longer than 65535 bytes");
- return false;
- }
-
- if (!suck_check_classbuffer_size(cb, m->jcodelength))
- return false;
-
- m->jcode = MNEW(u1, m->jcodelength);
- suck_nbytes(m->jcode, cb, m->jcodelength);
-
- if (!suck_check_classbuffer_size(cb, 2))
- return false;
-
- m->rawexceptiontablelength = suck_u2(cb);
- if (!suck_check_classbuffer_size(cb, (2 + 2 + 2 + 2) * m->rawexceptiontablelength))
- return false;
-
- m->rawexceptiontable = MNEW(raw_exception_entry, m->rawexceptiontablelength);
-
-#if defined(ENABLE_STATISTICS)
- if (opt_stat) {
- count_vmcode_len += m->jcodelength + 18;
- count_extable_len +=
- m->rawexceptiontablelength * sizeof(raw_exception_entry);
- }
-#endif
-
- for (j = 0; j < m->rawexceptiontablelength; j++) {
- u4 idx;
- m->rawexceptiontable[j].startpc = suck_u2(cb);
- m->rawexceptiontable[j].endpc = suck_u2(cb);
- m->rawexceptiontable[j].handlerpc = suck_u2(cb);
-
- idx = suck_u2(cb);
- if (!idx) {
- m->rawexceptiontable[j].catchtype.any = NULL;
-
- } else {
- /* the classref is created later */
- if (!(m->rawexceptiontable[j].catchtype.any =
- (utf*)class_getconstant(c, idx, CONSTANT_Class)))
- return false;
- }
- }
-
- if (!suck_check_classbuffer_size(cb, 2))
- return false;
-
- /* code attributes count */
-
- code_attributes_count = suck_u2(cb);
-
- for (k = 0; k < code_attributes_count; k++) {
- if (!suck_check_classbuffer_size(cb, 2))
- return false;
-
- /* code attribute name index */
-
- code_attribute_name_index = suck_u2(cb);
-
- if (!(code_attribute_name = class_getconstant(c, code_attribute_name_index, CONSTANT_Utf8)))
- return false;
-
- /* check which code attribute */
-
- if (code_attribute_name == utf_LineNumberTable) {
- /* LineNumberTable */
- if (!suck_check_classbuffer_size(cb, 4 + 2))
- return false;
-
- /* attribute length */
-
- (void) suck_u4(cb);
-
- /* line number table length */
-
- m->linenumbercount = suck_u2(cb);
-
- if (!suck_check_classbuffer_size(cb,
- (2 + 2) * m->linenumbercount))
- return false;
-
- m->linenumbers = MNEW(lineinfo, m->linenumbercount);
-
-#if defined(ENABLE_STATISTICS)
- if (opt_stat)
- size_lineinfo += sizeof(lineinfo) * m->linenumbercount;
-#endif
-
- for (l = 0; l < m->linenumbercount; l++) {
- m->linenumbers[l].start_pc = suck_u2(cb);
- m->linenumbers[l].line_number = suck_u2(cb);
- }
- }
-#if defined(ENABLE_JAVASE)
- else if (code_attribute_name == utf_StackMapTable) {
- /* StackTableMap */
-
- if (!stackmap_load_attribute_stackmaptable(cb, m))
- return false;
- }
-#endif
- else {
- /* unknown code attribute */
-
- if (!loader_skip_attribute_body(cb))
- return false;
- }
- }
- }
- else if (attribute_name == utf_Exceptions) {
- /* Exceptions */
-
- if (m->thrownexceptions != NULL) {
- exceptions_throw_classformaterror(c, "Multiple Exceptions attributes");
- return false;
- }
-
- if (!suck_check_classbuffer_size(cb, 4 + 2))
- return false;
-
- /* attribute length */
-
- (void) suck_u4(cb);
-
- m->thrownexceptionscount = suck_u2(cb);
-
- if (!suck_check_classbuffer_size(cb, 2 * m->thrownexceptionscount))
- return false;
-
- m->thrownexceptions = MNEW(classref_or_classinfo, m->thrownexceptionscount);
-
- for (j = 0; j < m->thrownexceptionscount; j++) {
- /* the classref is created later */
- if (!((m->thrownexceptions)[j].any =
- (utf*) class_getconstant(c, suck_u2(cb), CONSTANT_Class)))
- return false;
- }
- }
-#if defined(ENABLE_JAVASE)
- else if (attribute_name == utf_Signature) {
- /* Signature */
-
- if (!loader_load_attribute_signature(cb, &(m->signature)))
- return false;
- }
-#endif
- else {
- /* unknown attribute */
-
- if (!loader_skip_attribute_body(cb))
- return false;
- }
- }
-
- if ((m->jcode == NULL) && !(m->flags & (ACC_ABSTRACT | ACC_NATIVE))) {
- exceptions_throw_classformaterror(c, "Missing Code attribute");
- return false;
- }
-
- /* initialize the hit countdown field */
-
-#if defined(ENABLE_REPLACEMENT)
- m->hitcountdown = METHOD_INITIAL_HIT_COUNTDOWN;
-#endif
-
- /* everything was ok */
-
- return true;
-}
-
-
/* load_class_from_sysloader ***************************************************
Load the class with the given name using the system class loader
The super class and the interfaces implemented by this class need
not be loaded. The link is set later by the function 'class_link'.
- The loaded class is removed from the list 'unloadedclasses' and
- added to the list 'unlinkedclasses'.
-
SYNCHRONIZATION:
This function is NOT synchronized!
#endif
for (i = 0; i < c->fieldscount; i++) {
- if (!load_field(cb, &(c->fields[i]),descpool))
+ if (!field_load(cb, &(c->fields[i]), descpool))
goto return_exception;
}
MZERO(c->methods, methodinfo, c->methodscount);
for (i = 0; i < c->methodscount; i++) {
- if (!loader_load_method(cb, &(c->methods[i]), descpool))
+ if (!method_load(cb, &(c->methods[i]), descpool))
goto return_exception;
}
assert(comp->state & CLASS_LOADED);
- if (opt_eager)
- if (!link_class(c))
- return NULL;
-
/* the array's flags are that of the component class */
c->flags = (comp->flags & ~ACC_INTERFACE) | ACC_FINAL | ACC_ABSTRACT;
c->classloader = comp->classloader;
assert(comp->state & CLASS_LOADED);
- if (opt_eager)
- if (!link_class(c))
- return NULL;
-
/* the array's flags are that of the component class */
c->flags = (comp->flags & ~ACC_INTERFACE) | ACC_FINAL | ACC_ABSTRACT;
c->classloader = comp->classloader;
c->super.cls = class_java_lang_Object;
#if defined(ENABLE_JAVASE)
- c->interfacescount = 2;
- c->interfaces = MNEW(classref_or_classinfo, 2);
- if (opt_eager) {
- classinfo *tc;
+ c->interfacescount = 2;
+ c->interfaces = MNEW(classref_or_classinfo, 2);
+ c->interfaces[0].cls = class_java_lang_Cloneable;
+ c->interfaces[1].cls = class_java_io_Serializable;
- tc = class_java_lang_Cloneable;
- assert(tc->state & CLASS_LOADED);
- list_add_first(&unlinkedclasses, tc);
- c->interfaces[0].cls = tc;
-
- tc = class_java_io_Serializable;
- assert(tc->state & CLASS_LOADED);
- list_add_first(&unlinkedclasses, tc);
- c->interfaces[1].cls = tc;
- }
- else {
- c->interfaces[0].cls = class_java_lang_Cloneable;
- c->interfaces[1].cls = class_java_io_Serializable;
- }
#elif defined(ENABLE_JAVAME_CLDC1_1)
- c->interfacescount = 0;
- c->interfaces = NULL;
+
+ c->interfacescount = 0;
+ c->interfaces = NULL;
+
#else
-#error unknow Java configuration
+# error unknow Java configuration
#endif
c->methodscount = 1;
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
- $Id: method.c 8123 2007-06-20 23:50:55Z michi $
+ $Id: method.c 8228 2007-07-24 12:37:25Z twisti $
*/
#include "config.h"
#include <assert.h>
+#include <stdint.h>
#include <stdio.h>
#include "vm/types.h"
#include "mm/memory.h"
+#include "threads/lock-common.h"
+
#include "vm/builtin.h"
+#include "vm/exceptions.h"
#include "vm/global.h"
#include "vm/resolve.h"
#include "vmcore/loader.h"
#include "vmcore/method.h"
#include "vmcore/options.h"
+#include "vmcore/suck.h"
#if !defined(NDEBUG) && defined(ENABLE_INLINING)
#endif
+/* method_load *****************************************************************
+
+ Loads a method from the class file and fills an existing methodinfo
+ structure.
+
+ method_info {
+ u2 access_flags;
+ u2 name_index;
+ u2 descriptor_index;
+ u2 attributes_count;
+ attribute_info attributes[attribute_count];
+ }
+
+ attribute_info {
+ u2 attribute_name_index;
+ u4 attribute_length;
+ u1 info[attribute_length];
+ }
+
+ LineNumberTable_attribute {
+ u2 attribute_name_index;
+ u4 attribute_length;
+ u2 line_number_table_length;
+ {
+ u2 start_pc;
+ u2 line_number;
+ } line_number_table[line_number_table_length];
+ }
+
+*******************************************************************************/
+
+bool method_load(classbuffer *cb, methodinfo *m, descriptor_pool *descpool)
+{
+ classinfo *c;
+ int argcount;
+ s4 i, j, k, l;
+ utf *u;
+ u2 name_index;
+ u2 descriptor_index;
+ u2 attributes_count;
+ u2 attribute_name_index;
+ utf *attribute_name;
+ u2 code_attributes_count;
+ u2 code_attribute_name_index;
+ utf *code_attribute_name;
+
+ /* get classinfo */
+
+ c = cb->class;
+
+ LOCK_INIT_OBJECT_LOCK(&(m->header));
+
+#if defined(ENABLE_STATISTICS)
+ if (opt_stat)
+ count_all_methods++;
+#endif
+
+ /* all fields of m have been zeroed in load_class_from_classbuffer */
+
+ m->class = c;
+
+ if (!suck_check_classbuffer_size(cb, 2 + 2 + 2))
+ return false;
+
+ /* access flags */
+
+ m->flags = suck_u2(cb);
+
+ /* name */
+
+ name_index = suck_u2(cb);
+
+ if (!(u = class_getconstant(c, name_index, CONSTANT_Utf8)))
+ return false;
+
+ m->name = u;
+
+ /* descriptor */
+
+ descriptor_index = suck_u2(cb);
+
+ if (!(u = class_getconstant(c, descriptor_index, CONSTANT_Utf8)))
+ return false;
+
+ m->descriptor = u;
+
+ if (!descriptor_pool_add(descpool, u, &argcount))
+ return false;
+
+#ifdef ENABLE_VERIFIER
+ if (opt_verify) {
+ if (!is_valid_name_utf(m->name)) {
+ exceptions_throw_classformaterror(c, "Method with invalid name");
+ return false;
+ }
+
+ if (m->name->text[0] == '<' &&
+ m->name != utf_init && m->name != utf_clinit) {
+ exceptions_throw_classformaterror(c, "Method with invalid special name");
+ return false;
+ }
+ }
+#endif /* ENABLE_VERIFIER */
+
+ if (!(m->flags & ACC_STATIC))
+ argcount++; /* count the 'this' argument */
+
+#ifdef ENABLE_VERIFIER
+ if (opt_verify) {
+ if (argcount > 255) {
+ exceptions_throw_classformaterror(c, "Too many arguments in signature");
+ return false;
+ }
+
+ /* check flag consistency */
+ if (m->name != utf_clinit) {
+ i = (m->flags & (ACC_PUBLIC | ACC_PRIVATE | ACC_PROTECTED));
+
+ if (i != 0 && i != ACC_PUBLIC && i != ACC_PRIVATE && i != ACC_PROTECTED) {
+ exceptions_throw_classformaterror(c,
+ "Illegal method modifiers: 0x%X",
+ m->flags);
+ return false;
+ }
+
+ if (m->flags & ACC_ABSTRACT) {
+ if ((m->flags & (ACC_FINAL | ACC_NATIVE | ACC_PRIVATE |
+ ACC_STATIC | ACC_STRICT | ACC_SYNCHRONIZED))) {
+ exceptions_throw_classformaterror(c,
+ "Illegal method modifiers: 0x%X",
+ m->flags);
+ return false;
+ }
+ }
+
+ if (c->flags & ACC_INTERFACE) {
+ if ((m->flags & (ACC_ABSTRACT | ACC_PUBLIC)) != (ACC_ABSTRACT | ACC_PUBLIC)) {
+ exceptions_throw_classformaterror(c,
+ "Illegal method modifiers: 0x%X",
+ m->flags);
+ return false;
+ }
+ }
+
+ if (m->name == utf_init) {
+ if (m->flags & (ACC_STATIC | ACC_FINAL | ACC_SYNCHRONIZED |
+ ACC_NATIVE | ACC_ABSTRACT)) {
+ exceptions_throw_classformaterror(c, "Instance initialization method has invalid flags set");
+ return false;
+ }
+ }
+ }
+ }
+#endif /* ENABLE_VERIFIER */
+
+ /* mark the method as monomorphic until further notice */
+
+ m->flags |= ACC_METHOD_MONOMORPHIC;
+
+ /* non-abstract methods have an implementation in this class */
+
+ if (!(m->flags & ACC_ABSTRACT))
+ m->flags |= ACC_METHOD_IMPLEMENTED;
+
+ if (!suck_check_classbuffer_size(cb, 2))
+ return false;
+
+ /* attributes count */
+
+ attributes_count = suck_u2(cb);
+
+ for (i = 0; i < attributes_count; i++) {
+ if (!suck_check_classbuffer_size(cb, 2))
+ return false;
+
+ /* attribute name index */
+
+ attribute_name_index = suck_u2(cb);
+
+ attribute_name =
+ class_getconstant(c, attribute_name_index, CONSTANT_Utf8);
+
+ if (attribute_name == NULL)
+ return false;
+
+ if (attribute_name == utf_Code) {
+ /* Code */
+
+ if (m->flags & (ACC_ABSTRACT | ACC_NATIVE)) {
+ exceptions_throw_classformaterror(c, "Code attribute in native or abstract methods");
+ return false;
+ }
+
+ if (m->jcode) {
+ exceptions_throw_classformaterror(c, "Multiple Code attributes");
+ return false;
+ }
+
+ if (!suck_check_classbuffer_size(cb, 4 + 2 + 2))
+ return false;
+
+ suck_u4(cb);
+ m->maxstack = suck_u2(cb);
+ m->maxlocals = suck_u2(cb);
+
+ if (m->maxlocals < argcount) {
+ exceptions_throw_classformaterror(c, "Arguments can't fit into locals");
+ return false;
+ }
+
+ if (!suck_check_classbuffer_size(cb, 4))
+ return false;
+
+ m->jcodelength = suck_u4(cb);
+
+ if (m->jcodelength == 0) {
+ exceptions_throw_classformaterror(c, "Code of a method has length 0");
+ return false;
+ }
+
+ if (m->jcodelength > 65535) {
+ exceptions_throw_classformaterror(c, "Code of a method longer than 65535 bytes");
+ return false;
+ }
+
+ if (!suck_check_classbuffer_size(cb, m->jcodelength))
+ return false;
+
+ m->jcode = MNEW(u1, m->jcodelength);
+ suck_nbytes(m->jcode, cb, m->jcodelength);
+
+ if (!suck_check_classbuffer_size(cb, 2))
+ return false;
+
+ m->rawexceptiontablelength = suck_u2(cb);
+ if (!suck_check_classbuffer_size(cb, (2 + 2 + 2 + 2) * m->rawexceptiontablelength))
+ return false;
+
+ m->rawexceptiontable = MNEW(raw_exception_entry, m->rawexceptiontablelength);
+
+#if defined(ENABLE_STATISTICS)
+ if (opt_stat) {
+ count_vmcode_len += m->jcodelength + 18;
+ count_extable_len +=
+ m->rawexceptiontablelength * sizeof(raw_exception_entry);
+ }
+#endif
+
+ for (j = 0; j < m->rawexceptiontablelength; j++) {
+ u4 idx;
+ m->rawexceptiontable[j].startpc = suck_u2(cb);
+ m->rawexceptiontable[j].endpc = suck_u2(cb);
+ m->rawexceptiontable[j].handlerpc = suck_u2(cb);
+
+ idx = suck_u2(cb);
+
+ if (!idx) {
+ m->rawexceptiontable[j].catchtype.any = NULL;
+ }
+ else {
+ /* the classref is created later */
+ if (!(m->rawexceptiontable[j].catchtype.any =
+ (utf *) class_getconstant(c, idx, CONSTANT_Class)))
+ return false;
+ }
+ }
+
+ if (!suck_check_classbuffer_size(cb, 2))
+ return false;
+
+ /* code attributes count */
+
+ code_attributes_count = suck_u2(cb);
+
+ for (k = 0; k < code_attributes_count; k++) {
+ if (!suck_check_classbuffer_size(cb, 2))
+ return false;
+
+ /* code attribute name index */
+
+ code_attribute_name_index = suck_u2(cb);
+
+ code_attribute_name =
+ class_getconstant(c, code_attribute_name_index, CONSTANT_Utf8);
+
+ if (code_attribute_name == NULL)
+ return false;
+
+ /* check which code attribute */
+
+ if (code_attribute_name == utf_LineNumberTable) {
+ /* LineNumberTable */
+
+ if (!suck_check_classbuffer_size(cb, 4 + 2))
+ return false;
+
+ /* attribute length */
+
+ (void) suck_u4(cb);
+
+ /* line number table length */
+
+ m->linenumbercount = suck_u2(cb);
+
+ if (!suck_check_classbuffer_size(cb,
+ (2 + 2) * m->linenumbercount))
+ return false;
+
+ m->linenumbers = MNEW(lineinfo, m->linenumbercount);
+
+#if defined(ENABLE_STATISTICS)
+ if (opt_stat)
+ size_lineinfo += sizeof(lineinfo) * m->linenumbercount;
+#endif
+
+ for (l = 0; l < m->linenumbercount; l++) {
+ m->linenumbers[l].start_pc = suck_u2(cb);
+ m->linenumbers[l].line_number = suck_u2(cb);
+ }
+ }
+#if defined(ENABLE_JAVASE)
+ else if (code_attribute_name == utf_StackMapTable) {
+ /* StackTableMap */
+
+ if (!stackmap_load_attribute_stackmaptable(cb, m))
+ return false;
+ }
+#endif
+ else {
+ /* unknown code attribute */
+
+ if (!loader_skip_attribute_body(cb))
+ return false;
+ }
+ }
+ }
+ else if (attribute_name == utf_Exceptions) {
+ /* Exceptions */
+
+ if (m->thrownexceptions != NULL) {
+ exceptions_throw_classformaterror(c, "Multiple Exceptions attributes");
+ return false;
+ }
+
+ if (!suck_check_classbuffer_size(cb, 4 + 2))
+ return false;
+
+ /* attribute length */
+
+ (void) suck_u4(cb);
+
+ m->thrownexceptionscount = suck_u2(cb);
+
+ if (!suck_check_classbuffer_size(cb, 2 * m->thrownexceptionscount))
+ return false;
+
+ m->thrownexceptions = MNEW(classref_or_classinfo, m->thrownexceptionscount);
+
+ for (j = 0; j < m->thrownexceptionscount; j++) {
+ /* the classref is created later */
+ if (!((m->thrownexceptions)[j].any =
+ (utf*) class_getconstant(c, suck_u2(cb), CONSTANT_Class)))
+ return false;
+ }
+ }
+#if defined(ENABLE_JAVASE)
+ else if (attribute_name == utf_Signature) {
+ /* Signature */
+
+ if (!loader_load_attribute_signature(cb, &(m->signature)))
+ return false;
+ }
+#endif
+ else {
+ /* unknown attribute */
+
+ if (!loader_skip_attribute_body(cb))
+ return false;
+ }
+ }
+
+ if ((m->jcode == NULL) && !(m->flags & (ACC_ABSTRACT | ACC_NATIVE))) {
+ exceptions_throw_classformaterror(c, "Missing Code attribute");
+ return false;
+ }
+
+#if defined(ENABLE_REPLACEMENT)
+ /* initialize the hit countdown field */
+
+ m->hitcountdown = METHOD_INITIAL_HIT_COUNTDOWN;
+#endif
+
+ /* everything was ok */
+
+ return true;
+}
+
+
/* method_free *****************************************************************
Frees all memory that was allocated for this method.
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
- $Id: method.h 8123 2007-06-20 23:50:55Z michi $
+ $Id: method.h 8231 2007-07-25 14:21:24Z twisti $
*/
#include "vmcore/descriptor.h"
#include "vmcore/references.h"
#include "vmcore/linker.h"
+#include "vmcore/loader.h"
#if defined(ENABLE_JAVASE)
# include "vmcore/stackmap.h"
/* function prototypes ********************************************************/
+bool method_load(classbuffer *cb, methodinfo *m, descriptor_pool *descpool);
void method_free(methodinfo *m);
bool method_canoverwrite(methodinfo *m, methodinfo *old);
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
- $Id: options.c 8174 2007-07-01 17:49:25Z twisti $
+ $Id: options.c 8236 2007-07-27 10:18:17Z twisti $
*/
#if defined(ENABLE_VERIFIER)
bool opt_verify = true; /* true if classfiles should be verified */
#endif
-bool opt_eager = false;
#if defined(ENABLE_PROFILING)
bool opt_prof = false;
#if defined(ENABLE_INLINING)
bool opt_inlining = false;
#if defined(ENABLE_INLINING_DEBUG) || !defined(NDEBUG)
-s4 opt_replace_verbose = 0;
s4 opt_inline_debug_min_size = 0;
s4 opt_inline_debug_max_size = INT_MAX;
s4 opt_inline_debug_end_counter = INT_MAX;
/* NOTE: For better readability keep these alpha-sorted. */
+int32_t opt_DebugStackFrameInfo = 0;
+int32_t opt_DebugStackTrace = 0;
int32_t opt_MaxPermSize = 0;
int32_t opt_PermSize = 0;
+int opt_PrintConfig = 0;
int32_t opt_ProfileGCMemoryUsage = 0;
int32_t opt_ProfileMemoryUsage = 0;
FILE *opt_ProfileMemoryUsageGNUPlot = NULL;
int32_t opt_ThreadStackSize = 0;
int32_t opt_TraceExceptions = 0;
+int32_t opt_TraceJavaCalls = 0;
+int32_t opt_TraceJNICalls = 0;
+int32_t opt_TraceJVMCalls = 0;
#if defined(ENABLE_REPLACEMENT)
int32_t opt_TraceReplacement = 0;
#endif
enum {
+ OPT_TYPE_BOOLEAN,
+ OPT_TYPE_VALUE
+};
+
+enum {
+ OPT_DebugStackFrameInfo,
+ OPT_DebugStackTrace,
OPT_MaxPermSize,
OPT_PermSize,
+ OPT_PrintConfig,
OPT_ProfileGCMemoryUsage,
OPT_ProfileMemoryUsage,
OPT_ProfileMemoryUsageGNUPlot,
OPT_ThreadStackSize,
OPT_TraceExceptions,
+ OPT_TraceJavaCalls,
+ OPT_TraceJNICalls,
+ OPT_TraceJVMCalls,
OPT_TraceReplacement
};
option_t options_XX[] = {
- { "MaxPermSize", OPT_MaxPermSize, "" },
- { "PermSize", OPT_PermSize, "" },
- { "ProfileGCMemoryUsage", OPT_ProfileGCMemoryUsage, "" },
- { "ProfileMemoryUsage", OPT_ProfileMemoryUsage, "" },
- { "ProfileMemoryUsageGNUPlot", OPT_ProfileMemoryUsageGNUPlot, "" },
- { "ThreadStackSize", OPT_ThreadStackSize, "" },
- { "TraceExceptions", OPT_TraceExceptions, "" },
+ { "DebugStackFrameInfo", OPT_DebugStackFrameInfo, OPT_TYPE_BOOLEAN, "TODO" },
+ { "DebugStackTrace", OPT_DebugStackTrace, OPT_TYPE_BOOLEAN, "TODO" },
+ { "MaxPermSize", OPT_MaxPermSize, OPT_TYPE_VALUE, "not implemented" },
+ { "PermSize", OPT_PermSize, OPT_TYPE_VALUE, "not implemented" },
+ { "PrintConfig", OPT_PrintConfig, OPT_TYPE_BOOLEAN, "print VM configuration" },
+ { "ProfileGCMemoryUsage", OPT_ProfileGCMemoryUsage, OPT_TYPE_VALUE, "profiles GC memory usage in the given interval, <value> is in seconds (default: 5)" },
+ { "ProfileMemoryUsage", OPT_ProfileMemoryUsage, OPT_TYPE_VALUE, "TODO" },
+ { "ProfileMemoryUsageGNUPlot", OPT_ProfileMemoryUsageGNUPlot, OPT_TYPE_VALUE, "TODO" },
+ { "ThreadStackSize", OPT_ThreadStackSize, OPT_TYPE_VALUE, "TODO" },
+ { "TraceExceptions", OPT_TraceExceptions, OPT_TYPE_BOOLEAN, "TODO" },
+ { "TraceJavaCalls", OPT_TraceJavaCalls, OPT_TYPE_BOOLEAN, "trace Java method calls" },
+ { "TraceJNICalls", OPT_TraceJNICalls, OPT_TYPE_BOOLEAN, "trace JNI method calls" },
+ { "TraceJVMCalls", OPT_TraceJVMCalls, OPT_TYPE_BOOLEAN, "TODO" },
#if defined(ENABLE_REPLACEMENT)
- { "TraceReplacement", OPT_TraceReplacement, "" },
+ { "TraceReplacement", OPT_TraceReplacement, OPT_TYPE_VALUE, "trace on-stack replacement with the given verbosity level (default: 1)" },
#endif
+
+ /* end marker */
+
+ { NULL, -1, -1, NULL }
};
}
+/* options_xxusage *************************************************************
+
+ Print usage message for debugging options.
+
+*******************************************************************************/
+
+static void options_xxusage(void)
+{
+ option_t *opt;
+ int length;
+ int i;
+ char *c;
+
+ for (opt = options_XX; opt->name != NULL; opt++) {
+ printf(" -XX:");
+
+ switch (opt->type) {
+ case OPT_TYPE_BOOLEAN:
+ printf("+%s", opt->name);
+ length = strlen(" -XX:+") + strlen(opt->name);
+ break;
+ case OPT_TYPE_VALUE:
+ printf("%s=<value>", opt->name);
+ length = strlen(" -XX:") + strlen(opt->name) + strlen("=<value>");
+ break;
+ }
+
+ /* Check if the help fits into one 80-column line.
+ Documentation starts at column 29. */
+
+ if (length < (29 - 1)) {
+ /* Print missing spaces up to column 29. */
+
+ for (i = length; i < 29; i++)
+ printf(" ");
+ }
+ else {
+ printf("\n");
+ printf(" "); /* 29 spaces */
+ }
+
+ /* Check documentation length. */
+
+ length = strlen(opt->doc);
+
+ if (length < (80 - 29)) {
+ printf("%s", opt->doc);
+ }
+ else {
+ for (c = opt->doc, i = 29; *c != 0; c++, i++) {
+ /* If we are at the end of the line, break it. */
+
+ if (i == 80) {
+ printf("\n");
+ printf(" "); /* 29 spaces */
+ i = 29;
+ }
+
+ printf("%c", *c);
+ }
+ }
+
+ printf("\n");
+ }
+
+ /* exit with error code */
+
+ exit(1);
+}
+
+
/* options_xx ******************************************************************
Handle -XX: options.
{
const char *start;
char *end;
- int32_t length;
- int32_t enable;
+ int length;
+ int enable;
char *value;
- int32_t option;
+ option_t *opt;
char *filename;
FILE *file;
- int32_t i;
+
+ /* Check for help (-XX), in this case name is NULL. */
+
+ if (name == NULL)
+ options_xxusage();
/* Check if the option is a boolean option. */
/* search the option in the option array */
- option = OPT_ERROR;
+ for (opt = options_XX; opt->name != NULL; opt++) {
+ if (strncmp(opt->name, start, length) == 0) {
+ /* Check if the options passed fits to the type. */
+
+ switch (opt->type) {
+ case OPT_TYPE_BOOLEAN:
+ if ((enable == -1) || (value != NULL))
+ options_xxusage();
+ break;
+ case OPT_TYPE_VALUE:
+ if ((enable != -1) || (value == NULL))
+ options_xxusage();
+ break;
+ default:
+ vm_abort("options_xx: unknown option type %d for option %s",
+ opt->type, opt->name);
+ }
- for (i = 0; options_XX[i].name != NULL; i++) {
- if (strncmp(options_XX[i].name, start, length) == 0) {
- option = options_XX[i].option;
break;
}
}
/* process the option */
- switch (option) {
+ switch (opt->value) {
+ case OPT_DebugStackFrameInfo:
+ opt_DebugStackFrameInfo = enable;
+ break;
+
+ case OPT_DebugStackTrace:
+ opt_DebugStackTrace = enable;
+ break;
+
case OPT_MaxPermSize:
/* currently ignored */
break;
/* currently ignored */
break;
+ case OPT_PrintConfig:
+ vm_printconfig();
+ break;
+
case OPT_ProfileGCMemoryUsage:
if (value == NULL)
opt_ProfileGCMemoryUsage = 5;
opt_TraceExceptions = enable;
break;
+ case OPT_TraceJavaCalls:
+ opt_verbosecall = enable;
+ opt_TraceJavaCalls = enable;
+ break;
+
+ case OPT_TraceJNICalls:
+ opt_TraceJNICalls = enable;
+ break;
+
+ case OPT_TraceJVMCalls:
+ opt_TraceJVMCalls = enable;
+ break;
+
#if defined(ENABLE_REPLACEMENT)
case OPT_TraceReplacement:
if (value == NULL)
#endif
default:
- printf("Unknown option: -XX:%s\n", name);
+ printf("Unknown -XX option: %s\n", name);
break;
}
}
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
- $Id: options.h 8134 2007-06-22 14:49:10Z twisti $
+ $Id: options.h 8236 2007-07-27 10:18:17Z twisti $
*/
typedef struct option_t option_t;
struct option_t {
- char *name;
- int32_t option;
- char *doc;
+ char *name;
+ int value;
+ int type;
+ char *doc;
};
#if defined(ENABLE_VERIFIER)
extern bool opt_verify;
#endif
-extern bool opt_eager;
#if defined(ENABLE_PROFILING)
extern bool opt_prof;
#if defined(ENABLE_INLINING)
extern bool opt_inlining;
#if defined(ENABLE_INLINING_DEBUG) || !defined(NDEBUG)
-extern s4 opt_replace_verbose;
extern s4 opt_inline_debug_min_size;
extern s4 opt_inline_debug_max_size;
extern s4 opt_inline_debug_end_counter;
/* NOTE: For better readability keep these alpha-sorted. */
+extern int32_t opt_DebugStackFrameInfo;
+extern int32_t opt_DebugStackTrace;
extern int32_t opt_MaxPermSize;
extern int32_t opt_PermSize;
+extern int opt_PrintConfig;
extern int32_t opt_ProfileGCMemoryUsage;
extern int32_t opt_ProfileMemoryUsage;
extern FILE *opt_ProfileMemoryUsageGNUPlot;
extern int32_t opt_ThreadStackSize;
extern int32_t opt_TraceExceptions;
+extern int32_t opt_TraceJavaCalls;
+extern int32_t opt_TraceJNICalls;
+extern int32_t opt_TraceJVMCalls;
#if defined(ENABLE_REPLACEMENT)
extern int32_t opt_TraceReplacement;
#endif
#include "config.h"
#include <assert.h>
-
-#include "vm/types.h"
+#include <stdint.h>
#include "vm/global.h"
utf *name;
classinfo *c;
utf *u;
- s4 i;
+ int i;
for (i = 0; i < PRIMITIVETYPE_COUNT; i++) {
/* skip dummies */
}
-/* primitive_class_is_primitive ************************************************
-
- Check if the given class is a primitive class.
-
-*******************************************************************************/
-
-bool primitive_class_is_primitive(classinfo *c)
-{
- s4 i;
-
- /* search table of primitive classes */
-
- for (i = 0; i < PRIMITIVETYPE_COUNT; i++)
- if (primitivetype_table[i].class_primitive == c)
- return true;
-
- return false;
-}
-
-
/* primitive_class_get_by_name *************************************************
Returns the primitive class of the given class name.
classinfo *primitive_class_get_by_name(utf *name)
{
- s4 i;
+ int i;
/* search table of primitive classes */
*******************************************************************************/
-classinfo *primitive_class_get_by_type(s4 type)
+classinfo *primitive_class_get_by_type(int32_t type)
{
return primitivetype_table[type].class_primitive;
}
classinfo *primitive_class_get_by_char(char ch)
{
- s4 index;
+ int32_t index;
switch (ch) {
case 'I':
}
+/* primitive_arrayclass_get_by_name ********************************************
+
+ Returns the primitive array-class of the given primitive class
+ name.
+
+*******************************************************************************/
+
+classinfo *primitive_arrayclass_get_by_name(utf *name)
+{
+ int i;
+
+ /* search table of primitive classes */
+
+ for (i = 0; i < PRIMITIVETYPE_COUNT; i++)
+ if (primitivetype_table[i].name == name)
+ return primitivetype_table[i].arrayclass;
+
+ /* keep compiler happy */
+
+ return NULL;
+}
+
+
/* primitive_arrayclass_get_by_type ********************************************
Returns the primitive array-class of the given type.
*******************************************************************************/
-classinfo *primitive_arrayclass_get_by_type(s4 type)
+classinfo *primitive_arrayclass_get_by_type(int32_t type)
{
return primitivetype_table[type].arrayclass;
}
#include "config.h"
+#include <stdint.h>
+
#include "vm/global.h"
#include "vmcore/class.h"
/* function prototypes ********************************************************/
bool primitive_init(void);
-bool primitive_class_is_primitive(classinfo *c);
classinfo *primitive_class_get_by_name(utf *name);
-classinfo *primitive_class_get_by_type(s4 type);
+classinfo *primitive_class_get_by_type(int32_t type);
classinfo *primitive_class_get_by_char(char ch);
-classinfo *primitive_arrayclass_get_by_type(s4 type);
+classinfo *primitive_arrayclass_get_by_name(utf *name);
+classinfo *primitive_arrayclass_get_by_type(int32_t type);
#endif /* _PRIMITIVE_H */
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
- $Id: statistics.c 8123 2007-06-20 23:50:55Z michi $
+ $Id: statistics.c 8199 2007-07-13 00:39:49Z michi $
*/
s4 size_lock_hashtable = 0;
s4 size_lock_waiter = 0;
+s4 size_patchref = 0;
+
u8 count_calls_java_to_native = 0;
u8 count_calls_native_to_java = 0;
log_println("lock record: %10d", size_lock_record);
log_println("lock hashtable: %10d", size_lock_hashtable);
log_println("lock waiter: %10d", size_lock_waiter);
+ log_println("patcher references: %10d", size_patchref);
log_println(" ----------");
sum =
size_threadobject +
size_lock_record +
size_lock_hashtable +
- size_lock_waiter;
+ size_lock_waiter +
+ size_patchref;
log_println(" %10d", sum);
log_println("");
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
- $Id: statistics.h 8123 2007-06-20 23:50:55Z michi $
+ $Id: statistics.h 8199 2007-07-13 00:39:49Z michi $
*/
extern s4 size_lock_hashtable;
extern s4 size_lock_waiter;
+extern s4 size_patchref;
+
extern u8 count_calls_java_to_native;
extern u8 count_calls_native_to_java;
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
- $Id: suck.c 7813 2007-04-25 19:20:13Z twisti $
+ $Id: suck.c 8236 2007-07-27 10:18:17Z twisti $
*/
/* (We use `free` as the memory came from the C library.) */
free(namelist[i]);
+
+#if defined(ENABLE_JAVASE)
+ properties_add("java.boot.class.path", _Jv_bootclasspath);
+ properties_add("sun.boot.class.path", _Jv_bootclasspath);
+#endif
}
}