Function memoization

Add support for `experimental_memoize` function, which enables memoization
for f(int) => int Perfetto SQL functions.

Combined with support for recursive SQL functions, it allows us to write
efficient operations over recursive trees.

Change-Id: I1593330ce1950b502fef5540e4355dcf8081edb4
diff --git a/src/trace_processor/prelude/functions/create_function.h b/src/trace_processor/prelude/functions/create_function.h
index ed8c06c..612abf1 100644
--- a/src/trace_processor/prelude/functions/create_function.h
+++ b/src/trace_processor/prelude/functions/create_function.h
@@ -44,6 +44,23 @@
                           Destructors&);
 };
 
+// Implementation of MEMOIZE SQL function.
+// SELECT EXPERIMENTAL_MEMOIZE('my_func') enables memoization for the results of
+// the calls to `my_func`. `my_func` must be a Perfetto SQL function created
+// through CREATE_FUNCTION that takes a single integer argument and returns a
+// int.
+struct ExperimentalMemoize : public SqlFunction {
+  using Context = PerfettoSqlEngine;
+
+  static constexpr bool kVoidReturn = true;
+
+  static base::Status Run(Context* ctx,
+                          size_t argc,
+                          sqlite3_value** argv,
+                          SqlValue& out,
+                          Destructors&);
+};
+
 }  // namespace trace_processor
 }  // namespace perfetto