Changeset 211116 in webkit
- Timestamp:
- Jan 24, 2017, 3:29:30 PM (10 years ago)
- Location:
- branches/safari-603-branch
- 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
-
branches/safari-603-branch/JSTests/ChangeLog
r210868 r211116 1 2017-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 1 22 2017-01-18 Matthew Hanson <matthew_hanson@apple.com> 2 23 -
branches/safari-603-branch/Source/JavaScriptCore/ChangeLog
r211115 r211116 1 2017-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 1 44 2017-01-24 Matthew Hanson <matthew_hanson@apple.com> 2 45 -
branches/safari-603-branch/Source/JavaScriptCore/dfg/DFGOperations.cpp
r209638 r211116 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); -
branches/safari-603-branch/Source/JavaScriptCore/jsc.cpp
r210868 r211116 1008 1008 static EncodedJSValue JSC_HOST_CALL functionSetRandomSeed(ExecState*); 1009 1009 static EncodedJSValue JSC_HOST_CALL functionIsRope(ExecState*); 1010 static EncodedJSValue JSC_HOST_CALL functionGlobalObjectForObject(ExecState*); 1010 1011 1011 1012 struct Script { … … 1231 1232 addFunction(vm, "setRandomSeed", functionSetRandomSeed, 1); 1232 1233 addFunction(vm, "isRope", functionIsRope, 1); 1234 1235 addFunction(vm, "globalObjectForObject", functionGlobalObjectForObject, 1); 1233 1236 1234 1237 addFunction(vm, "is32BitPlatform", functionIs32BitPlatform, 0); … … 2105 2108 } 2106 2109 2110 EncodedJSValue 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 2107 2119 EncodedJSValue JSC_HOST_CALL functionReadline(ExecState* exec) 2108 2120 { -
branches/safari-603-branch/Source/JavaScriptCore/runtime/CommonSlowPaths.cpp
r208936 r211116 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; -
branches/safari-603-branch/Source/JavaScriptCore/runtime/JSArray.h
r211102 r211116 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) -
branches/safari-603-branch/Source/JavaScriptCore/runtime/JSArrayInlines.h
r209036 r211116 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.