Add some heursitics for compiling, close to Quick's.

Quick has more machinery to give up/not give up, but we can
backport them later.

Change-Id: I5eb62c664246f4ce46f0400cf24ec34a72afb51e
3 files changed