Skip to content

Commit 9be597d

Browse files
backesV8 LUCI CQ
authored andcommitted
[arm] Do not emit the constant pool before a branch
After computing the branch offset but before emitting the actual branch, we should not emit a constant pool. Otherwise the previously computed offset would be off. Instead of handling this indirectly via the Assembler::branch_offset method, do this directly in the Assembler::b method (and friends), so it is not missed on other call sites. [email protected] Bug: chromium:1399424 Change-Id: I0cbb219ced5b671001a296b1cc7c339f395abffe Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4102800 Commit-Queue: Clemens Backes <[email protected]> Reviewed-by: Jakob Kummerow <[email protected]> Cr-Commit-Position: refs/heads/main@{#84828}
1 parent 4c32668 commit 9be597d

1 file changed

Lines changed: 15 additions & 4 deletions

File tree

src/codegen/arm/assembler-arm.cc

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1444,10 +1444,6 @@ int Assembler::branch_offset(Label* L) {
14441444
L->link_to(pc_offset());
14451445
}
14461446

1447-
// Block the emission of the constant pool, since the branch instruction must
1448-
// be emitted at the pc offset recorded by the label.
1449-
if (!is_const_pool_blocked()) BlockConstPoolFor(1);
1450-
14511447
return target_pos - (pc_offset() + Instruction::kPcLoadDelta);
14521448
}
14531449

@@ -1458,6 +1454,11 @@ void Assembler::b(int branch_offset, Condition cond, RelocInfo::Mode rmode) {
14581454
int imm24 = branch_offset >> 2;
14591455
const bool b_imm_check = is_int24(imm24);
14601456
CHECK(b_imm_check);
1457+
1458+
// Block the emission of the constant pool before the next instruction.
1459+
// Otherwise the passed-in branch offset would be off.
1460+
BlockConstPoolFor(1);
1461+
14611462
emit(cond | B27 | B25 | (imm24 & kImm24Mask));
14621463

14631464
if (cond == al) {
@@ -1472,6 +1473,11 @@ void Assembler::bl(int branch_offset, Condition cond, RelocInfo::Mode rmode) {
14721473
int imm24 = branch_offset >> 2;
14731474
const bool bl_imm_check = is_int24(imm24);
14741475
CHECK(bl_imm_check);
1476+
1477+
// Block the emission of the constant pool before the next instruction.
1478+
// Otherwise the passed-in branch offset would be off.
1479+
BlockConstPoolFor(1);
1480+
14751481
emit(cond | B27 | B25 | B24 | (imm24 & kImm24Mask));
14761482
}
14771483

@@ -1481,6 +1487,11 @@ void Assembler::blx(int branch_offset) {
14811487
int imm24 = branch_offset >> 2;
14821488
const bool blx_imm_check = is_int24(imm24);
14831489
CHECK(blx_imm_check);
1490+
1491+
// Block the emission of the constant pool before the next instruction.
1492+
// Otherwise the passed-in branch offset would be off.
1493+
BlockConstPoolFor(1);
1494+
14841495
emit(kSpecialCondition | B27 | B25 | h | (imm24 & kImm24Mask));
14851496
}
14861497

0 commit comments

Comments
 (0)