Changeset 245917 in webkit
- Timestamp:
- May 30, 2019, 5:29:49 PM (7 years ago)
- Location:
- branches/safari-607-branch
- Files:
-
- 1 added
- 15 edited
-
JSTests/ChangeLog (modified) (1 diff)
-
JSTests/stress/array-species-config-array-constructor.js (modified) (1 diff)
-
JSTests/stress/put-direct-index-broken-2.js (modified) (1 diff)
-
JSTests/stress/typed-array-canonical-numeric-index-string.js (added)
-
JSTests/stress/typedarray-access-monomorphic-neutered.js (modified) (2 diffs)
-
JSTests/stress/typedarray-access-neutered.js (modified) (1 diff)
-
JSTests/stress/typedarray-getownproperty-not-configurable.js (modified) (1 diff)
-
JSTests/test262/expectations.yaml (modified) (5 diffs)
-
LayoutTests/ChangeLog (modified) (1 diff)
-
LayoutTests/fast/canvas/canvas-ImageData-behaviour-expected.txt (modified) (1 diff)
-
LayoutTests/fast/canvas/canvas-ImageData-behaviour.js (modified) (1 diff)
-
Source/JavaScriptCore/CMakeLists.txt (modified) (1 diff)
-
Source/JavaScriptCore/ChangeLog (modified) (1 diff)
-
Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj (modified) (1 diff)
-
Source/JavaScriptCore/runtime/JSGenericTypedArrayViewInlines.h (modified) (9 diffs)
-
Source/JavaScriptCore/runtime/PropertyName.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/safari-607-branch/JSTests/ChangeLog
r245352 r245917 1 2019-05-30 Kocsen Chung <kocsen_chung@apple.com> 2 3 Cherry-pick r244950. rdar://problem/51265731 4 5 TypedArrays should not store properties that are canonical numeric indices 6 https://bugs.webkit.org/show_bug.cgi?id=197228 7 <rdar://problem/49557381> 8 9 Reviewed by Saam Barati. 10 11 JSTests: 12 13 * stress/array-species-config-array-constructor.js: 14 (test): 15 * stress/put-direct-index-broken-2.js: 16 * stress/typed-array-canonical-numeric-index-string.js: Added. 17 (makeTest.assert): 18 (makeTest): 19 (const.testInvalidIndices.makeTest.set assert): 20 (const.testInvalidIndices.makeTest): 21 (const.makeTestValidIndex.configurable.set assert): 22 (const.makeTestValidIndex.configurable): 23 * stress/typedarray-access-monomorphic-neutered.js: 24 (checkNoException): 25 (testNoException): 26 (testFTLNoException): 27 * stress/typedarray-access-neutered.js: 28 (testNoException): 29 * stress/typedarray-getownproperty-not-configurable.js: 30 (foo): 31 * test262/expectations.yaml: 32 33 Source/JavaScriptCore: 34 35 According to the spec[1]: 36 - TypedArrays should not perform an ordinary GetOwnProperty/SetOwnProperty if the index is a 37 CanonicalNumericIndexString, but invalid according to IntegerIndexedElementGet and similar 38 functions. I.e., there are a few properties that should not be set in a TypedArray, like NaN, 39 Infinity and -0. 40 - On DefineOwnProperty, the out-of-bounds check should be performed before validating the property 41 descriptor. 42 - On GetOwnProperty, the returned descriptor for numeric properties should have writable set to true. 43 44 [1]: https://www.ecma-international.org/ecma-262/9.0/index.html#sec-integer-indexed-exotic-objects-defineownproperty-p-desc 45 46 * CMakeLists.txt: 47 * JavaScriptCore.xcodeproj/project.pbxproj: 48 * runtime/JSGenericTypedArrayViewInlines.h: 49 (JSC::JSGenericTypedArrayView<Adaptor>::getOwnPropertySlot): 50 (JSC::JSGenericTypedArrayView<Adaptor>::put): 51 (JSC::JSGenericTypedArrayView<Adaptor>::defineOwnProperty): 52 (JSC::JSGenericTypedArrayView<Adaptor>::getOwnPropertySlotByIndex): 53 (JSC::JSGenericTypedArrayView<Adaptor>::putByIndex): 54 * runtime/PropertyName.h: 55 (JSC::isCanonicalNumericIndexString): 56 57 LayoutTests: 58 59 * fast/canvas/canvas-ImageData-behaviour-expected.txt: 60 * fast/canvas/canvas-ImageData-behaviour.js: 61 62 63 git-svn-id: https://svn.webkit.org/repository/webkit/trunk@244950 268f45cc-cd09-0410-ab3c-d52691b4dbfc 64 65 2019-05-04 Tadeu Zagallo <tzagallo@apple.com> 66 67 TypedArrays should not store properties that are canonical numeric indices 68 https://bugs.webkit.org/show_bug.cgi?id=197228 69 <rdar://problem/49557381> 70 71 Reviewed by Saam Barati. 72 73 * stress/array-species-config-array-constructor.js: 74 (test): 75 * stress/put-direct-index-broken-2.js: 76 * stress/typed-array-canonical-numeric-index-string.js: Added. 77 (makeTest.assert): 78 (makeTest): 79 (const.testInvalidIndices.makeTest.set assert): 80 (const.testInvalidIndices.makeTest): 81 (const.makeTestValidIndex.configurable.set assert): 82 (const.makeTestValidIndex.configurable): 83 * stress/typedarray-access-monomorphic-neutered.js: 84 (checkNoException): 85 (testNoException): 86 (testFTLNoException): 87 * stress/typedarray-access-neutered.js: 88 (testNoException): 89 * stress/typedarray-getownproperty-not-configurable.js: 90 (foo): 91 * test262/expectations.yaml: 92 1 93 2019-05-14 Kocsen Chung <kocsen_chung@apple.com> 2 94 -
branches/safari-607-branch/JSTests/stress/array-species-config-array-constructor.js
r216279 r245917 33 33 function test() { 34 34 const message = "TypeError: Attempting to configure non-configurable property on a typed array at index: 0"; 35 shouldThrow(() => foo.concat([1]), message);35 foo.concat([1]); 36 36 foo = [1,2,3,4]; 37 37 shouldThrow(() => foo.slice(0), message); -
branches/safari-607-branch/JSTests/stress/put-direct-index-broken-2.js
r232525 r245917 58 58 err = e; 59 59 } 60 assert( err.toString() === "TypeError: Attempting to configure non-configurable property on a typed array at index: 0");60 assert(!err); 61 61 }); 62 62 -
branches/safari-607-branch/JSTests/stress/typedarray-access-monomorphic-neutered.js
r203096 r245917 29 29 test("delete array[0]", array); 30 30 test("Object.getOwnPropertyDescriptor(array, 0)", array); 31 test("Object.defineProperty(array, 0, { value: 1, writable: true, configurable: false, enumerable: true })", array);32 31 test("array[0] = 1", array); 33 32 test("array[i] = 1", array); … … 49 48 testFTL("delete array[0]", array, failArray); 50 49 testFTL("Object.getOwnPropertyDescriptor(array, 0)", array, failArray); 51 testFTL("Object.defineProperty(array, 0, { value: 1, writable: true, configurable: false, enumerable: true })", array, failArray);52 50 testFTL("array[0] = 1", array, failArray); 53 51 testFTL("array[i] = 1", array, failArray); 54 52 } 53 54 55 function checkNoException(array, thunk, count) { 56 thunk(array, count); 57 } 58 noInline(check); 59 60 function testNoException(thunk, array) { 61 let fn = Function("array", "i", thunk); 62 noInline(fn); 63 for (let i = 0; i < 10000; i++) 64 checkNoException(array, fn, i); 65 } 66 67 for (let constructor of typedArrays) { 68 let array = new constructor(10); 69 transferArrayBuffer(array.buffer); 70 testNoException("Object.defineProperty(array, 0, { value: 1, writable: true, configurable: false, enumerable: true })", array); 71 } 72 73 function testFTLNoException(thunk, array, failArray) { 74 let fn = Function("array", "i", thunk); 75 noInline(fn); 76 for (let i = 0; i < 10000; i++) 77 fn(array, i) 78 checkNoException(failArray, fn, 10000); 79 } 80 for (let constructor of typedArrays) { 81 let array = new constructor(10); 82 let failArray = new constructor(10); 83 transferArrayBuffer(failArray.buffer); 84 testFTLNoException("Object.defineProperty(array, 0, { value: 1, writable: true, configurable: false, enumerable: true })", array, failArray); 85 } -
branches/safari-607-branch/JSTests/stress/typedarray-access-neutered.js
r203096 r245917 26 26 test((array) => delete array[0], i); 27 27 test((array) => Object.getOwnPropertyDescriptor(array, 0), i); 28 test((array) => Object.defineProperty(array, 0, { value: 1, writable: true, configurable: false, enumerable: true }), i)29 28 test((array) => array[0] = 1, i); 30 29 } 30 31 function checkNoException(thunk, count) { 32 let array = new constructor(10); 33 transferArrayBuffer(array.buffer); 34 thunk(array); 35 } 36 37 function testNoException(thunk, count) { 38 for (constructor of typedArrays) 39 checkNoException(thunk, count); 40 } 41 42 for (let i = 0; i < 10000; i++) { 43 testNoException((array) => Object.defineProperty(array, 0, { value: 1, writable: true, configurable: false, enumerable: true }), i) 44 } -
branches/safari-607-branch/JSTests/stress/typedarray-getownproperty-not-configurable.js
r220377 r245917 11 11 let b = Object.getOwnPropertyDescriptor(a, 0); 12 12 assert(b.value === 0); 13 assert(b.writable === false);13 assert(b.writable === true); 14 14 assert(b.enumerable === true); 15 15 assert(b.configurable === false); -
branches/safari-607-branch/JSTests/test262/expectations.yaml
r239605 r245917 1416 1416 default: 'Test262Error: Expected a Test262Error but got a TypeError (Testing with Float64Array.)' 1417 1417 strict mode: 'Test262Error: Expected a Test262Error but got a TypeError (Testing with Float64Array.)' 1418 test/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/detached-buffer-realm.js: 1419 default: 'Test262Error: Expected a TypeError to be thrown but no exception was thrown at all (Testing with Float64Array.)' 1420 strict mode: 'Test262Error: Expected a TypeError to be thrown but no exception was thrown at all (Testing with Float64Array.)' 1418 1421 test/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/detached-buffer.js: 1419 default: 'Test262Error: Return false before Detached Buffer check when value is a negative number Expected SameValue(«true», «false») to be true (Testing with Float64Array.)' 1420 strict mode: 'Test262Error: Return false before Detached Buffer check when value is a negative number Expected SameValue(«true», «false») to be true (Testing with Float64Array.)' 1421 test/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/key-is-lower-than-zero.js: 1422 default: 'Test262Error: -1 Expected SameValue(«true», «false») to be true (Testing with Float64Array.)' 1423 strict mode: 'Test262Error: -1 Expected SameValue(«true», «false») to be true (Testing with Float64Array.)' 1424 test/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/key-is-minus-zero.js: 1425 default: 'Test262Error: defineProperty returns false Expected SameValue(«true», «false») to be true (Testing with Float64Array.)' 1426 strict mode: 'Test262Error: defineProperty returns false Expected SameValue(«true», «false») to be true (Testing with Float64Array.)' 1427 test/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/key-is-not-integer.js: 1428 default: 'Test262Error: 0.1 Expected SameValue(«true», «false») to be true (Testing with Float64Array.)' 1429 strict mode: 'Test262Error: 0.1 Expected SameValue(«true», «false») to be true (Testing with Float64Array.)' 1430 test/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/key-is-numericindex.js: 1431 default: 'Test262Error: property is writable Expected SameValue(«false», «true») to be true (Testing with Float64Array.)' 1432 strict mode: 'Test262Error: property is writable Expected SameValue(«false», «true») to be true (Testing with Float64Array.)' 1422 default: 'Test262Error: Throws TypeError on valid numeric index if instance has a detached buffer Expected a TypeError to be thrown but no exception was thrown at all (Testing with Float64Array.)' 1423 strict mode: 'Test262Error: Throws TypeError on valid numeric index if instance has a detached buffer Expected a TypeError to be thrown but no exception was thrown at all (Testing with Float64Array.)' 1433 1424 test/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/set-value.js: 1434 1425 default: 'Test262Error: set value for sample[0] returns true Expected SameValue(«false», «true») to be true (Testing with Float64Array.)' … … 1437 1428 default: 'Test262Error: detaching a ArrayBuffer during defining an element of a typed array viewing it should throw Expected a TypeError to be thrown but no exception was thrown at all (Testing with Float64Array.)' 1438 1429 strict mode: 'Test262Error: detaching a ArrayBuffer during defining an element of a typed array viewing it should throw Expected a TypeError to be thrown but no exception was thrown at all (Testing with Float64Array.)' 1439 test/built-ins/TypedArrayConstructors/internals/Get/detached-buffer.js:1440 default: 'Test262Error: detach buffer runs before checking for 1.1 Expected a TypeError to be thrown but no exception was thrown at all (Testing with Float64Array.)'1441 strict mode: 'Test262Error: detach buffer runs before checking for 1.1 Expected a TypeError to be thrown but no exception was thrown at all (Testing with Float64Array.)'1442 test/built-ins/TypedArrayConstructors/internals/Get/infinity-detached-buffer.js:1443 default: 'Test262Error: Expected a TypeError to be thrown but no exception was thrown at all (Testing with Float64Array.)'1444 strict mode: 'Test262Error: Expected a TypeError to be thrown but no exception was thrown at all (Testing with Float64Array.)'1445 1430 test/built-ins/TypedArrayConstructors/internals/Get/key-is-not-integer.js: 1446 1431 default: 'Test262Error: OrdinaryGet was called! Ref: 9.1.8.1 3.c (Testing with Float64Array.)' … … 1455 1440 default: 'Test262Error: Expected a TypeError to be thrown but no exception was thrown at all (Testing with Float64Array.)' 1456 1441 strict mode: 'Test262Error: Expected a TypeError to be thrown but no exception was thrown at all (Testing with Float64Array.)' 1457 test/built-ins/TypedArrayConstructors/internals/GetOwnProperty/index-prop-desc.js:1458 default: 'Test262Error: index descriptor is writable [0] Expected SameValue(«false», «true») to be true (Testing with Float64Array.)'1459 strict mode: 'Test262Error: index descriptor is writable [0] Expected SameValue(«false», «true») to be true (Testing with Float64Array.)'1460 1442 test/built-ins/TypedArrayConstructors/internals/HasProperty/abrupt-from-ordinary-has-parent-hasproperty.js: 1461 1443 default: 'Test262Error: (Testing with Float64Array.)' … … 1467 1449 default: 'Test262Error: 0 Expected a TypeError to be thrown but no exception was thrown at all (Testing with Float64Array.)' 1468 1450 strict mode: 'Test262Error: 0 Expected a TypeError to be thrown but no exception was thrown at all (Testing with Float64Array.)' 1469 test/built-ins/TypedArrayConstructors/internals/HasProperty/infinity-with-detached-buffer.js:1470 default: 'Test262Error: Expected a TypeError to be thrown but no exception was thrown at all (Testing with Float64Array.)'1471 1451 test/built-ins/TypedArrayConstructors/internals/HasProperty/inherited-property.js: 1472 1452 default: 'Test262Error: 42 Expected SameValue(«true», «false») to be true (Testing with Float64Array.)' … … 1484 1464 default: 'Test262Error: 1.1 Expected SameValue(«true», «false») to be true (Testing with Float64Array.)' 1485 1465 strict mode: 'Test262Error: 1.1 Expected SameValue(«true», «false») to be true (Testing with Float64Array.)' 1486 test/built-ins/TypedArrayConstructors/internals/Set/detached-buffer.js:1487 default: 'Test262Error: detach buffer runs before checking for 1.1 Expected a TypeError to be thrown but no exception was thrown at all (Testing with Float64Array.)'1488 strict mode: 'Test262Error: detach buffer runs before checking for 1.1 Expected a TypeError to be thrown but no exception was thrown at all (Testing with Float64Array.)'1489 test/built-ins/TypedArrayConstructors/internals/Set/key-is-minus-zero.js:1490 default: 'Test262Error: -0 Expected SameValue(«true», «false») to be true (Testing with Float64Array.)'1491 strict mode: 'Test262Error: -0 Expected SameValue(«true», «false») to be true (Testing with Float64Array.)'1492 test/built-ins/TypedArrayConstructors/internals/Set/key-is-not-integer.js:1493 default: 'Test262Error: 1.1 Expected SameValue(«true», «false») to be true (Testing with Float64Array.)'1494 strict mode: 'Test262Error: 1.1 Expected SameValue(«true», «false») to be true (Testing with Float64Array.)'1495 test/built-ins/TypedArrayConstructors/internals/Set/key-is-out-of-bounds.js:1496 default: 'Test262Error: -1 Expected SameValue(«true», «false») to be true (Testing with Float64Array.)'1497 strict mode: 'Test262Error: -1 Expected SameValue(«true», «false») to be true (Testing with Float64Array.)'1498 1466 test/built-ins/TypedArrayConstructors/internals/Set/tonumber-value-throws.js: 1499 1467 default: 'Test262Error: ToNumber runs before ToInteger(index) Expected a Test262Error to be thrown but no exception was thrown at all (Testing with Float64Array.)' -
branches/safari-607-branch/LayoutTests/ChangeLog
r245916 r245917 1 2019-05-30 Kocsen Chung <kocsen_chung@apple.com> 2 3 Cherry-pick r244950. rdar://problem/51265731 4 5 TypedArrays should not store properties that are canonical numeric indices 6 https://bugs.webkit.org/show_bug.cgi?id=197228 7 <rdar://problem/49557381> 8 9 Reviewed by Saam Barati. 10 11 JSTests: 12 13 * stress/array-species-config-array-constructor.js: 14 (test): 15 * stress/put-direct-index-broken-2.js: 16 * stress/typed-array-canonical-numeric-index-string.js: Added. 17 (makeTest.assert): 18 (makeTest): 19 (const.testInvalidIndices.makeTest.set assert): 20 (const.testInvalidIndices.makeTest): 21 (const.makeTestValidIndex.configurable.set assert): 22 (const.makeTestValidIndex.configurable): 23 * stress/typedarray-access-monomorphic-neutered.js: 24 (checkNoException): 25 (testNoException): 26 (testFTLNoException): 27 * stress/typedarray-access-neutered.js: 28 (testNoException): 29 * stress/typedarray-getownproperty-not-configurable.js: 30 (foo): 31 * test262/expectations.yaml: 32 33 Source/JavaScriptCore: 34 35 According to the spec[1]: 36 - TypedArrays should not perform an ordinary GetOwnProperty/SetOwnProperty if the index is a 37 CanonicalNumericIndexString, but invalid according to IntegerIndexedElementGet and similar 38 functions. I.e., there are a few properties that should not be set in a TypedArray, like NaN, 39 Infinity and -0. 40 - On DefineOwnProperty, the out-of-bounds check should be performed before validating the property 41 descriptor. 42 - On GetOwnProperty, the returned descriptor for numeric properties should have writable set to true. 43 44 [1]: https://www.ecma-international.org/ecma-262/9.0/index.html#sec-integer-indexed-exotic-objects-defineownproperty-p-desc 45 46 * CMakeLists.txt: 47 * JavaScriptCore.xcodeproj/project.pbxproj: 48 * runtime/JSGenericTypedArrayViewInlines.h: 49 (JSC::JSGenericTypedArrayView<Adaptor>::getOwnPropertySlot): 50 (JSC::JSGenericTypedArrayView<Adaptor>::put): 51 (JSC::JSGenericTypedArrayView<Adaptor>::defineOwnProperty): 52 (JSC::JSGenericTypedArrayView<Adaptor>::getOwnPropertySlotByIndex): 53 (JSC::JSGenericTypedArrayView<Adaptor>::putByIndex): 54 * runtime/PropertyName.h: 55 (JSC::isCanonicalNumericIndexString): 56 57 LayoutTests: 58 59 * fast/canvas/canvas-ImageData-behaviour-expected.txt: 60 * fast/canvas/canvas-ImageData-behaviour.js: 61 62 63 git-svn-id: https://svn.webkit.org/repository/webkit/trunk@244950 268f45cc-cd09-0410-ab3c-d52691b4dbfc 64 65 2019-05-04 Tadeu Zagallo <tzagallo@apple.com> 66 67 TypedArrays should not store properties that are canonical numeric indices 68 https://bugs.webkit.org/show_bug.cgi?id=197228 69 <rdar://problem/49557381> 70 71 Reviewed by Saam Barati. 72 73 * fast/canvas/canvas-ImageData-behaviour-expected.txt: 74 * fast/canvas/canvas-ImageData-behaviour.js: 75 1 76 2019-05-30 Kocsen Chung <kocsen_chung@apple.com> 2 77 -
branches/safari-607-branch/LayoutTests/fast/canvas/canvas-ImageData-behaviour-expected.txt
r126023 r245917 44 44 PASS imageData.data[0] = undefined, imageData.data[0] is 0 45 45 PASS imageData.data['foo']='garbage',imageData.data['foo'] is 'garbage' 46 PASS imageData.data[-1]='garbage',imageData.data[-1] is 'garbage'46 PASS imageData.data[-1]='garbage',imageData.data[-1] is undefined 47 47 PASS imageData.data[17]='garbage',imageData.data[17] is undefined 48 48 PASS successfullyParsed is true -
branches/safari-607-branch/LayoutTests/fast/canvas/canvas-ImageData-behaviour.js
r126023 r245917 22 22 23 23 shouldBe("imageData.data['foo']='garbage',imageData.data['foo']", "'garbage'"); 24 shouldBe("imageData.data[-1]='garbage',imageData.data[-1]", " 'garbage'");24 shouldBe("imageData.data[-1]='garbage',imageData.data[-1]", "undefined"); 25 25 shouldBe("imageData.data[17]='garbage',imageData.data[17]", "undefined"); -
branches/safari-607-branch/Source/JavaScriptCore/CMakeLists.txt
r240375 r245917 832 832 runtime/JSGlobalLexicalEnvironment.h 833 833 runtime/JSGlobalObject.h 834 runtime/JSGlobalObjectFunctions.h 834 835 runtime/JSGlobalObjectInlines.h 835 836 runtime/JSInternalPromise.h -
branches/safari-607-branch/Source/JavaScriptCore/ChangeLog
r245352 r245917 1 2019-05-30 Kocsen Chung <kocsen_chung@apple.com> 2 3 Cherry-pick r244950. rdar://problem/51265731 4 5 TypedArrays should not store properties that are canonical numeric indices 6 https://bugs.webkit.org/show_bug.cgi?id=197228 7 <rdar://problem/49557381> 8 9 Reviewed by Saam Barati. 10 11 JSTests: 12 13 * stress/array-species-config-array-constructor.js: 14 (test): 15 * stress/put-direct-index-broken-2.js: 16 * stress/typed-array-canonical-numeric-index-string.js: Added. 17 (makeTest.assert): 18 (makeTest): 19 (const.testInvalidIndices.makeTest.set assert): 20 (const.testInvalidIndices.makeTest): 21 (const.makeTestValidIndex.configurable.set assert): 22 (const.makeTestValidIndex.configurable): 23 * stress/typedarray-access-monomorphic-neutered.js: 24 (checkNoException): 25 (testNoException): 26 (testFTLNoException): 27 * stress/typedarray-access-neutered.js: 28 (testNoException): 29 * stress/typedarray-getownproperty-not-configurable.js: 30 (foo): 31 * test262/expectations.yaml: 32 33 Source/JavaScriptCore: 34 35 According to the spec[1]: 36 - TypedArrays should not perform an ordinary GetOwnProperty/SetOwnProperty if the index is a 37 CanonicalNumericIndexString, but invalid according to IntegerIndexedElementGet and similar 38 functions. I.e., there are a few properties that should not be set in a TypedArray, like NaN, 39 Infinity and -0. 40 - On DefineOwnProperty, the out-of-bounds check should be performed before validating the property 41 descriptor. 42 - On GetOwnProperty, the returned descriptor for numeric properties should have writable set to true. 43 44 [1]: https://www.ecma-international.org/ecma-262/9.0/index.html#sec-integer-indexed-exotic-objects-defineownproperty-p-desc 45 46 * CMakeLists.txt: 47 * JavaScriptCore.xcodeproj/project.pbxproj: 48 * runtime/JSGenericTypedArrayViewInlines.h: 49 (JSC::JSGenericTypedArrayView<Adaptor>::getOwnPropertySlot): 50 (JSC::JSGenericTypedArrayView<Adaptor>::put): 51 (JSC::JSGenericTypedArrayView<Adaptor>::defineOwnProperty): 52 (JSC::JSGenericTypedArrayView<Adaptor>::getOwnPropertySlotByIndex): 53 (JSC::JSGenericTypedArrayView<Adaptor>::putByIndex): 54 * runtime/PropertyName.h: 55 (JSC::isCanonicalNumericIndexString): 56 57 LayoutTests: 58 59 * fast/canvas/canvas-ImageData-behaviour-expected.txt: 60 * fast/canvas/canvas-ImageData-behaviour.js: 61 62 63 git-svn-id: https://svn.webkit.org/repository/webkit/trunk@244950 268f45cc-cd09-0410-ab3c-d52691b4dbfc 64 65 2019-05-04 Tadeu Zagallo <tzagallo@apple.com> 66 67 TypedArrays should not store properties that are canonical numeric indices 68 https://bugs.webkit.org/show_bug.cgi?id=197228 69 <rdar://problem/49557381> 70 71 Reviewed by Saam Barati. 72 73 According to the spec[1]: 74 - TypedArrays should not perform an ordinary GetOwnProperty/SetOwnProperty if the index is a 75 CanonicalNumericIndexString, but invalid according to IntegerIndexedElementGet and similar 76 functions. I.e., there are a few properties that should not be set in a TypedArray, like NaN, 77 Infinity and -0. 78 - On DefineOwnProperty, the out-of-bounds check should be performed before validating the property 79 descriptor. 80 - On GetOwnProperty, the returned descriptor for numeric properties should have writable set to true. 81 82 [1]: https://www.ecma-international.org/ecma-262/9.0/index.html#sec-integer-indexed-exotic-objects-defineownproperty-p-desc 83 84 * CMakeLists.txt: 85 * JavaScriptCore.xcodeproj/project.pbxproj: 86 * runtime/JSGenericTypedArrayViewInlines.h: 87 (JSC::JSGenericTypedArrayView<Adaptor>::getOwnPropertySlot): 88 (JSC::JSGenericTypedArrayView<Adaptor>::put): 89 (JSC::JSGenericTypedArrayView<Adaptor>::defineOwnProperty): 90 (JSC::JSGenericTypedArrayView<Adaptor>::getOwnPropertySlotByIndex): 91 (JSC::JSGenericTypedArrayView<Adaptor>::putByIndex): 92 * runtime/PropertyName.h: 93 (JSC::isCanonicalNumericIndexString): 94 1 95 2019-05-14 Kocsen Chung <kocsen_chung@apple.com> 2 96 -
branches/safari-607-branch/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj
r244254 r245917 1635 1635 BC3046070E1F497F003232CF /* Error.h in Headers */ = {isa = PBXBuildFile; fileRef = BC3046060E1F497F003232CF /* Error.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1636 1636 BC6AAAE50E1F426500AD87D8 /* ClassInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = BC6AAAE40E1F426500AD87D8 /* ClassInfo.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1637 BC756FC90E2031B200DE7D12 /* JSGlobalObjectFunctions.h in Headers */ = {isa = PBXBuildFile; fileRef = BC756FC70E2031B200DE7D12 /* JSGlobalObjectFunctions.h */; };1637 BC756FC90E2031B200DE7D12 /* JSGlobalObjectFunctions.h in Headers */ = {isa = PBXBuildFile; fileRef = BC756FC70E2031B200DE7D12 /* JSGlobalObjectFunctions.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1638 1638 BC87CDB910712AD4000614CF /* JSONObject.lut.h in Headers */ = {isa = PBXBuildFile; fileRef = BC87CDB810712ACA000614CF /* JSONObject.lut.h */; }; 1639 1639 BC9041480EB9250900FE26FA /* StructureTransitionTable.h in Headers */ = {isa = PBXBuildFile; fileRef = BC9041470EB9250900FE26FA /* StructureTransitionTable.h */; settings = {ATTRIBUTES = (Private, ); }; }; -
branches/safari-607-branch/Source/JavaScriptCore/runtime/JSGenericTypedArrayViewInlines.h
r239427 r245917 1 1 /* 2 * Copyright (C) 2013-201 8Apple Inc. All rights reserved.2 * Copyright (C) 2013-2019 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 352 352 353 353 if (thisObject->canGetIndexQuickly(index.value())) { 354 slot.setValue(thisObject, PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly, thisObject->getIndexQuickly(index.value()));354 slot.setValue(thisObject, static_cast<unsigned>(PropertyAttribute::DontDelete), thisObject->getIndexQuickly(index.value())); 355 355 return true; 356 356 } 357 357 358 slot.setValue(thisObject, PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly, jsUndefined()); 359 return false; 360 } 361 358 return false; 359 } 360 361 if (isCanonicalNumericIndexString(propertyName)) { 362 if (thisObject->isNeutered()) { 363 slot.setCustom(thisObject, static_cast<unsigned>(PropertyAttribute::None), throwNeuteredTypedArrayTypeError); 364 return true; 365 } 366 367 return false; 368 } 369 362 370 return Base::getOwnPropertySlot(thisObject, exec, propertyName, slot); 363 371 } … … 368 376 PutPropertySlot& slot) 369 377 { 378 VM& vm = exec->vm(); 379 auto scope = DECLARE_THROW_SCOPE(vm); 380 370 381 JSGenericTypedArrayView* thisObject = jsCast<JSGenericTypedArrayView*>(cell); 371 382 … … 374 385 // 9.4.5.5-2-b-i Return ? IntegerIndexedElementSet(O, numericIndex, V). 375 386 if (Optional<uint32_t> index = parseIndex(propertyName)) 376 return putByIndex(thisObject, exec, index.value(), value, slot.isStrictMode()); 377 378 return Base::put(thisObject, exec, propertyName, value, slot); 387 RELEASE_AND_RETURN(scope, putByIndex(thisObject, exec, index.value(), value, slot.isStrictMode())); 388 389 if (isCanonicalNumericIndexString(propertyName)) { 390 if (thisObject->isNeutered()) 391 throwTypeError(exec, scope, typedArrayBufferHasBeenDetachedErrorMessage); 392 return false; 393 } 394 395 RELEASE_AND_RETURN(scope, Base::put(thisObject, exec, propertyName, value, slot)); 379 396 } 380 397 … … 395 412 }; 396 413 414 if (index.value() >= thisObject->m_length) 415 return false; 416 397 417 if (descriptor.isAccessorDescriptor()) 398 418 return throwTypeErrorIfNeeded("Attempting to store accessor property on a typed array at index: "); … … 404 424 return throwTypeErrorIfNeeded("Attempting to store non-enumerable or non-writable property on a typed array at index: "); 405 425 406 if (descriptor.value()) { 407 PutPropertySlot unused(JSValue(thisObject), shouldThrow); 408 RELEASE_AND_RETURN(scope, thisObject->put(thisObject, exec, propertyName, descriptor.value(), unused)); 409 } 410 return true; 411 } 412 426 if (descriptor.value()) 427 RELEASE_AND_RETURN(scope, thisObject->putByIndex(thisObject, exec, index.value(), descriptor.value(), shouldThrow)); 428 429 return true; 430 } 431 432 if (isCanonicalNumericIndexString(propertyName)) 433 return false; 434 413 435 RELEASE_AND_RETURN(scope, Base::defineOwnProperty(thisObject, exec, propertyName, descriptor, shouldThrow)); 414 436 } … … 433 455 template<typename Adaptor> 434 456 bool JSGenericTypedArrayView<Adaptor>::getOwnPropertySlotByIndex( 435 JSObject* object, ExecState* exec, unsigned propertyName, PropertySlot& slot)457 JSObject* object, ExecState*, unsigned propertyName, PropertySlot& slot) 436 458 { 437 459 JSGenericTypedArrayView* thisObject = jsCast<JSGenericTypedArrayView*>(object); … … 442 464 } 443 465 444 if (propertyName > MAX_ARRAY_INDEX) {445 return thisObject->methodTable(exec->vm())->getOwnPropertySlot(446 thisObject, exec, Identifier::from(exec, propertyName), slot);447 }448 449 466 if (!thisObject->canGetIndexQuickly(propertyName)) 450 467 return false; … … 456 473 template<typename Adaptor> 457 474 bool JSGenericTypedArrayView<Adaptor>::putByIndex( 458 JSCell* cell, ExecState* exec, unsigned propertyName, JSValue value, bool shouldThrow)475 JSCell* cell, ExecState* exec, unsigned propertyName, JSValue value, bool) 459 476 { 460 477 JSGenericTypedArrayView* thisObject = jsCast<JSGenericTypedArrayView*>(cell); 461 462 if (propertyName > MAX_ARRAY_INDEX) {463 PutPropertySlot slot(JSValue(thisObject), shouldThrow);464 return thisObject->methodTable(exec->vm())->put(thisObject, exec, Identifier::from(exec, propertyName), value, slot);465 }466 467 478 return thisObject->setIndex(exec, propertyName, value); 468 479 } -
branches/safari-607-branch/Source/JavaScriptCore/runtime/PropertyName.h
r239427 r245917 27 27 28 28 #include "Identifier.h" 29 #include "JSGlobalObjectFunctions.h" 29 30 #include "PrivateName.h" 30 31 #include <wtf/Optional.h> 32 #include <wtf/dtoa.h> 31 33 32 34 namespace JSC { … … 131 133 } 132 134 135 // https://www.ecma-international.org/ecma-262/9.0/index.html#sec-canonicalnumericindexstring 136 ALWAYS_INLINE bool isCanonicalNumericIndexString(const PropertyName& propertyName) 137 { 138 StringImpl* property = propertyName.uid(); 139 if (!property) 140 return false; 141 if (property->isSymbol()) 142 return false; 143 if (equal(property, "-0")) 144 return true; 145 double index = jsToNumber(property); 146 NumberToStringBuffer buffer; 147 const char* indexString = WTF::numberToString(index, buffer); 148 if (!equal(property, indexString)) 149 return false; 150 return true; 151 } 152 133 153 } // namespace JSC
Note:
See TracChangeset
for help on using the changeset viewer.