Additional Math functions

Andrea Giammarchi andrea.giammarchi at gmail.com
Thu Apr 30 08:36:12 UTC 2015


I've actually found this limit in the past [1] mostly for string operations
and I remember it was already discussed in here.

2048 was a safe bet for all browsers I could test those days, but it'b be
very nice if any generic function, accordingly with the environment
capabilities, could expose somehow a `Function.MAX_SAFE_ARGUMENTS_LENGTH`
like property, similar to what `Number.MAX_SAFE_INTEGER` does already.

Regards

[1] 2011 post:
http://webreflection.blogspot.co.uk/2011/07/about-javascript-apply-arguments-limit.html

On Thu, Apr 30, 2015 at 1:50 AM, Caitlin Potter <caitpotter88 at gmail.com>
wrote:

> Just a note about the whole upper bounds on arguments thing
>
> In V8’s case (per the comment regarding io.js), the maximum arguments
> count for Function.prototype.apply/Reflect.apply/Reflect.construct
> is 0x800000 (
> https://github.com/v8/v8-git-mirror/blob/81345f1a2cdceaee8c891fc7512ae671f171308e/src/macros.py#L75)
> — On a 64mb system, this ends up being close to 70mb of data which the
> engine pushes to the stack, in addition to being on the heap in the array
> itself — which is not super tiny, but a desktop machine can probably handle
> a lot more. This isn’t a “real” stack overflow, because the RangeError is
> thrown before any arguments are actually pushed to the stack — it’s just an
> upper bound on the size of the array which can be pushed. SpiderMonkey has
> a similar arbitrary upper bounds on the argument length, ARGS_LENGTH_MAX (
> https://github.com/mozilla/gecko-dev/blob/d03ee825c74355f070b14cf4325897c813373902/js/src/vm/ArgumentsObject.h#L77)
> or 0x7A120, which is a much more conservative limit. Apparently nobody has
> complained about the smaller limit, so that’s something =)
>
> I guess what this means is, people aren’t generally depending on being
> able to push zillions of arguments to the stack via fn.apply — it’s almost
> always one of two things: either a small-ish array literal, or an actual
> Arguments object, which most likely doesn’t contain zillions of arguments
> either. These limits don’t seem unreasonable, and it’s probably okay to
> figure out an appropriate limit (especially for mobile devices) that still
> makes developers happy.
>
>
> On Apr 29, 2015, at 8:28 PM, Brendan Eich <brendan at mozilla.org> wrote:
>
> C. Scott Ananian wrote:
>
> I'm just saying: it's not safe to spread an arbitrary array into
> `arguments` unless the spec explicitly says that the number of arguments is
> limited only by heap size (not stack size) or something like that.  The ES6
> spec does not contain any such language.
>
>
> We've talked about this in past meetings. We want implementations and
> developers to cooperate and compete, to find a normative spec we can back.
> It would be silly for us to "pick a number".
>
> /be
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>
>
>
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20150430/8072dc1c/attachment-0001.html>


More information about the es-discuss mailing list