Additional Math functions
caitpotter88 at gmail.com
Thu Apr 30 00:50:08 UTC 2015
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 <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 <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".
> es-discuss mailing list
> es-discuss at mozilla.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the es-discuss