Return-Path: Delivered-To: apmail-incubator-harmony-commits-archive@www.apache.org Received: (qmail 7187 invoked from network); 4 Nov 2005 21:21:53 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 4 Nov 2005 21:21:53 -0000 Received: (qmail 55709 invoked by uid 500); 4 Nov 2005 21:21:52 -0000 Delivered-To: apmail-incubator-harmony-commits-archive@incubator.apache.org Received: (qmail 55678 invoked by uid 500); 4 Nov 2005 21:21:52 -0000 Mailing-List: contact harmony-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: harmony-dev@incubator.apache.org Delivered-To: mailing list harmony-commits@incubator.apache.org Received: (qmail 55667 invoked by uid 99); 4 Nov 2005 21:21:51 -0000 X-ASF-Spam-Status: No, hits=-9.4 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [209.237.227.194] (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.29) with SMTP; Fri, 04 Nov 2005 13:21:51 -0800 Received: (qmail 7060 invoked by uid 65534); 4 Nov 2005 21:21:31 -0000 Message-ID: <20051104212131.7059.qmail@minotaur.apache.org> Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r330906 - /incubator/harmony/enhanced/trunk/sandbox/contribs/bootjvm/bootJVM/jvm/src/class.c Date: Fri, 04 Nov 2005 21:21:30 -0000 To: harmony-commits@incubator.apache.org From: dlydick@apache.org X-Mailer: svnmailer-1.0.5 X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Author: dlydick Date: Fri Nov 4 13:21:20 2005 New Revision: 330906 URL: http://svn.apache.org/viewcvs?rev=330906&view=rev Log: Added mechanism for internal support of strings as a quasi-primative. Retain crucial class indices. Connect (CONSTANT_String) type to string quasi-primatives. Modified: incubator/harmony/enhanced/trunk/sandbox/contribs/bootjvm/bootJVM/jvm/src/class.c Modified: incubator/harmony/enhanced/trunk/sandbox/contribs/bootjvm/bootJVM/jvm/src/class.c URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/trunk/sandbox/contribs/bootjvm/bootJVM/jvm/src/class.c?rev=330906&r1=330905&r2=330906&view=diff ============================================================================== --- incubator/harmony/enhanced/trunk/sandbox/contribs/bootjvm/bootJVM/jvm/src/class.c (original) +++ incubator/harmony/enhanced/trunk/sandbox/contribs/bootjvm/bootJVM/jvm/src/class.c Fri Nov 4 13:21:20 2005 @@ -160,6 +160,16 @@ pjvm->class_allocate_last = jvm_class_index_null; + pjvm->class_java_lang_Object = jvm_class_index_null; + + pjvm->class_primative_char = jvm_class_index_null; + + pjvm->class_java_lang_Class = jvm_class_index_null; + + pjvm->class_java_lang_String = jvm_class_index_null; + + pjvm->class_java_lang_Thread = jvm_class_index_null; + /* Declare this module initialized */ jvm_class_initialized = rtrue; @@ -328,7 +338,8 @@ * * @param arraylength Array of length @b arraydims containing the * length of array in each of those dimensions. - * E.g., @b arraydims is 4 for new X[7][3][9][2] + * E.g., @b arraydims is 4 for + * new X[7][3][9][2] * so this parameter will be a 4-element array * containing the numbers {7, 3, 9, 2} * @@ -414,7 +425,8 @@ arraydims, arraylength, rfalse, - jvm_thread_index_null); + jvm_thread_index_null, + (CONSTANT_Utf8_info *) rnull); /* * Mark as a primative class, @c @b \ done @@ -441,7 +453,8 @@ arraydims, arraylength, rfalse, - jvm_thread_index_null); + jvm_thread_index_null, + (CONSTANT_Utf8_info *) rnull); CLASS(clsidx).status |= CLASS_STATUS_ARRAY; @@ -484,7 +497,8 @@ arraydims, arraylength, rfalse, - jvm_thread_index_null); + jvm_thread_index_null, + (CONSTANT_Utf8_info *) rnull); /* Delay loading field data until after @b objhash is known */ CLASS(clsidx).class_static_field_data = @@ -498,6 +512,37 @@ CLASS(clsidx).class_objhash = objhash; (rvoid) GC_OBJECT_MKREF_FROM_CLASS(clsidx, objhash); + /* + * Mark class if it is one of the startup classes + */ + if (0 == utf_prchar_classname_strcmp(JVMCLASS_JAVA_LANG_OBJECT, + pcfs, + pcfs->this_class)) + { + pjvm->class_java_lang_Object = clsidx; + } + else + if (0 == utf_prchar_classname_strcmp(JVMCLASS_JAVA_LANG_CLASS, + pcfs, + pcfs->this_class)) + { + pjvm->class_java_lang_Class = clsidx; + } + else + if (0 == utf_prchar_classname_strcmp(JVMCLASS_JAVA_LANG_STRING, + pcfs, + pcfs->this_class)) + { + pjvm->class_java_lang_String = clsidx; + } + else + if (0 == utf_prchar_classname_strcmp(JVMCLASS_JAVA_LANG_THREAD, + pcfs, + pcfs->this_class)) + { + pjvm->class_java_lang_Thread = clsidx; + } + /* normal class definition */ CLASS(clsidx).status &= ~CLASS_STATUS_NULL; @@ -712,6 +757,29 @@ if (CLASS(clsidx).status & CLASS_STATUS_INUSE) { + /* + * Unmark class if it was a startup class + */ + if (clsidx == pjvm->class_java_lang_Object) + { + pjvm->class_java_lang_Object = jvm_class_index_null; + } + else + if (clsidx == pjvm->class_java_lang_Class) + { + pjvm->class_java_lang_Class = jvm_class_index_null; + } + else + if (clsidx == pjvm->class_java_lang_String) + { + pjvm->class_java_lang_String = jvm_class_index_null; + } + else + if (clsidx == pjvm->class_java_lang_Thread) + { + pjvm->class_java_lang_Thread = jvm_class_index_null; + } + /*! * @todo HARMONY-6-jvm-class.c-5 Determine what to do, if * anything, when rfalse is returned from @@ -1685,13 +1753,11 @@ switch(CP_TAG(pcfs, constantvalue_index)) { case CONSTANT_Long: - pu4h = &PTR_CP_ENTRY_TYPE( - CONSTANT_Long_info, + pu4h = &PTR_CP_ENTRY_LONG( pcfs, constantvalue_index)->high_bytes; - pu4l = &PTR_CP_ENTRY_TYPE( - CONSTANT_Long_info, + pu4l = &PTR_CP_ENTRY_LONG( pcfs, constantvalue_index)->low_bytes; @@ -1719,8 +1785,7 @@ break; case CONSTANT_Float: - pu4 = &PTR_CP_ENTRY_TYPE( - CONSTANT_Float_info, + pu4 = &PTR_CP_ENTRY_FLOAT( pcfs, constantvalue_index) ->bytes; @@ -1731,12 +1796,10 @@ break; case CONSTANT_Double: - pu4h = &PTR_CP_ENTRY_TYPE( - CONSTANT_Long_info, + pu4h = &PTR_CP_ENTRY_LONG( pcfs, constantvalue_index)->high_bytes; - pu4l = &PTR_CP_ENTRY_TYPE( - CONSTANT_Long_info, + pu4l = &PTR_CP_ENTRY_LONG( pcfs, constantvalue_index)->low_bytes; @@ -1765,15 +1828,25 @@ break; case CONSTANT_Integer: - pu4 = &PTR_CP_ENTRY_TYPE( - CONSTANT_Integer_info, + pu4 = &PTR_CP_ENTRY_INTEGER( pcfs, constantvalue_index) ->bytes; vali = (jint) *pu4; - /* + /*! + * @todo HARMONY-6-jvm-class.c-18 This may be + * a @e very bad assumption! Verify that + * casting method is valid in all + * situations. What is implied is that + * since the value is stored as a (jint), + * then all other accesses reference the + * (jint) and then cast it to other + * shorter types. This @e may have + * portability implications, which is + * the main concern. + * * Casting to shorter types, namely * (jshort), (jchar), (jbyte), and * (jboolean), is done during field @@ -1786,39 +1859,38 @@ case CONSTANT_String: /*! - * @todo HARMONY-6-jvm-class.c-17 Load up this - * string into a @c @b java.lang.String - * using the source from - * - * pcfs->constant_pool - [PTR_CP_ENTRY_TYPE( - CONSTANT_String_info, - pcfs, - constantvalue_index) - ->string_index] - * - * But do not store directly into, + * @internal DO NOT do this until the + * class initialization is complete + * for @c @b java.lang.String or the + * results may be arbitrary or even + * fatal. A well-formed class + * library will not attempt such an + * operation. The probable result + * for a malformed class library + * will probably result in a null + * pointer core dump here: * - * val._jstring = ... * - * Instead, store the resulting object - * hash from the algorithm shown in - * @link #jvm_init() jvm_init()@endlink - * where the @link #main() main()@endlink - * parameter @c @b argv[] array is loaded - * into the Java edition of the same. - * The pseudocode for this operation is - * shown there. - * - * DO NOT do this until the - * class initialization is complete for - * @c @b java.lang.String or the results - * may be arbitrary or even fatal. A - * well-formed class library will not - * attempt such an operation. + * @todo HARMONY-6-jvm-class.c-19 This invoca + * invocation needs better unit testing + * with real data. * */ - + val._jstring = + object_instance_new(OBJECT_STATUS_STRING, + CLASS_OBJECT_LINKAGE( + pjvm->class_java_lang_String)->pcfs, + pjvm->class_java_lang_String, + LOCAL_CONSTANT_NO_ARRAY_DIMS, + (jint *) rnull, + rfalse, + jvm_thread_index_null, + PTR_THIS_CP_Utf8( + pcfs + ->constant_pool + [PTR_CP_ENTRY_STRING(pcfs, + constantvalue_index) + ->string_index])); /* * DO NOT do GC_OBJECT_MKREF(val._jstring)