Revert "Prevent overflow for AOT hotness counters"

This reverts commit 79e6eb8b79be6249358b7801bc511290dacf10d0.

Bug: 139883463

Reason for revert: 674-hotness-compiled fails on target.

Change-Id: I02fce74d70a4ae69dd5b4ae3924aa11728d9e16f
diff --git a/compiler/optimizing/code_generator_arm64.cc b/compiler/optimizing/code_generator_arm64.cc
index 269b4e9..a299ece 100644
--- a/compiler/optimizing/code_generator_arm64.cc
+++ b/compiler/optimizing/code_generator_arm64.cc
@@ -1068,10 +1068,8 @@
   if (GetCompilerOptions().CountHotnessInCompiledCode()) {
     UseScratchRegisterScope temps(masm);
     Register temp = temps.AcquireX();
-    __ Ldrsh(temp, MemOperand(kArtMethodRegister, ArtMethod::HotnessCountOffset().Int32Value()));
-    __ Adds(temp, temp, 1);
-    // Subtract carry if it overflowed.
-    __ Sbc(temp, temp, xzr);
+    __ Ldrh(temp, MemOperand(kArtMethodRegister, ArtMethod::HotnessCountOffset().Int32Value()));
+    __ Add(temp, temp, 1);
     __ Strh(temp, MemOperand(kArtMethodRegister, ArtMethod::HotnessCountOffset().Int32Value()));
   }
 
@@ -3177,10 +3175,8 @@
       Register temp1 = temps.AcquireX();
       Register temp2 = temps.AcquireX();
       __ Ldr(temp1, MemOperand(sp, 0));
-      __ Ldrsh(temp2, MemOperand(temp1, ArtMethod::HotnessCountOffset().Int32Value()));
-      __ Adds(temp2, temp2, 1);
-      // Subtract carry if it overflowed.
-      __ Sbc(temp2, temp2, xzr);
+      __ Ldrh(temp2, MemOperand(temp1, ArtMethod::HotnessCountOffset().Int32Value()));
+      __ Add(temp2, temp2, 1);
       __ Strh(temp2, MemOperand(temp1, ArtMethod::HotnessCountOffset().Int32Value()));
     }
     GenerateSuspendCheck(info->GetSuspendCheck(), successor);
diff --git a/compiler/optimizing/code_generator_arm_vixl.cc b/compiler/optimizing/code_generator_arm_vixl.cc
index 0ddae52..b3141bf 100644
--- a/compiler/optimizing/code_generator_arm_vixl.cc
+++ b/compiler/optimizing/code_generator_arm_vixl.cc
@@ -2087,12 +2087,8 @@
   if (GetCompilerOptions().CountHotnessInCompiledCode()) {
     UseScratchRegisterScope temps(GetVIXLAssembler());
     vixl32::Register temp = temps.Acquire();
-    static_assert(ArtMethod::MaxCounter() == 0xFFFF, "asm is probably wrong");
-    // Load with sign extend to set the high bits for integer overflow check.
-    __ Ldrsh(temp, MemOperand(kMethodRegister, ArtMethod::HotnessCountOffset().Int32Value()));
-    __ Adds(temp, temp, 1);
-    // Subtract carry if it overflowed.
-    __ Sbc(temp, temp, 0);
+    __ Ldrh(temp, MemOperand(kMethodRegister, ArtMethod::HotnessCountOffset().Int32Value()));
+    __ Add(temp, temp, 1);
     __ Strh(temp, MemOperand(kMethodRegister, ArtMethod::HotnessCountOffset().Int32Value()));
   }
 
@@ -2501,11 +2497,8 @@
       vixl32::Register temp = temps.Acquire();
       __ Push(vixl32::Register(kMethodRegister));
       GetAssembler()->LoadFromOffset(kLoadWord, kMethodRegister, sp, kArmWordSize);
-      // Load with sign extend to set the high bits for integer overflow check.
-      __ Ldrsh(temp, MemOperand(kMethodRegister, ArtMethod::HotnessCountOffset().Int32Value()));
-      __ Adds(temp, temp, 1);
-      // Subtract carry if it overflowed.
-      __ Sbc(temp, temp, 0);
+      __ Ldrh(temp, MemOperand(kMethodRegister, ArtMethod::HotnessCountOffset().Int32Value()));
+      __ Add(temp, temp, 1);
       __ Strh(temp, MemOperand(kMethodRegister, ArtMethod::HotnessCountOffset().Int32Value()));
       __ Pop(vixl32::Register(kMethodRegister));
     }
