[aarch64-port-dev ] RFR: Optimise addressing of card table byte map base

Edward Nevill ed at camswl.com
Mon May 12 13:21:05 UTC 2014


Hi,

The following patch optimises the addressing of the card table byte map from

 movz x, #N
 movk x, #N << 16
 movk x, #N << 32


to

 adrp x, #N

The implementation is identical to the previous optimisation of addressing the safepoint polling page.

The card table byte map is always page aligned (and this is asserted in the code below).

Regards,
Ed.

--- CUT HERE ---
# HG changeset patch
# User Edward Nevill edward.nevill at linaro.org
# Date 1399900167 -3600
#      Mon May 12 14:09:27 2014 +0100
# Node ID 1a6e4b95d2689fc31c1715bf8bec786a7d66161f
# Parent  6523308f9626004171794372e5577a0f6939b4df
Optimise addressing of card table byte map base

diff -r 6523308f9626 -r 1a6e4b95d268 src/cpu/aarch64/vm/aarch64.ad
--- a/src/cpu/aarch64/vm/aarch64.ad	Mon May 12 13:41:43 2014 +0100
+++ b/src/cpu/aarch64/vm/aarch64.ad	Mon May 12 14:09:27 2014 +0100
@@ -2565,6 +2565,15 @@
     assert(off == 0, "assumed offset == 0");
   %}
 
+  enc_class aarch64_enc_mov_byte_map_base(iRegP dst, immByteMapBase src) %{
+    MacroAssembler _masm(&cbuf);
+    address page = (address)$src$$constant;
+    Register dst_reg = as_Register($dst$$reg);
+    unsigned long off;
+    __ adrp(dst_reg, Address(page, relocInfo::poll_type), off);
+    assert(off == 0, "assumed offset == 0");
+  %}
+
   enc_class aarch64_enc_mov_n(iRegN dst, immN src) %{
     MacroAssembler _masm(&cbuf);
     Register dst_reg = as_Register($dst$$reg);
@@ -3745,6 +3754,19 @@
   interface(CONST_INTER);
 %}
 
+// Card Table Byte Map Base
+operand immByteMapBase()
+%{
+  // Get base of card map
+  predicate((jbyte*)n->get_ptr() ==
+	((CardTableModRefBS*)(Universe::heap()->barrier_set()))->byte_map_base);
+  match(ConP);
+
+  op_cost(0);
+  format %{ %}
+  interface(CONST_INTER);
+%}
+
 // Pointer Immediate Minus One
 // this is used when we want to write the current PC to the thread anchor
 operand immP_M1()
@@ -5091,6 +5113,20 @@
   ins_pipe(pipe_class_default);
 %}
 
+// Load Byte Map Base Constant
+
+instruct loadByteMapBase(iRegPNoSp dst, immByteMapBase con)
+%{
+  match(Set dst con);
+
+  ins_cost(INSN_COST);
+  format %{ "adr  $dst, $con\t# Byte Map Base" %}
+
+  ins_encode(aarch64_enc_mov_byte_map_base(dst, con));
+
+  ins_pipe(pipe_class_default);
+%}
+
 // Load Narrow Pointer Constant
 
 instruct loadConN(iRegNNoSp dst, immN con)
diff -r 6523308f9626 -r 1a6e4b95d268 src/cpu/aarch64/vm/macroAssembler_aarch64.cpp
--- a/src/cpu/aarch64/vm/macroAssembler_aarch64.cpp	Mon May 12 13:41:43 2014 +0100
+++ b/src/cpu/aarch64/vm/macroAssembler_aarch64.cpp	Mon May 12 14:09:27 2014 +0100
@@ -94,7 +94,9 @@
       offset = adr_page - pc_page;
 
       unsigned insn2 = ((unsigned*)branch)[1];
-      if ((address)target == os::get_polling_page()) {
+      if ((jbyte *)target ==
+		((CardTableModRefBS*)(Universe::heap()->barrier_set()))->byte_map_base ||
+          (address)target == os::get_polling_page()) {
 	assert(offset_lo == 0, "offset must be 0 for polling page");
       } else if (Instruction_aarch64::extract(insn2, 29, 24) == 0b111001) {
 	// Load/store register (unsigned immediate)
@@ -182,7 +184,9 @@
       uint64_t target_page = ((uint64_t)insn_addr) + offset;
       target_page &= ((uint64_t)-1) << shift;
       unsigned insn2 = ((unsigned*)insn_addr)[1];
-      if ((address)target_page == os::get_polling_page()) {
+      if ((jbyte *)target_page ==
+		((CardTableModRefBS*)(Universe::heap()->barrier_set()))->byte_map_base ||
+          (address)target_page == os::get_polling_page()) {
 	return (address)target_page;
       } else if (Instruction_aarch64::extract(insn2, 29, 24) == 0b111001) {
 	// Load/store register (unsigned immediate)
diff -r 6523308f9626 -r 1a6e4b95d268 src/cpu/aarch64/vm/relocInfo_aarch64.cpp
--- a/src/cpu/aarch64/vm/relocInfo_aarch64.cpp	Mon May 12 13:41:43 2014 +0100
+++ b/src/cpu/aarch64/vm/relocInfo_aarch64.cpp	Mon May 12 14:09:27 2014 +0100
@@ -62,16 +62,7 @@
   // fprintf(stderr, "Try to fix poll reloc at %p to %p\n", addr(), dest);
   if (NativeInstruction::maybe_cpool_ref(addr())) {
     address old_addr = old_addr_for(addr(), src, dest);
-    if (! os::is_poll_address(pd_call_destination(old_addr))) {
-      fprintf(stderr, "  bollocks!\n");
-      old_addr = old_addr_for(addr(), src, dest);
-    }
     MacroAssembler::pd_patch_instruction(addr(), pd_call_destination(old_addr));
-    if (! os::is_poll_address(pd_call_destination(addr()))) {
-      fprintf(stderr, "  result at %p is %p\n", addr(), pd_call_destination(addr()));
-      MacroAssembler::pd_patch_instruction(addr(), pd_call_destination(old_addr));
-    }
-  } else {
   }
 }
 
--- CUT HERE ---




More information about the aarch64-port-dev mailing list