Index: src/arm64/assembler-arm64.cc |
diff --git a/src/arm64/assembler-arm64.cc b/src/arm64/assembler-arm64.cc |
index 524be154c53bef81a410c3c648f456fc32f85bd3..bf44c0810e138b729c7cd7f7fbe9ca87ec6517eb 100644 |
--- a/src/arm64/assembler-arm64.cc |
+++ b/src/arm64/assembler-arm64.cc |
@@ -603,9 +603,12 @@ void Assembler::Align(int m) { |
void Assembler::CheckLabelLinkChain(Label const * label) { |
#ifdef DEBUG |
if (label->is_linked()) { |
+ static const int kMaxLinksToCheck = 256; // Avoid O(n2) behaviour. |
+ int links_checked = 0; |
int linkoffset = label->pos(); |
bool end_of_chain = false; |
while (!end_of_chain) { |
+ if (++links_checked > kMaxLinksToCheck) break; |
Instruction * link = InstructionAt(linkoffset); |
int linkpcoffset = link->ImmPCOffset(); |
int prevlinkoffset = linkoffset + linkpcoffset; |