Changeset 196644 in webkit


Ignore:
Timestamp:
Feb 16, 2016 11:28:09 AM (8 years ago)
Author:
keith_miller@apple.com
Message:

ClonedArguments should not materialize its special properties unless they are being changed or deleted
https://bugs.webkit.org/show_bug.cgi?id=154128

Reviewed by Filip Pizlo.

Source/JavaScriptCore:

Before we would materialize ClonedArguments whenever they were being accessed.
However this would cause the IC to miss every time as the structure for
the arguments object would change as we went to IC it. Thus on the next
function call we would miss the cache since the new arguments object
would not have materialized the value.

  • runtime/ClonedArguments.cpp:

(JSC::ClonedArguments::getOwnPropertySlot):

  • tests/stress/cloned-arguments-modification.js: Added.

(foo):

LayoutTests:

Have argumnets-strict-mode test the speed of spreading the arguments object.

  • js/regress/script-tests/arguments-strict-mode.js:

(foo):

Location:
trunk
Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r196643 r196644  
     12016-02-16  Keith Miller  <keith_miller@apple.com>
     2
     3        ClonedArguments should not materialize its special properties unless they are being changed or deleted
     4        https://bugs.webkit.org/show_bug.cgi?id=154128
     5
     6        Reviewed by Filip Pizlo.
     7
     8        Have argumnets-strict-mode test the speed of spreading the arguments object.
     9
     10        * js/regress/script-tests/arguments-strict-mode.js:
     11        (foo):
     12
    1132016-02-16  Ryan Haddad  <ryanhaddad@apple.com>
    214
  • trunk/LayoutTests/js/regress/script-tests/arguments-strict-mode.js

    r181993 r196644  
    11function foo() {
    22    "use strict";
    3     return arguments[0];
     3    return [...arguments];
     4
    45}
    56
    67noInline(foo);
    78
    8 for (var i = 0; i < 1000000; ++i) {
     9for (var i = 0; i < 200000; ++i) {
    910    var result = foo(i);
    10     if (result != i)
     11    if (result[0] != i)
    1112        throw "Error: bad result: " + result;
    1213}
  • trunk/Source/JavaScriptCore/ChangeLog

    r196642 r196644  
     12016-02-16  Keith Miller  <keith_miller@apple.com>
     2
     3        ClonedArguments should not materialize its special properties unless they are being changed or deleted
     4        https://bugs.webkit.org/show_bug.cgi?id=154128
     5
     6        Reviewed by Filip Pizlo.
     7
     8        Before we would materialize ClonedArguments whenever they were being accessed.
     9        However this would cause the IC to miss every time as the structure for
     10        the arguments object would change as we went to IC it. Thus on the next
     11        function call we would miss the cache since the new arguments object
     12        would not have materialized the value.
     13
     14        * runtime/ClonedArguments.cpp:
     15        (JSC::ClonedArguments::getOwnPropertySlot):
     16        * tests/stress/cloned-arguments-modification.js: Added.
     17        (foo):
     18
    1192016-02-16  Filip Pizlo  <fpizlo@apple.com>
    220
  • trunk/Source/JavaScriptCore/runtime/ClonedArguments.cpp

    r188585 r196644  
    133133    ClonedArguments* thisObject = jsCast<ClonedArguments*>(object);
    134134    VM& vm = exec->vm();
    135    
    136     if (ident == vm.propertyNames->callee
    137         || ident == vm.propertyNames->caller
    138         || ident == vm.propertyNames->iteratorSymbol)
    139         thisObject->materializeSpecialsIfNecessary(exec);
    140    
    141     if (Base::getOwnPropertySlot(thisObject, exec, ident, slot))
    142         return true;
    143    
    144     return false;
     135
     136    if (!thisObject->specialsMaterialized()) {
     137        FunctionExecutable* executable = jsCast<FunctionExecutable*>(thisObject->m_callee->executable());
     138        bool isStrictMode = executable->isStrictMode();
     139
     140        if (isStrictMode) {
     141            if (ident == vm.propertyNames->callee) {
     142                slot.setGetterSlot(thisObject, DontDelete | DontEnum | Accessor, thisObject->globalObject()->throwTypeErrorGetterSetter(vm));
     143                return true;
     144            }
     145            if (ident == vm.propertyNames->caller) {
     146                slot.setGetterSlot(thisObject, DontDelete | DontEnum | Accessor, thisObject->globalObject()->throwTypeErrorGetterSetter(vm));
     147                return true;
     148            }
     149
     150        } else if (ident == vm.propertyNames->callee) {
     151            slot.setValue(thisObject, 0, thisObject->m_callee.get());
     152            return true;
     153        }
     154
     155        if (ident == vm.propertyNames->iteratorSymbol) {
     156            slot.setValue(thisObject, DontEnum, thisObject->globalObject()->arrayProtoValuesFunction());
     157            return true;
     158        }
     159    }
     160
     161    return Base::getOwnPropertySlot(thisObject, exec, ident, slot);
    145162}
    146163
Note: See TracChangeset for help on using the changeset viewer.