https://bugs.webkit.org/show_bug.cgi?id=167247
authorsbarati@apple.com <sbarati@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 24 Jan 2017 00:15:21 +0000 (00:15 +0000)
committersbarati@apple.com <sbarati@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 24 Jan 2017 00:15:21 +0000 (00:15 +0000)
commitd752ea12584ff276ff0b00223d5dcd8a27c8ae1d
tree70b7273566dc4fcf1a4d98a04fbb7eecb8ef81d8
parenta476fd6c5853062e6a718e39a9a51112759ae4b5
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):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@211070 268f45cc-cd09-0410-ab3c-d52691b4dbfc
JSTests/ChangeLog
JSTests/stress/spread-consults-correct-global-object.js [new file with mode: 0644]
JSTests/stress/spread-correct-global-object-on-exception.js [new file with mode: 0644]
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/dfg/DFGOperations.cpp
Source/JavaScriptCore/jsc.cpp
Source/JavaScriptCore/runtime/CommonSlowPaths.cpp
Source/JavaScriptCore/runtime/JSArray.h
Source/JavaScriptCore/runtime/JSArrayInlines.h