[aarch64-port-dev ] Fix profile counters in tiered compilation

Andrew Haley aph at redhat.com
Mon Aug 19 05:34:18 PDT 2013


This seems to be the only missing piece in the tiered compilation puzzle.

Andrew.


# HG changeset patch
# User aph
# Date 1376909605 -3600
# Node ID 0cc30c126c9211f17223e01c9b62abec98fc0017
# Parent  80e741fc14e2cda15b58ba9190b5910ad52d5ad4
Fix profile counters used by tiered compilation.

diff -r 80e741fc14e2 -r 0cc30c126c92 src/cpu/aarch64/vm/c1_LIRAssembler_aarch64.cpp
--- a/src/cpu/aarch64/vm/c1_LIRAssembler_aarch64.cpp	Wed Aug 14 14:08:18 2013 +0100
+++ b/src/cpu/aarch64/vm/c1_LIRAssembler_aarch64.cpp	Mon Aug 19 11:53:25 2013 +0100
@@ -1275,7 +1275,34 @@

 void LIR_Assembler::type_profile_helper(Register mdo,
                                         ciMethodData *md, ciProfileData *data,
-                                        Register recv, Label* update_done) { Unimplemented(); }
+                                        Register recv, Label* update_done) {
+  for (uint i = 0; i < ReceiverTypeData::row_limit(); i++) {
+    Label next_test;
+    // See if the receiver is receiver[n].
+    __ lea(rscratch1, Address(mdo, md->byte_offset_of_slot(data, ReceiverTypeData::receiver_offset(i))));
+    __ cmp(recv, rscratch1);
+    __ br(Assembler::NE, next_test);
+    Address data_addr(mdo, md->byte_offset_of_slot(data, ReceiverTypeData::receiver_count_offset(i)));
+    __ ldr(rscratch1, data_addr);
+    __ add(rscratch1, rscratch1, DataLayout::counter_increment);
+    __ str(rscratch1, data_addr);
+    __ b(*update_done);
+    __ bind(next_test);
+  }
+
+  // Didn't find receiver; find next empty slot and fill it in
+  for (uint i = 0; i < ReceiverTypeData::row_limit(); i++) {
+    Label next_test;
+    Address recv_addr(mdo, md->byte_offset_of_slot(data, ReceiverTypeData::receiver_offset(i)));
+    __ ldr(rscratch1, recv_addr);
+    __ cbnz(rscratch1, next_test);
+    __ str(recv, recv_addr);
+    __ mov(rscratch1, DataLayout::counter_increment);
+    __ str(rscratch1, Address(mdo, md->byte_offset_of_slot(data, ReceiverTypeData::receiver_count_offset(i))));
+    __ b(*update_done);
+    __ bind(next_test);
+  }
+}

 void LIR_Assembler::emit_typecheck_helper(LIR_OpTypeCheck *op, Label* success, Label* failure, Label* obj_is_null) {
   // we always need a stub for the failure case.
@@ -2513,9 +2540,7 @@
 	  __ mov_metadata(rscratch1, known_klass->constant_encoding());
           __ str(rscratch1, recv_addr);
           Address data_addr(mdo, md->byte_offset_of_slot(data, VirtualCallData::receiver_count_offset(i)));
-	  __ ldr(rscratch1, data_addr);
-	  __ add(rscratch1, rscratch1, DataLayout::counter_increment);
-	  __ str(rscratch1, data_addr);
+	  __ addptr(counter_addr, DataLayout::counter_increment);
           return;
         }
       }
@@ -2531,9 +2556,7 @@
     }
   } else {
     // Static call
-    __ ldr(rscratch1, counter_addr);
-    __ add(rscratch1, rscratch1, DataLayout::counter_increment);
-    __ str(rscratch1, counter_addr);
+    __ addptr(counter_addr, DataLayout::counter_increment);
   }
 }

diff -r 80e741fc14e2 -r 0cc30c126c92 src/cpu/aarch64/vm/c1_LIRGenerator_aarch64.cpp
--- a/src/cpu/aarch64/vm/c1_LIRGenerator_aarch64.cpp	Wed Aug 14 14:08:18 2013 +0100
+++ b/src/cpu/aarch64/vm/c1_LIRGenerator_aarch64.cpp	Mon Aug 19 11:53:25 2013 +0100
@@ -260,9 +260,20 @@


 void LIRGenerator::increment_counter(LIR_Address* addr, int step) {
-  LIR_Opr reg = new_register(T_INT);
+  LIR_Opr imm = NULL;
+  switch(addr->type()) {
+  case T_INT:
+    imm = LIR_OprFact::intConst(step);
+    break;
+  case T_LONG:
+    imm = LIR_OprFact::longConst(step);
+    break;
+  default:
+    ShouldNotReachHere();
+  }
+  LIR_Opr reg = new_register(addr->type());
   __ load(addr, reg);
-  __ add(reg, reg, LIR_OprFact::intConst(step));
+  __ add(reg, imm, reg);
   __ store(reg, addr);
 }

diff -r 80e741fc14e2 -r 0cc30c126c92 src/cpu/aarch64/vm/macroAssembler_aarch64.hpp
--- a/src/cpu/aarch64/vm/macroAssembler_aarch64.hpp	Wed Aug 14 14:08:18 2013 +0100
+++ b/src/cpu/aarch64/vm/macroAssembler_aarch64.hpp	Mon Aug 19 11:53:25 2013 +0100
@@ -1020,7 +1020,11 @@

   // Arithmetics

-  void addptr(Address dst, int32_t src) { Unimplemented(); }
+  void addptr(Address dst, int32_t src) {
+    ldr(rscratch1, dst);
+    add(rscratch1, rscratch1, src);
+    str(rscratch1, dst);
+}
   // unimplemented
 #if 0
   void addptr(Address dst, Register src);
# HG changeset patch
# User aph
# Date 1376913627 -3600
# Node ID c0cc4bab989c6cd86781f6d90a6177b6b5bb5cb9
# Parent  e73fcb59a72704e777fe61075eaede2d4a5ff232
Fix profile counters used by tiered compilation.

diff -r e73fcb59a727 -r c0cc4bab989c src/cpu/aarch64/vm/c1_LIRAssembler_aarch64.cpp
--- a/src/cpu/aarch64/vm/c1_LIRAssembler_aarch64.cpp	Mon Aug 19 11:54:18 2013 +0100
+++ b/src/cpu/aarch64/vm/c1_LIRAssembler_aarch64.cpp	Mon Aug 19 13:00:27 2013 +0100
@@ -1279,13 +1279,11 @@
   for (uint i = 0; i < ReceiverTypeData::row_limit(); i++) {
     Label next_test;
     // See if the receiver is receiver[n].
-    __ lea(rscratch1, Address(mdo, md->byte_offset_of_slot(data, ReceiverTypeData::receiver_offset(i))));
+    __ ldr(rscratch1, Address(mdo, md->byte_offset_of_slot(data, ReceiverTypeData::receiver_offset(i))));
     __ cmp(recv, rscratch1);
     __ br(Assembler::NE, next_test);
     Address data_addr(mdo, md->byte_offset_of_slot(data, ReceiverTypeData::receiver_count_offset(i)));
-    __ ldr(rscratch1, data_addr);
-    __ add(rscratch1, rscratch1, DataLayout::counter_increment);
-    __ str(rscratch1, data_addr);
+    __ addptr(data_addr, DataLayout::counter_increment);
     __ b(*update_done);
     __ bind(next_test);
   }



More information about the aarch64-port-dev mailing list