diff --git a/compiler/optimizing/code_generator_x86.cc b/compiler/optimizing/code_generator_x86.cc
index 797fe32..4ab398e 100644
--- a/compiler/optimizing/code_generator_x86.cc
+++ b/compiler/optimizing/code_generator_x86.cc
@@ -1078,15 +1078,8 @@
   DCHECK(GetCompilerOptions().GetImplicitStackOverflowChecks());
 
   if (GetCompilerOptions().CountHotnessInCompiledCode()) {
-    NearLabel overflow;
-    __ cmpw(Address(kMethodRegisterArgument,
-                    ArtMethod::HotnessCountOffset().Int32Value()),
-            Immediate(ArtMethod::MaxCounter()));
-    __ j(kEqual, &overflow);
-    __ addw(Address(kMethodRegisterArgument,
-                    ArtMethod::HotnessCountOffset().Int32Value()),
+    __ addw(Address(kMethodRegisterArgument, ArtMethod::HotnessCountOffset().Int32Value()),
             Immediate(1));
-    __ Bind(&overflow);
   }
 
   if (!skip_overflow_check) {
@@ -1392,13 +1385,7 @@
     if (codegen_->GetCompilerOptions().CountHotnessInCompiledCode()) {
       __ pushl(EAX);
       __ movl(EAX, Address(ESP, kX86WordSize));
-          NearLabel overflow;
-      __ cmpw(Address(EAX, ArtMethod::HotnessCountOffset().Int32Value()),
-              Immediate(ArtMethod::MaxCounter()));
-      __ j(kEqual, &overflow);
-      __ addw(Address(EAX, ArtMethod::HotnessCountOffset().Int32Value()),
-              Immediate(1));
-      __ Bind(&overflow);
+      __ addw(Address(EAX, ArtMethod::HotnessCountOffset().Int32Value()), Immediate(1));
       __ popl(EAX);
     }
     GenerateSuspendCheck(info->GetSuspendCheck(), successor);
diff --git a/compiler/optimizing/code_generator_x86_64.cc b/compiler/optimizing/code_generator_x86_64.cc
index 2d51f32..a75c745 100644
--- a/compiler/optimizing/code_generator_x86_64.cc
+++ b/compiler/optimizing/code_generator_x86_64.cc
@@ -1349,15 +1349,9 @@
   DCHECK(GetCompilerOptions().GetImplicitStackOverflowChecks());
 
   if (GetCompilerOptions().CountHotnessInCompiledCode()) {
-    NearLabel overflow;
-    __ cmpw(Address(CpuRegister(kMethodRegisterArgument),
-                    ArtMethod::HotnessCountOffset().Int32Value()),
-            Immediate(ArtMethod::MaxCounter()));
-    __ j(kEqual, &overflow);
     __ addw(Address(CpuRegister(kMethodRegisterArgument),
                     ArtMethod::HotnessCountOffset().Int32Value()),
             Immediate(1));
-    __ Bind(&overflow);
   }
 
   if (!skip_overflow_check) {
@@ -1553,13 +1547,8 @@
   if (info != nullptr && info->IsBackEdge(*block) && info->HasSuspendCheck()) {
     if (codegen_->GetCompilerOptions().CountHotnessInCompiledCode()) {
       __ movq(CpuRegister(TMP), Address(CpuRegister(RSP), 0));
-      NearLabel overflow;
-      __ cmpw(Address(CpuRegister(TMP), ArtMethod::HotnessCountOffset().Int32Value()),
-              Immediate(ArtMethod::MaxCounter()));
-      __ j(kEqual, &overflow);
       __ addw(Address(CpuRegister(TMP), ArtMethod::HotnessCountOffset().Int32Value()),
               Immediate(1));
-      __ Bind(&overflow);
     }
     GenerateSuspendCheck(info->GetSuspendCheck(), successor);
     return;