Ignore:
Timestamp:
Jan 23, 2017, 4:15:21 PM (8 years ago)
Author:
[email protected]
Message:

https://bugs.webkit.org/show_bug.cgi?id=167247
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
<rdar://problem/30121809>

Reviewed by Filip Pizlo.

JSTests:

  • stress/spread-consults-correct-global-object.js: Added.

(assert):
(spread):

  • stress/spread-correct-global-object-on-exception.js: Added.

(assert):
(spread):
(const.objectText.let.o.Symbol.iterator):
(catch):

Source/JavaScriptCore:

There were two bugs in the different tiers with respect to how
spread handled global objects.

The first was in the LLInt/baseline inside slow_path_spread:

We consulted the lexical global object instead of the thing we're
spreading's global object to determine if the array iterator protocol
is unobservable. This is wrong if the incoming array is from a different
global object. We must consult the incoming array's global object
to determine if it can be spread using the fast path.

The second was in operationSpreadGeneric in the DFG/FTL:

We were always using the incoming array's global object, even
when going down the slow path. This is wrong because we were
fetching the builtin iteration function helper from the incoming
array's global object, which meant that if the iterator function
were to throw an exception, it could leak objects from a different
global object. We should be executing the iterator function with
the lexical global object.

  • dfg/DFGOperations.cpp:
  • jsc.cpp:

(GlobalObject::finishCreation):
(functionGlobalObjectForObject):

  • runtime/CommonSlowPaths.cpp:

(JSC::SLOW_PATH_DECL):

  • runtime/JSArray.h:
  • runtime/JSArrayInlines.h:

(JSC::JSArray::isIteratorProtocolFastAndNonObservable):

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/jsc.cpp

    r211018 r211070  
    10121012static EncodedJSValue JSC_HOST_CALL functionIsRope(ExecState*);
    10131013static EncodedJSValue JSC_HOST_CALL functionCallerSourceOrigin(ExecState*);
     1014static EncodedJSValue JSC_HOST_CALL functionGlobalObjectForObject(ExecState*);
    10141015
    10151016struct Script {
     
    12351236        addFunction(vm, "isRope", functionIsRope, 1);
    12361237        addFunction(vm, "callerSourceOrigin", functionCallerSourceOrigin, 0);
     1238
     1239        addFunction(vm, "globalObjectForObject", functionGlobalObjectForObject, 1);
    12371240
    12381241        addFunction(vm, "is32BitPlatform", functionIs32BitPlatform, 0);
     
    21542157        return JSValue::encode(jsNull());
    21552158    return JSValue::encode(jsString(state, sourceOrigin.string()));
     2159}
     2160
     2161EncodedJSValue JSC_HOST_CALL functionGlobalObjectForObject(ExecState* exec)
     2162{
     2163    JSValue value = exec->argument(0);
     2164    RELEASE_ASSERT(value.isObject());
     2165    JSGlobalObject* globalObject = jsCast<JSObject*>(value)->globalObject();
     2166    RELEASE_ASSERT(globalObject);
     2167    return JSValue::encode(globalObject);
    21562168}
    21572169
Note: See TracChangeset for help on using the changeset viewer.