src/hotspot/cpu/x86/macroAssembler_x86.cpp
changeset 49164 7e958a8ebcd3
parent 49027 8dc742d9bbab
child 49347 edb65305d3ac
equal deleted inserted replaced
49163:580bb0b85f63 49164:7e958a8ebcd3
    25 #include "precompiled.hpp"
    25 #include "precompiled.hpp"
    26 #include "jvm.h"
    26 #include "jvm.h"
    27 #include "asm/assembler.hpp"
    27 #include "asm/assembler.hpp"
    28 #include "asm/assembler.inline.hpp"
    28 #include "asm/assembler.inline.hpp"
    29 #include "compiler/disassembler.hpp"
    29 #include "compiler/disassembler.hpp"
       
    30 #include "gc/shared/cardTable.hpp"
    30 #include "gc/shared/cardTableModRefBS.hpp"
    31 #include "gc/shared/cardTableModRefBS.hpp"
    31 #include "gc/shared/collectedHeap.inline.hpp"
    32 #include "gc/shared/collectedHeap.inline.hpp"
    32 #include "interpreter/interpreter.hpp"
    33 #include "interpreter/interpreter.hpp"
    33 #include "memory/resourceArea.hpp"
    34 #include "memory/resourceArea.hpp"
    34 #include "memory/universe.hpp"
    35 #include "memory/universe.hpp"
    43 #include "runtime/sharedRuntime.hpp"
    44 #include "runtime/sharedRuntime.hpp"
    44 #include "runtime/stubRoutines.hpp"
    45 #include "runtime/stubRoutines.hpp"
    45 #include "runtime/thread.hpp"
    46 #include "runtime/thread.hpp"
    46 #include "utilities/macros.hpp"
    47 #include "utilities/macros.hpp"
    47 #if INCLUDE_ALL_GCS
    48 #if INCLUDE_ALL_GCS
       
    49 #include "gc/g1/g1CardTable.hpp"
    48 #include "gc/g1/g1CollectedHeap.inline.hpp"
    50 #include "gc/g1/g1CollectedHeap.inline.hpp"
    49 #include "gc/g1/g1SATBCardTableModRefBS.hpp"
    51 #include "gc/g1/g1SATBCardTableModRefBS.hpp"
    50 #include "gc/g1/heapRegion.hpp"
    52 #include "gc/g1/heapRegion.hpp"
    51 #endif // INCLUDE_ALL_GCS
    53 #endif // INCLUDE_ALL_GCS
    52 #include "crc32c.h"
    54 #include "crc32c.h"
  5405   Address queue_index(thread, in_bytes(JavaThread::dirty_card_queue_offset() +
  5407   Address queue_index(thread, in_bytes(JavaThread::dirty_card_queue_offset() +
  5406                                        DirtyCardQueue::byte_offset_of_index()));
  5408                                        DirtyCardQueue::byte_offset_of_index()));
  5407   Address buffer(thread, in_bytes(JavaThread::dirty_card_queue_offset() +
  5409   Address buffer(thread, in_bytes(JavaThread::dirty_card_queue_offset() +
  5408                                        DirtyCardQueue::byte_offset_of_buf()));
  5410                                        DirtyCardQueue::byte_offset_of_buf()));
  5409 
  5411 
  5410   CardTableModRefBS* ct =
  5412   CardTableModRefBS* ctbs =
  5411     barrier_set_cast<CardTableModRefBS>(Universe::heap()->barrier_set());
  5413     barrier_set_cast<CardTableModRefBS>(Universe::heap()->barrier_set());
  5412   assert(sizeof(*ct->byte_map_base) == sizeof(jbyte), "adjust this code");
  5414   CardTable* ct = ctbs->card_table();
       
  5415   assert(sizeof(*ct->byte_map_base()) == sizeof(jbyte), "adjust this code");
  5413 
  5416 
  5414   Label done;
  5417   Label done;
  5415   Label runtime;
  5418   Label runtime;
  5416 
  5419 
  5417   // Does store cross heap regions?
  5420   // Does store cross heap regions?
  5430 
  5433 
  5431   const Register card_addr = tmp;
  5434   const Register card_addr = tmp;
  5432   const Register cardtable = tmp2;
  5435   const Register cardtable = tmp2;
  5433 
  5436 
  5434   movptr(card_addr, store_addr);
  5437   movptr(card_addr, store_addr);
  5435   shrptr(card_addr, CardTableModRefBS::card_shift);
  5438   shrptr(card_addr, CardTable::card_shift);
  5436   // Do not use ExternalAddress to load 'byte_map_base', since 'byte_map_base' is NOT
  5439   // Do not use ExternalAddress to load 'byte_map_base', since 'byte_map_base' is NOT
  5437   // a valid address and therefore is not properly handled by the relocation code.
  5440   // a valid address and therefore is not properly handled by the relocation code.
  5438   movptr(cardtable, (intptr_t)ct->byte_map_base);
  5441   movptr(cardtable, (intptr_t)ct->byte_map_base());
  5439   addptr(card_addr, cardtable);
  5442   addptr(card_addr, cardtable);
  5440 
  5443 
  5441   cmpb(Address(card_addr, 0), (int)G1SATBCardTableModRefBS::g1_young_card_val());
  5444   cmpb(Address(card_addr, 0), (int)G1CardTable::g1_young_card_val());
  5442   jcc(Assembler::equal, done);
  5445   jcc(Assembler::equal, done);
  5443 
  5446 
  5444   membar(Assembler::Membar_mask_bits(Assembler::StoreLoad));
  5447   membar(Assembler::Membar_mask_bits(Assembler::StoreLoad));
  5445   cmpb(Address(card_addr, 0), (int)CardTableModRefBS::dirty_card_val());
  5448   cmpb(Address(card_addr, 0), (int)CardTable::dirty_card_val());
  5446   jcc(Assembler::equal, done);
  5449   jcc(Assembler::equal, done);
  5447 
  5450 
  5448 
  5451 
  5449   // storing a region crossing, non-NULL oop, card is clean.
  5452   // storing a region crossing, non-NULL oop, card is clean.
  5450   // dirty card and log.
  5453   // dirty card and log.
  5451 
  5454 
  5452   movb(Address(card_addr, 0), (int)CardTableModRefBS::dirty_card_val());
  5455   movb(Address(card_addr, 0), (int)CardTable::dirty_card_val());
  5453 
  5456 
  5454   cmpl(queue_index, 0);
  5457   cmpl(queue_index, 0);
  5455   jcc(Assembler::equal, runtime);
  5458   jcc(Assembler::equal, runtime);
  5456   subl(queue_index, wordSize);
  5459   subl(queue_index, wordSize);
  5457   movptr(tmp2, buffer);
  5460   movptr(tmp2, buffer);
  5492 
  5495 
  5493 void MacroAssembler::store_check(Register obj) {
  5496 void MacroAssembler::store_check(Register obj) {
  5494   // Does a store check for the oop in register obj. The content of
  5497   // Does a store check for the oop in register obj. The content of
  5495   // register obj is destroyed afterwards.
  5498   // register obj is destroyed afterwards.
  5496   BarrierSet* bs = Universe::heap()->barrier_set();
  5499   BarrierSet* bs = Universe::heap()->barrier_set();
  5497   assert(bs->kind() == BarrierSet::CardTableForRS ||
  5500   assert(bs->kind() == BarrierSet::CardTableModRef,
  5498          bs->kind() == BarrierSet::CardTableExtension,
       
  5499          "Wrong barrier set kind");
  5501          "Wrong barrier set kind");
  5500 
  5502 
  5501   CardTableModRefBS* ct = barrier_set_cast<CardTableModRefBS>(bs);
  5503   CardTableModRefBS* ctbs = barrier_set_cast<CardTableModRefBS>(bs);
  5502   assert(sizeof(*ct->byte_map_base) == sizeof(jbyte), "adjust this code");
  5504   CardTable* ct = ctbs->card_table();
  5503 
  5505   assert(sizeof(*ct->byte_map_base()) == sizeof(jbyte), "adjust this code");
  5504   shrptr(obj, CardTableModRefBS::card_shift);
  5506 
       
  5507   shrptr(obj, CardTable::card_shift);
  5505 
  5508 
  5506   Address card_addr;
  5509   Address card_addr;
  5507 
  5510 
  5508   // The calculation for byte_map_base is as follows:
  5511   // The calculation for byte_map_base is as follows:
  5509   // byte_map_base = _byte_map - (uintptr_t(low_bound) >> card_shift);
  5512   // byte_map_base = _byte_map - (uintptr_t(low_bound) >> card_shift);
  5510   // So this essentially converts an address to a displacement and it will
  5513   // So this essentially converts an address to a displacement and it will
  5511   // never need to be relocated. On 64bit however the value may be too
  5514   // never need to be relocated. On 64bit however the value may be too
  5512   // large for a 32bit displacement.
  5515   // large for a 32bit displacement.
  5513   intptr_t disp = (intptr_t) ct->byte_map_base;
  5516   intptr_t disp = (intptr_t) ct->byte_map_base();
  5514   if (is_simm32(disp)) {
  5517   if (is_simm32(disp)) {
  5515     card_addr = Address(noreg, obj, Address::times_1, disp);
  5518     card_addr = Address(noreg, obj, Address::times_1, disp);
  5516   } else {
  5519   } else {
  5517     // By doing it as an ExternalAddress 'disp' could be converted to a rip-relative
  5520     // By doing it as an ExternalAddress 'disp' could be converted to a rip-relative
  5518     // displacement and done in a single instruction given favorable mapping and a
  5521     // displacement and done in a single instruction given favorable mapping and a
  5519     // smarter version of as_Address. However, 'ExternalAddress' generates a relocation
  5522     // smarter version of as_Address. However, 'ExternalAddress' generates a relocation
  5520     // entry and that entry is not properly handled by the relocation code.
  5523     // entry and that entry is not properly handled by the relocation code.
  5521     AddressLiteral cardtable((address)ct->byte_map_base, relocInfo::none);
  5524     AddressLiteral cardtable((address)ct->byte_map_base(), relocInfo::none);
  5522     Address index(noreg, obj, Address::times_1);
  5525     Address index(noreg, obj, Address::times_1);
  5523     card_addr = as_Address(ArrayAddress(cardtable, index));
  5526     card_addr = as_Address(ArrayAddress(cardtable, index));
  5524   }
  5527   }
  5525 
  5528 
  5526   int dirty = CardTableModRefBS::dirty_card_val();
  5529   int dirty = CardTable::dirty_card_val();
  5527   if (UseCondCardMark) {
  5530   if (UseCondCardMark) {
  5528     Label L_already_dirty;
  5531     Label L_already_dirty;
  5529     if (UseConcMarkSweepGC) {
  5532     if (UseConcMarkSweepGC) {
  5530       membar(Assembler::StoreLoad);
  5533       membar(Assembler::StoreLoad);
  5531     }
  5534     }