27 #include "c1/c1_Defs.hpp"
28 #include "c1/c1_MacroAssembler.hpp"
29 #include "c1/c1_Runtime1.hpp"
30 #include "ci/ciUtilities.hpp"
31 #include "gc/shared/cardTable.hpp"
32 #include "gc/shared/cardTableBarrierSet.hpp"
33 #include "interpreter/interpreter.hpp"
34 #include "nativeInst_x86.hpp"
35 #include "oops/compiledICHolder.hpp"
36 #include "oops/oop.inline.hpp"
37 #include "prims/jvmtiExport.hpp"
38 #include "register_x86.hpp"
39 #include "runtime/sharedRuntime.hpp"
40 #include "runtime/signature.hpp"
41 #include "runtime/vframeArray.hpp"
42 #include "utilities/macros.hpp"
43 #include "vmreg_x86.inline.hpp"
44 #if INCLUDE_ALL_GCS
45 #include "gc/g1/g1BarrierSet.hpp"
46 #include "gc/g1/g1CardTable.hpp"
47 #endif
48
49
50 // Implementation of StubAssembler
51
52 int StubAssembler::call_RT(Register oop_result1, Register metadata_result, address entry, int args_size) {
53 // setup registers
54 const Register thread = NOT_LP64(rdi) LP64_ONLY(r15_thread); // is callee-saved register (Visual C++ calling conventions)
55 assert(!(oop_result1->is_valid() || metadata_result->is_valid()) || oop_result1 != metadata_result, "registers must be different");
56 assert(oop_result1 != thread && metadata_result != thread, "registers must be different");
57 assert(args_size >= 0, "illegal args_size");
58 bool align_stack = false;
59 #ifdef _LP64
60 // At a method handle call, the stack may not be properly aligned
61 // when returning with an exception.
62 align_stack = (stub_id() == Runtime1::handle_exception_from_callee_id);
63 #endif
64
65 #ifdef _LP64
66 mov(c_rarg0, thread);
1561 {
1562 StubFrame f(sasm, "g1_pre_barrier", dont_gc_arguments);
1563 // arg0 : previous value of memory
1564
1565 BarrierSet* bs = Universe::heap()->barrier_set();
1566 if (bs->kind() != BarrierSet::G1BarrierSet) {
1567 __ movptr(rax, (int)id);
1568 __ call_RT(noreg, noreg, CAST_FROM_FN_PTR(address, unimplemented_entry), rax);
1569 __ should_not_reach_here();
1570 break;
1571 }
1572 __ push(rax);
1573 __ push(rdx);
1574
1575 const Register pre_val = rax;
1576 const Register thread = NOT_LP64(rax) LP64_ONLY(r15_thread);
1577 const Register tmp = rdx;
1578
1579 NOT_LP64(__ get_thread(thread);)
1580
1581 Address queue_active(thread, in_bytes(JavaThread::satb_mark_queue_offset() +
1582 SATBMarkQueue::byte_offset_of_active()));
1583 Address queue_index(thread, in_bytes(JavaThread::satb_mark_queue_offset() +
1584 SATBMarkQueue::byte_offset_of_index()));
1585 Address buffer(thread, in_bytes(JavaThread::satb_mark_queue_offset() +
1586 SATBMarkQueue::byte_offset_of_buf()));
1587
1588 Label done;
1589 Label runtime;
1590
1591 // Is marking still active?
1592 if (in_bytes(SATBMarkQueue::byte_width_of_active()) == 4) {
1593 __ cmpl(queue_active, 0);
1594 } else {
1595 assert(in_bytes(SATBMarkQueue::byte_width_of_active()) == 1, "Assumption");
1596 __ cmpb(queue_active, 0);
1597 }
1598 __ jcc(Assembler::equal, done);
1599
1600 // Can we store original value in the thread's buffer?
1601
1602 __ movptr(tmp, queue_index);
1603 __ testptr(tmp, tmp);
1604 __ jcc(Assembler::zero, runtime);
1605 __ subptr(tmp, wordSize);
1606 __ movptr(queue_index, tmp);
1635 BarrierSet* bs = Universe::heap()->barrier_set();
1636 if (bs->kind() != BarrierSet::G1BarrierSet) {
1637 __ movptr(rax, (int)id);
1638 __ call_RT(noreg, noreg, CAST_FROM_FN_PTR(address, unimplemented_entry), rax);
1639 __ should_not_reach_here();
1640 break;
1641 }
1642
1643 // arg0: store_address
1644 Address store_addr(rbp, 2*BytesPerWord);
1645
1646 Label done;
1647 Label enqueued;
1648 Label runtime;
1649
1650 // At this point we know new_value is non-NULL and the new_value crosses regions.
1651 // Must check to see if card is already dirty
1652
1653 const Register thread = NOT_LP64(rax) LP64_ONLY(r15_thread);
1654
1655 Address queue_index(thread, in_bytes(JavaThread::dirty_card_queue_offset() +
1656 DirtyCardQueue::byte_offset_of_index()));
1657 Address buffer(thread, in_bytes(JavaThread::dirty_card_queue_offset() +
1658 DirtyCardQueue::byte_offset_of_buf()));
1659
1660 __ push(rax);
1661 __ push(rcx);
1662
1663 const Register cardtable = rax;
1664 const Register card_addr = rcx;
1665
1666 f.load_argument(0, card_addr);
1667 __ shrptr(card_addr, CardTable::card_shift);
1668 // Do not use ExternalAddress to load 'byte_map_base', since 'byte_map_base' is NOT
1669 // a valid address and therefore is not properly handled by the relocation code.
1670 __ movptr(cardtable, ci_card_table_address_as<intptr_t>());
1671 __ addptr(card_addr, cardtable);
1672
1673 NOT_LP64(__ get_thread(thread);)
1674
1675 __ cmpb(Address(card_addr, 0), (int)G1CardTable::g1_young_card_val());
1676 __ jcc(Assembler::equal, done);
1677
1678 __ membar(Assembler::Membar_mask_bits(Assembler::StoreLoad));
|
27 #include "c1/c1_Defs.hpp"
28 #include "c1/c1_MacroAssembler.hpp"
29 #include "c1/c1_Runtime1.hpp"
30 #include "ci/ciUtilities.hpp"
31 #include "gc/shared/cardTable.hpp"
32 #include "gc/shared/cardTableBarrierSet.hpp"
33 #include "interpreter/interpreter.hpp"
34 #include "nativeInst_x86.hpp"
35 #include "oops/compiledICHolder.hpp"
36 #include "oops/oop.inline.hpp"
37 #include "prims/jvmtiExport.hpp"
38 #include "register_x86.hpp"
39 #include "runtime/sharedRuntime.hpp"
40 #include "runtime/signature.hpp"
41 #include "runtime/vframeArray.hpp"
42 #include "utilities/macros.hpp"
43 #include "vmreg_x86.inline.hpp"
44 #if INCLUDE_ALL_GCS
45 #include "gc/g1/g1BarrierSet.hpp"
46 #include "gc/g1/g1CardTable.hpp"
47 #include "gc/g1/g1ThreadLocalData.hpp"
48 #endif
49
50
51 // Implementation of StubAssembler
52
53 int StubAssembler::call_RT(Register oop_result1, Register metadata_result, address entry, int args_size) {
54 // setup registers
55 const Register thread = NOT_LP64(rdi) LP64_ONLY(r15_thread); // is callee-saved register (Visual C++ calling conventions)
56 assert(!(oop_result1->is_valid() || metadata_result->is_valid()) || oop_result1 != metadata_result, "registers must be different");
57 assert(oop_result1 != thread && metadata_result != thread, "registers must be different");
58 assert(args_size >= 0, "illegal args_size");
59 bool align_stack = false;
60 #ifdef _LP64
61 // At a method handle call, the stack may not be properly aligned
62 // when returning with an exception.
63 align_stack = (stub_id() == Runtime1::handle_exception_from_callee_id);
64 #endif
65
66 #ifdef _LP64
67 mov(c_rarg0, thread);
1562 {
1563 StubFrame f(sasm, "g1_pre_barrier", dont_gc_arguments);
1564 // arg0 : previous value of memory
1565
1566 BarrierSet* bs = Universe::heap()->barrier_set();
1567 if (bs->kind() != BarrierSet::G1BarrierSet) {
1568 __ movptr(rax, (int)id);
1569 __ call_RT(noreg, noreg, CAST_FROM_FN_PTR(address, unimplemented_entry), rax);
1570 __ should_not_reach_here();
1571 break;
1572 }
1573 __ push(rax);
1574 __ push(rdx);
1575
1576 const Register pre_val = rax;
1577 const Register thread = NOT_LP64(rax) LP64_ONLY(r15_thread);
1578 const Register tmp = rdx;
1579
1580 NOT_LP64(__ get_thread(thread);)
1581
1582 Address queue_active(thread, in_bytes(G1ThreadLocalData::satb_mark_queue_active_offset()));
1583 Address queue_index(thread, in_bytes(G1ThreadLocalData::satb_mark_queue_index_offset()));
1584 Address buffer(thread, in_bytes(G1ThreadLocalData::satb_mark_queue_buffer_offset()));
1585
1586 Label done;
1587 Label runtime;
1588
1589 // Is marking still active?
1590 if (in_bytes(SATBMarkQueue::byte_width_of_active()) == 4) {
1591 __ cmpl(queue_active, 0);
1592 } else {
1593 assert(in_bytes(SATBMarkQueue::byte_width_of_active()) == 1, "Assumption");
1594 __ cmpb(queue_active, 0);
1595 }
1596 __ jcc(Assembler::equal, done);
1597
1598 // Can we store original value in the thread's buffer?
1599
1600 __ movptr(tmp, queue_index);
1601 __ testptr(tmp, tmp);
1602 __ jcc(Assembler::zero, runtime);
1603 __ subptr(tmp, wordSize);
1604 __ movptr(queue_index, tmp);
1633 BarrierSet* bs = Universe::heap()->barrier_set();
1634 if (bs->kind() != BarrierSet::G1BarrierSet) {
1635 __ movptr(rax, (int)id);
1636 __ call_RT(noreg, noreg, CAST_FROM_FN_PTR(address, unimplemented_entry), rax);
1637 __ should_not_reach_here();
1638 break;
1639 }
1640
1641 // arg0: store_address
1642 Address store_addr(rbp, 2*BytesPerWord);
1643
1644 Label done;
1645 Label enqueued;
1646 Label runtime;
1647
1648 // At this point we know new_value is non-NULL and the new_value crosses regions.
1649 // Must check to see if card is already dirty
1650
1651 const Register thread = NOT_LP64(rax) LP64_ONLY(r15_thread);
1652
1653 Address queue_index(thread, in_bytes(G1ThreadLocalData::dirty_card_queue_index_offset()));
1654 Address buffer(thread, in_bytes(G1ThreadLocalData::dirty_card_queue_buffer_offset()));
1655
1656 __ push(rax);
1657 __ push(rcx);
1658
1659 const Register cardtable = rax;
1660 const Register card_addr = rcx;
1661
1662 f.load_argument(0, card_addr);
1663 __ shrptr(card_addr, CardTable::card_shift);
1664 // Do not use ExternalAddress to load 'byte_map_base', since 'byte_map_base' is NOT
1665 // a valid address and therefore is not properly handled by the relocation code.
1666 __ movptr(cardtable, ci_card_table_address_as<intptr_t>());
1667 __ addptr(card_addr, cardtable);
1668
1669 NOT_LP64(__ get_thread(thread);)
1670
1671 __ cmpb(Address(card_addr, 0), (int)G1CardTable::g1_young_card_val());
1672 __ jcc(Assembler::equal, done);
1673
1674 __ membar(Assembler::Membar_mask_bits(Assembler::StoreLoad));
|