changeset 14:d1c481f44844

Fix a bug in computing the size of an array. The size of an array is computed with error in the stub (either new_type_array_id or new_object_array_id) which allocates space for arrays.
author YANG Yongqiang <yangyongqiang@loongson.cn>
date Mon, 25 Oct 2010 15:43:04 +0800
parents 71f3d14ed0eb
children 817893aa0b86
files hotspot/src/cpu/mips/vm/c1_Runtime1_mips.cpp
diffstat 1 files changed, 17 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/hotspot/src/cpu/mips/vm/c1_Runtime1_mips.cpp	Sun Oct 24 21:58:11 2010 +0800
+++ b/hotspot/src/cpu/mips/vm/c1_Runtime1_mips.cpp	Mon Oct 25 15:43:04 2010 +0800
@@ -894,26 +894,26 @@
           __ slt(AT, AT, length);
           __ bne(AT, ZERO, slow_path);
           __ delayed()->nop();
-        
+
           // if we got here then the TLAB allocation failed, so try
           // refilling the TLAB or allocating directly from eden.
           Label retry_tlab, try_eden;
           //T0,T1,T5,T8 have changed! 
-          __ tlab_refill(retry_tlab, try_eden, slow_path); // preserves ebx & edx
+          __ tlab_refill(retry_tlab, try_eden, slow_path); // preserves T2 & T4
         
           __ bind(retry_tlab);
         
           // get the allocation size: (length << (layout_helper & 0x1F)) + header_size
           __ lw(t1, klass, klassOopDesc::header_size() * HeapWordSize 
                            + Klass::layout_helper_offset_in_bytes());	 
-          __ srl(AT, t1, Klass::_lh_log2_element_size_shift);
-          __ andi(AT, AT, Klass::_lh_log2_element_size_mask);
+          __ andi(AT, t1, 0x1f);
           __ sllv(arr_size, length, AT);
-          __ srl(AT, t1, Klass::_lh_header_size_shift);
-          __ andi(AT, AT, Klass::_lh_header_size_mask);
-          __ add(arr_size, AT, arr_size);
+          __ srl(t1, t1, Klass::_lh_header_size_shift);
+          __ andi(t1, t1, Klass::_lh_header_size_mask);
+          __ add(arr_size, t1, arr_size);
           __ addi(arr_size, arr_size, MinObjAlignmentInBytesMask);  // align up
-          __ andi(arr_size, arr_size, ~MinObjAlignmentInBytesMask);
+          __ move(AT, ~MinObjAlignmentInBytesMask);
+          __ andr(arr_size, arr_size, AT);
         
         
           __ tlab_allocate(obj, arr_size, 0, t1, t2, slow_path);  // preserves arr_size
@@ -921,6 +921,8 @@
           __ lbu(t1, Address(klass, klassOopDesc::header_size() * HeapWordSize 
                                     + Klass::layout_helper_offset_in_bytes() 
                                     + (Klass::_lh_header_size_shift / BitsPerByte)));
+          assert(Klass::_lh_header_size_shift % BitsPerByte == 0, "bytewise");
+          assert(Klass::_lh_header_size_mask <= 0xFF, "bytewise");
           __ andi(t1, t1, Klass::_lh_header_size_mask);
           __ sub(arr_size, arr_size, t1);  // body length
           __ add(t1, t1, obj);             // body start
@@ -932,19 +934,16 @@
           __ bind(try_eden);
           // get the allocation size: (length << (layout_helper & 0x1F)) + header_size
           __ lw(t1, klass, klassOopDesc::header_size() * HeapWordSize 
-                           + Klass::layout_helper_offset_in_bytes());
-          __ srl(AT, t1, Klass::_lh_log2_element_size_shift);
-          __ andi(AT, AT, Klass::_lh_log2_element_size_mask);
+                           + Klass::layout_helper_offset_in_bytes());	 
+          __ andi(AT, t1, 0x1f);
           __ sllv(arr_size, length, AT);
-          __ srl(AT, t1, Klass::_lh_header_size_shift);
-          __ andi(AT, AT, Klass::_lh_header_size_mask);
-          __ add(arr_size, AT, arr_size);
+          __ srl(t1, t1, Klass::_lh_header_size_shift);
+          __ andi(t1, t1, Klass::_lh_header_size_mask);
+          __ add(arr_size, t1, arr_size);
           __ addi(arr_size, arr_size, MinObjAlignmentInBytesMask);  // align up
-          __ andi(arr_size, arr_size, ~MinObjAlignmentInBytesMask);
-        
-        
+          __ move(AT, ~MinObjAlignmentInBytesMask);
+          __ andr(arr_size, arr_size, AT);
           __ eden_allocate(obj, arr_size, 0, t1, t2, slow_path);  // preserves arr_size
-        
           __ initialize_header(obj, klass, length,t1,t2);
           __ lbu(t1, Address(klass, klassOopDesc::header_size() * HeapWordSize 
                                     + Klass::layout_helper_offset_in_bytes()