ChakraCore/test/Function/apply3.js is resulting wrong result in x86_64
authorticaiolima@gmail.com <ticaiolima@gmail.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 2 Oct 2017 18:15:09 +0000 (18:15 +0000)
committerticaiolima@gmail.com <ticaiolima@gmail.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 2 Oct 2017 18:15:09 +0000 (18:15 +0000)
commit2b2aee19355c8d5cef25bfbdadebdaef0f981bdc
treee50845fb70a89d28b2b95e88d3f8e709c8a161c3
parent8e5c1d0b6fea8bb75284ac3887e70c36b05a1eef
ChakraCore/test/Function/apply3.js is resulting wrong result in x86_64
https://bugs.webkit.org/show_bug.cgi?id=175642

Reviewed by Darin Adler.

JSTests:

* ChakraCore/test/Function/apply3.baseline-jsc:

Source/JavaScriptCore:

According JS spec, the ToLength operation[1] has a range of 0..(2^53)
- 1. In Interpreter.cpp::sizeFrameForVarargs, the call to
sizeOfVarargs() was being assigned to "unsigned length", forcing a
type cast that results in different value among architectures JSC supports.
For instance, in x86_64 "4294967295 + 1" results in 0, while in ARMv6 it
results 4294967295. This patch is changing "sizeOfVarargs" to clamp the
result from "toLength" to unsigned and then get desired behavior for
all supported platforms.

[1] - https://tc39.github.io/ecma262/#sec-tolength

* interpreter/Interpreter.cpp:
(JSC::sizeOfVarargs):
* interpreter/Interpreter.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@222724 268f45cc-cd09-0410-ab3c-d52691b4dbfc
JSTests/ChakraCore/test/Function/apply3.baseline-jsc
JSTests/ChangeLog
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/interpreter/Interpreter.cpp