< prev index next >

src/hotspot/cpu/s390/gc/g1/g1BarrierSetAssembler_s390.cpp

BarrierSetC1_v2

BarrierSetC1

8  *                                                                                                                                   
9  * This code is distributed in the hope that it will be useful, but WITHOUT                                                          
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or                                                             
11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License                                                             
12  * version 2 for more details (a copy is included in the LICENSE file that                                                           
13  * accompanied this code).                                                                                                           
14  *                                                                                                                                   
15  * You should have received a copy of the GNU General Public License version                                                         
16  * 2 along with this work; if not, write to the Free Software Foundation,                                                            
17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.                                                                     
18  *                                                                                                                                   
19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA                                                           
20  * or visit www.oracle.com if you need additional information or have any                                                            
21  * questions.                                                                                                                        
22  *                                                                                                                                   
23  */                                                                                                                                  
24 
25 #include "precompiled.hpp"                                                                                                           
26 #include "asm/macroAssembler.inline.hpp"                                                                                             
27 #include "registerSaver_s390.hpp"                                                                                                    
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
28 #include "gc/g1/g1CardTable.hpp"                                                                                                     
29 #include "gc/g1/g1BarrierSet.hpp"                                                                                                    
30 #include "gc/g1/g1BarrierSetAssembler.hpp"                                                                                           
31 #include "gc/g1/g1ThreadLocalData.hpp"                                                                                               
32 #include "gc/g1/heapRegion.hpp"                                                                                                      
33 #include "interpreter/interp_masm.hpp"                                                                                               
34 #include "runtime/sharedRuntime.hpp"                                                                                                 
35 
36 #define __ masm->                                                                                                                    
37 
38 #define BLOCK_COMMENT(str) if (PrintAssembly) __ block_comment(str)                                                                  
39 
40 void G1BarrierSetAssembler::gen_write_ref_array_pre_barrier(MacroAssembler* masm, DecoratorSet decorators,                           
41                                                             Register addr, Register count) {                                         
42   bool dest_uninitialized = (decorators & AS_DEST_NOT_INITIALIZED) != 0;                                                             
43 
44   // With G1, don't generate the call if we statically know that the target is uninitialized.                                        
45   if (!dest_uninitialized) {                                                                                                         
46     // Is marking active?                                                                                                            

8  *
9  * This code is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
12  * version 2 for more details (a copy is included in the LICENSE file that
13  * accompanied this code).
14  *
15  * You should have received a copy of the GNU General Public License version
16  * 2 along with this work; if not, write to the Free Software Foundation,
17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18  *
19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20  * or visit www.oracle.com if you need additional information or have any
21  * questions.
22  *
23  */
24 
25 #include "precompiled.hpp"
26 #include "asm/macroAssembler.inline.hpp"
27 #include "registerSaver_s390.hpp"
28 #include "c1/c1_LIRAssembler.hpp"
29 #include "c1/c1_MacroAssembler.hpp"
30 #include "gc/g1/c1/g1BarrierSetC1.hpp"
31 #include "gc/g1/g1CardTable.hpp"
32 #include "gc/g1/g1BarrierSet.hpp"
33 #include "gc/g1/g1BarrierSetAssembler.hpp"
34 #include "gc/g1/g1ThreadLocalData.hpp"
35 #include "gc/g1/heapRegion.hpp"
36 #include "interpreter/interp_masm.hpp"
37 #include "runtime/sharedRuntime.hpp"
38 
39 #define __ masm->
40 
41 #define BLOCK_COMMENT(str) if (PrintAssembly) __ block_comment(str)
42 
43 void G1BarrierSetAssembler::gen_write_ref_array_pre_barrier(MacroAssembler* masm, DecoratorSet decorators,
44                                                             Register addr, Register count) {
45   bool dest_uninitialized = (decorators & AS_DEST_NOT_INITIALIZED) != 0;
46 
47   // With G1, don't generate the call if we statically know that the target is uninitialized.
48   if (!dest_uninitialized) {
49     // Is marking active?

388 }                                                                                                                                    
389 
390 void G1BarrierSetAssembler::resolve_jobject(MacroAssembler* masm, Register value, Register tmp1, Register tmp2) {                    
391   NearLabel Ldone, Lnot_weak;                                                                                                        
392   __ z_ltgr(tmp1, value);                                                                                                            
393   __ z_bre(Ldone);          // Use NULL result as-is.                                                                                
394 
395   __ z_nill(value, ~JNIHandles::weak_tag_mask);                                                                                      
396   __ z_lg(value, 0, value); // Resolve (untagged) jobject.                                                                           
397 
398   __ z_tmll(tmp1, JNIHandles::weak_tag_mask); // Test for jweak tag.                                                                 
399   __ z_braz(Lnot_weak);                                                                                                              
400   __ verify_oop(value);                                                                                                              
401   DecoratorSet decorators = IN_ROOT | ON_PHANTOM_OOP_REF;                                                                            
402   g1_write_barrier_pre(masm, decorators, (const Address*)NULL, value, noreg, tmp1, tmp2, true);                                      
403   __ bind(Lnot_weak);                                                                                                                
404   __ verify_oop(value);                                                                                                              
405   __ bind(Ldone);                                                                                                                    
406 }                                                                                                                                    
407 
                                                                                                                                     
                                                                                                                                     
408 #undef __                                                                                                                            
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     

391 }
392 
393 void G1BarrierSetAssembler::resolve_jobject(MacroAssembler* masm, Register value, Register tmp1, Register tmp2) {
394   NearLabel Ldone, Lnot_weak;
395   __ z_ltgr(tmp1, value);
396   __ z_bre(Ldone);          // Use NULL result as-is.
397 
398   __ z_nill(value, ~JNIHandles::weak_tag_mask);
399   __ z_lg(value, 0, value); // Resolve (untagged) jobject.
400 
401   __ z_tmll(tmp1, JNIHandles::weak_tag_mask); // Test for jweak tag.
402   __ z_braz(Lnot_weak);
403   __ verify_oop(value);
404   DecoratorSet decorators = IN_ROOT | ON_PHANTOM_OOP_REF;
405   g1_write_barrier_pre(masm, decorators, (const Address*)NULL, value, noreg, tmp1, tmp2, true);
406   __ bind(Lnot_weak);
407   __ verify_oop(value);
408   __ bind(Ldone);
409 }
410 
411 #ifdef COMPILER1
412 
413 #undef __
414 #define __ ce->masm()->
415 
416 void G1BarrierSetAssembler::gen_g1_pre_barrier_stub(LIR_Assembler* ce, G1PreBarrierStub* stub) {
417   G1BarrierSetC1* bs = (G1BarrierSetC1*)BarrierSet::barrier_set()->barrier_set_c1();
418   // At this point we know that marking is in progress.
419   // If do_load() is true then we have to emit the
420   // load of the previous value; otherwise it has already
421   // been loaded into _pre_val.
422   __ bind(*stub->entry());
423   ce->check_reserved_argument_area(16); // RT stub needs 2 spill slots.
424   assert(stub->pre_val()->is_register(), "Precondition.");
425 
426   Register pre_val_reg = stub->pre_val()->as_register();
427 
428   if (stub->do_load()) {
429     ce->mem2reg(stub->addr(), stub->pre_val(), T_OBJECT, stub->patch_code(), stub->info(), false /*wide*/, false /*unaligned*/);
430   }
431 
432   __ z_ltgr(Z_R1_scratch, pre_val_reg); // Pass oop in Z_R1_scratch to Runtime1::g1_pre_barrier_slow_id.
433   __ branch_optimized(Assembler::bcondZero, *stub->continuation());
434   ce->emit_call_c(bs->pre_barrier_c1_runtime_code_blob()->code_begin());
435   __ branch_optimized(Assembler::bcondAlways, *stub->continuation());
436 }
437 
438 void G1BarrierSetAssembler::gen_g1_post_barrier_stub(LIR_Assembler* ce, G1PostBarrierStub* stub) {
439   G1BarrierSetC1* bs = (G1BarrierSetC1*)BarrierSet::barrier_set()->barrier_set_c1();
440   __ bind(*stub->entry());
441   ce->check_reserved_argument_area(16); // RT stub needs 2 spill slots.
442   assert(stub->addr()->is_register(), "Precondition.");
443   assert(stub->new_val()->is_register(), "Precondition.");
444   Register new_val_reg = stub->new_val()->as_register();
445   __ z_ltgr(new_val_reg, new_val_reg);
446   __ branch_optimized(Assembler::bcondZero, *stub->continuation());
447   __ z_lgr(Z_R1_scratch, stub->addr()->as_pointer_register());
448   ce->emit_call_c(bs->post_barrier_c1_runtime_code_blob()->code_begin());
449   __ branch_optimized(Assembler::bcondAlways, *stub->continuation());
450 }
451 
452 #undef __
453 
454 #define __ sasm->
455 
456 static OopMap* save_volatile_registers(StubAssembler* sasm, Register return_pc = Z_R14) {
457   __ block_comment("save_volatile_registers");
458   RegisterSaver::RegisterSet reg_set = RegisterSaver::all_volatile_registers;
459   int frame_size_in_slots = RegisterSaver::live_reg_frame_size(reg_set) / VMRegImpl::stack_slot_size;
460   sasm->set_frame_size(frame_size_in_slots / VMRegImpl::slots_per_word);
461   return RegisterSaver::save_live_registers(sasm, reg_set, return_pc);
462 }
463 
464 static void restore_volatile_registers(StubAssembler* sasm) {
465   __ block_comment("restore_volatile_registers");
466   RegisterSaver::RegisterSet reg_set = RegisterSaver::all_volatile_registers;
467   RegisterSaver::restore_live_registers(sasm, reg_set);
468 }
469 
470 void G1BarrierSetAssembler::generate_c1_pre_barrier_runtime_stub(StubAssembler* sasm) {
471   // Z_R1_scratch: previous value of memory
472 
473   BarrierSet* bs = BarrierSet::barrier_set();
474   __ set_info("g1_pre_barrier_slow_id", false);
475 
476   Register pre_val = Z_R1_scratch;
477   Register tmp  = Z_R6; // Must be non-volatile because it is used to save pre_val.
478   Register tmp2 = Z_R7;
479 
480   Label refill, restart, marking_not_active;
481   int satb_q_active_byte_offset = in_bytes(G1ThreadLocalData::satb_mark_queue_active_offset());
482   int satb_q_index_byte_offset = in_bytes(G1ThreadLocalData::satb_mark_queue_index_offset());
483   int satb_q_buf_byte_offset = in_bytes(G1ThreadLocalData::satb_mark_queue_buffer_offset());
484 
485   // Save tmp registers (see assertion in G1PreBarrierStub::emit_code()).
486   __ z_stg(tmp,  0*BytesPerWord + FrameMap::first_available_sp_in_frame, Z_SP);
487   __ z_stg(tmp2, 1*BytesPerWord + FrameMap::first_available_sp_in_frame, Z_SP);
488 
489   // Is marking still active?
490   if (in_bytes(SATBMarkQueue::byte_width_of_active()) == 4) {
491     __ load_and_test_int(tmp, Address(Z_thread, satb_q_active_byte_offset));
492   } else {
493     assert(in_bytes(SATBMarkQueue::byte_width_of_active()) == 1, "Assumption");
494     __ load_and_test_byte(tmp, Address(Z_thread, satb_q_active_byte_offset));
495   }
496   __ z_bre(marking_not_active); // Activity indicator is zero, so there is no marking going on currently.
497 
498   __ bind(restart);
499   // Load the index into the SATB buffer. SATBMarkQueue::_index is a
500   // size_t so ld_ptr is appropriate.
501   __ z_ltg(tmp, satb_q_index_byte_offset, Z_R0, Z_thread);
502 
503   // index == 0?
504   __ z_brz(refill);
505 
506   __ z_lg(tmp2, satb_q_buf_byte_offset, Z_thread);
507   __ add2reg(tmp, -oopSize);
508 
509   __ z_stg(pre_val, 0, tmp, tmp2); // [_buf + index] := <address_of_card>
510   __ z_stg(tmp, satb_q_index_byte_offset, Z_thread);
511 
512   __ bind(marking_not_active);
513   // Restore tmp registers (see assertion in G1PreBarrierStub::emit_code()).
514   __ z_lg(tmp,  0*BytesPerWord + FrameMap::first_available_sp_in_frame, Z_SP);
515   __ z_lg(tmp2, 1*BytesPerWord + FrameMap::first_available_sp_in_frame, Z_SP);
516   __ z_br(Z_R14);
517 
518   __ bind(refill);
519   save_volatile_registers(sasm);
520   __ z_lgr(tmp, pre_val); // save pre_val
521   __ call_VM_leaf(CAST_FROM_FN_PTR(address, SATBMarkQueueSet::handle_zero_index_for_thread),
522                   Z_thread);
523   __ z_lgr(pre_val, tmp); // restore pre_val
524   restore_volatile_registers(sasm);
525   __ z_bru(restart);
526 }
527 
528 void G1BarrierSetAssembler::generate_c1_post_barrier_runtime_stub(StubAssembler* sasm) {
529   // Z_R1_scratch: oop address, address of updated memory slot
530 
531   BarrierSet* bs = BarrierSet::barrier_set();
532   __ set_info("g1_post_barrier_slow_id", false);
533 
534   Register addr_oop  = Z_R1_scratch;
535   Register addr_card = Z_R1_scratch;
536   Register r1        = Z_R6; // Must be saved/restored.
537   Register r2        = Z_R7; // Must be saved/restored.
538   Register cardtable = r1;   // Must be non-volatile, because it is used to save addr_card.
539   CardTableBarrierSet* ctbs = barrier_set_cast<CardTableBarrierSet>(bs);
540   CardTable* ct = ctbs->card_table();
541   jbyte* byte_map_base = ct->byte_map_base();
542 
543   // Save registers used below (see assertion in G1PreBarrierStub::emit_code()).
544   __ z_stg(r1, 0*BytesPerWord + FrameMap::first_available_sp_in_frame, Z_SP);
545 
546   Label not_already_dirty, restart, refill, young_card;
547 
548   // Calculate address of card corresponding to the updated oop slot.
549   AddressLiteral rs(byte_map_base);
550   __ z_srlg(addr_card, addr_oop, CardTable::card_shift);
551   addr_oop = noreg; // dead now
552   __ load_const_optimized(cardtable, rs); // cardtable := <card table base>
553   __ z_agr(addr_card, cardtable); // addr_card := addr_oop>>card_shift + cardtable
554 
555   __ z_cli(0, addr_card, (int)G1CardTable::g1_young_card_val());
556   __ z_bre(young_card);
557 
558   __ z_sync(); // Required to support concurrent cleaning.
559 
560   __ z_cli(0, addr_card, (int)CardTable::dirty_card_val());
561   __ z_brne(not_already_dirty);
562 
563   __ bind(young_card);
564   // We didn't take the branch, so we're already dirty: restore
565   // used registers and return.
566   __ z_lg(r1, 0*BytesPerWord + FrameMap::first_available_sp_in_frame, Z_SP);
567   __ z_br(Z_R14);
568 
569   // Not dirty.
570   __ bind(not_already_dirty);
571 
572   // First, dirty it: [addr_card] := 0
573   __ z_mvi(0, addr_card, CardTable::dirty_card_val());
574 
575   Register idx = cardtable; // Must be non-volatile, because it is used to save addr_card.
576   Register buf = r2;
577   cardtable = noreg; // now dead
578 
579   // Save registers used below (see assertion in G1PreBarrierStub::emit_code()).
580   __ z_stg(r2, 1*BytesPerWord + FrameMap::first_available_sp_in_frame, Z_SP);
581 
582   ByteSize dirty_card_q_index_byte_offset = G1ThreadLocalData::dirty_card_queue_index_offset();
583   ByteSize dirty_card_q_buf_byte_offset = G1ThreadLocalData::dirty_card_queue_buffer_offset();
584 
585   __ bind(restart);
586 
587   // Get the index into the update buffer. DirtyCardQueue::_index is
588   // a size_t so z_ltg is appropriate here.
589   __ z_ltg(idx, Address(Z_thread, dirty_card_q_index_byte_offset));
590 
591   // index == 0?
592   __ z_brz(refill);
593 
594   __ z_lg(buf, Address(Z_thread, dirty_card_q_buf_byte_offset));
595   __ add2reg(idx, -oopSize);
596 
597   __ z_stg(addr_card, 0, idx, buf); // [_buf + index] := <address_of_card>
598   __ z_stg(idx, Address(Z_thread, dirty_card_q_index_byte_offset));
599   // Restore killed registers and return.
600   __ z_lg(r1, 0*BytesPerWord + FrameMap::first_available_sp_in_frame, Z_SP);
601   __ z_lg(r2, 1*BytesPerWord + FrameMap::first_available_sp_in_frame, Z_SP);
602   __ z_br(Z_R14);
603 
604   __ bind(refill);
605   save_volatile_registers(sasm);
606   __ z_lgr(idx, addr_card); // Save addr_card, tmp3 must be non-volatile.
607   __ call_VM_leaf(CAST_FROM_FN_PTR(address, DirtyCardQueueSet::handle_zero_index_for_thread),
608                                    Z_thread);
609   __ z_lgr(addr_card, idx);
610   restore_volatile_registers(sasm); // Restore addr_card.
611   __ z_bru(restart);
612 }
613 
614 #undef __
615 
616 #endif // COMPILER1
< prev index next >