From 6c689a1566e1af28cc711719d64510b7cb4c5b33 Mon Sep 17 00:00:00 2001 From: Brian Hackett Date: Wed, 1 Jul 2015 15:47:35 -0700 Subject: [PATCH] Bug 1174230 - Limit the complexity of regalloc bundles which can be merged together, r=sunfish. --- js/src/jit/BacktrackingAllocator.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/js/src/jit/BacktrackingAllocator.cpp b/js/src/jit/BacktrackingAllocator.cpp index f8f935c10231..3781625f6c30 100644 --- a/js/src/jit/BacktrackingAllocator.cpp +++ b/js/src/jit/BacktrackingAllocator.cpp @@ -900,9 +900,17 @@ BacktrackingAllocator::tryMergeBundles(LiveBundle* bundle0, LiveBundle* bundle1) } } + // Limit the number of times we compare ranges if there are many ranges in + // one of the bundles, to avoid quadratic behavior. + static const size_t MAX_RANGES = 200; + // Make sure that ranges in the bundles do not overlap. LiveRange::BundleLinkIterator iter0 = bundle0->rangesBegin(), iter1 = bundle1->rangesBegin(); + size_t count = 0; while (iter0 && iter1) { + if (++count >= MAX_RANGES) + return true; + LiveRange* range0 = LiveRange::get(*iter0); LiveRange* range1 = LiveRange::get(*iter1);