< prev index next >

src/hotspot/cpu/x86/stubGenerator_x86_32.cpp

rename things

8  * This code is distributed in the hope that it will be useful, but WITHOUT                                                          
9  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or                                                             
10  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License                                                             
11  * version 2 for more details (a copy is included in the LICENSE file that                                                           
12  * accompanied this code).                                                                                                           
13  *                                                                                                                                   
14  * You should have received a copy of the GNU General Public License version                                                         
15  * 2 along with this work; if not, write to the Free Software Foundation,                                                            
16  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.                                                                     
17  *                                                                                                                                   
18  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA                                                           
19  * or visit www.oracle.com if you need additional information or have any                                                            
20  * questions.                                                                                                                        
21  *                                                                                                                                   
22  */                                                                                                                                  
23 
24 #include "precompiled.hpp"                                                                                                           
25 #include "asm/macroAssembler.hpp"                                                                                                    
26 #include "asm/macroAssembler.inline.hpp"                                                                                             
27 #include "gc/shared/barrierSet.hpp"                                                                                                  
28 #include "gc/shared/barrierSetCodeGen.hpp"                                                                                           
29 #include "interpreter/interpreter.hpp"                                                                                               
30 #include "nativeInst_x86.hpp"                                                                                                        
31 #include "oops/instanceOop.hpp"                                                                                                      
32 #include "oops/method.hpp"                                                                                                           
33 #include "oops/objArrayKlass.hpp"                                                                                                    
34 #include "oops/oop.inline.hpp"                                                                                                       
35 #include "prims/methodHandles.hpp"                                                                                                   
36 #include "runtime/frame.inline.hpp"                                                                                                  
37 #include "runtime/handles.inline.hpp"                                                                                                
38 #include "runtime/sharedRuntime.hpp"                                                                                                 
39 #include "runtime/stubCodeGenerator.hpp"                                                                                             
40 #include "runtime/stubRoutines.hpp"                                                                                                  
41 #include "runtime/thread.inline.hpp"                                                                                                 
42 #ifdef COMPILER2                                                                                                                     
43 #include "opto/runtime.hpp"                                                                                                          
44 #endif                                                                                                                               
45 
46 // Declaration and definition of StubGenerator (no .hpp file).                                                                       
47 // For a more detailed description of the stub routine structure                                                                     

8  * This code is distributed in the hope that it will be useful, but WITHOUT
9  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
11  * version 2 for more details (a copy is included in the LICENSE file that
12  * accompanied this code).
13  *
14  * You should have received a copy of the GNU General Public License version
15  * 2 along with this work; if not, write to the Free Software Foundation,
16  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
17  *
18  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
19  * or visit www.oracle.com if you need additional information or have any
20  * questions.
21  *
22  */
23 
24 #include "precompiled.hpp"
25 #include "asm/macroAssembler.hpp"
26 #include "asm/macroAssembler.inline.hpp"
27 #include "gc/shared/barrierSet.hpp"
28 #include "gc/shared/barrierSetAssembler.hpp"
29 #include "interpreter/interpreter.hpp"
30 #include "nativeInst_x86.hpp"
31 #include "oops/instanceOop.hpp"
32 #include "oops/method.hpp"
33 #include "oops/objArrayKlass.hpp"
34 #include "oops/oop.inline.hpp"
35 #include "prims/methodHandles.hpp"
36 #include "runtime/frame.inline.hpp"
37 #include "runtime/handles.inline.hpp"
38 #include "runtime/sharedRuntime.hpp"
39 #include "runtime/stubCodeGenerator.hpp"
40 #include "runtime/stubRoutines.hpp"
41 #include "runtime/thread.inline.hpp"
42 #ifdef COMPILER2
43 #include "opto/runtime.hpp"
44 #endif
45 
46 // Declaration and definition of StubGenerator (no .hpp file).
47 // For a more detailed description of the stub routine structure

