Adds bound method to the prototype of the given object.
function AddBoundMethod(obj, methodName, implementation, length, type) {
  %CheckIsBootstrapping();
  var internalName = %CreatePrivateSymbol(methodName);
  // Making getter an anonymous function will cause
  // %DefineGetterPropertyUnchecked to properly set the "name"
  // property on each JSFunction instance created here, rather
  // than (as utils.InstallGetter would) on the SharedFunctionInfo
  // associated with all functions returned from AddBoundMethod.
  var getter = ANONYMOUS_FUNCTION(function() {
    if (!%IsInitializedIntlObjectOfType(this, type)) {
      throw MakeTypeError(kMethodCalledOnWrongObject, methodName);
    }
    if (IS_UNDEFINED(this[internalName])) {
      var boundMethod;
      if (IS_UNDEFINED(length) || length === 2) {
        boundMethod = ANONYMOUS_FUNCTION((x, y) => implementation(this, x, y));
      } else if (length === 1) {
        boundMethod = ANONYMOUS_FUNCTION(x => implementation(this, x));
      } else {
        boundMethod = ANONYMOUS_FUNCTION((...args) => {
          // DateTimeFormat.format needs to be 0 arg method, but can still
          // receive an optional dateValue param. If one was provided, pass it
          // along.
          if (args.length > 0) {
            return implementation(this, args[0]);
          } else {
            return implementation(this);
          }
        });
      }
      %SetNativeFlag(boundMethod);
      this[internalName] = boundMethod;
    }
    return this[internalName];
  });

  %FunctionRemovePrototype(getter);
  %DefineGetterPropertyUnchecked(obj.prototype, methodName, getter, DONT_ENUM);
  %SetNativeFlag(getter);
}