Ignore:
Timestamp:
Jun 17, 2017, 3:52:34 AM (8 years ago)
Author:
[email protected]
Message:

ArrayPrototype methods should use JSValue::toLength for non-Arrays.
https://bugs.webkit.org/show_bug.cgi?id=173506

JSTests:

Reviewed by Ryosuke Niwa.

Re-baseline tests.

  • ChakraCore/test/Function/apply3.baseline-jsc:
  • test262.yaml:

Source/JavaScriptCore:

Reviewed by Ryosuke Niwa.

This patch changes the result of unshift if old length +
unshift.arguments.length > (2 53) - 1 to be a type error. Also,
the getLength function, which was always incorrect to use, has
been removed. Additionally, some cases where we were using a
constant for (2
53) - 1 have been replaced with
maxSafeInteger()

  • interpreter/Interpreter.cpp:

(JSC::sizeOfVarargs):

  • runtime/ArrayPrototype.cpp:

(JSC::arrayProtoFuncToLocaleString):
(JSC::arrayProtoFuncPop):
(JSC::arrayProtoFuncPush):
(JSC::arrayProtoFuncReverse):
(JSC::arrayProtoFuncShift):
(JSC::arrayProtoFuncSlice):
(JSC::arrayProtoFuncSplice):
(JSC::arrayProtoFuncUnShift):
(JSC::arrayProtoFuncIndexOf):
(JSC::arrayProtoFuncLastIndexOf):

  • runtime/JSArrayInlines.h:

(JSC::getLength): Deleted.

  • runtime/JSCJSValue.cpp:

(JSC::JSValue::toLength):

  • runtime/NumberConstructor.cpp:

(JSC::numberConstructorFuncIsSafeInteger):

LayoutTests:

Unreviewed test gardening.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/runtime/JSArrayInlines.h

    r215777 r218449  
    6868}
    6969
    70 ALWAYS_INLINE unsigned getLength(ExecState* exec, JSObject* obj)
    71 {
    72     VM& vm = exec->vm();
    73     auto scope = DECLARE_THROW_SCOPE(vm);
    74     if (isJSArray(obj))
    75         return jsCast<JSArray*>(obj)->length();
    76 
    77     JSValue lengthValue = obj->get(exec, vm.propertyNames->length);
    78     RETURN_IF_EXCEPTION(scope, UINT_MAX);
    79     scope.release();
    80     return lengthValue.toUInt32(exec);
    81 }
    82 
    8370ALWAYS_INLINE double toLength(ExecState* exec, JSObject* obj)
    8471{
Note: See TracChangeset for help on using the changeset viewer.