Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: Add utility to keep unused parameters #4233

Merged
merged 1 commit into from May 17, 2022

Commits on May 17, 2022

  1. refactor: Add utility to keep unused parameters

    Many times in our default configuration, we need to create an empty
    default implementation of a callback.  The compiler wants to strip
    out unused parameters from these functions, but this breaks our
    runtime-type-checking for functions in configure().  We need a way to
    keep the full function signature in default config callbacks in
    compiled mode.
    
    This adds a new utility: ConfigUtils.referenceParametersAndReturn().
    
    It references the input parameters so the compiler doesn't remove them
    from the calling function, and returns whatever value is specified.
    The utility function is marked with `@noinline`, so the compiler won't
    tamper with it.
    
    Default config callbacks that use this utility will still bear the
    complete function signature even in compiled mode.
    
    The caller should look something like this:
    
      const callback = (a, b, c, d) => {
        return referenceParametersAndReturn(
            [a, b, c, d],
            a);  // Can be anything, doesn't need to be one of the parameters
      };
    
    See also shaka-project#4231 (comment)
    joeyparrish committed May 17, 2022
    Configuration menu
    Copy the full SHA
    5e3d2a8 View commit details
    Browse the repository at this point in the history