⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 211116 in webkit


Ignore:
Timestamp:
Jan 24, 2017, 3:29:30 PM (10 years ago)
Author:
matthew_hanson@apple.com
Message:

Merge r211070. rdar://problem/30121809

Location:
branches/safari-603-branch
Files:
2 added
7 edited

Legend:

Unmodified
Added
Removed
  • branches/safari-603-branch/JSTests/ChangeLog

    r210868 r211116  
     12017-01-24  Matthew Hanson  <matthew_hanson@apple.com>
     2
     3        Merge r211070. rdar://problem/30121809
     4
     5    2017-01-23  Saam Barati  <sbarati@apple.com>
     6
     7            https://bugs.webkit.org/show_bug.cgi?id=167247
     8            JSC: operationSpreadGeneric uses the wrong global object for the builtin function and slow_path_spread consults the wrong global object to prove if the iterator protocol is unobservable
     9            <rdar://problem/30121809>
     10
     11            Reviewed by Filip Pizlo.
     12
     13            * stress/spread-consults-correct-global-object.js: Added.
     14            (assert):
     15            (spread):
     16            * stress/spread-correct-global-object-on-exception.js: Added.
     17            (assert):
     18            (spread):
     19            (const.objectText.let.o.Symbol.iterator):
     20            (catch):
     21
    1222017-01-18  Matthew Hanson  <matthew_hanson@apple.com>
    223
  • branches/safari-603-branch/Source/JavaScriptCore/ChangeLog

    r211115 r211116  
     12017-01-24  Matthew Hanson  <matthew_hanson@apple.com>
     2
     3        Merge r211070. rdar://problem/30121809
     4
     5    2017-01-23  Saam Barati  <sbarati@apple.com>
     6
     7            https://bugs.webkit.org/show_bug.cgi?id=167247
     8            JSC: operationSpreadGeneric uses the wrong global object for the builtin function and slow_path_spread consults the wrong global object to prove if the iterator protocol is unobservable
     9            <rdar://problem/30121809>
     10
     11            Reviewed by Filip Pizlo.
     12
     13            There were two bugs in the different tiers with respect to how
     14            spread handled global objects.
     15
     16            The first was in the LLInt/baseline inside slow_path_spread:
     17
     18            We consulted the lexical global object instead of the thing we're
     19            spreading's global object to determine if the array iterator protocol
     20            is unobservable. This is wrong if the incoming array is from a different
     21            global object. We must consult the incoming array's global object
     22            to determine if it can be spread using the fast path.
     23
     24            The second was in operationSpreadGeneric in the DFG/FTL:
     25
     26            We were always using the incoming array's global object, even
     27            when going down the slow path. This is wrong because we were
     28            fetching the builtin iteration function helper from the incoming
     29            array's global object, which meant that if the iterator function
     30            were to throw an exception, it could leak objects from a different
     31            global object. We should be executing the iterator function with
     32            the lexical global object.
     33
     34            * dfg/DFGOperations.cpp:
     35            * jsc.cpp:
     36            (GlobalObject::finishCreation):
     37            (functionGlobalObjectForObject):
     38            * runtime/CommonSlowPaths.cpp:
     39            (JSC::SLOW_PATH_DECL):
     40            * runtime/JSArray.h:
     41            * runtime/JSArrayInlines.h:
     42            (JSC::JSArray::isIteratorProtocolFastAndNonObservable):
     43
    1442017-01-24  Matthew Hanson  <matthew_hanson@apple.com>
    245
  • branches/safari-603-branch/Source/JavaScriptCore/dfg/DFGOperations.cpp

    r209638 r211116  
    4848#include "JIT.h"
    4949#include "JITExceptions.h"
     50#include "JSArrayInlines.h"
    5051#include "JSCInlines.h"
    5152#include "JSFixedArray.h"
     
    19851986    auto throwScope = DECLARE_THROW_SCOPE(vm);
    19861987
    1987     JSGlobalObject* globalObject = iterable->structure(vm)->globalObject();
    1988     if (!globalObject)
    1989         globalObject = exec->lexicalGlobalObject();
    1990 
    1991     if (isJSArray(iterable) && globalObject->isArrayIteratorProtocolFastAndNonObservable()) {
     1988    if (isJSArray(iterable)) {
    19921989        JSArray* array = jsCast<JSArray*>(iterable);
    1993         throwScope.release();
    1994         return JSFixedArray::createFromArray(exec, vm, array);
     1990        if (array->isIteratorProtocolFastAndNonObservable()) {
     1991            throwScope.release();
     1992            return JSFixedArray::createFromArray(exec, vm, array);
     1993        }
    19951994    }
    19961995
     
    19981997    // the iteration protocol builtin: https://bugs.webkit.org/show_bug.cgi?id=164520
    19991998
     1999    JSGlobalObject* globalObject = exec->lexicalGlobalObject();
    20002000    JSArray* array;
    20012001    {
     
    20232023    ASSERT(isJSArray(cell));
    20242024    JSArray* array = jsCast<JSArray*>(cell);
    2025     ASSERT(array->globalObject()->isArrayIteratorProtocolFastAndNonObservable());
     2025    ASSERT(array->isIteratorProtocolFastAndNonObservable());
    20262026
    20272027    return JSFixedArray::createFromArray(exec, vm, array);
  • branches/safari-603-branch/Source/JavaScriptCore/jsc.cpp

    r210868 r211116  
    10081008static EncodedJSValue JSC_HOST_CALL functionSetRandomSeed(ExecState*);
    10091009static EncodedJSValue JSC_HOST_CALL functionIsRope(ExecState*);
     1010static EncodedJSValue JSC_HOST_CALL functionGlobalObjectForObject(ExecState*);
    10101011
    10111012struct Script {
     
    12311232        addFunction(vm, "setRandomSeed", functionSetRandomSeed, 1);
    12321233        addFunction(vm, "isRope", functionIsRope, 1);
     1234
     1235        addFunction(vm, "globalObjectForObject", functionGlobalObjectForObject, 1);
    12331236
    12341237        addFunction(vm, "is32BitPlatform", functionIs32BitPlatform, 0);
     
    21052108}
    21062109
     2110EncodedJSValue JSC_HOST_CALL functionGlobalObjectForObject(ExecState* exec)
     2111{
     2112    JSValue value = exec->argument(0);
     2113    RELEASE_ASSERT(value.isObject());
     2114    JSGlobalObject* globalObject = jsCast<JSObject*>(value)->globalObject();
     2115    RELEASE_ASSERT(globalObject);
     2116    return JSValue::encode(globalObject);
     2117}
     2118
    21072119EncodedJSValue JSC_HOST_CALL functionReadline(ExecState* exec)
    21082120{
  • branches/safari-603-branch/Source/JavaScriptCore/runtime/CommonSlowPaths.cpp

    r208936 r211116  
    4444#include "IteratorOperations.h"
    4545#include "JIT.h"
     46#include "JSArrayInlines.h"
    4647#include "JSCInlines.h"
    4748#include "JSCJSValue.h"
     
    10351036    JSValue iterable = OP_C(2).jsValue();
    10361037
     1038    if (iterable.isCell() && isJSArray(iterable.asCell())) {
     1039        JSArray* array = jsCast<JSArray*>(iterable);
     1040        if (array->isIteratorProtocolFastAndNonObservable()) {
     1041            // JSFixedArray::createFromArray does not consult the prototype chain,
     1042            // so we must be sure that not consulting the prototype chain would
     1043            // produce the same value during iteration.
     1044            RETURN(JSFixedArray::createFromArray(exec, vm, array));
     1045        }
     1046    }
     1047
    10371048    JSGlobalObject* globalObject = exec->lexicalGlobalObject();
    1038 
    1039     if (iterable.isCell() && isJSArray(iterable.asCell()) && globalObject->isArrayIteratorProtocolFastAndNonObservable()) {
    1040         // JSFixedArray::createFromArray does not consult the prototype chain,
    1041         // so we must be sure that not consulting the prototype chain would
    1042         // produce the same value during iteration.
    1043         JSArray* array = jsCast<JSArray*>(iterable);
    1044         RETURN(JSFixedArray::createFromArray(exec, vm, array));
    1045     }
    10461049
    10471050    JSArray* array;
  • branches/safari-603-branch/Source/JavaScriptCore/runtime/JSArray.h

    r211102 r211116  
    150150    JS_EXPORT_PRIVATE void fillArgList(ExecState*, MarkedArgumentBuffer&);
    151151    JS_EXPORT_PRIVATE void copyToArguments(ExecState*, VirtualRegister firstElementDest, unsigned offset, unsigned length);
     152
     153    bool isIteratorProtocolFastAndNonObservable();
    152154
    153155    static Structure* createStructure(VM& vm, JSGlobalObject* globalObject, JSValue prototype, IndexingType indexingType)
  • branches/safari-603-branch/Source/JavaScriptCore/runtime/JSArrayInlines.h

    r209036 r211116  
    9494}
    9595
     96ALWAYS_INLINE bool JSArray::isIteratorProtocolFastAndNonObservable()
     97{
     98    return globalObject()->isArrayIteratorProtocolFastAndNonObservable();
     99}
     100
    96101} // namespace JSC
Note: See TracChangeset for help on using the changeset viewer.