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 "ci/ciUtilities.hpp"
28 #include "gc/shared/cardTable.hpp"
29 #include "gc/shared/cardTableModRefBS.hpp"
30 #include "interpreter/interpreter.hpp"
31 #include "nativeInst_x86.hpp"
32 #include "oops/instanceOop.hpp"
33 #include "oops/method.hpp"
34 #include "oops/objArrayKlass.hpp"
35 #include "oops/oop.inline.hpp"
36 #include "prims/methodHandles.hpp"
37 #include "runtime/frame.inline.hpp"
38 #include "runtime/handles.inline.hpp"
39 #include "runtime/sharedRuntime.hpp"
40 #include "runtime/stubCodeGenerator.hpp"
41 #include "runtime/stubRoutines.hpp"
42 #include "runtime/thread.inline.hpp"
43 #ifdef COMPILER2
44 #include "opto/runtime.hpp"
45 #endif
46
47 // Declaration and definition of StubGenerator (no .hpp file).
48 // For a more detailed description of the stub routine structure
|
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 "ci/ciUtilities.hpp"
28 #include "gc/shared/cardTable.hpp"
29 #include "gc/shared/cardTableBarrierSet.hpp"
30 #include "interpreter/interpreter.hpp"
31 #include "nativeInst_x86.hpp"
32 #include "oops/instanceOop.hpp"
33 #include "oops/method.hpp"
34 #include "oops/objArrayKlass.hpp"
35 #include "oops/oop.inline.hpp"
36 #include "prims/methodHandles.hpp"
37 #include "runtime/frame.inline.hpp"
38 #include "runtime/handles.inline.hpp"
39 #include "runtime/sharedRuntime.hpp"
40 #include "runtime/stubCodeGenerator.hpp"
41 #include "runtime/stubRoutines.hpp"
42 #include "runtime/thread.inline.hpp"
43 #ifdef COMPILER2
44 #include "opto/runtime.hpp"
45 #endif
46
47 // Declaration and definition of StubGenerator (no .hpp file).
48 // For a more detailed description of the stub routine structure
|
1217
1218 __ pusha(); // push registers
1219 if (count == c_rarg0) {
1220 if (addr == c_rarg1) {
1221 // exactly backwards!!
1222 __ xchgptr(c_rarg1, c_rarg0);
1223 } else {
1224 __ movptr(c_rarg1, count);
1225 __ movptr(c_rarg0, addr);
1226 }
1227 } else {
1228 __ movptr(c_rarg0, addr);
1229 __ movptr(c_rarg1, count);
1230 }
1231 __ call_VM_leaf(CAST_FROM_FN_PTR(address, BarrierSet::static_write_ref_array_pre), 2);
1232 __ popa();
1233
1234 __ bind(filtered);
1235 }
1236 break;
1237 case BarrierSet::CardTableModRef:
1238 break;
1239 default:
1240 ShouldNotReachHere();
1241
1242 }
1243 }
1244
1245 //
1246 // Generate code for an array write post barrier
1247 //
1248 // Input:
1249 // start - register containing starting address of destination array
1250 // count - elements count
1251 // scratch - scratch register
1252 //
1253 // The input registers are overwritten.
1254 //
1255 void gen_write_ref_array_post_barrier(Register start, Register count, Register scratch) {
1256 assert_different_registers(start, count, scratch);
1257 BarrierSet* bs = Universe::heap()->barrier_set();
1258 switch (bs->kind()) {
1259 case BarrierSet::G1BarrierSet:
1260 {
1261 __ pusha(); // push registers (overkill)
1262 if (c_rarg0 == count) { // On win64 c_rarg0 == rcx
1263 assert_different_registers(c_rarg1, start);
1264 __ mov(c_rarg1, count);
1265 __ mov(c_rarg0, start);
1266 } else {
1267 assert_different_registers(c_rarg0, count);
1268 __ mov(c_rarg0, start);
1269 __ mov(c_rarg1, count);
1270 }
1271 __ call_VM_leaf(CAST_FROM_FN_PTR(address, BarrierSet::static_write_ref_array_post), 2);
1272 __ popa();
1273 }
1274 break;
1275 case BarrierSet::CardTableModRef:
1276 {
1277 Label L_loop, L_done;
1278 const Register end = count;
1279
1280 __ testl(count, count);
1281 __ jcc(Assembler::zero, L_done); // zero count - nothing to do
1282
1283 __ leaq(end, Address(start, count, TIMES_OOP, 0)); // end == start+count*oop_size
1284 __ subptr(end, BytesPerHeapOop); // end - 1 to make inclusive
1285 __ shrptr(start, CardTable::card_shift);
1286 __ shrptr(end, CardTable::card_shift);
1287 __ subptr(end, start); // end --> cards count
1288
1289 int64_t disp = ci_card_table_address_as<int64_t>();
1290 __ mov64(scratch, disp);
1291 __ addptr(start, scratch);
1292 __ BIND(L_loop);
1293 __ movb(Address(start, count, Address::times_1), 0);
1294 __ decrement(count);
|
1217
1218 __ pusha(); // push registers
1219 if (count == c_rarg0) {
1220 if (addr == c_rarg1) {
1221 // exactly backwards!!
1222 __ xchgptr(c_rarg1, c_rarg0);
1223 } else {
1224 __ movptr(c_rarg1, count);
1225 __ movptr(c_rarg0, addr);
1226 }
1227 } else {
1228 __ movptr(c_rarg0, addr);
1229 __ movptr(c_rarg1, count);
1230 }
1231 __ call_VM_leaf(CAST_FROM_FN_PTR(address, BarrierSet::static_write_ref_array_pre), 2);
1232 __ popa();
1233
1234 __ bind(filtered);
1235 }
1236 break;
1237 case BarrierSet::CardTableBarrierSet:
1238 break;
1239 default:
1240 ShouldNotReachHere();
1241
1242 }
1243 }
1244
1245 //
1246 // Generate code for an array write post barrier
1247 //
1248 // Input:
1249 // start - register containing starting address of destination array
1250 // count - elements count
1251 // scratch - scratch register
1252 //
1253 // The input registers are overwritten.
1254 //
1255 void gen_write_ref_array_post_barrier(Register start, Register count, Register scratch) {
1256 assert_different_registers(start, count, scratch);
1257 BarrierSet* bs = Universe::heap()->barrier_set();
1258 switch (bs->kind()) {
1259 case BarrierSet::G1BarrierSet:
1260 {
1261 __ pusha(); // push registers (overkill)
1262 if (c_rarg0 == count) { // On win64 c_rarg0 == rcx
1263 assert_different_registers(c_rarg1, start);
1264 __ mov(c_rarg1, count);
1265 __ mov(c_rarg0, start);
1266 } else {
1267 assert_different_registers(c_rarg0, count);
1268 __ mov(c_rarg0, start);
1269 __ mov(c_rarg1, count);
1270 }
1271 __ call_VM_leaf(CAST_FROM_FN_PTR(address, BarrierSet::static_write_ref_array_post), 2);
1272 __ popa();
1273 }
1274 break;
1275 case BarrierSet::CardTableBarrierSet:
1276 {
1277 Label L_loop, L_done;
1278 const Register end = count;
1279
1280 __ testl(count, count);
1281 __ jcc(Assembler::zero, L_done); // zero count - nothing to do
1282
1283 __ leaq(end, Address(start, count, TIMES_OOP, 0)); // end == start+count*oop_size
1284 __ subptr(end, BytesPerHeapOop); // end - 1 to make inclusive
1285 __ shrptr(start, CardTable::card_shift);
1286 __ shrptr(end, CardTable::card_shift);
1287 __ subptr(end, start); // end --> cards count
1288
1289 int64_t disp = ci_card_table_address_as<int64_t>();
1290 __ mov64(scratch, disp);
1291 __ addptr(start, scratch);
1292 __ BIND(L_loop);
1293 __ movb(Address(start, count, Address::times_1), 0);
1294 __ decrement(count);
|