From: Michael Starzinger Date: Mon, 16 Mar 2009 19:45:58 +0000 (+0100) Subject: Merged with michi branch at rev 1684fe51cf3d. X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=commitdiff_plain;h=6e920e48a314cfed80ff5db1b026c28049cba600;hp=-c;p=cacao.git Merged with michi branch at rev 1684fe51cf3d. --- 6e920e48a314cfed80ff5db1b026c28049cba600 diff --combined src/native/jni.cpp index e048a216d,34c090d4c..d33892469 --- a/src/native/jni.cpp +++ b/src/native/jni.cpp @@@ -793,7 -793,9 +793,7 @@@ jint _Jv_JNI_GetVersion(JNIEnv *env { TRACEJNICALLS(("_Jv_JNI_GetVersion(env=%p)", env)); - /* We support JNI 1.6. */ - - return JNI_VERSION_1_6; + return JNI_VERSION_SUPPORTED; } @@@ -2482,22 -2484,25 +2482,25 @@@ void _Jv_JNI_SetStaticObjectField(JNIEn jstring jni_NewString(JNIEnv *env, const jchar *buf, jsize len) { TRACEJNICALLS(("jni_NewString(env=%p, buf=%p, len=%d)", env, buf, len)); - - java_handle_chararray_t* a = builtin_newarray_char(len); - if (a == NULL) + CharArray ca(len); + + if (ca.is_null()) return NULL; /* copy text */ + + // XXX: Fix me! + uint16_t* ptr = (uint16_t*) ca.get_raw_data_ptr(); for (jsize i = 0; i < len; i++) - LLNI_array_direct(a, i) = buf[i]; + ptr[i] = buf[i]; java_handle_t* h = builtin_new(class_java_lang_String); if (h == NULL) return NULL; - java_lang_String s(h, a, len, 0); + java_lang_String s(h, ca.get_handle(), len, 0); return (jstring) jni_NewLocalRef(env, (jobject) s.get_handle()); } @@@ -2545,11 -2550,12 +2548,12 @@@ const jchar* jni_GetStringChars(JNIEnv java_lang_String s(str); - java_handle_chararray_t* ca = s.get_value(); - int32_t count = s.get_count(); - int32_t offset = s.get_offset(); + CharArray ca(s.get_value()); + + int32_t count = s.get_count(); + int32_t offset = s.get_offset(); - if (ca == NULL) + if (ca.is_null()) return NULL; /* allocate memory */ @@@ -2558,8 -2564,10 +2562,10 @@@ /* copy text */ + // XXX: Fix me! + uint16_t* ptr = (uint16_t*) ca.get_raw_data_ptr(); for (i = 0; i < count; i++) - stringbuffer[i] = LLNI_array_direct(ca, offset + i); + stringbuffer[i] = ptr[offset + i]; /* terminate string */ @@@ -2619,11 -2627,12 +2625,12 @@@ jsize jni_GetStringUTFLength(JNIEnv *en TRACEJNICALLS(("jni_GetStringUTFLength(env=%p, string=%p)", env, string)); java_lang_String s(string); - java_handle_chararray_t* ca = s.get_value(); - int32_t count = s.get_count(); + CharArray ca(s.get_value()); + int32_t count = s.get_count(); // FIXME GC critical section! - int32_t length = u2_utflength(ca->data, count); + uint16_t* ptr = (uint16_t*) ca.get_raw_data_ptr(); + int32_t length = u2_utflength(ptr, count); return length; } @@@ -2687,14 -2696,11 +2694,11 @@@ void _Jv_JNI_ReleaseStringUTFChars(JNIE jsize _Jv_JNI_GetArrayLength(JNIEnv *env, jarray array) { - java_handle_t *a; - jsize size; - TRACEJNICALLS(("_Jv_JNI_GetArrayLength(env=%p, array=%p)", env, array)); - a = (java_handle_t *) array; + Array a(array); - size = LLNI_array_size(a); + jsize size = a.get_length(); return size; } @@@ -2710,10 -2716,9 +2714,9 @@@ jobjectArray _Jv_JNI_NewObjectArray(JNIEnv *env, jsize length, jclass elementClass, jobject initialElement) { - classinfo *c; - java_handle_t *o; - java_handle_objectarray_t *oa; - s4 i; + classinfo* c; + java_handle_t* o; + s4 i; STATISTICS(jniinvokation()); @@@ -2725,36 -2730,33 +2728,33 @@@ return NULL; } - oa = builtin_anewarray(length, c); + ObjectArray oa(length, c); - if (oa == NULL) + if (oa.is_null()) return NULL; /* set all elements to initialElement */ for (i = 0; i < length; i++) - array_objectarray_element_set(oa, i, o); + oa.set_element(i, o); - return (jobjectArray) jni_NewLocalRef(env, (jobject) oa); + return (jobjectArray) jni_NewLocalRef(env, (jobject) oa.get_handle()); } jobject _Jv_JNI_GetObjectArrayElement(JNIEnv *env, jobjectArray array, jsize index) { - java_handle_objectarray_t *oa; - java_handle_t *o; - STATISTICS(jniinvokation()); - oa = (java_handle_objectarray_t *) array; + ObjectArray oa(array); - if (index >= LLNI_array_size(oa)) { + if (index >= oa.get_length()) { exceptions_throw_arrayindexoutofboundsexception(); return NULL; } - o = array_objectarray_element_get(oa, index); + java_handle_t* o = oa.get_element(index); return jni_NewLocalRef(env, (jobject) o); } @@@ -2763,15 -2765,11 +2763,11 @@@ void _Jv_JNI_SetObjectArrayElement(JNIEnv *env, jobjectArray array, jsize index, jobject val) { - java_handle_objectarray_t *oa; - java_handle_t *o; - STATISTICS(jniinvokation()); - oa = (java_handle_objectarray_t *) array; - o = (java_handle_t *) val; + ObjectArray oa(array); - if (index >= LLNI_array_size(oa)) { + if (index >= oa.get_length()) { exceptions_throw_arrayindexoutofboundsexception(); return; } @@@ -2779,18 -2777,18 +2775,18 @@@ /* check if the class of value is a subclass of the element class of the array */ - if (!builtin_canstore(oa, o)) + java_handle_t* o = (java_handle_t *) val; + + if (!builtin_canstore(oa.get_handle(), o)) return; - array_objectarray_element_set(oa, index, o); + oa.set_element(index, o); } - #define JNI_NEW_ARRAY(name, type, intern) \ + #define JNI_NEW_ARRAY(name, type) \ type _Jv_JNI_New##name##Array(JNIEnv *env, jsize len) \ { \ - java_handle_##intern##array_t *a; \ - \ STATISTICS(jniinvokation()); \ \ if (len < 0) { \ @@@ -2798,19 -2796,20 +2794,20 @@@ return NULL; \ } \ \ - a = builtin_newarray_##intern(len); \ + name##Array a(len); \ \ - return (type) jni_NewLocalRef(env, (jobject) a); \ + return (type) jni_NewLocalRef(env, \ + (jobject) a.get_handle()); \ } - JNI_NEW_ARRAY(Boolean, jbooleanArray, boolean) - JNI_NEW_ARRAY(Byte, jbyteArray, byte) - JNI_NEW_ARRAY(Char, jcharArray, char) - JNI_NEW_ARRAY(Short, jshortArray, short) - JNI_NEW_ARRAY(Int, jintArray, int) - JNI_NEW_ARRAY(Long, jlongArray, long) - JNI_NEW_ARRAY(Float, jfloatArray, float) - JNI_NEW_ARRAY(Double, jdoubleArray, double) + JNI_NEW_ARRAY(Boolean, jbooleanArray) + JNI_NEW_ARRAY(Byte, jbyteArray) + JNI_NEW_ARRAY(Char, jcharArray) + JNI_NEW_ARRAY(Short, jshortArray) + JNI_NEW_ARRAY(Int, jintArray) + JNI_NEW_ARRAY(Long, jlongArray) + JNI_NEW_ARRAY(Float, jfloatArray) + JNI_NEW_ARRAY(Double, jdoubleArray) /* GetArrayElements ********************************************* @@@ -2823,16 -2822,14 +2820,14 @@@ type *_Jv_JNI_Get##name##ArrayElements(JNIEnv *env, type##Array array, \ jboolean *isCopy) \ { \ - java_handle_##intern##array_t *a; \ - \ TRACEJNICALLS(("_Jv_JNI_Get" STR(name) "ArrayElements(env=%p, array=%p, isCopy=%d)", env, array, isCopy)); \ \ - a = (java_handle_##intern##array_t *) array; \ + name##Array a(array); \ \ if (isCopy) \ *isCopy = JNI_FALSE; \ \ - return (type *) LLNI_array_data(a); \ + return (type *) a.get_raw_data_ptr(); \ } JNI_GET_ARRAY_ELEMENTS(Boolean, jboolean, boolean) @@@ -2860,19 -2857,17 +2855,17 @@@ JNI_GET_ARRAY_ELEMENTS(Double, jdouble void _Jv_JNI_Release##name##ArrayElements(JNIEnv *env, type##Array array, \ type *elems, jint mode) \ { \ - java_handle_##intern##array_t *a; \ - \ STATISTICS(jniinvokation()); \ \ - a = (java_handle_##intern##array_t *) array; \ + name##Array a(array); \ \ - if (elems != (type *) LLNI_array_data(a)) { \ + if (elems != (type *) a.get_raw_data_ptr()) { \ switch (mode) { \ case JNI_COMMIT: \ - MCOPY(LLNI_array_data(a), elems, intern2, LLNI_array_size(a)); \ + a.set_region(0, a.get_length(), (intern2 *) elems); \ break; \ case 0: \ - MCOPY(LLNI_array_data(a), elems, intern2, LLNI_array_size(a)); \ + a.set_region(0, a.get_length(), (intern2 *) elems); \ /* XXX TWISTI how should it be freed? */ \ break; \ case JNI_ABORT: \ @@@ -2903,16 -2898,14 +2896,14 @@@ JNI_RELEASE_ARRAY_ELEMENTS(Double, jdo void _Jv_JNI_Get##name##ArrayRegion(JNIEnv *env, type##Array array, \ jsize start, jsize len, type *buf) \ { \ - java_handle_##intern##array_t *a; \ - \ TRACEJNICALLS(("_Jv_JNI_Get" STR(name) "ArrayRegion(env=%p, array=%p, start=%d, len=%d, buf=%p)", env, array, start, len, buf)); \ \ - a = (java_handle_##intern##array_t *) array; \ + name##Array a(array); \ \ - if ((start < 0) || (len < 0) || (start + len > LLNI_array_size(a))) \ + if ((start < 0) || (len < 0) || (start + len > a.get_length())) \ exceptions_throw_arrayindexoutofboundsexception(); \ else \ - MCOPY(buf, &LLNI_array_direct(a, start), intern2, len); \ + a.get_region(start, len, (intern2 *) buf); \ } JNI_GET_ARRAY_REGION(Boolean, jboolean, boolean, u1) @@@ -2936,16 -2929,14 +2927,14 @@@ JNI_GET_ARRAY_REGION(Double, jdouble void _Jv_JNI_Set##name##ArrayRegion(JNIEnv *env, type##Array array, \ jsize start, jsize len, const type *buf) \ { \ - java_handle_##intern##array_t *a; \ - \ STATISTICS(jniinvokation()); \ \ - a = (java_handle_##intern##array_t *) array; \ + name##Array a(array); \ \ - if ((start < 0) || (len < 0) || (start + len > LLNI_array_size(a))) \ + if ((start < 0) || (len < 0) || (start + len > a.get_length())) \ exceptions_throw_arrayindexoutofboundsexception(); \ else \ - MCOPY(&LLNI_array_direct(a, start), buf, intern2, len); \ + a.set_region(start, len, (intern2 *) buf); \ } JNI_SET_ARRAY_REGION(Boolean, jboolean, boolean, u1) @@@ -3092,15 -3083,15 +3081,15 @@@ jint _Jv_JNI_GetJavaVM(JNIEnv *env, Jav void jni_GetStringRegion(JNIEnv* env, jstring str, jsize start, jsize len, jchar *buf) { java_lang_String s(str); - java_handle_chararray_t* ca = s.get_value(); - int32_t count = s.get_count(); + CharArray ca(s.get_value()); + int32_t count = s.get_count(); if ((start < 0) || (len < 0) || (start > count) || (start + len > count)) { exceptions_throw_stringindexoutofboundsexception(); return; } - MCOPY(buf, &LLNI_array_direct(ca, start), u2, len); + ca.get_region(start, len, buf); } @@@ -3119,9 -3110,11 +3108,11 @@@ void jni_GetStringUTFRegion(JNIEnv* env TRACEJNICALLS(("jni_GetStringUTFRegion(env=%p, str=%p, start=%d, len=%d, buf=%p)", env, str, start, len, buf)); java_lang_String s(str); - java_handle_chararray_t* ca = s.get_value(); - int32_t count = s.get_count(); - int32_t offset = s.get_offset(); + + CharArray ca(s.get_value()); + + int32_t count = s.get_count(); + int32_t offset = s.get_offset(); if ((start < 0) || (len < 0) || (start > count) || (start + len > count)) { exceptions_throw_stringindexoutofboundsexception(); @@@ -3130,8 -3123,10 +3121,10 @@@ int32_t i; + // XXX: Fix me! + uint16_t* ptr = (uint16_t*) ca.get_raw_data_ptr(); for (i = 0; i < len; i++) - buf[i] = LLNI_array_direct(ca, offset + start + i); + buf[i] = ptr[offset + start + i]; buf[i] = '\0'; } @@@ -4123,28 -4118,22 +4116,28 @@@ jint JNI_GetDefaultJavaVMInitArgs(void /* GNU classpath currently supports JNI 1.2 */ switch (_vm_args->version) { - case JNI_VERSION_1_1: + case JNI_VERSION_1_1: _vm_args->version = JNI_VERSION_1_1; break; - case JNI_VERSION_1_2: - case JNI_VERSION_1_4: + case JNI_VERSION_1_2: + case JNI_VERSION_1_4: _vm_args->ignoreUnrecognized = JNI_FALSE; _vm_args->options = NULL; _vm_args->nOptions = 0; break; - default: - return -1; + case JNI_VERSION_CACAO: + // We reveal ourselves by accepting this version number, + // this actually means we are using the supported JNI version. + _vm_args->version = JNI_VERSION_SUPPORTED; + break; + + default: + return JNI_ERR; } - - return 0; + + return JNI_OK; } diff --combined src/native/vm/cldc1.1/com_sun_cldc_io_ResourceInputStream.cpp index ac12cc835,81742ad62..bdfaf37b1 --- a/src/native/vm/cldc1.1/com_sun_cldc_io_ResourceInputStream.cpp +++ b/src/native/vm/cldc1.1/com_sun_cldc_io_ResourceInputStream.cpp @@@ -34,7 -34,6 +34,6 @@@ #include "mm/memory.hpp" #include "native/jni.hpp" - #include "native/llni.h" #include "native/native.hpp" #if defined(ENABLE_JNI_HEADERS) @@@ -193,10 -192,7 +192,10 @@@ JNIEXPORT jobject JNICALL Java_com_sun_ char *path; utf *uname; java_handle_t* descriptor; - + + // Get current list of classpath entries. + SuckClasspath& suckclasspath = VM::get_current()->get_suckclasspath(); + /* get the classname as char string (do it here for the warning at the end of the function) */ @@@ -204,10 -200,10 +203,10 @@@ filenamelen = utf_bytes(uname) + strlen("0"); filename = MNEW(char, filenamelen); utf_copy(filename, uname); - + /* walk through all classpath entries */ - for (List::iterator it = list_classpath_entries->begin(); it != list_classpath_entries->end(); it++) { + for (SuckClasspath::iterator it = suckclasspath.begin(); it != suckclasspath.end(); it++) { list_classpath_entry* lce = *it; #if defined(ENABLE_ZLIB) @@@ -305,8 -301,9 +304,9 @@@ JNIEXPORT jint JNICALL Java_com_sun_cld { /* get pointer to the buffer */ // XXX Not GC safe. - void* buf = &(LLNI_array_direct((java_handle_bytearray_t*) byteArray, off)); - + ByteArray ba(byteArray); + void* buf = (void*) (((int8_t*) ba.get_raw_data_ptr()) + off); + com_sun_cldchi_jvm_FileDescriptor fd(jobj); int64_t filep = fd.get_pointer(); diff --combined src/native/vm/cldc1.1/com_sun_cldc_io_j2me_socket_Protocol.cpp index 860d88d5d,856745cfb..02caed9ee --- a/src/native/vm/cldc1.1/com_sun_cldc_io_j2me_socket_Protocol.cpp +++ b/src/native/vm/cldc1.1/com_sun_cldc_io_j2me_socket_Protocol.cpp @@@ -37,7 -37,6 +37,6 @@@ #include "mm/memory.hpp" #include "native/jni.hpp" - #include "native/llni.h" #include "native/native.hpp" #if defined(ENABLE_JNI_HEADERS) @@@ -45,7 -44,6 +44,7 @@@ #endif #include "vm/global.h" +#include "vm/os.hpp" #include "vm/vm.hpp" /* REMOVE ME: temporarily */ @@@ -64,7 -62,8 +63,8 @@@ JNIEXPORT jint JNICALL Java_com_sun_cld // The hostname byte-array is a NULL terminated C-string. // XXX Not GC safe. - char* name = (char*) &(LLNI_array_data((java_handle_bytearray_t*) hostname)); + ByteArray ba(hostname); + char* name = (char*) ba.get_raw_data_ptr(); /* get the host */ @@@ -107,7 -106,8 +107,8 @@@ JNIEXPORT jint JNICALL Java_com_sun_cld { // Get pointer to the buffer. // XXX Not GC safe. - void* buf = &(LLNI_array_direct((java_handle_bytearray_t*) b, off)); + ByteArray ba(b); + void* buf = (void*) (((int8_t*) ba.get_raw_data_ptr()) + off); // Receive from the socket. ssize_t result = recv(handle, buf, len, 0); @@@ -117,7 -117,7 +118,7 @@@ return -1; } else if (result < 0) { - vm_abort_errno("Java_com_sun_cldc_io_j2me_socket_Protocol_readBuf: recv failed"); + os::abort_errno("Java_com_sun_cldc_io_j2me_socket_Protocol_readBuf: recv failed"); } return result; @@@ -142,7 -142,7 +143,7 @@@ JNIEXPORT jint JNICALL Java_com_sun_cld } else if (result < 0) { // TODO Should throw an IOException. - vm_abort_errno("Java_com_sun_cldc_io_j2me_socket_Protocol_readByte: recv failed"); + os::abort_errno("Java_com_sun_cldc_io_j2me_socket_Protocol_readByte: recv failed"); } return byte; @@@ -158,14 -158,15 +159,15 @@@ JNIEXPORT jint JNICALL Java_com_sun_cld { // Get pointer to the buffer. // XXX Not GC safe. - void* buf = &(LLNI_array_direct((java_handle_bytearray_t*) b, off)); + ByteArray ba(b); + void* buf = (void*) (((int8_t*) ba.get_raw_data_ptr()) + off); // Send the given byte to the socket. ssize_t result = send(handle, buf, len, 0); if (result < 0) { // TODO Should throw an IOException. - vm_abort_errno("Java_com_sun_cldc_io_j2me_socket_Protocol_writeBuf: send failed"); + os::abort_errno("Java_com_sun_cldc_io_j2me_socket_Protocol_writeBuf: send failed"); } return result; @@@ -185,7 -186,7 +187,7 @@@ JNIEXPORT jint JNICALL Java_com_sun_cld ssize_t result = send(handle, &byte, 1, 0); if (result < 0) - vm_abort_errno("Java_com_sun_cldc_io_j2me_socket_Protocol_writeByte: send failed"); + os::abort_errno("Java_com_sun_cldc_io_j2me_socket_Protocol_writeByte: send failed"); return result; } @@@ -214,7 -215,7 +216,7 @@@ JNIEXPORT void JNICALL Java_com_sun_cld int result = close(handle); if (result < 0) - vm_abort_errno("Java_com_sun_cldc_io_j2me_socket_Protocol_close0: close failed"); + os::abort_errno("Java_com_sun_cldc_io_j2me_socket_Protocol_close0: close failed"); } } // extern "C" diff --combined src/native/vm/gnuclasspath/java_lang_VMClassLoader.cpp index 2c3bc5125,b67c8bc9e..10e2d63eb --- a/src/native/vm/gnuclasspath/java_lang_VMClassLoader.cpp +++ b/src/native/vm/gnuclasspath/java_lang_VMClassLoader.cpp @@@ -46,6 -46,7 +46,7 @@@ #include "vm/assertion.hpp" #endif + #include "vm/array.hpp" #include "vm/jit/builtin.hpp" #include "vm/class.hpp" #include "vm/classcache.hpp" @@@ -79,11 -80,10 +80,10 @@@ extern "C" */ JNIEXPORT jclass JNICALL Java_java_lang_VMClassLoader_defineClass(JNIEnv *env, jclass clazz, jobject cl, jstring name, jbyteArray data, jint offset, jint len, jobject pd) { - utf *utfname; - classinfo *c; - classloader_t *loader; - java_handle_bytearray_t* ba; - uint8_t* stream; + utf* utfname; + classinfo* c; + classloader_t* loader; + uint8_t* stream; #if defined(ENABLE_JVMTI) jint new_class_data_len = 0; @@@ -99,7 -99,9 +99,9 @@@ /* check the indexes passed */ - if ((offset < 0) || (len < 0) || ((offset + len) > LLNI_array_size(data))) { + ByteArray ba(data); + + if ((offset < 0) || (len < 0) || ((offset + len) > ba.get_length())) { exceptions_throw_arrayindexoutofboundsexception(); return NULL; } @@@ -138,8 -140,7 +140,7 @@@ else #endif { - ba = (java_handle_bytearray_t*) data; - stream = (uint8_t *) &LLNI_array_direct(ba, offset); + stream = ((uint8_t *) ba.get_raw_data_ptr()) + offset; c = class_define(utfname, loader, len, stream, (java_handle_t *) pd); } @@@ -259,9 -260,6 +260,9 @@@ JNIEXPORT jobject JNICALL Java_java_lan struct stat buf; /* buffer for stat */ jboolean ret; /* return value of "add" */ + // Get current list of classpath entries. + SuckClasspath& suckclasspath = VM::get_current()->get_suckclasspath(); + /* get the resource name as utf string */ utfname = javastring_toutf((java_handle_t *) name, false); @@@ -321,7 -319,7 +322,7 @@@ /* iterate over all classpath entries */ - for (List::iterator it = list_classpath_entries->begin(); it != list_classpath_entries->end(); it++) { + for (SuckClasspath::iterator it = suckclasspath.begin(); it != suckclasspath.end(); it++) { list_classpath_entry* lce = *it; /* clear path pointer */ diff --combined src/native/vm/sun_misc_Unsafe.cpp index 63ec0c201,8c9779ecc..bcbfe0fec --- a/src/native/vm/sun_misc_Unsafe.cpp +++ b/src/native/vm/sun_misc_Unsafe.cpp @@@ -40,6 -40,7 +40,7 @@@ # include "native/include/sun_misc_Unsafe.h" #endif + #include "vm/array.hpp" #include "vm/jit/builtin.hpp" #include "vm/exceptions.hpp" #include "vm/initialize.hpp" @@@ -825,7 -826,9 +826,9 @@@ JNIEXPORT jclass JNICALL Java_sun_misc_ /* check the indexes passed */ - if ((off < 0) || (len < 0) || ((off + len) > LLNI_array_size(b))) { + ByteArray ba(b); + + if ((off < 0) || (len < 0) || ((off + len) > ba.get_length())) { exceptions_throw_arrayindexoutofboundsexception(); return NULL; } @@@ -841,7 -844,8 +844,8 @@@ /* define the class */ - c = class_define(utfname, cl, len, (uint8_t *) &(LLNI_array_direct((java_handle_bytearray_t*) b, off)), + uint8_t* ptr = ((uint8_t*) ba.get_raw_data_ptr()) + off; + c = class_define(utfname, cl, len, ptr, (java_handle_t *) protectionDomain); if (c == NULL) @@@ -899,14 -903,14 +903,14 @@@ JNIEXPORT void JNICALL Java_sun_misc_Un */ JNIEXPORT jboolean JNICALL Java_sun_misc_Unsafe_compareAndSwapObject(JNIEnv *env, jobject _this, jobject o, jlong offset, jobject expected, jobject x) { - volatile void **p; + void **p; void *result; /* XXX Use LLNI */ - p = (volatile void **) (((uint8_t *) o) + offset); + p = (void **) (((uint8_t *) o) + offset); - result = Atomic::compare_and_swap(p, expected, x); + result = Atomic::compare_and_swap(p, (void *) expected, (void *) x); if (result == expected) return true; @@@ -929,7 -933,7 +933,7 @@@ JNIEXPORT jboolean JNICALL Java_sun_mis p = (uint32_t *) (((uint8_t *) o) + offset); - result = Atomic::compare_and_swap(p, expected, x); + result = Atomic::compare_and_swap(p, (uint32_t) expected, (uint32_t) x); if (result == (uint32_t) expected) return true; @@@ -952,7 -956,7 +956,7 @@@ JNIEXPORT jboolean JNICALL Java_sun_mis p = (uint64_t *) (((uint8_t *) o) + offset); - result = Atomic::compare_and_swap(p, expected, x); + result = Atomic::compare_and_swap(p, (uint64_t) expected, (uint64_t) x); if (result == (uint64_t) expected) return true; diff --combined src/vm/class.cpp index 0c1739a3c,07329bc31..ee17a20ca --- a/src/vm/class.cpp +++ b/src/vm/class.cpp @@@ -1445,7 -1445,8 +1445,7 @@@ bool class_issubclass(classinfo *sub, c bool class_isanysubclass(classinfo *sub, classinfo *super) { - uint32_t diffval; - bool result; + bool result; /* This is the trivial case. */ @@@ -1475,8 -1476,8 +1475,8 @@@ #else LOCK_CLASSRENUMBER_LOCK; - diffval = sub->vftbl->baseval - super->vftbl->baseval; - result = diffval <= (uint32_t) super->vftbl->diffval; + uint32_t diffval = sub->vftbl->baseval - super->vftbl->baseval; + result = diffval <= (uint32_t) super->vftbl->diffval; UNLOCK_CLASSRENUMBER_LOCK; #endif @@@ -1486,54 -1487,6 +1486,54 @@@ } +/* class_is_arraycompatible **************************************************** + + Checks if two array type descriptors are assignment compatible. + + RETURN VALUE: + true .... target = desc is possible + false ... otherwise + +*******************************************************************************/ + +bool class_is_arraycompatible(arraydescriptor *desc, arraydescriptor *target) +{ + if (desc == target) + return true; + + if (desc->arraytype != target->arraytype) + return false; + + if (desc->arraytype != ARRAYTYPE_OBJECT) + return true; + + /* {both arrays are arrays of references} */ + + if (desc->dimension == target->dimension) { + if (!desc->elementvftbl) + return false; + + /* an array which contains elements of interface types is + allowed to be casted to array of Object (JOWENN) */ + + if ((desc->elementvftbl->baseval < 0) && + (target->elementvftbl->baseval == 1)) + return true; + + return class_isanysubclass(desc->elementvftbl->clazz, + target->elementvftbl->clazz); + } + + if (desc->dimension < target->dimension) + return false; + + /* {desc has higher dimension than target} */ + + return class_isanysubclass(pseudo_class_Arraystub, + target->elementvftbl->clazz); +} + + /* class_is_assignable_from **************************************************** Return whether an instance of the "from" class parameter would be @@@ -1559,12 -1512,7 +1559,12 @@@ bool class_is_assignable_from(classinf if (!link_class(from)) return false; - return class_isanysubclass(from, to); + /* Decide whether we are dealing with array types or object types. */ + + if (class_is_array(to) && class_is_array(from)) + return class_is_arraycompatible(from->vftbl->arraydesc, to->vftbl->arraydesc); + else + return class_isanysubclass(from, to); } @@@ -1588,12 -1536,7 +1588,12 @@@ bool class_is_instance(classinfo *c, ja if (!link_class(c)) return false; - return builtin_instanceof(h, c); + /* Decide whether we are dealing with array types or object types. */ + + if (class_is_array(c)) + return builtin_arrayinstanceof(h, c); + else + return builtin_instanceof(h, c); } @@@ -1643,7 -1586,6 +1643,6 @@@ java_handle_objectarray_t *class_get_de utf *outername; int declaredclasscount; /* number of declared classes */ int pos; /* current declared class */ - java_handle_objectarray_t *oa; /* array of declared classes */ int i; classinfo *ic; @@@ -1676,9 -1618,9 +1675,9 @@@ /* Allocate Class[] and check for OOM. */ - oa = builtin_anewarray(declaredclasscount, class_java_lang_Class); + ClassArray declaredclasses(declaredclasscount); - if (oa == NULL) + if (declaredclasses.is_null()) return NULL; for (i = 0, pos = 0; i < c->innerclasscount; i++) { @@@ -1710,11 -1652,11 +1709,11 @@@ if (!link_class(ic)) return NULL; - LLNI_array_direct(oa, pos++) = (java_object_t *) ic; + declaredclasses.set_element(pos++, ic); } } - return oa; + return declaredclasses.get_handle(); } @@@ -1729,11 -1671,10 +1728,10 @@@ #if defined(ENABLE_JAVASE) java_handle_objectarray_t *class_get_declaredconstructors(classinfo *c, bool publicOnly) { - methodinfo* m; - java_handle_objectarray_t* oa; - int count; - int index; - int i; + methodinfo* m; + int count; + int index; + int i; /* Determine number of constructors. */ @@@ -1749,9 -1690,9 +1747,9 @@@ /* Create array of constructors. */ - oa = builtin_anewarray(count, class_java_lang_reflect_Constructor); + ObjectArray oa(count, class_java_lang_reflect_Constructor); - if (oa == NULL) + if (oa.is_null()) return NULL; /* Get the constructors and store them in the array. */ @@@ -1767,12 -1708,12 +1765,12 @@@ /* Store object into array. */ - array_objectarray_element_set(oa, index, rc.get_handle()); + oa.set_element(index, rc.get_handle()); index++; } } - return oa; + return oa.get_handle(); } #endif @@@ -1793,11 -1734,10 +1791,10 @@@ #if defined(ENABLE_JAVASE) java_handle_objectarray_t *class_get_declaredfields(classinfo *c, bool publicOnly) { - java_handle_objectarray_t *oa; - fieldinfo *f; - int count; - int index; - int i; + fieldinfo* f; + int count; + int index; + int i; /* Determine number of fields. */ @@@ -1809,9 -1749,9 +1806,9 @@@ /* Create array of fields. */ - oa = builtin_anewarray(count, class_java_lang_reflect_Field); + ObjectArray oa(count, class_java_lang_reflect_Field); - if (oa == NULL) + if (oa.is_null()) return NULL; /* Get the fields and store them in the array. */ @@@ -1826,12 -1766,12 +1823,12 @@@ /* Store object into array. */ - array_objectarray_element_set(oa, index, rf.get_handle()); + oa.set_element(index, rf.get_handle()); index++; } } - return oa; + return oa.get_handle(); } #endif @@@ -1852,19 -1792,20 +1849,20 @@@ #if defined(ENABLE_JAVASE) java_handle_objectarray_t *class_get_declaredmethods(classinfo *c, bool publicOnly) { - java_handle_objectarray_t *oa; /* result: array of Method-objects */ - methodinfo *m; /* the current method to be represented */ - int count; - int index; - int i; + methodinfo* m; /* the current method to be represented */ + int count; + int index; + int i; /* JOWENN: array classes do not declare methods according to mauve test. It should be considered, if we should return to my old clone method overriding instead of declaring it as a member function. */ - if (class_is_array(c)) - return builtin_anewarray(0, class_java_lang_reflect_Method); + if (class_is_array(c)) { + ObjectArray oa(0, class_java_lang_reflect_Method); + return oa.get_handle(); + } /* Determine number of methods. */ @@@ -1881,9 -1822,9 +1879,9 @@@ /* Create array of methods. */ - oa = builtin_anewarray(count, class_java_lang_reflect_Method); + ObjectArray oa(count, class_java_lang_reflect_Method); - if (oa == NULL) + if (oa.is_null()) return NULL; /* Get the methods and store them in the array. */ @@@ -1900,12 -1841,12 +1898,12 @@@ /* Store object into array. */ - array_objectarray_element_set(oa, index, rm.get_handle()); + oa.set_element(index, rm.get_handle()); index++; } } - return oa; + return oa.get_handle(); } #endif @@@ -2103,28 -2044,27 +2101,27 @@@ java_handle_t* class_get_enclosingmetho *******************************************************************************/ - java_handle_objectarray_t *class_get_interfaces(classinfo *c) + java_handle_objectarray_t* class_get_interfaces(classinfo *c) { - classinfo *ic; - java_handle_objectarray_t *oa; - u4 i; + classinfo* ic; + u4 i; if (!(c->state & CLASS_LINKED)) if (!link_class(c)) return NULL; - oa = builtin_anewarray(c->interfacescount, class_java_lang_Class); + ClassArray interfaces(c->interfacescount); - if (oa == NULL) + if (interfaces.is_null()) return NULL; for (i = 0; i < c->interfacescount; i++) { ic = c->interfaces[i]; - LLNI_array_direct(oa, i) = (java_object_t *) ic; + interfaces.set_element(i, ic); } - return oa; + return interfaces.get_handle(); } @@@ -2149,7 -2089,7 +2146,7 @@@ java_handle_bytearray_t *class_get_anno LLNI_classinfo_field_get(c, annotations, annotations); - return (java_handle_bytearray_t*)annotations; + return (java_handle_bytearray_t*) annotations; #else return NULL; #endif diff --combined src/vm/jit/builtin.cpp index bdfb79a4b,b7b2a54c0..ff1e2dd9c --- a/src/vm/jit/builtin.cpp +++ b/src/vm/jit/builtin.cpp @@@ -441,6 -441,53 +441,6 @@@ bool builtin_checkcast(java_handle_t *o } -/* builtin_descriptorscompatible *********************************************** - - Checks if two array type descriptors are assignment compatible. - - RETURN VALUE: - 1......target = desc is possible - 0......otherwise - -*******************************************************************************/ - -static bool builtin_descriptorscompatible(arraydescriptor *desc, arraydescriptor *target) -{ - if (desc == target) - return 1; - - if (desc->arraytype != target->arraytype) - return 0; - - if (desc->arraytype != ARRAYTYPE_OBJECT) - return 1; - - /* {both arrays are arrays of references} */ - - if (desc->dimension == target->dimension) { - if (!desc->elementvftbl) - return 0; - /* an array which contains elements of interface types is - allowed to be casted to Object (JOWENN)*/ - - if ((desc->elementvftbl->baseval < 0) && - (target->elementvftbl->baseval == 1)) - return 1; - - return class_isanysubclass(desc->elementvftbl->clazz, - target->elementvftbl->clazz); - } - - if (desc->dimension < target->dimension) - return 0; - - /* {desc has higher dimension than target} */ - - return class_isanysubclass(pseudo_class_Arraystub, - target->elementvftbl->clazz); -} - - /* builtin_arraycheckcast ****************************************************** Checks if an object is really a subtype of the requested array @@@ -468,7 -515,7 +468,7 @@@ bool builtin_fast_arraycheckcast(java_o if (desc == NULL) return 0; - return builtin_descriptorscompatible(desc, targetclass->vftbl->arraydesc); + return class_is_arraycompatible(desc, targetclass->vftbl->arraydesc); } @@@ -581,7 -628,7 +581,7 @@@ bool builtin_canstore(java_handle_objec LLNI_CRITICAL_START; - result = builtin_fast_canstore(LLNI_DIRECT(oa), LLNI_UNWRAP(o)); + result = builtin_fast_canstore((java_objectarray_t*) LLNI_DIRECT(oa), LLNI_UNWRAP(o)); LLNI_CRITICAL_END; @@@ -635,6 -682,7 +635,6 @@@ bool builtin_fast_canstore(java_objecta vftbl_t *componentvftbl; vftbl_t *valuevftbl; int32_t baseval; - uint32_t diffval; bool result; if (o == NULL) @@@ -673,8 -721,8 +673,8 @@@ #if USES_NEW_SUBTYPE result = fast_subtype_check(valuevftbl, componentvftbl); #else - diffval = valuevftbl->baseval - componentvftbl->baseval; - result = diffval <= (uint32_t) componentvftbl->diffval; + uint32_t diffval = valuevftbl->baseval - componentvftbl->baseval; + result = diffval <= (uint32_t) componentvftbl->diffval; #endif } @@@ -691,7 -739,7 +691,7 @@@ else { /* {o is an array} */ - result = builtin_descriptorscompatible(valuedesc, componentvftbl->arraydesc); + result = class_is_arraycompatible(valuedesc, componentvftbl->arraydesc); } /* return result */ @@@ -707,6 -755,7 +707,6 @@@ bool builtin_fast_canstore_onedim(java_ vftbl_t *elementvftbl; vftbl_t *valuevftbl; int32_t baseval; - uint32_t diffval; bool result; if (o == NULL) @@@ -742,8 -791,8 +742,8 @@@ #if USES_NEW_SUBTYPE result = fast_subtype_check(valuevftbl, elementvftbl); #else - diffval = valuevftbl->baseval - elementvftbl->baseval; - result = diffval <= (uint32_t) elementvftbl->diffval; + uint32_t diffval = valuevftbl->baseval - elementvftbl->baseval; + result = diffval <= (uint32_t) elementvftbl->diffval; #endif } @@@ -757,9 -806,10 +757,9 @@@ * one-dimensional array of a class type */ bool builtin_fast_canstore_onedim_class(java_objectarray_t *a, java_object_t *o) { - vftbl_t *elementvftbl; - vftbl_t *valuevftbl; - uint32_t diffval; - bool result; + vftbl_t *elementvftbl; + vftbl_t *valuevftbl; + bool result; if (o == NULL) return 1; @@@ -786,8 -836,8 +786,8 @@@ #if USES_NEW_SUBTYPE result = fast_subtype_check(valuevftbl, elementvftbl); #else - diffval = valuevftbl->baseval - elementvftbl->baseval; - result = diffval <= (uint32_t) elementvftbl->diffval; + uint32_t diffval = valuevftbl->baseval - elementvftbl->baseval; + result = diffval <= (uint32_t) elementvftbl->diffval; #endif UNLOCK_CLASSRENUMBER_LOCK; @@@ -1036,7 -1086,7 +1036,7 @@@ java_object_t *builtin_fast_new(classin } - /* builtin_newarray ************************************************************ + /* builtin_java_newarray ******************************************************* Creates an array with the given vftbl on the heap. This function takes as class argument an array class. @@@ -1044,111 -1094,27 +1044,27 @@@ RETURN VALUE: pointer to the array or NULL if no memory is available - NOTE: This builtin can be called from NATIVE code only. + NOTE: This is a SLOW builtin and can be called from JIT code only. *******************************************************************************/ - java_handle_t *builtin_newarray(int32_t size, classinfo *arrayclass) + java_handle_array_t *builtin_java_newarray(int32_t size, java_handle_t *arrayclazz) { - arraydescriptor *desc; - s4 dataoffset; - s4 componentsize; - s4 actualsize; - java_handle_t *a; #if defined(ENABLE_RT_TIMING) struct timespec time_start, time_end; #endif RT_TIMING_GET_TIME(time_start); - desc = arrayclass->vftbl->arraydesc; - dataoffset = desc->dataoffset; - componentsize = desc->componentsize; - - if (size < 0) { - exceptions_throw_negativearraysizeexception(); - return NULL; - } - - actualsize = dataoffset + size * componentsize; + classinfo* arrayclass = LLNI_classinfo_unwrap(arrayclazz); - /* check for overflow */ - - if (((u4) actualsize) < ((u4) size)) { - exceptions_throw_outofmemoryerror(); - return NULL; - } - - a = (java_handle_t*) heap_alloc(actualsize, (desc->arraytype == ARRAYTYPE_OBJECT), NULL, true); - - if (a == NULL) - return NULL; - - #if !defined(ENABLE_GC_CACAO) && defined(ENABLE_HANDLES) - /* XXX this is only a dirty hack to make Boehm work with handles */ - - a = LLNI_WRAP((java_object_t *) a); - #endif - - LLNI_vftbl_direct(a) = arrayclass->vftbl; - - #if defined(ENABLE_THREADS) - LLNI_DIRECT(a)->lockword.init(); - #endif - - LLNI_array_size(a) = size; + // Allocate a new array with given size and class on the heap + Array a(size, arrayclass); RT_TIMING_GET_TIME(time_end); RT_TIMING_TIME_DIFF(time_start, time_end, RT_TIMING_NEW_ARRAY); - return a; - } - - - /* builtin_java_newarray ******************************************************* - - NOTE: This is a SLOW builtin and can be called from JIT code only. - - *******************************************************************************/ - - java_handle_t *builtin_java_newarray(int32_t size, java_handle_t *arrayclazz) - { - return builtin_newarray(size, LLNI_classinfo_unwrap(arrayclazz)); - } - - - /* builtin_anewarray *********************************************************** - - Creates an array of references to the given class type on the heap. - - RETURN VALUE: - pointer to the array or NULL if no memory is - available - - NOTE: This builtin can be called from NATIVE code only. - - *******************************************************************************/ - - java_handle_objectarray_t *builtin_anewarray(int32_t size, classinfo *componentclass) - { - classinfo *arrayclass; - - /* is class loaded */ - - assert(componentclass->state & CLASS_LOADED); - - /* is class linked */ - - if (!(componentclass->state & CLASS_LINKED)) - if (!link_class(componentclass)) - return NULL; - - arrayclass = class_array_of(componentclass, true); - - if (!arrayclass) - return NULL; - - return (java_handle_objectarray_t *) builtin_newarray(size, arrayclass); + return a.get_handle(); } @@@ -1163,21 -1129,21 +1079,21 @@@ *******************************************************************************/ - #define BUILTIN_NEWARRAY_TYPE(type, arraytype) \ - java_handle_##type##array_t *builtin_newarray_##type(int32_t size) \ - { \ - return (java_handle_##type##array_t *) \ - builtin_newarray(size, primitivetype_table[arraytype].arrayclass); \ + #define BUILTIN_NEWARRAY_TYPE(type, name) \ + java_handle_##type##array_t *builtin_newarray_##type(int32_t size) \ + { \ + name##Array a(size); \ + return a.get_handle(); \ } - BUILTIN_NEWARRAY_TYPE(boolean, ARRAYTYPE_BOOLEAN) - BUILTIN_NEWARRAY_TYPE(byte, ARRAYTYPE_BYTE) - BUILTIN_NEWARRAY_TYPE(char, ARRAYTYPE_CHAR) - BUILTIN_NEWARRAY_TYPE(short, ARRAYTYPE_SHORT) - BUILTIN_NEWARRAY_TYPE(int, ARRAYTYPE_INT) - BUILTIN_NEWARRAY_TYPE(long, ARRAYTYPE_LONG) - BUILTIN_NEWARRAY_TYPE(float, ARRAYTYPE_FLOAT) - BUILTIN_NEWARRAY_TYPE(double, ARRAYTYPE_DOUBLE) + BUILTIN_NEWARRAY_TYPE(boolean, Boolean) + BUILTIN_NEWARRAY_TYPE(byte, Byte) + BUILTIN_NEWARRAY_TYPE(char, Char) + BUILTIN_NEWARRAY_TYPE(short, Short) + BUILTIN_NEWARRAY_TYPE(int, Int) + BUILTIN_NEWARRAY_TYPE(long, Long) + BUILTIN_NEWARRAY_TYPE(float, Float) + BUILTIN_NEWARRAY_TYPE(double, Double) /* builtin_multianewarray_intern *********************************************** @@@ -1195,38 -1161,37 +1111,37 @@@ ******************************************************************************/ - static java_handle_t *builtin_multianewarray_intern(int n, + static java_handle_array_t *builtin_multianewarray_intern(int n, classinfo *arrayclass, long *dims) { - s4 size; - java_handle_t *a; - classinfo *componentclass; - s4 i; + int32_t i; /* create this dimension */ - size = (s4) dims[0]; - a = builtin_newarray(size, arrayclass); + int32_t size = (int32_t) dims[0]; + Array a(size, arrayclass); - if (!a) + if (a.is_null()) return NULL; /* if this is the last dimension return */ if (!--n) - return a; + return a.get_handle(); /* get the class of the components to create */ - componentclass = arrayclass->vftbl->arraydesc->componentvftbl->clazz; + classinfo* componentclass = arrayclass->vftbl->arraydesc->componentvftbl->clazz; /* The verifier guarantees that the dimension count is in the range. */ /* create the component arrays */ + ObjectArray oa(a.get_handle()); + for (i = 0; i < size; i++) { - java_handle_t *ea = + java_handle_array_t *ea = #if defined(__MIPS__) && (SIZEOF_VOID_P == 4) /* we save an s4 to a s8 slot, 8-byte aligned */ @@@ -1238,10 -1203,10 +1153,10 @@@ if (!ea) return NULL; - array_objectarray_element_set((java_handle_objectarray_t *) a, i, ea); + oa.set_element(i, (java_handle_t*) ea); } - return a; + return a.get_handle(); } @@@ -2086,6 -2051,9 +2001,9 @@@ void builtin_arraycopy(java_handle_t *s return; } + Array sa(src); + Array da(dest); + sdesc = LLNI_vftbl_direct(src)->arraydesc; ddesc = LLNI_vftbl_direct(dest)->arraydesc; @@@ -2101,8 -2069,8 +2019,8 @@@ } // Check if ranges are valid. - if ((((uint32_t) srcStart + (uint32_t) len) > (uint32_t) LLNI_array_size(src)) || - (((uint32_t) destStart + (uint32_t) len) > (uint32_t) LLNI_array_size(dest))) { + if ((((uint32_t) srcStart + (uint32_t) len) > (uint32_t) sa.get_length()) || + (((uint32_t) destStart + (uint32_t) len) > (uint32_t) da.get_length())) { exceptions_throw_arrayindexoutofboundsexception(); return; } @@@ -2129,19 -2097,17 +2047,17 @@@ else { /* We copy references of different type */ - java_handle_objectarray_t *oas = (java_handle_objectarray_t *) src; - java_handle_objectarray_t *oad = (java_handle_objectarray_t *) dest; + ObjectArray oas((java_handle_objectarray_t*) src); + ObjectArray oad((java_handle_objectarray_t*) dest); if (destStart <= srcStart) { for (i = 0; i < len; i++) { - java_handle_t *o; + java_handle_t* o = oas.get_element(srcStart + i); - o = array_objectarray_element_get(oas, srcStart + i); - - if (!builtin_canstore(oad, o)) + if (!builtin_canstore(oad.get_handle(), o)) return; - array_objectarray_element_set(oad, destStart + i, o); + oad.set_element(destStart + i, o); } } else { @@@ -2152,14 -2118,12 +2068,12 @@@ index have been copied before the throw. */ for (i = len - 1; i >= 0; i--) { - java_handle_t *o; - - o = array_objectarray_element_get(oas, srcStart + i); + java_handle_t* o = oas.get_element(srcStart + i); - if (!builtin_canstore(oad, o)) + if (!builtin_canstore(oad.get_handle(), o)) return; - array_objectarray_element_set(oad, destStart + i, o); + oad.set_element(destStart + i, o); } } } @@@ -2224,7 -2188,9 +2138,9 @@@ java_handle_t *builtin_clone(void *env /* we are cloning an array */ if (ad != NULL) { - size = ad->dataoffset + ad->componentsize * LLNI_array_size(o); + Array a(o); + + size = ad->dataoffset + ad->componentsize * a.get_length(); co = (java_handle_t*) heap_alloc(size, (ad->arraytype == ARRAYTYPE_OBJECT), NULL, true); diff --combined src/vm/vm.cpp index 8cbc0ed5c,497d75490..23518fd85 --- a/src/vm/vm.cpp +++ b/src/vm/vm.cpp @@@ -101,7 -101,7 +101,7 @@@ # include "vm/jit/python.h" #endif -#include "vm/jit/trap.h" +#include "vm/jit/trap.hpp" #if defined(ENABLE_JVMTI) # include "native/jvmti/cacaodbg.h" @@@ -206,6 -206,12 +206,6 @@@ enum OPT_SHOW, OPT_DEBUGCOLOR, -#if !defined(NDEBUG) - OPT_ALL, - OPT_METHOD, - OPT_SIGNATURE, -#endif - #if defined(ENABLE_VERIFIER) OPT_NOVERIFY, OPT_XVERIFY_ALL, @@@ -319,6 -325,11 +319,6 @@@ opt_struct opts[] = { "c", true, OPT_CHECK }, { "l", false, OPT_LOAD }, -#if !defined(NDEBUG) - { "all", false, OPT_ALL }, - { "sig", true, OPT_SIGNATURE }, -#endif - #if defined(ENABLE_LOOP) { "oloop", false, OPT_OLOOP }, #endif @@@ -379,6 -390,10 +379,6 @@@ /* keep these at the end of the list */ -#if !defined(NDEBUG) - { "m", true, OPT_METHOD }, -#endif - { "s", true, OPT_SHOW }, { "debug-color", false, OPT_DEBUGCOLOR }, @@@ -510,6 -525,11 +510,6 @@@ static void XXusage(void puts(" -oloop optimize array accesses in loops"); #endif puts(" -l don't start the class after loading"); -#if !defined(NDEBUG) - puts(" -all compile all methods, no execution"); - puts(" -m compile only a specific method"); - puts(" -sig specify signature for a specific method"); -#endif puts(" -s... show..."); puts(" (c)onstants the constant pool"); @@@ -1064,6 -1084,24 +1064,6 @@@ VM::VM(JavaVMInitArgs* vm_args makeinitializations = false; break; -#if !defined(NDEBUG) - case OPT_ALL: - compileall = true; - opt_run = false; - makeinitializations = false; - break; - - case OPT_METHOD: - opt_run = false; - opt_method = opt_arg; - makeinitializations = false; - break; - - case OPT_SIGNATURE: - opt_signature = opt_arg; - break; -#endif - case OPT_SHOW: /* Display options */ for (unsigned int i = 0; i < strlen(opt_arg); i++) { switch (opt_arg[i]) { @@@ -1332,7 -1370,10 +1332,7 @@@ /* AFTER: thread_preinit */ - if (!suck_init()) - os::abort("vm_create: suck_init failed"); - - suck_add_from_property("java.endorsed.dirs"); + _suckclasspath.add_from_property("java.endorsed.dirs"); /* Now we have all options handled and we can print the version information. @@@ -1346,7 -1387,7 +1346,7 @@@ // FIXME Make boot_class_path const char*. boot_class_path = (char*) _properties.get("sun.boot.class.path"); - suck_add(boot_class_path); + _suckclasspath.add(boot_class_path); /* initialize the classcache hashtable stuff: lock, hashtable (must be done _after_ threads_preinit) */ @@@ -1431,8 -1472,7 +1431,8 @@@ /* Initialize the native VM subsystem. */ /* AFTER: threads_init (at least for SUN's classes) */ - nativevm_init(); + if (!nativevm_init()) + os::abort("vm_create: nativevm_init failed"); #if defined(ENABLE_PROFILING) /* initialize profiling */ @@@ -1577,32 -1617,19 +1577,19 @@@ void VM::print_run_time_config( void vm_run(JavaVM *vm, JavaVMInitArgs *vm_args) { - char* option; - char* mainname; - char* p; - utf *mainutf; - classinfo *mainclass; - java_handle_t *e; - methodinfo *m; - java_handle_objectarray_t *oa; - s4 oalength; - utf *u; - java_handle_t *s; - int status; - - // Prevent compiler warnings. - oa = NULL; + methodinfo* m; + int status; #if !defined(NDEBUG) - if (compileall) { + if (opt_CompileAll) { vm_compile_all(); return; } #endif - /* Get the main class plus it's arguments. */ + /* Get the main class or jar file argument. */ - mainname = NULL; + char* mainname = NULL; if (opt_index < vm_args->nOptions) { /* Get main-class argument. */ @@@ -1613,7 -1640,7 +1600,7 @@@ classpath. */ if (opt_jar == true) { - p = MNEW(char, strlen(mainname) + strlen("0")); + char* p = MNEW(char, strlen(mainname) + strlen("0")); strcpy(p, mainname); @@@ -1629,22 -1656,9 +1616,9 @@@ mainname[i] = '/'; } - /* Build argument array. Move index to first argument. */ + /* Move index to first argument. */ opt_index++; - - oalength = vm_args->nOptions - opt_index; - - oa = builtin_anewarray(oalength, class_java_lang_String); - - for (int i = 0; i < oalength; i++) { - option = vm_args->options[opt_index + i].optionString; - - u = utf_new_char(option); - s = javastring_new(u); - - array_objectarray_element_set(oa, i, s); - } } /* Do we have a main-class argument? */ @@@ -1653,12 -1667,30 +1627,30 @@@ usage(); #if !defined(NDEBUG) - if (opt_method != NULL) { + if (opt_CompileMethod != NULL) { vm_compile_method(mainname); return; } #endif + /* Build argument array. */ + + int32_t oalength = vm_args->nOptions - opt_index; + + ObjectArray oa(oalength, class_java_lang_String); + + if (oa.is_null()) + vm_exit(1); + + for (int i = 0; i < oalength; i++) { + char* option = vm_args->options[opt_index + i].optionString; + + utf* u = utf_new_char(option); + java_handle_t* s = javastring_new(u); + + oa.set_element(i, s); + } + /* set return value to OK */ status = 0; @@@ -1674,17 -1706,17 +1666,17 @@@ /* load the main class */ - mainutf = utf_new_char(mainname); + utf* mainutf = utf_new_char(mainname); #if defined(ENABLE_JAVAME_CLDC1_1) - mainclass = load_class_bootstrap(mainutf); + classinfo* mainclass = load_class_bootstrap(mainutf); #else - mainclass = load_class_from_sysloader(mainutf); + classinfo* mainclass = load_class_from_sysloader(mainutf); #endif /* error loading class */ - e = exceptions_get_and_clear_exception(); + java_handle_t* e = exceptions_get_and_clear_exception(); if ((e != NULL) || (mainclass == NULL)) { exceptions_throw_noclassdeffounderror_cause(e); @@@ -1744,7 -1776,7 +1736,7 @@@ /* start the main thread */ - (void) vm_call_method(m, NULL, oa); + (void) vm_call_method(m, NULL, oa.get_handle()); /* exception occurred? */ @@@ -2227,16 -2259,16 +2219,16 @@@ static void vm_compile_method(char* mai if (!link_class(mainclass)) exceptions_print_stacktrace(); - if (opt_signature != NULL) { + if (opt_CompileSignature != NULL) { m = class_resolveclassmethod(mainclass, - utf_new_char(opt_method), - utf_new_char(opt_signature), + utf_new_char(opt_CompileMethod), + utf_new_char(opt_CompileSignature), mainclass, false); } else { m = class_resolveclassmethod(mainclass, - utf_new_char(opt_method), + utf_new_char(opt_CompileMethod), NULL, mainclass, false); @@@ -2244,7 -2276,7 +2236,7 @@@ if (m == NULL) os::abort("vm_compile_method: java.lang.NoSuchMethodException: %s.%s", - opt_method, opt_signature ? opt_signature : ""); + opt_CompileMethod, opt_CompileSignature ? opt_CompileSignature : ""); jit_compile(m); } @@@ -2524,22 -2556,27 +2516,22 @@@ void vm_abort(const char* text, ... { va_list ap; - va_start(ap, text); - os::abort(text, ap); - va_end(ap); -} + log_println("vm_abort: WARNING, port me to C++ and use os::abort() instead."); -void vm_abort_errnum(int errnum, const char* text, ...) -{ - va_list ap; + // Print the log message. + log_start(); va_start(ap, text); - os::abort_errnum(errnum, text, ap); + log_vprint(text, ap); va_end(ap); -} -void vm_abort_errno(const char* text, ...) -{ - va_list ap; + log_finish(); - va_start(ap, text); - os::abort_errno(text, ap); - va_end(ap); + // Print a backtrace. + os::print_backtrace(); + + // Now abort the VM. + os::abort(); } }