Use a label-branch in CheckConstPool.
authorjacob.bramley <jacob.bramley@arm.com>
Mon, 20 Jul 2015 09:03:12 +0000 (02:03 -0700)
committerCommit bot <commit-bot@chromium.org>
Mon, 20 Jul 2015 09:03:21 +0000 (09:03 +0000)
This removes a dependency on the size of the pool. Whilst the size is
checked in debug mode, it is still more robust to use a label.

This should also be cherry-picked to fix 4.4.63.20. (At that time, the
size of the pool was _not_ checked, and was sometimes wrong.)

This partially reverts 879550c, "[arm] Don't call branch_offset within
CheckConstPool." However, branch_offset now only blocks the constant
pool if it is not already blocked.

BUG=

Review URL: https://codereview.chromium.org/1227403006

Cr-Commit-Position: refs/heads/master@{#29746}

src/arm/assembler-arm.cc

index 96bdf79..6f67a70 100644 (file)
@@ -1325,7 +1325,8 @@ int Assembler::branch_offset(Label* L) {
 
   // Block the emission of the constant pool, since the branch instruction must
   // be emitted at the pc offset recorded by the label.
-  BlockConstPoolFor(1);
+  if (!is_const_pool_blocked()) BlockConstPoolFor(1);
+
   return target_pos - (pc_offset() + kPcLoadDelta);
 }
 
@@ -3838,7 +3839,10 @@ void Assembler::CheckConstPool(bool force_emit, bool require_jump) {
     bind(&size_check);
 
     // Emit jump over constant pool if necessary.
-    if (require_jump) b(size - kPcLoadDelta);
+    Label after_pool;
+    if (require_jump) {
+      b(&after_pool);
+    }
 
     // Put down constant pool marker "Undefined instruction".
     // The data size helps disassembly know what to print.
@@ -3922,6 +3926,10 @@ void Assembler::CheckConstPool(bool force_emit, bool require_jump) {
     RecordComment("]");
 
     DCHECK_EQ(size, SizeOfCodeGeneratedSince(&size_check));
+
+    if (after_pool.is_linked()) {
+      bind(&after_pool);
+    }
   }
 
   // Since a constant pool was just emitted, move the check offset forward by