Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
[JSC] Improve resizable TypedArray's slice implementation's spec conf…
…ormance https://bugs.webkit.org/show_bug.cgi?id=248337 rdar://problem/102661384 Reviewed by Ross Kirsling. This patch fixes TypedArray#slice's spec conformance a bit: test length against previously passed value (not updatedLength). We also import new V8 tests more. * JSTests/stress/v8-regress-1376784.js: Added. (test.const.factory.async foo): (test.const.factory): (test): * JSTests/stress/v8-regress-1380398.js: Added. (test): * JSTests/stress/v8-regress-crbug-1359991.js: Added. (MyFloat64Array): * JSTests/stress/v8-regress-crbug-1362487.js: Added. (MyInt8Array): (assertThrows): * JSTests/stress/v8-regress-crbug-1384474-variant2.js: Added. (ta.Symbol.species): (assertThrows): * JSTests/stress/v8-regress-crbug-1384474-variant3.js: Added. (ta.Symbol.species): (assertThrows): * JSTests/stress/v8-regress-crbug-1384474.js: Added. (ta.Symbol.species): (assertThrows): * JSTests/stress/v8-regress-crbug-1392577.js: Added. (start.valueOf): * Source/JavaScriptCore/runtime/JSGenericTypedArrayViewPrototypeFunctions.h: (JSC::speciesConstruct): (JSC::genericTypedArrayViewProtoFuncSlice): (JSC::genericTypedArrayViewProtoFuncSubarray): Canonical link: https://commits.webkit.org/257018@main
- Loading branch information
1 parent
7560d94
commit c8c81173ec65dce5414985944e7f12e04a711308
Showing
9 changed files
with
203 additions
and
19 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 |
---|---|---|
@@ -0,0 +1,36 @@ | ||
//@ requireOptions("--useResizableArrayBuffer=1") | ||
// Copyright 2022 the V8 project authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
// Flags: --allow-natives-syntax --turbofan | ||
|
||
load("./resources/v8-mjsunit.js", "caller relative"); | ||
load("./resources/v8-typedarray-helpers.js", "caller relative"); | ||
|
||
function test() { | ||
let depth = 100; | ||
const arr = []; | ||
const factory = class MyArray extends Uint8Array { | ||
constructor() { | ||
async function foo() { new factory(); } | ||
if(depth-- > 0) { | ||
const x = foo(); | ||
super(arr); | ||
this.__proto__ = x; | ||
const unused1 = super.byteLength; | ||
} else { | ||
super(arr); | ||
} | ||
} | ||
}; | ||
const unused2 = new factory(); | ||
arr.__proto__ = factory; | ||
return arr; | ||
} | ||
|
||
test(); | ||
// %PrepareFunctionForOptimization(test); | ||
test(); | ||
// %OptimizeFunctionOnNextCall(test); | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
//@ requireOptions("--useResizableArrayBuffer=1") | ||
// Copyright 2022 the V8 project authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
// Flags: --allow-natives-syntax --turbofan --harmony-rab-gsab | ||
|
||
load("./resources/v8-mjsunit.js", "caller relative"); | ||
load("./resources/v8-typedarray-helpers.js", "caller relative"); | ||
|
||
function test() { | ||
const ab = new ArrayBuffer(2996, { maxByteLength: 8588995 }); | ||
const dv = new DataView(ab); | ||
const len = dv.byteLength; | ||
return len >= 255; | ||
} | ||
|
||
// %PrepareFunctionForOptimization(test); | ||
assertTrue(test()); | ||
assertTrue(test()); | ||
// %OptimizeFunctionOnNextCall(test); | ||
assertTrue(test()); | ||
// assertOptimized(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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
//@ requireOptions("--useResizableArrayBuffer=1") | ||
// Copyright 2022 the V8 project authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
// Copyright 2022 Apple Inc. All rights reserved. | ||
// Modified since original V8's test had an issue. | ||
|
||
// Flags: --harmony-rab-gsab | ||
|
||
"use strict"; | ||
|
||
load("./resources/v8-mjsunit.js", "caller relative"); | ||
load("./resources/v8-typedarray-helpers.js", "caller relative"); | ||
|
||
const rab = new ArrayBuffer(1744, {"maxByteLength": 4000}); | ||
let callSlice = true; | ||
class MyFloat64Array extends Float64Array { | ||
constructor() { | ||
super(rab); | ||
if (callSlice) { | ||
callSlice = false; // Prevent recursion | ||
super.slice(); | ||
} | ||
} | ||
}; | ||
new MyFloat64Array(); |
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,22 @@ | ||
//@ requireOptions("--useResizableArrayBuffer=1") | ||
// Copyright 2022 the V8 project authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
// Copyright 2022 Apple Inc. All rights reserved. | ||
// Modified since original V8's test had an issue. | ||
|
||
// Flags: --harmony-rab-gsab | ||
|
||
load("./resources/v8-mjsunit.js", "caller relative"); | ||
load("./resources/v8-typedarray-helpers.js", "caller relative"); | ||
|
||
const rab1 = new ArrayBuffer(1000, {'maxByteLength': 4000}); | ||
class MyInt8Array extends Int8Array { | ||
constructor() { | ||
super(rab1); | ||
} | ||
}; | ||
const rab2 = new ArrayBuffer(2000, {'maxByteLength': 4000}); | ||
const ta = new Int8Array(rab2); | ||
ta.constructor = MyInt8Array; | ||
assertThrows(() => { ta.slice(); }, TypeError); |
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,17 @@ | ||
//@ requireOptions("--useResizableArrayBuffer=1") | ||
// Copyright 2022 the V8 project authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
// Flags: --harmony-rab-gsab | ||
|
||
load("./resources/v8-mjsunit.js", "caller relative"); | ||
load("./resources/v8-typedarray-helpers.js", "caller relative"); | ||
|
||
const rab1 = new ArrayBuffer(4, {"maxByteLength": 100}); | ||
const ta = new Int8Array(rab1); | ||
const rab2 = new ArrayBuffer(10, {"maxByteLength": 20}); | ||
const lengthTracking = new Int8Array(rab2); | ||
rab2.resize(0); | ||
ta.constructor = { [Symbol.species]: function() { return lengthTracking; } }; | ||
assertThrows(() => { ta.slice(); }, TypeError); |
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,18 @@ | ||
//@ requireOptions("--useResizableArrayBuffer=1") | ||
// Copyright 2022 the V8 project authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
// Flags: --harmony-rab-gsab | ||
|
||
load("./resources/v8-mjsunit.js", "caller relative"); | ||
load("./resources/v8-typedarray-helpers.js", "caller relative"); | ||
|
||
const rab1 = new ArrayBuffer(4, {"maxByteLength": 100}); | ||
const ta = new Int8Array(rab1); | ||
const rab2 = new ArrayBuffer(10, {"maxByteLength": 20}); | ||
const lengthTracking = new Int8Array(rab2); | ||
rab2.resize(0); | ||
ta.constructor = { [Symbol.species]: function() { return lengthTracking; } }; | ||
assertThrows(() => { ta.filter(() => { return true; }); }, | ||
TypeError); |
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,16 @@ | ||
//@ requireOptions("--useResizableArrayBuffer=1") | ||
// Copyright 2022 the V8 project authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
// Flags: --harmony-rab-gsab | ||
|
||
load("./resources/v8-mjsunit.js", "caller relative"); | ||
load("./resources/v8-typedarray-helpers.js", "caller relative"); | ||
|
||
const ta = new Int8Array(4); | ||
const rab = new ArrayBuffer(10, {"maxByteLength": 20}); | ||
const lengthTracking = new Int8Array(rab); | ||
rab.resize(0); | ||
ta.constructor = { [Symbol.species]: function() { return lengthTracking; } }; | ||
assertThrows(() => { ta.slice(); }, TypeError); |
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,18 @@ | ||
//@ requireOptions("--useResizableArrayBuffer=1") | ||
// Copyright 2022 the V8 project authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
// Flags: --harmony-rab-gsab | ||
|
||
load("./resources/v8-mjsunit.js", "caller relative"); | ||
load("./resources/v8-typedarray-helpers.js", "caller relative"); | ||
|
||
const rab = new ArrayBuffer(50, {"maxByteLength": 100}); | ||
const ta = new Int8Array(rab); | ||
const start = {}; | ||
start.valueOf = function() { | ||
rab.resize(0); | ||
return 5; | ||
} | ||
ta.fill(5, start); |
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