Changeset 211070 in webkit
- Timestamp:
- Jan 23, 2017, 4:15:21 PM (10 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 7 edited
-
JSTests/ChangeLog (modified) (1 diff)
-
JSTests/stress/spread-consults-correct-global-object.js (added)
-
JSTests/stress/spread-correct-global-object-on-exception.js (added)
-
Source/JavaScriptCore/ChangeLog (modified) (1 diff)
-
Source/JavaScriptCore/dfg/DFGOperations.cpp (modified) (4 diffs)
-
Source/JavaScriptCore/jsc.cpp (modified) (3 diffs)
-
Source/JavaScriptCore/runtime/CommonSlowPaths.cpp (modified) (2 diffs)
-
Source/JavaScriptCore/runtime/JSArray.h (modified) (1 diff)
-
Source/JavaScriptCore/runtime/JSArrayInlines.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/JSTests/ChangeLog
r211017 r211070 1 2017-01-23 Saam Barati <sbarati@apple.com> 2 3 https://bugs.webkit.org/show_bug.cgi?id=167247 4 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 5 <rdar://problem/30121809> 6 7 Reviewed by Filip Pizlo. 8 9 * stress/spread-consults-correct-global-object.js: Added. 10 (assert): 11 (spread): 12 * stress/spread-correct-global-object-on-exception.js: Added. 13 (assert): 14 (spread): 15 (const.objectText.let.o.Symbol.iterator): 16 (catch): 17 1 18 2017-01-21 Yusuke Suzuki <utatane.tea@gmail.com> 2 19 -
trunk/Source/JavaScriptCore/ChangeLog
r211069 r211070 1 2017-01-23 Saam Barati <sbarati@apple.com> 2 3 https://bugs.webkit.org/show_bug.cgi?id=167247 4 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 5 <rdar://problem/30121809> 6 7 Reviewed by Filip Pizlo. 8 9 There were two bugs in the different tiers with respect to how 10 spread handled global objects. 11 12 The first was in the LLInt/baseline inside slow_path_spread: 13 14 We consulted the lexical global object instead of the thing we're 15 spreading's global object to determine if the array iterator protocol 16 is unobservable. This is wrong if the incoming array is from a different 17 global object. We must consult the incoming array's global object 18 to determine if it can be spread using the fast path. 19 20 The second was in operationSpreadGeneric in the DFG/FTL: 21 22 We were always using the incoming array's global object, even 23 when going down the slow path. This is wrong because we were 24 fetching the builtin iteration function helper from the incoming 25 array's global object, which meant that if the iterator function 26 were to throw an exception, it could leak objects from a different 27 global object. We should be executing the iterator function with 28 the lexical global object. 29 30 * dfg/DFGOperations.cpp: 31 * jsc.cpp: 32 (GlobalObject::finishCreation): 33 (functionGlobalObjectForObject): 34 * runtime/CommonSlowPaths.cpp: 35 (JSC::SLOW_PATH_DECL): 36 * runtime/JSArray.h: 37 * runtime/JSArrayInlines.h: 38 (JSC::JSArray::isIteratorProtocolFastAndNonObservable): 39 1 40 2017-01-22 Filip Pizlo <fpizlo@apple.com> 2 41 -
trunk/Source/JavaScriptCore/dfg/DFGOperations.cpp
r209638 r211070 48 48 #include "JIT.h" 49 49 #include "JITExceptions.h" 50 #include "JSArrayInlines.h" 50 51 #include "JSCInlines.h" 51 52 #include "JSFixedArray.h" … … 1985 1986 auto throwScope = DECLARE_THROW_SCOPE(vm); 1986 1987 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)) { 1992 1989 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 } 1995 1994 } 1996 1995 … … 1998 1997 // the iteration protocol builtin: https://bugs.webkit.org/show_bug.cgi?id=164520 1999 1998 1999 JSGlobalObject* globalObject = exec->lexicalGlobalObject(); 2000 2000 JSArray* array; 2001 2001 { … … 2023 2023 ASSERT(isJSArray(cell)); 2024 2024 JSArray* array = jsCast<JSArray*>(cell); 2025 ASSERT(array-> globalObject()->isArrayIteratorProtocolFastAndNonObservable());2025 ASSERT(array->isIteratorProtocolFastAndNonObservable()); 2026 2026 2027 2027 return JSFixedArray::createFromArray(exec, vm, array); -
trunk/Source/JavaScriptCore/jsc.cpp
r211018 r211070 1012 1012 static EncodedJSValue JSC_HOST_CALL functionIsRope(ExecState*); 1013 1013 static EncodedJSValue JSC_HOST_CALL functionCallerSourceOrigin(ExecState*); 1014 static EncodedJSValue JSC_HOST_CALL functionGlobalObjectForObject(ExecState*); 1014 1015 1015 1016 struct Script { … … 1235 1236 addFunction(vm, "isRope", functionIsRope, 1); 1236 1237 addFunction(vm, "callerSourceOrigin", functionCallerSourceOrigin, 0); 1238 1239 addFunction(vm, "globalObjectForObject", functionGlobalObjectForObject, 1); 1237 1240 1238 1241 addFunction(vm, "is32BitPlatform", functionIs32BitPlatform, 0); … … 2154 2157 return JSValue::encode(jsNull()); 2155 2158 return JSValue::encode(jsString(state, sourceOrigin.string())); 2159 } 2160 2161 EncodedJSValue 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); 2156 2168 } 2157 2169 -
trunk/Source/JavaScriptCore/runtime/CommonSlowPaths.cpp
r208936 r211070 44 44 #include "IteratorOperations.h" 45 45 #include "JIT.h" 46 #include "JSArrayInlines.h" 46 47 #include "JSCInlines.h" 47 48 #include "JSCJSValue.h" … … 1035 1036 JSValue iterable = OP_C(2).jsValue(); 1036 1037 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 1037 1048 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 would1042 // produce the same value during iteration.1043 JSArray* array = jsCast<JSArray*>(iterable);1044 RETURN(JSFixedArray::createFromArray(exec, vm, array));1045 }1046 1049 1047 1050 JSArray* array; -
trunk/Source/JavaScriptCore/runtime/JSArray.h
r211043 r211070 150 150 JS_EXPORT_PRIVATE void fillArgList(ExecState*, MarkedArgumentBuffer&); 151 151 JS_EXPORT_PRIVATE void copyToArguments(ExecState*, VirtualRegister firstElementDest, unsigned offset, unsigned length); 152 153 bool isIteratorProtocolFastAndNonObservable(); 152 154 153 155 static Structure* createStructure(VM& vm, JSGlobalObject* globalObject, JSValue prototype, IndexingType indexingType) -
trunk/Source/JavaScriptCore/runtime/JSArrayInlines.h
r209036 r211070 94 94 } 95 95 96 ALWAYS_INLINE bool JSArray::isIteratorProtocolFastAndNonObservable() 97 { 98 return globalObject()->isArrayIteratorProtocolFastAndNonObservable(); 99 } 100 96 101 } // namespace JSC
Note:
See TracChangeset
for help on using the changeset viewer.