Add profiling for Skylark lexer, parser, user- and built-in functions.

--
MOS_MIGRATED_REVID=101769963
diff --git a/src/main/java/com/google/devtools/build/lib/syntax/UserDefinedFunction.java b/src/main/java/com/google/devtools/build/lib/syntax/UserDefinedFunction.java
index 750429d..f9719ae 100644
--- a/src/main/java/com/google/devtools/build/lib/syntax/UserDefinedFunction.java
+++ b/src/main/java/com/google/devtools/build/lib/syntax/UserDefinedFunction.java
@@ -15,6 +15,8 @@
 
 import com.google.common.collect.ImmutableList;
 import com.google.devtools.build.lib.events.Location;
+import com.google.devtools.build.lib.profiler.Profiler;
+import com.google.devtools.build.lib.profiler.ProfilerTask;
 
 /**
  * The actual function registered in the environment. This function is defined in the
@@ -57,6 +59,7 @@
       env.update(name, arguments[i++]);
     }
 
+    long startTimeProfiler = Profiler.nanoTimeMaybe();
     Statement lastStatement = null;
     try {
       for (Statement stmt : statements) {
@@ -74,6 +77,8 @@
           new EvalExceptionWithStackTrace(ex, lastStatement.getLocation());
       real.registerStatement(lastStatement);
       throw real;
+    } finally {
+      Profiler.instance().logSimpleTask(startTimeProfiler, ProfilerTask.SKYLARK_USER_FN, getName());
     }
     return Environment.NONE;
   }