Skip to content

Commit 3cc6919

Browse files
FarazmandCommit Bot
authored andcommitted
PPC: fix Regex addi overflow
using add insetad of addi when Operand is more than 16 bits long Change-Id: I7f9452381ed8b321ec71e68d0d90485508b69885 Reviewed-on: https://chromium-review.googlesource.com/c/1430619 Commit-Queue: Junliang Yan <[email protected]> Reviewed-by: Junliang Yan <[email protected]> Cr-Commit-Position: refs/heads/master@{#59049}
1 parent 40b0be4 commit 3cc6919

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

src/regexp/ppc/regexp-macro-assembler-ppc.cc

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,13 @@ int RegExpMacroAssemblerPPC::stack_limit_slack() {
143143

144144
void RegExpMacroAssemblerPPC::AdvanceCurrentPosition(int by) {
145145
if (by != 0) {
146-
__ addi(current_input_offset(), current_input_offset(),
147-
Operand(by * char_size()));
146+
if (is_int16(by * char_size())) {
147+
__ addi(current_input_offset(), current_input_offset(),
148+
Operand(by * char_size()));
149+
} else {
150+
__ mov(r0, Operand(by * char_size()));
151+
__ add(current_input_offset(), r0, current_input_offset());
152+
}
148153
}
149154
}
150155

@@ -1275,7 +1280,12 @@ void RegExpMacroAssemblerPPC::LoadCurrentCharacterUnchecked(int cp_offset,
12751280
Register offset = current_input_offset();
12761281
if (cp_offset != 0) {
12771282
// r25 is not being used to store the capture start index at this point.
1278-
__ addi(r25, current_input_offset(), Operand(cp_offset * char_size()));
1283+
if (is_int16(cp_offset * char_size())) {
1284+
__ addi(r25, current_input_offset(), Operand(cp_offset * char_size()));
1285+
} else {
1286+
__ mov(r25, Operand(cp_offset * char_size()));
1287+
__ add(r25, r25, current_input_offset());
1288+
}
12791289
offset = r25;
12801290
}
12811291
// The lwz, stw, lhz, sth instructions can do unaligned accesses, if the CPU

0 commit comments

Comments
 (0)