827     __ movl(count, Address(rsp, 12+ 12));                                                                                            
828 
829     if (entry != NULL) {                                                                                                             
830       *entry = __ pc(); // Entry point from conjoint arraycopy stub.                                                                 
831       BLOCK_COMMENT("Entry:");                                                                                                       
832     }                                                                                                                                
833 
834     if (t == T_OBJECT) {                                                                                                             
835       __ testl(count, count);                                                                                                        
836       __ jcc(Assembler::zero, L_0_count);                                                                                            
837     }                                                                                                                                
838 
839     DecoratorSet decorators = ARRAYCOPY_DISJOINT;                                                                                    
840     if (dest_uninitialized) {                                                                                                        
841       decorators |= AS_DEST_NOT_INITIALIZED;                                                                                         
842     }                                                                                                                                
843     if (aligned) {                                                                                                                   
844       decorators |= ARRAYCOPY_ALIGNED;                                                                                               
845     }                                                                                                                                
846 
847     BarrierSetCodeGen *bs = Universe::heap()->barrier_set()->code_gen();                                                             
848     bs->arraycopy_prologue(_masm, decorators, t, from, to, count);                                                                   
849 
850     __ subptr(to, from); // to --> to_from                                                                                           
851     __ cmpl(count, 2<<shift); // Short arrays (< 8 bytes) copy by element                                                            
852     __ jcc(Assembler::below, L_copy_4_bytes); // use unsigned cmp                                                                    
853     if (!UseUnalignedLoadStores && !aligned && (t == T_BYTE || t == T_SHORT)) {                                                      
854       // align source address at 4 bytes address boundary                                                                            
855       if (t == T_BYTE) {                                                                                                             
856         // One byte misalignment happens only for byte arrays                                                                        
857         __ testl(from, 1);                                                                                                           
858         __ jccb(Assembler::zero, L_skip_align1);                                                                                     
859         __ movb(rax, Address(from, 0));                                                                                              
860         __ movb(Address(from, to_from, Address::times_1, 0), rax);                                                                   
861         __ increment(from);                                                                                                          
862         __ decrement(count);                                                                                                         
863       __ BIND(L_skip_align1);                                                                                                        
864       }                                                                                                                              
865       // Two bytes misalignment happens only for byte and short (char) arrays                                                        
866       __ testl(from, 2);                                                                                                             

827     __ movl(count, Address(rsp, 12+ 12));
828 
829     if (entry != NULL) {
830       *entry = __ pc(); // Entry point from conjoint arraycopy stub.
831       BLOCK_COMMENT("Entry:");
832     }
833 
834     if (t == T_OBJECT) {
835       __ testl(count, count);
836       __ jcc(Assembler::zero, L_0_count);
837     }
838 
839     DecoratorSet decorators = ARRAYCOPY_DISJOINT;
840     if (dest_uninitialized) {
841       decorators |= AS_DEST_NOT_INITIALIZED;
842     }
843     if (aligned) {
844       decorators |= ARRAYCOPY_ALIGNED;
845     }
846 
847     BarrierSetAssembler *bs = Universe::heap()->barrier_set()->barrier_set_assembler();
848     bs->arraycopy_prologue(_masm, decorators, t, from, to, count);
849 
850     __ subptr(to, from); // to --> to_from
851     __ cmpl(count, 2<<shift); // Short arrays (< 8 bytes) copy by element
852     __ jcc(Assembler::below, L_copy_4_bytes); // use unsigned cmp
853     if (!UseUnalignedLoadStores && !aligned && (t == T_BYTE || t == T_SHORT)) {
854       // align source address at 4 bytes address boundary
855       if (t == T_BYTE) {
856         // One byte misalignment happens only for byte arrays
857         __ testl(from, 1);
858         __ jccb(Assembler::zero, L_skip_align1);
859         __ movb(rax, Address(from, 0));
860         __ movb(Address(from, to_from, Address::times_1, 0), rax);
861         __ increment(from);
862         __ decrement(count);
863       __ BIND(L_skip_align1);
864       }
865       // Two bytes misalignment happens only for byte and short (char) arrays
866       __ testl(from, 2);

1016     RuntimeAddress nooverlap(nooverlap_target);                                                                                      
1017     __ cmpptr(dst, src);                                                                                                             
1018     __ lea(end, Address(src, count, sf, 0)); // src + count * elem_size                                                              
1019     __ jump_cc(Assembler::belowEqual, nooverlap);                                                                                    
1020     __ cmpptr(dst, end);                                                                                                             
1021     __ jump_cc(Assembler::aboveEqual, nooverlap);                                                                                    
1022 
1023     if (t == T_OBJECT) {                                                                                                             
1024       __ testl(count, count);                                                                                                        
1025       __ jcc(Assembler::zero, L_0_count);                                                                                            
1026     }                                                                                                                                
1027 
1028     DecoratorSet decorators = 0;                                                                                                     
1029     if (dest_uninitialized) {                                                                                                        
1030       decorators |= AS_DEST_NOT_INITIALIZED;                                                                                         
1031     }                                                                                                                                
1032     if (aligned) {                                                                                                                   
1033       decorators |= ARRAYCOPY_ALIGNED;                                                                                               
1034     }                                                                                                                                
1035 
1036     BarrierSetCodeGen *bs = Universe::heap()->barrier_set()->code_gen();                                                             
1037     bs->arraycopy_prologue(_masm, decorators, t, from, to, count);                                                                   
1038 
1039     // copy from high to low                                                                                                         
1040     __ cmpl(count, 2<<shift); // Short arrays (< 8 bytes) copy by element                                                            
1041     __ jcc(Assembler::below, L_copy_4_bytes); // use unsigned cmp                                                                    
1042     if (t == T_BYTE || t == T_SHORT) {                                                                                               
1043       // Align the end of destination array at 4 bytes address boundary                                                              
1044       __ lea(end, Address(dst, count, sf, 0));                                                                                       
1045       if (t == T_BYTE) {                                                                                                             
1046         // One byte misalignment happens only for byte arrays                                                                        
1047         __ testl(end, 1);                                                                                                            
1048         __ jccb(Assembler::zero, L_skip_align1);                                                                                     
1049         __ decrement(count);                                                                                                         
1050         __ movb(rdx, Address(from, count, sf, 0));                                                                                   
1051         __ movb(Address(to, count, sf, 0), rdx);                                                                                     
1052       __ BIND(L_skip_align1);                                                                                                        
1053       }                                                                                                                              
1054       // Two bytes misalignment happens only for byte and short (char) arrays                                                        
1055       __ testl(end, 2);                                                                                                              

1016     RuntimeAddress nooverlap(nooverlap_target);
1017     __ cmpptr(dst, src);
1018     __ lea(end, Address(src, count, sf, 0)); // src + count * elem_size
1019     __ jump_cc(Assembler::belowEqual, nooverlap);
1020     __ cmpptr(dst, end);
1021     __ jump_cc(Assembler::aboveEqual, nooverlap);
1022 
1023     if (t == T_OBJECT) {
1024       __ testl(count, count);
1025       __ jcc(Assembler::zero, L_0_count);
1026     }
1027 
1028     DecoratorSet decorators = 0;
1029     if (dest_uninitialized) {
1030       decorators |= AS_DEST_NOT_INITIALIZED;
1031     }
1032     if (aligned) {
1033       decorators |= ARRAYCOPY_ALIGNED;
1034     }
1035 
1036     BarrierSetAssembler *bs = Universe::heap()->barrier_set()->barrier_set_assembler();
1037     bs->arraycopy_prologue(_masm, decorators, t, from, to, count);
1038 
1039     // copy from high to low
1040     __ cmpl(count, 2<<shift); // Short arrays (< 8 bytes) copy by element
1041     __ jcc(Assembler::below, L_copy_4_bytes); // use unsigned cmp
1042     if (t == T_BYTE || t == T_SHORT) {
1043       // Align the end of destination array at 4 bytes address boundary
1044       __ lea(end, Address(dst, count, sf, 0));
1045       if (t == T_BYTE) {
1046         // One byte misalignment happens only for byte arrays
1047         __ testl(end, 1);
1048         __ jccb(Assembler::zero, L_skip_align1);
1049         __ decrement(count);
1050         __ movb(rdx, Address(from, count, sf, 0));
1051         __ movb(Address(to, count, sf, 0), rdx);
1052       __ BIND(L_skip_align1);
1053       }
1054       // Two bytes misalignment happens only for byte and short (char) arrays
1055       __ testl(end, 2);

1371 
1372     // Loop-invariant addresses.  They are exclusive end pointers.                                                                   
1373     Address end_from_addr(from, length, Address::times_ptr, 0);                                                                      
1374     Address   end_to_addr(to,   length, Address::times_ptr, 0);                                                                      
1375 
1376     Register end_from = from;           // re-use                                                                                    
1377     Register end_to   = to;             // re-use                                                                                    
1378     Register count    = length;         // re-use                                                                                    
1379 
1380     // Loop-variant addresses.  They assume post-incremented count < 0.                                                              
1381     Address from_element_addr(end_from, count, Address::times_ptr, 0);                                                               
1382     Address   to_element_addr(end_to,   count, Address::times_ptr, 0);                                                               
1383     Address elem_klass_addr(elem, oopDesc::klass_offset_in_bytes());                                                                 
1384 
1385     DecoratorSet decorators = ARRAYCOPY_CHECKCAST;                                                                                   
1386     if (dest_uninitialized) {                                                                                                        
1387       decorators |= AS_DEST_NOT_INITIALIZED;                                                                                         
1388     }                                                                                                                                
1389 
1390     BasicType type = T_OBJECT;                                                                                                       
1391     BarrierSetCodeGen *bs = Universe::heap()->barrier_set()->code_gen();                                                             
1392     bs->arraycopy_prologue(_masm, decorators, type, from, to, count);                                                                
1393 
1394     // Copy from low to high addresses, indexed from the end of each array.                                                          
1395     __ lea(end_from, end_from_addr);                                                                                                 
1396     __ lea(end_to,   end_to_addr);                                                                                                   
1397     assert(length == count, "");        // else fix next line:                                                                       
1398     __ negptr(count);                   // negate and test the length                                                                
1399     __ jccb(Assembler::notZero, L_load_element);                                                                                     
1400 
1401     // Empty array:  Nothing to do.                                                                                                  
1402     __ xorptr(rax, rax);                  // return 0 on (trivial) success                                                           
1403     __ jmp(L_done);                                                                                                                  
1404 
1405     // ======== begin loop ========                                                                                                  
1406     // (Loop is rotated; its entry is L_load_element.)                                                                               
1407     // Loop control:                                                                                                                 
1408     //   for (count = -count; count != 0; count++)                                                                                   
1409     // Base pointers src, dst are biased by 8*count,to last element.                                                                 
1410     __ align(OptoLoopAlignment);                                                                                                     

1371 
1372     // Loop-invariant addresses.  They are exclusive end pointers.
1373     Address end_from_addr(from, length, Address::times_ptr, 0);
1374     Address   end_to_addr(to,   length, Address::times_ptr, 0);
1375 
1376     Register end_from = from;           // re-use
1377     Register end_to   = to;             // re-use
1378     Register count    = length;         // re-use
1379 
1380     // Loop-variant addresses.  They assume post-incremented count < 0.
1381     Address from_element_addr(end_from, count, Address::times_ptr, 0);
1382     Address   to_element_addr(end_to,   count, Address::times_ptr, 0);
1383     Address elem_klass_addr(elem, oopDesc::klass_offset_in_bytes());
1384 
1385     DecoratorSet decorators = ARRAYCOPY_CHECKCAST;
1386     if (dest_uninitialized) {
1387       decorators |= AS_DEST_NOT_INITIALIZED;
1388     }
1389 
1390     BasicType type = T_OBJECT;
1391     BarrierSetAssembler *bs = Universe::heap()->barrier_set()->barrier_set_assembler();
1392     bs->arraycopy_prologue(_masm, decorators, type, from, to, count);
1393 
1394     // Copy from low to high addresses, indexed from the end of each array.
1395     __ lea(end_from, end_from_addr);
1396     __ lea(end_to,   end_to_addr);
1397     assert(length == count, "");        // else fix next line:
1398     __ negptr(count);                   // negate and test the length
1399     __ jccb(Assembler::notZero, L_load_element);
1400 
1401     // Empty array:  Nothing to do.
1402     __ xorptr(rax, rax);                  // return 0 on (trivial) success
1403     __ jmp(L_done);
1404 
1405     // ======== begin loop ========
1406     // (Loop is rotated; its entry is L_load_element.)
1407     // Loop control:
1408     //   for (count = -count; count != 0; count++)
1409     // Base pointers src, dst are biased by 8*count,to last element.
1410     __ align(OptoLoopAlignment);
< prev index next >