Stop catching OutOfMemoryErrors when evaluating Skylark BuiltinFunctions.

--
MOS_MIGRATED_REVID=124338362
diff --git a/src/main/java/com/google/devtools/build/lib/syntax/BuiltinFunction.java b/src/main/java/com/google/devtools/build/lib/syntax/BuiltinFunction.java
index 74a9f4c..eab18ce 100644
--- a/src/main/java/com/google/devtools/build/lib/syntax/BuiltinFunction.java
+++ b/src/main/java/com/google/devtools/build/lib/syntax/BuiltinFunction.java
@@ -13,6 +13,7 @@
 // limitations under the License.
 package com.google.devtools.build.lib.syntax;
 
+import com.google.common.base.Throwables;
 import com.google.devtools.build.lib.events.Location;
 import com.google.devtools.build.lib.profiler.Profiler;
 import com.google.devtools.build.lib.profiler.ProfilerTask;
@@ -25,7 +26,6 @@
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.NoSuchElementException;
-import java.util.concurrent.ExecutionException;
 
 import javax.annotation.Nullable;
 
@@ -157,19 +157,17 @@
       return invokeMethod.invoke(this, args);
     } catch (InvocationTargetException x) {
       Throwable e = x.getCause();
+
       if (e instanceof EvalException) {
         throw ((EvalException) e).ensureLocation(loc);
-      } else if (e instanceof InterruptedException) {
-        throw (InterruptedException) e;
-      } else if (e instanceof ClassCastException
-          || e instanceof ExecutionException
-          || e instanceof IllegalStateException) {
-        throw new EvalException(loc, "in call to " + getName(), e);
       } else if (e instanceof IllegalArgumentException) {
         throw new EvalException(loc, "Illegal argument in call to " + getName(), e);
-      } else {
-        throw badCallException(loc, e, args);
       }
+      // TODO(bazel-team): replace with Throwables.throwIfInstanceOf once Guava 20 is released.
+      Throwables.propagateIfInstanceOf(e, InterruptedException.class);
+      // TODO(bazel-team): replace with Throwables.throwIfUnchecked once Guava 20 is released.
+      Throwables.propagateIfPossible(e);
+      throw badCallException(loc, e, args);
     } catch (IllegalArgumentException e) {
       // Either this was thrown by Java itself, or it's a bug
       // To cover the first case, let's manually check the arguments.