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 "jvm.h"
26 #include "asm/assembler.hpp"
27 #include "asm/assembler.inline.hpp"
28 #include "compiler/disassembler.hpp"
29 #include "gc/shared/cardTable.hpp"
30 #include "gc/shared/cardTableModRefBS.hpp"
31 #include "gc/shared/collectedHeap.inline.hpp"
32 #include "interpreter/interpreter.hpp"
33 #include "memory/resourceArea.hpp"
34 #include "memory/universe.hpp"
35 #include "oops/klass.inline.hpp"
36 #include "prims/methodHandles.hpp"
37 #include "runtime/biasedLocking.hpp"
38 #include "runtime/interfaceSupport.hpp"
39 #include "runtime/objectMonitor.hpp"
40 #include "runtime/os.hpp"
41 #include "runtime/safepoint.hpp"
42 #include "runtime/safepointMechanism.hpp"
43 #include "runtime/sharedRuntime.hpp"
44 #include "runtime/stubRoutines.hpp"
45 #include "runtime/thread.hpp"
46 #include "utilities/macros.hpp"
47 #if INCLUDE_ALL_GCS
48 #include "gc/g1/g1BarrierSet.hpp"
49 #include "gc/g1/g1CardTable.hpp"
|
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 "jvm.h"
26 #include "asm/assembler.hpp"
27 #include "asm/assembler.inline.hpp"
28 #include "compiler/disassembler.hpp"
29 #include "gc/shared/cardTable.hpp"
30 #include "gc/shared/cardTableBarrierSet.hpp"
31 #include "gc/shared/collectedHeap.inline.hpp"
32 #include "interpreter/interpreter.hpp"
33 #include "memory/resourceArea.hpp"
34 #include "memory/universe.hpp"
35 #include "oops/klass.inline.hpp"
36 #include "prims/methodHandles.hpp"
37 #include "runtime/biasedLocking.hpp"
38 #include "runtime/interfaceSupport.hpp"
39 #include "runtime/objectMonitor.hpp"
40 #include "runtime/os.hpp"
41 #include "runtime/safepoint.hpp"
42 #include "runtime/safepointMechanism.hpp"
43 #include "runtime/sharedRuntime.hpp"
44 #include "runtime/stubRoutines.hpp"
45 #include "runtime/thread.hpp"
46 #include "utilities/macros.hpp"
47 #if INCLUDE_ALL_GCS
48 #include "gc/g1/g1BarrierSet.hpp"
49 #include "gc/g1/g1CardTable.hpp"
|
5391
5392 if(tosca_live) pop(rax);
5393
5394 bind(done);
5395 }
5396
5397 void MacroAssembler::g1_write_barrier_post(Register store_addr,
5398 Register new_val,
5399 Register thread,
5400 Register tmp,
5401 Register tmp2) {
5402 #ifdef _LP64
5403 assert(thread == r15_thread, "must be");
5404 #endif // _LP64
5405
5406 Address queue_index(thread, in_bytes(JavaThread::dirty_card_queue_offset() +
5407 DirtyCardQueue::byte_offset_of_index()));
5408 Address buffer(thread, in_bytes(JavaThread::dirty_card_queue_offset() +
5409 DirtyCardQueue::byte_offset_of_buf()));
5410
5411 CardTableModRefBS* ctbs =
5412 barrier_set_cast<CardTableModRefBS>(Universe::heap()->barrier_set());
5413 CardTable* ct = ctbs->card_table();
5414 assert(sizeof(*ct->byte_map_base()) == sizeof(jbyte), "adjust this code");
5415
5416 Label done;
5417 Label runtime;
5418
5419 // Does store cross heap regions?
5420
5421 movptr(tmp, store_addr);
5422 xorptr(tmp, new_val);
5423 shrptr(tmp, HeapRegion::LogOfHRGrainBytes);
5424 jcc(Assembler::equal, done);
5425
5426 // crosses regions, storing NULL?
5427
5428 cmpptr(new_val, (int32_t) NULL_WORD);
5429 jcc(Assembler::equal, done);
5430
5431 // storing region crossing non-NULL, is card already dirty?
|
5391
5392 if(tosca_live) pop(rax);
5393
5394 bind(done);
5395 }
5396
5397 void MacroAssembler::g1_write_barrier_post(Register store_addr,
5398 Register new_val,
5399 Register thread,
5400 Register tmp,
5401 Register tmp2) {
5402 #ifdef _LP64
5403 assert(thread == r15_thread, "must be");
5404 #endif // _LP64
5405
5406 Address queue_index(thread, in_bytes(JavaThread::dirty_card_queue_offset() +
5407 DirtyCardQueue::byte_offset_of_index()));
5408 Address buffer(thread, in_bytes(JavaThread::dirty_card_queue_offset() +
5409 DirtyCardQueue::byte_offset_of_buf()));
5410
5411 CardTableBarrierSet* ctbs =
5412 barrier_set_cast<CardTableBarrierSet>(Universe::heap()->barrier_set());
5413 CardTable* ct = ctbs->card_table();
5414 assert(sizeof(*ct->byte_map_base()) == sizeof(jbyte), "adjust this code");
5415
5416 Label done;
5417 Label runtime;
5418
5419 // Does store cross heap regions?
5420
5421 movptr(tmp, store_addr);
5422 xorptr(tmp, new_val);
5423 shrptr(tmp, HeapRegion::LogOfHRGrainBytes);
5424 jcc(Assembler::equal, done);
5425
5426 // crosses regions, storing NULL?
5427
5428 cmpptr(new_val, (int32_t) NULL_WORD);
5429 jcc(Assembler::equal, done);
5430
5431 // storing region crossing non-NULL, is card already dirty?
|
5479 pop(thread);
5480 #endif
5481 pop(new_val);
5482 pop(store_addr);
5483
5484 bind(done);
5485 }
5486
5487 #endif // INCLUDE_ALL_GCS
5488 //////////////////////////////////////////////////////////////////////////////////
5489
5490
5491 void MacroAssembler::store_check(Register obj, Address dst) {
5492 store_check(obj);
5493 }
5494
5495 void MacroAssembler::store_check(Register obj) {
5496 // Does a store check for the oop in register obj. The content of
5497 // register obj is destroyed afterwards.
5498 BarrierSet* bs = Universe::heap()->barrier_set();
5499 assert(bs->kind() == BarrierSet::CardTableModRef,
5500 "Wrong barrier set kind");
5501
5502 CardTableModRefBS* ctbs = barrier_set_cast<CardTableModRefBS>(bs);
5503 CardTable* ct = ctbs->card_table();
5504 assert(sizeof(*ct->byte_map_base()) == sizeof(jbyte), "adjust this code");
5505
5506 shrptr(obj, CardTable::card_shift);
5507
5508 Address card_addr;
5509
5510 // The calculation for byte_map_base is as follows:
5511 // byte_map_base = _byte_map - (uintptr_t(low_bound) >> card_shift);
5512 // So this essentially converts an address to a displacement and it will
5513 // never need to be relocated. On 64bit however the value may be too
5514 // large for a 32bit displacement.
5515 intptr_t disp = (intptr_t) ct->byte_map_base();
5516 if (is_simm32(disp)) {
5517 card_addr = Address(noreg, obj, Address::times_1, disp);
5518 } else {
5519 // By doing it as an ExternalAddress 'disp' could be converted to a rip-relative
5520 // displacement and done in a single instruction given favorable mapping and a
5521 // smarter version of as_Address. However, 'ExternalAddress' generates a relocation
|
5479 pop(thread);
5480 #endif
5481 pop(new_val);
5482 pop(store_addr);
5483
5484 bind(done);
5485 }
5486
5487 #endif // INCLUDE_ALL_GCS
5488 //////////////////////////////////////////////////////////////////////////////////
5489
5490
5491 void MacroAssembler::store_check(Register obj, Address dst) {
5492 store_check(obj);
5493 }
5494
5495 void MacroAssembler::store_check(Register obj) {
5496 // Does a store check for the oop in register obj. The content of
5497 // register obj is destroyed afterwards.
5498 BarrierSet* bs = Universe::heap()->barrier_set();
5499 assert(bs->kind() == BarrierSet::CardTableBarrierSet,
5500 "Wrong barrier set kind");
5501
5502 CardTableBarrierSet* ctbs = barrier_set_cast<CardTableBarrierSet>(bs);
5503 CardTable* ct = ctbs->card_table();
5504 assert(sizeof(*ct->byte_map_base()) == sizeof(jbyte), "adjust this code");
5505
5506 shrptr(obj, CardTable::card_shift);
5507
5508 Address card_addr;
5509
5510 // The calculation for byte_map_base is as follows:
5511 // byte_map_base = _byte_map - (uintptr_t(low_bound) >> card_shift);
5512 // So this essentially converts an address to a displacement and it will
5513 // never need to be relocated. On 64bit however the value may be too
5514 // large for a 32bit displacement.
5515 intptr_t disp = (intptr_t) ct->byte_map_base();
5516 if (is_simm32(disp)) {
5517 card_addr = Address(noreg, obj, Address::times_1, disp);
5518 } else {
5519 // By doing it as an ExternalAddress 'disp' could be converted to a rip-relative
5520 // displacement and done in a single instruction given favorable mapping and a
5521 // smarter version of as_Address. However, 'ExternalAddress' generates a relocation
|