Return-Path: Delivered-To: apmail-incubator-harmony-commits-archive@www.apache.org Received: (qmail 12244 invoked from network); 19 Feb 2006 20:15:31 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 19 Feb 2006 20:15:31 -0000 Received: (qmail 61301 invoked by uid 500); 19 Feb 2006 20:15:31 -0000 Delivered-To: apmail-incubator-harmony-commits-archive@incubator.apache.org Received: (qmail 61229 invoked by uid 500); 19 Feb 2006 20:15:30 -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 61218 invoked by uid 99); 19 Feb 2006 20:15:30 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 19 Feb 2006 12:15:30 -0800 X-ASF-Spam-Status: No, hits=-7.6 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME,SUBJECT_FUZZY_CHEAP 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; Sun, 19 Feb 2006 12:15:30 -0800 Received: (qmail 12120 invoked by uid 65534); 19 Feb 2006 20:15:09 -0000 Message-ID: <20060219201509.12117.qmail@minotaur.apache.org> Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r378953 - in /incubator/harmony/enhanced/jchevm/libjc: derive.c derive2.c heap.c inline.h libjc.h vm.c Date: Sun, 19 Feb 2006 20:15:08 -0000 To: harmony-commits@incubator.apache.org From: archie@apache.org X-Mailer: svnmailer-1.0.6 X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Author: archie Date: Sun Feb 19 12:15:07 2006 New Revision: 378953 URL: http://svn.apache.org/viewcvs?rev=378953&view=rev Log: Handle architectures where object alignment can be greater than word alignment (e.g., for doubles and longs). For objects containing one or more primitive fields with strict alignment requirements but an odd number of reference fields, force allocation with a skip word to even out the number of references and therefore align the object. Modified: incubator/harmony/enhanced/jchevm/libjc/derive.c incubator/harmony/enhanced/jchevm/libjc/derive2.c incubator/harmony/enhanced/jchevm/libjc/heap.c incubator/harmony/enhanced/jchevm/libjc/inline.h incubator/harmony/enhanced/jchevm/libjc/libjc.h incubator/harmony/enhanced/jchevm/libjc/vm.c Modified: incubator/harmony/enhanced/jchevm/libjc/derive.c URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/jchevm/libjc/derive.c?rev=378953&r1=378952&r2=378953&view=diff ============================================================================== --- incubator/harmony/enhanced/jchevm/libjc/derive.c (original) +++ incubator/harmony/enhanced/jchevm/libjc/derive.c Sun Feb 19 12:15:07 2006 @@ -453,9 +453,11 @@ * _JC_TYPE_SKIPWORD flag in type->flags if appropriate. */ void -_jc_initialize_bsi(_jc_jvm *vm, _jc_type *type) +_jc_initialize_bsi(_jc_jvm *vm, _jc_type *type, int align) { _jc_nonarray_type *const ntype = &type->u.nonarray; + int alloc_size = ntype->instance_size; + jboolean force_skip = JNI_FALSE; int block_size; int bsi; @@ -463,17 +465,33 @@ _JC_ASSERT(!_JC_FLG_TEST(type, ARRAY)); _JC_ASSERT(!_JC_ACC_TEST(type, ABSTRACT)); + /* + * When object alignment is greater than reference word alignment, + * an odd number of references will put the object out of alignment. + * In that case, we force a skip word to align the object header. + */ + if (align > _jc_type_align[_JC_TYPE_REFERENCE] + && ((ntype->num_virtual_refs * sizeof(_jc_word)) % align) != 0) { + _JC_ASSERT((ntype->num_virtual_refs & 1) != 0); + _JC_ASSERT((sizeof(_jc_word) * 2) % align == 0); + alloc_size += sizeof(_jc_word); + force_skip = JNI_TRUE; + } + /* Get block size index */ - bsi = _jc_heap_block_size(vm, ntype->instance_size); + bsi = _jc_heap_block_size(vm, alloc_size); /* Reverse-engineer actual block size */ block_size = bsi < 0 ? ((-bsi * _JC_PAGE_SIZE) - _JC_HEAP_BLOCK_OFFSET) : vm->heap.sizes[bsi].size; + _JC_ASSERT(!force_skip + || block_size - sizeof(_jc_word) >= ntype->instance_size); - /* Determine if there's room for a skip word */ + /* Determine if we want a skip word */ if (block_size - sizeof(_jc_word) >= ntype->instance_size - && ntype->num_virtual_refs >= _JC_SKIPWORD_MIN_REFS) + && (force_skip + || ntype->num_virtual_refs >= _JC_SKIPWORD_MIN_REFS)) type->flags |= _JC_TYPE_SKIPWORD; /* Done */ Modified: incubator/harmony/enhanced/jchevm/libjc/derive2.c URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/jchevm/libjc/derive2.c?rev=378953&r1=378952&r2=378953&view=diff ============================================================================== --- incubator/harmony/enhanced/jchevm/libjc/derive2.c (original) +++ incubator/harmony/enhanced/jchevm/libjc/derive2.c Sun Feb 19 12:15:07 2006 @@ -53,6 +53,7 @@ _jc_type_node *node; size_t virtual_offset; size_t static_offset; + int object_align; int vtable_index; _jc_type *type; void *mark; @@ -175,6 +176,7 @@ (type->superclass->u.nonarray.instance_size - ntype->num_virtual_refs * sizeof(void *)) : sizeof(_jc_object); static_offset = 0; + object_align = _jc_type_align[_JC_TYPE_REFERENCE]; for (i = 0; i < ntype->num_fields; i++) { _jc_field *const field = ntype->fields[i]; const u_char ptype = _jc_sig_types[(u_char)*field->signature]; @@ -197,6 +199,8 @@ field->offset = virtual_offset; virtual_offset += size; } + if (align > object_align) + object_align = align; } } @@ -208,7 +212,7 @@ /* Initialize heap block size index skip word flag */ if (!_JC_ACC_TEST(type, ABSTRACT)) - _jc_initialize_bsi(vm, type); + _jc_initialize_bsi(vm, type, object_align); /* Allocate memory for static fields, if any */ if (static_offset > 0 Modified: incubator/harmony/enhanced/jchevm/libjc/heap.c URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/jchevm/libjc/heap.c?rev=378953&r1=378952&r2=378953&view=diff ============================================================================== --- incubator/harmony/enhanced/jchevm/libjc/heap.c (original) +++ incubator/harmony/enhanced/jchevm/libjc/heap.c Sun Feb 19 12:15:07 2006 @@ -579,12 +579,14 @@ object_size = _jc_array_head_sizes[elem_type] + array->length * _jc_type_sizes[elem_type]; - } else + bsi = _jc_heap_block_size(vm, object_size); + } else { object_size = type->u.nonarray.instance_size; + bsi = type->u.nonarray.block_size_index; + } /* Find object start */ obj_start = ((_jc_word *)obj) - _jc_num_refs(obj); - bsi = _jc_heap_block_size(vm, object_size); /* Get page info for page containing start of object */ page = (char *)((_jc_word)obj_start & ~(_JC_PAGE_SIZE - 1)); @@ -604,9 +606,16 @@ _JC_ASSERT(object_size <= block_size); /* Determine if there is a skip word */ - block_start = (block_size >= object_size + sizeof(_jc_word) - && _jc_num_refs(obj) >= _JC_SKIPWORD_MIN_REFS) ? - obj_start - 1 : obj_start; + block_start = obj_start; + if (block_size >= object_size + sizeof(_jc_word)) { + if (_JC_LW_TEST(obj->lockword, ARRAY)) { + if (_jc_num_refs(obj) >= _JC_SKIPWORD_MIN_REFS) + block_start--; + } else { + if _JC_FLG_TEST(obj->type, SKIPWORD) + block_start--; + } + } /* Check alignment of object start */ if (bsi < 0) { @@ -639,7 +648,6 @@ /* Check for possible skip word and find object header */ if (_JC_HEAP_EXTRACT(word, BTYPE) == _JC_HEAP_BLOCK_SKIP) { skip = _JC_HEAP_EXTRACT(word, SKIP); - _JC_ASSERT(skip >= 1 + _JC_SKIPWORD_MIN_REFS); obj = (_jc_object *)(block + skip); } else { skip = 0; @@ -672,8 +680,10 @@ if (bsi < 0) { _JC_ASSERT(obj_size + _JC_HEAP_BLOCK_OFFSET >= (-bsi - 1) * _JC_PAGE_SIZE); - } else if (bsi > 0) - _JC_ASSERT(obj_size > heap->sizes[bsi - 1].size); + } else if (bsi > 0) { + _JC_ASSERT(obj_size + (skip ? sizeof(_jc_word) : 0) + > heap->sizes[bsi - 1].size); + } /* Sanity check object itself */ _jc_heap_check_object(vm, obj, 1); Modified: incubator/harmony/enhanced/jchevm/libjc/inline.h URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/jchevm/libjc/inline.h?rev=378953&r1=378952&r2=378953&view=diff ============================================================================== --- incubator/harmony/enhanced/jchevm/libjc/inline.h (original) +++ incubator/harmony/enhanced/jchevm/libjc/inline.h Sun Feb 19 12:15:07 2006 @@ -15,7 +15,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * - * $Id: inline.h,v 1.7 2005/11/09 18:14:22 archiecobbs Exp $ + * $Id$ */ /* @@ -32,8 +32,6 @@ _JC_ASSERT(word != _JC_HEAP_BLOCK_FREE && word != _JC_HEAP_BLOCK_ALLOC); if (_JC_HEAP_EXTRACT(word, BTYPE) == _JC_HEAP_BLOCK_SKIP) { - _JC_ASSERT(_JC_HEAP_EXTRACT(word, SKIP) - >= 1 + _JC_SKIPWORD_MIN_REFS); return (_jc_object *)((_jc_word *)block + _JC_HEAP_EXTRACT(word, SKIP)); } Modified: incubator/harmony/enhanced/jchevm/libjc/libjc.h URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/jchevm/libjc/libjc.h?rev=378953&r1=378952&r2=378953&view=diff ============================================================================== --- incubator/harmony/enhanced/jchevm/libjc/libjc.h (original) +++ incubator/harmony/enhanced/jchevm/libjc/libjc.h Sun Feb 19 12:15:07 2006 @@ -127,7 +127,8 @@ _jc_class_loader *loader, const char *name); extern void _jc_initialize_lockword(_jc_env *env, _jc_type *type, _jc_type *stype); -extern void _jc_initialize_bsi(_jc_jvm *vm, _jc_type *type); +extern void _jc_initialize_bsi(_jc_jvm *vm, _jc_type *type, + int align); /* derive2.c */ extern _jc_type *_jc_derive_type_interp(_jc_env *env, Modified: incubator/harmony/enhanced/jchevm/libjc/vm.c URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/jchevm/libjc/vm.c?rev=378953&r1=378952&r2=378953&view=diff ============================================================================== --- incubator/harmony/enhanced/jchevm/libjc/vm.c (original) +++ incubator/harmony/enhanced/jchevm/libjc/vm.c Sun Feb 19 12:15:07 2006 @@ -43,7 +43,6 @@ /* Static checks */ _JC_ASSERT(_JC_VMEXCEPTION_MAX <= 64); /* must fit in jlong */ _JC_ASSERT(_JC_VERBOSE_MAX <= 32); /* must fit in jint */ - _JC_ASSERT(_JC_FULL_ALIGNMENT <= sizeof(_jc_word)); _JC_ASSERT(sizeof(void *) <= sizeof(jlong)); _JC_ASSERT(sizeof(_jc_word) == sizeof(void *));