From d05538827e32ebfed5297653266d65c11e438148 Mon Sep 17 00:00:00 2001 From: bmeurer Date: Thu, 9 Jul 2015 02:33:17 -0700 Subject: [PATCH] [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 R=yangguo@chromium.org Review URL: https://codereview.chromium.org/1223093004 Cr-Commit-Position: refs/heads/master@{#29550} --- src/arm/assembler-arm.cc | 18 +++++++++++++++ src/arm/assembler-arm.h | 8 +++---- test/cctest/test-assembler-arm.cc | 46 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 68 insertions(+), 4 deletions(-) diff --git a/src/arm/assembler-arm.cc b/src/arm/assembler-arm.cc index de49bb1..7278659 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, diff --git a/src/arm/assembler-arm.h b/src/arm/assembler-arm.h index 9140864..36f3fda 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 diff --git a/test/cctest/test-assembler-arm.cc b/test/cctest/test-assembler-arm.cc index 59ebaab..06b8d81 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 __ -- 2.7.4