forked from WebKit/WebKit-http
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Align %TypedArray% behavior with recent spec adjustments
https://bugs.webkit.org/show_bug.cgi?id=218776 Reviewed by Yusuke Suzuki. JSTests: * stress/reflect-set.js: * stress/typedarray-functions-with-neutered.js: * stress/typedarray-includes.js: * stress/typedarray-indexOf.js: * stress/typedarray-join.js: Added. * stress/typedarray-lastIndexOf.js: Update tests. * test262/expectations.yaml: Mark a handful of test cases as temporarily failing. These will disappear in a future test262 update. Source/JavaScriptCore: The recent spec changes for typed arrays with detached buffers had certain ripple effects, namely the following two PRs which will be presented in next week's TC39 meeting. Since no controversy is expected, this patch addresses them now, though test262 adjustments are forthcoming. 1. tc39/ecma262#2210 It is correct that `ta[i] = n` doesn't throw when `ta` has a detached buffer or `i` is otherwise OOB, but by not throwing, Reflect.set(ta, i, n) is obliged to return true. 2. tc39/ecma262#2221 Until now, %TypedArray%.prototype.{includes, indexOf, join, lastIndexOf} lacked a rigorous specification; in particular, each has a parameter that may detach the buffer upon valueOf or toString, and the expected behavior was not made clear. It seems most sensible to do what the corresponding Array methods do upon `array.length = 0`: make use of the cached length but don't access indices, such that indexOf/lastIndexOf return -1 while includes/join act as if the elements were all `undefined`. * runtime/JSGenericTypedArrayViewInlines.h: (JSC::JSGenericTypedArrayView<Adaptor>::put): (JSC::JSGenericTypedArrayView<Adaptor>::defineOwnProperty): (JSC::JSGenericTypedArrayView<Adaptor>::putByIndex): * runtime/JSGenericTypedArrayViewPrototypeFunctions.h: (JSC::genericTypedArrayViewProtoFuncIncludes): (JSC::genericTypedArrayViewProtoFuncIndexOf): (JSC::genericTypedArrayViewProtoFuncJoin): (JSC::genericTypedArrayViewProtoFuncLastIndexOf): git-svn-id: http://svn.webkit.org/repository/webkit/trunk@269670 268f45cc-cd09-0410-ab3c-d52691b4dbfc
- Loading branch information
1 parent
1a7def2
commit 5d29948
Showing
11 changed files
with
132 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,22 @@ | ||
2020-11-10 Ross Kirsling <[email protected]> | ||
|
||
Align %TypedArray% behavior with recent spec adjustments | ||
https://bugs.webkit.org/show_bug.cgi?id=218776 | ||
|
||
Reviewed by Yusuke Suzuki. | ||
|
||
* stress/reflect-set.js: | ||
* stress/typedarray-functions-with-neutered.js: | ||
* stress/typedarray-includes.js: | ||
* stress/typedarray-indexOf.js: | ||
* stress/typedarray-join.js: Added. | ||
* stress/typedarray-lastIndexOf.js: | ||
Update tests. | ||
|
||
* test262/expectations.yaml: | ||
Mark a handful of test cases as temporarily failing. | ||
These will disappear in a future test262 update. | ||
|
||
2020-11-10 Michael Catanzaro <[email protected]> | ||
|
||
stress/intl-datetimeformat-formatrange.js and stress/intl-datetimeformat-formatrange-relevant-extensions.js fail with ICU 65.1 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,16 @@ | ||
load("resources/typedarray-test-helper-functions.js", "caller relative"); | ||
|
||
for (constructor of typedArrays) { | ||
let a = new constructor(10); | ||
a = new constructor(10); | ||
passed = true; | ||
result = a.includes({ valueOf() { passed = false; return 1; } }); | ||
shouldBeTrue("passed"); | ||
shouldBeFalse("result"); | ||
|
||
shouldBeTrue("a.includes(undefined, { valueOf() { transferArrayBuffer(a.buffer); return 0; } })"); | ||
shouldThrow("a.includes(undefined)"); | ||
|
||
a = new constructor(1); | ||
shouldBeFalse("a.includes(null, { valueOf() { transferArrayBuffer(a.buffer); return 0; } })"); | ||
} | ||
finishJSTest(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
const typedArrays = [Int8Array, Uint8Array, Uint8ClampedArray, Int16Array, Uint16Array, Int32Array, Uint32Array, Float32Array, Float64Array]; | ||
|
||
function shouldBe(actual, expected) { | ||
if (actual !== expected) | ||
throw new Error(`expected ${expected} but got ${actual}`); | ||
} | ||
|
||
function shouldThrowTypeError(func) { | ||
let error; | ||
try { | ||
func(); | ||
} catch (e) { | ||
error = e; | ||
} | ||
|
||
if (!(error instanceof TypeError)) | ||
throw new Error('Expected TypeError!'); | ||
} | ||
|
||
function test() { | ||
for (const constructor of typedArrays) { | ||
const ta = new constructor([1,2,3]); | ||
shouldBe(ta.join(), '1,2,3'); | ||
shouldBe(ta.join(','), '1,2,3'); | ||
shouldBe(ta.join('--'), '1--2--3'); | ||
|
||
shouldBe(ta.join({ toString() { transferArrayBuffer(ta.buffer); return ','; } }), ',,'); | ||
shouldThrowTypeError(() => ta.join()); | ||
} | ||
} | ||
|
||
for (let i = 0; i < 1e3; i++) | ||
test(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,35 @@ | ||
2020-11-10 Ross Kirsling <[email protected]> | ||
|
||
Align %TypedArray% behavior with recent spec adjustments | ||
https://bugs.webkit.org/show_bug.cgi?id=218776 | ||
|
||
Reviewed by Yusuke Suzuki. | ||
|
||
The recent spec changes for typed arrays with detached buffers had certain ripple effects, | ||
namely the following two PRs which will be presented in next week's TC39 meeting. | ||
Since no controversy is expected, this patch addresses them now, though test262 adjustments are forthcoming. | ||
|
||
1. https://github.com/tc39/ecma262/pull/2210 | ||
It is correct that `ta[i] = n` doesn't throw when `ta` has a detached buffer or `i` is otherwise OOB, | ||
but by not throwing, Reflect.set(ta, i, n) is obliged to return true. | ||
|
||
2. https://github.com/tc39/ecma262/pull/2221 | ||
Until now, %TypedArray%.prototype.{includes, indexOf, join, lastIndexOf} lacked a rigorous specification; | ||
in particular, each has a parameter that may detach the buffer upon valueOf or toString, and the expected | ||
behavior was not made clear. It seems most sensible to do what the corresponding Array methods do upon | ||
`array.length = 0`: make use of the cached length but don't access indices, such that indexOf/lastIndexOf | ||
return -1 while includes/join act as if the elements were all `undefined`. | ||
|
||
* runtime/JSGenericTypedArrayViewInlines.h: | ||
(JSC::JSGenericTypedArrayView<Adaptor>::put): | ||
(JSC::JSGenericTypedArrayView<Adaptor>::defineOwnProperty): | ||
(JSC::JSGenericTypedArrayView<Adaptor>::putByIndex): | ||
* runtime/JSGenericTypedArrayViewPrototypeFunctions.h: | ||
(JSC::genericTypedArrayViewProtoFuncIncludes): | ||
(JSC::genericTypedArrayViewProtoFuncIndexOf): | ||
(JSC::genericTypedArrayViewProtoFuncJoin): | ||
(JSC::genericTypedArrayViewProtoFuncLastIndexOf): | ||
|
||
2020-11-10 John Wilander <[email protected]> | ||
|
||
PCM: Change from ad-click-attribution to private-click-measurement (in all forms, including .well-known URL) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters