function wrap(fn, name = 'anonymous') {
  if (!goog.DEBUG || !createTask) return fn;

  if (fn[assertExists(CONSOLE_TASK_SYMBOL)]) {
    return fn;
  }
  const consoleTask = createTask(fn.name || name);
  function wrappedFn(...args) {
    return consoleTask['run'](() => fn.call(/** @type {?} */ (this), ...args));
  }
  wrappedFn[assertExists(CONSOLE_TASK_SYMBOL)] = consoleTask;
  return wrappedFn;
}
Utility to wrap the function to tag its stack at this point. If the function
has already been tagged, this does nothing.
@param {!T} fn
@param {string=} name
@return {!T}
@template T