Reviewers: Yang,

Description:
[arm] Fix missing CheckBuffer for branches.

The b, bl and blx methods that take labels basically ignore the constant
pool check and just block the constant pool for the next instruction.
This way a long enough sequence of those instructions will block can
potentially block the constant pool emission for too long.

BUG=v8:4292
LOG=y
[email protected]

Please review this at https://codereview.chromium.org/1223093004/

Base URL: https://chromium.googlesource.com/v8/v8.git@master

Affected files (+68, -4 lines):
  M src/arm/assembler-arm.h
  M src/arm/assembler-arm.cc
  M test/cctest/test-assembler-arm.cc


Index: src/arm/assembler-arm.cc
diff --git a/src/arm/assembler-arm.cc b/src/arm/assembler-arm.cc
index de49bb185f106aefe58a0db91b4fb835ecf75b92..72786597f0ecfc7b2236dabd055dc9d24e548d70 100644
--- a/src/arm/assembler-arm.cc
+++ b/src/arm/assembler-arm.cc
@@ -1377,6 +1377,24 @@ void Assembler::bx(Register target, Condition cond) { // v5 and above, plus v4t
 }


+void Assembler::b(Label* L, Condition cond) {
+  CheckBuffer();
+  b(branch_offset(L), cond);
+}
+
+
+void Assembler::bl(Label* L, Condition cond) {
+  CheckBuffer();
+  bl(branch_offset(L), cond);
+}
+
+
+void Assembler::blx(Label* L) {
+  CheckBuffer();
+  blx(branch_offset(L));
+}
+
+
 // Data-processing instructions.

 void Assembler::and_(Register dst, Register src1, const Operand& src2,
Index: src/arm/assembler-arm.h
diff --git a/src/arm/assembler-arm.h b/src/arm/assembler-arm.h
index 9140864a2ce21de3337e70bbf394459644e2d774..36f3fda6f47daa6920e6cb0a6c5678042bd7cb57 100644
--- a/src/arm/assembler-arm.h
+++ b/src/arm/assembler-arm.h
@@ -806,11 +806,11 @@ class Assembler : public AssemblerBase {
   void bx(Register target, Condition cond = al);  // v5 and above, plus v4t

   // Convenience branch instructions using labels
-  void b(Label* L, Condition cond = al) { b(branch_offset(L), cond); }
+  void b(Label* L, Condition cond = al);
   void b(Condition cond, Label* L) { b(L, cond); }
-  void bl(Label* L, Condition cond = al) { bl(branch_offset(L), cond); }
-  void bl(Condition cond, Label* L) { bl(branch_offset(L), cond); }
-  void blx(Label* L) { blx(branch_offset(L)); }  // v5 and above
+  void bl(Label* L, Condition cond = al);
+  void bl(Condition cond, Label* L) { bl(L, cond); }
+  void blx(Label* L);  // v5 and above

   // Data-processing instructions

Index: test/cctest/test-assembler-arm.cc
diff --git a/test/cctest/test-assembler-arm.cc b/test/cctest/test-assembler-arm.cc index 59ebaab069270fa8626ef4f060a3aea03093685d..06b8d81be4dc4b95de817786ca749b2bb543acdd 100644
--- a/test/cctest/test-assembler-arm.cc
+++ b/test/cctest/test-assembler-arm.cc
@@ -1981,4 +1981,50 @@ TEST(ARMv8_vrintX) {
 #undef CHECK_VRINT
   }
 }
+
+
+TEST(regress4292_b) {
+  CcTest::InitializeVM();
+  Isolate* isolate = CcTest::i_isolate();
+  HandleScope scope(isolate);
+
+  Assembler assm(isolate, NULL, 0);
+  Label end;
+  __ mov(r0, Operand(isolate->factory()->infinity_value()));
+  for (int i = 0; i < 1020; ++i) {
+    __ b(hi, &end);
+  }
+  __ bind(&end);
+}
+
+
+TEST(regress4292_bl) {
+  CcTest::InitializeVM();
+  Isolate* isolate = CcTest::i_isolate();
+  HandleScope scope(isolate);
+
+  Assembler assm(isolate, NULL, 0);
+  Label end;
+  __ mov(r0, Operand(isolate->factory()->infinity_value()));
+  for (int i = 0; i < 1020; ++i) {
+    __ bl(hi, &end);
+  }
+  __ bind(&end);
+}
+
+
+TEST(regress4292_blx) {
+  CcTest::InitializeVM();
+  Isolate* isolate = CcTest::i_isolate();
+  HandleScope scope(isolate);
+
+  Assembler assm(isolate, NULL, 0);
+  Label end;
+  __ mov(r0, Operand(isolate->factory()->infinity_value()));
+  for (int i = 0; i < 1020; ++i) {
+    __ blx(&end);
+  }
+  __ bind(&end);
+}
+
 #undef __


--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to