Skip to content

Commit

Permalink
Add Options::allowDoubleShape() for testing.
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=247548
<rdar://problem/102013094>

Reviewed by Yusuke Suzuki.

1. Added Options::allowDoubleShape() which forces contiguous arrays to be used instead
   of double arrays.  Also added lots of ASSERTs to confirm that Options::allowDoubleShape()
   is true when double shaped arrays are in use.
2. Added $vm.exit() to enable exiting early.  This is needed to allow tests to exit early
   without failing if they require JIT but JIT is disabled.
3. Added $vm.allowDoubleShape() to check the state of Options::allowDoubleShape().  This
   is needed for tests that assert the shape of arrays.
4. Fixed up JSC stress tests to handle the case of running with --allowDoubleShape=false.
5. Fixed up JSC stress tests to handle the case of running without the JIT since
   --allowDoubleShape=false also disables the JIT for now.
6. Added a lockdown configuration for JSC stress tests.

* JSTests/microbenchmarks/bit-test-constant.js:
* JSTests/microbenchmarks/memcpy-typed-loop-large.js:
* JSTests/stress/arith-abs-on-various-types.js:
* JSTests/stress/arith-abs-to-arith-negate-range-optimizaton.js:
* JSTests/stress/arith-acos-on-various-types.js:
* JSTests/stress/arith-acosh-on-various-types.js:
* JSTests/stress/arith-asin-on-various-types.js:
* JSTests/stress/arith-asinh-on-various-types.js:
* JSTests/stress/arith-atan-on-various-types.js:
* JSTests/stress/arith-atanh-on-various-types.js:
* JSTests/stress/arith-cbrt-on-various-types.js:
* JSTests/stress/arith-ceil-on-various-types.js:
* JSTests/stress/arith-clz32-on-various-types.js:
* JSTests/stress/arith-cos-on-various-types.js:
* JSTests/stress/arith-cosh-on-various-types.js:
* JSTests/stress/arith-expm1-on-various-types.js:
* JSTests/stress/arith-floor-on-various-types.js:
* JSTests/stress/arith-fround-on-various-types.js:
* JSTests/stress/arith-log10-on-various-types.js:
* JSTests/stress/arith-log2-on-various-types.js:
* JSTests/stress/arith-negate-on-various-types.js:
* JSTests/stress/arith-round-on-various-types.js:
* JSTests/stress/arith-sin-on-various-types.js:
* JSTests/stress/arith-sinh-on-various-types.js:
* JSTests/stress/arith-sqrt-on-various-types.js:
* JSTests/stress/arith-tan-on-various-types.js:
* JSTests/stress/arith-tanh-on-various-types.js:
* JSTests/stress/arith-trunc-on-various-types.js:
* JSTests/stress/array-slice-cow.js:
(testDouble):
* JSTests/stress/arrayprofile-should-not-convert-get-by-val-cow.js:
(withArrayArgDouble):
(withArrayLiteralDouble):
* JSTests/stress/bit-op-with-object-returning-int32.js:
* JSTests/stress/bitwise-not-fixup-rules.js:
* JSTests/stress/compare-strict-eq-on-various-types.js:
* JSTests/stress/incorrect-put-could-generate-invalid-ic-but-still-not-causing-bad-behavior-bad-transition-debug.js:
* JSTests/stress/int8-repeat-in-then-out-of-bounds.js:
* JSTests/stress/regress-189028.js:
* Source/JavaScriptCore/bytecode/AccessCase.cpp:
(JSC::AccessCase::generateWithGuard):
* Source/JavaScriptCore/bytecode/ArrayProfile.h:
(JSC::shouldUseDouble):
* Source/JavaScriptCore/bytecode/Repatch.cpp:
(JSC::tryCacheArrayGetByVal):
(JSC::tryCacheArrayPutByVal):
* Source/JavaScriptCore/dfg/DFGArrayMode.cpp:
(JSC::DFG::toIndexingShape):
* Source/JavaScriptCore/dfg/DFGOperations.cpp:
(JSC::DFG::JSC_DEFINE_JIT_OPERATION):
* Source/JavaScriptCore/runtime/IndexingType.h:
(JSC::indexingTypeForValue):
* Source/JavaScriptCore/runtime/JSArrayInlines.h:
(JSC::JSArray::pushInline):
* Source/JavaScriptCore/runtime/JSGlobalObject.cpp:
(JSC::JSGlobalObject::init):
* Source/JavaScriptCore/runtime/JSImmutableButterfly.h:
(JSC::JSImmutableButterfly::createFromArray):
* Source/JavaScriptCore/runtime/JSObject.cpp:
(JSC::JSObject::convertUndecidedToDouble):
(JSC::JSObject::convertUndecidedForValue):
(JSC::JSObject::createInitialForValueAndSet):
(JSC::JSObject::convertInt32ForValue):
(JSC::JSObject::tryMakeWritableDoubleSlow):
(JSC::JSObject::putByIndexBeyondVectorLengthWithoutAttributes):
(JSC::JSObject::putByIndexBeyondVectorLength):
(JSC::JSObject::putDirectIndexSlowOrBeyondVectorLength):
(JSC::JSObject::countElements):
* Source/JavaScriptCore/runtime/Options.cpp:
(JSC::Options::recomputeDependentOptions):
* Source/JavaScriptCore/runtime/OptionsList.h:
* Source/JavaScriptCore/runtime/StructureTransitionTable.h:
(JSC::newIndexingType):
* Source/JavaScriptCore/runtime/VM.cpp:
(JSC::VM::VM):
* Source/JavaScriptCore/tools/JSDollarVM.cpp:
(JSC::JSC_DEFINE_HOST_FUNCTION):
(JSC::JSDollarVM::finishCreation):
* Source/WebCore/bindings/js/JSDOMConvertSequences.h:
(WebCore::Detail::NumericSequenceConverter::convertArray):
* Tools/Scripts/run-jsc-stress-tests:

Canonical link: https://commits.webkit.org/256537@main
  • Loading branch information
Mark Lam committed Nov 10, 2022
1 parent fa2a14f commit c8ec8e9
Show file tree
Hide file tree
Showing 53 changed files with 223 additions and 38 deletions.
3 changes: 3 additions & 0 deletions JSTests/microbenchmarks/bit-test-constant.js
@@ -1,4 +1,7 @@
//@ skip if not $jitTests
if (typeof $vm != "undefined" && !$vm.useJIT())
$vm.exit();

let glob = 0

function doTest(number) {
Expand Down
3 changes: 3 additions & 0 deletions JSTests/microbenchmarks/memcpy-typed-loop-large.js
@@ -1,4 +1,7 @@
//@ skip if not $jitTests
if (typeof $vm != "undefined" && !$vm.useJIT())
$vm.exit();

function doTest(arr1, arr2) {
if (arr1.length != arr2.length)
return []
Expand Down
3 changes: 3 additions & 0 deletions JSTests/stress/arith-abs-on-various-types.js
Expand Up @@ -3,6 +3,9 @@
//@ defaultNoEagerRun
"use strict";

if (typeof $vm != "undefined" && !$vm.useJIT())
$vm.exit();

let validInputTestCases = [
// input as string, expected result as string.
["undefined", "NaN"],
Expand Down
3 changes: 3 additions & 0 deletions JSTests/stress/arith-abs-to-arith-negate-range-optimizaton.js
Expand Up @@ -3,6 +3,9 @@
//@ defaultNoEagerRun
"use strict";

if (typeof $vm != "undefined" && !$vm.useJIT())
$vm.exit();

// Checked int_min < value < 0
function opaqueCheckedBetweenIntMinAndZeroExclusive(arg) {
if (arg < 0) {
Expand Down
3 changes: 3 additions & 0 deletions JSTests/stress/arith-acos-on-various-types.js
Expand Up @@ -3,6 +3,9 @@
//@ defaultNoEagerRun
"use strict";

if (typeof $vm != "undefined" && !$vm.useJIT())
$vm.exit();

let acosOfHalf = Math.acos(0.5);

let validInputTestCases = [
Expand Down
3 changes: 3 additions & 0 deletions JSTests/stress/arith-acosh-on-various-types.js
Expand Up @@ -3,6 +3,9 @@
//@ defaultNoEagerRun
"use strict";

if (typeof $vm != "undefined" && !$vm.useJIT())
$vm.exit();

let acoshOfFour = Math.acosh(4);

let validInputTestCases = [
Expand Down
3 changes: 3 additions & 0 deletions JSTests/stress/arith-asin-on-various-types.js
Expand Up @@ -3,6 +3,9 @@
//@ defaultNoEagerRun
"use strict";

if (typeof $vm != "undefined" && !$vm.useJIT())
$vm.exit();

let asinOfHalf = Math.asin(0.5);

let validInputTestCases = [
Expand Down
3 changes: 3 additions & 0 deletions JSTests/stress/arith-asinh-on-various-types.js
Expand Up @@ -3,6 +3,9 @@
//@ defaultNoEagerRun
"use strict";

if (typeof $vm != "undefined" && !$vm.useJIT())
$vm.exit();

let asinhOfFour = Math.asinh(4);

let validInputTestCases = [
Expand Down
3 changes: 3 additions & 0 deletions JSTests/stress/arith-atan-on-various-types.js
Expand Up @@ -3,6 +3,9 @@
//@ defaultNoEagerRun
"use strict";

if (typeof $vm != "undefined" && !$vm.useJIT())
$vm.exit();

let atanOfFour = Math.atan(4);

let validInputTestCases = [
Expand Down
3 changes: 3 additions & 0 deletions JSTests/stress/arith-atanh-on-various-types.js
Expand Up @@ -3,6 +3,9 @@
//@ defaultNoEagerRun
"use strict";

if (typeof $vm != "undefined" && !$vm.useJIT())
$vm.exit();

let atanhOfHalf = Math.atanh(0.5);

let validInputTestCases = [
Expand Down
3 changes: 3 additions & 0 deletions JSTests/stress/arith-cbrt-on-various-types.js
Expand Up @@ -3,6 +3,9 @@
//@ defaultNoEagerRun
"use strict";

if (typeof $vm != "undefined" && !$vm.useJIT())
$vm.exit();

let cbrtOfHalf = Math.cbrt(0.5);

let validInputTestCases = [
Expand Down
3 changes: 3 additions & 0 deletions JSTests/stress/arith-ceil-on-various-types.js
Expand Up @@ -3,6 +3,9 @@
//@ defaultNoEagerRun
"use strict";

if (typeof $vm != "undefined" && !$vm.useJIT())
$vm.exit();

let validInputTestCases = [
// input as string, expected result as string.
["undefined", "NaN"],
Expand Down
3 changes: 3 additions & 0 deletions JSTests/stress/arith-clz32-on-various-types.js
Expand Up @@ -3,6 +3,9 @@
//@ defaultNoEagerRun
"use strict";

if (typeof $vm != "undefined" && !$vm.useJIT())
$vm.exit();

let validInputTestCases = [
// input as string, expected result as string.
["undefined", "32"],
Expand Down
3 changes: 3 additions & 0 deletions JSTests/stress/arith-cos-on-various-types.js
Expand Up @@ -3,6 +3,9 @@
//@ defaultNoEagerRun
"use strict";

if (typeof $vm != "undefined" && !$vm.useJIT())
$vm.exit();

let cosOfFour = Math.cos(4);

let validInputTestCases = [
Expand Down
3 changes: 3 additions & 0 deletions JSTests/stress/arith-cosh-on-various-types.js
Expand Up @@ -3,6 +3,9 @@
//@ defaultNoEagerRun
"use strict";

if (typeof $vm != "undefined" && !$vm.useJIT())
$vm.exit();

let coshOfFour = Math.cosh(4);

let validInputTestCases = [
Expand Down
3 changes: 3 additions & 0 deletions JSTests/stress/arith-expm1-on-various-types.js
Expand Up @@ -3,6 +3,9 @@
//@ defaultNoEagerRun
"use strict";

if (typeof $vm != "undefined" && !$vm.useJIT())
$vm.exit();

let expm1OfHalf = Math.expm1(0.5);

let validInputTestCases = [
Expand Down
3 changes: 3 additions & 0 deletions JSTests/stress/arith-floor-on-various-types.js
Expand Up @@ -3,6 +3,9 @@
//@ defaultNoEagerRun
"use strict";

if (typeof $vm != "undefined" && !$vm.useJIT())
$vm.exit();

let validInputTestCases = [
// input as string, expected result as string.
["undefined", "NaN"],
Expand Down
3 changes: 3 additions & 0 deletions JSTests/stress/arith-fround-on-various-types.js
Expand Up @@ -3,6 +3,9 @@
//@ defaultNoEagerRun
"use strict";

if (typeof $vm != "undefined" && !$vm.useJIT())
$vm.exit();

let froundOfPi = Math.fround(Math.PI);
let froundOfE = Math.fround(Math.E);

Expand Down
3 changes: 3 additions & 0 deletions JSTests/stress/arith-log10-on-various-types.js
Expand Up @@ -3,6 +3,9 @@
//@ defaultNoEagerRun
"use strict";

if (typeof $vm != "undefined" && !$vm.useJIT())
$vm.exit();

let log10OfHalf = Math.log10(0.5);

let validInputTestCases = [
Expand Down
3 changes: 3 additions & 0 deletions JSTests/stress/arith-log2-on-various-types.js
Expand Up @@ -3,6 +3,9 @@
//@ defaultNoEagerRun
"use strict";

if (typeof $vm != "undefined" && !$vm.useJIT())
$vm.exit();

let log2OfHalf = Math.log2(0.5);

let validInputTestCases = [
Expand Down
3 changes: 3 additions & 0 deletions JSTests/stress/arith-negate-on-various-types.js
Expand Up @@ -2,6 +2,9 @@
//@ defaultNoEagerRun
"use strict";

if (typeof $vm != "undefined" && !$vm.useJIT())
$vm.exit();

let validInputTestCases = [
// input as string, expected result as string.
["undefined", "NaN"],
Expand Down
3 changes: 3 additions & 0 deletions JSTests/stress/arith-round-on-various-types.js
Expand Up @@ -3,6 +3,9 @@
//@ defaultNoEagerRun
"use strict";

if (typeof $vm != "undefined" && !$vm.useJIT())
$vm.exit();

let validInputTestCases = [
// input as string, expected result as string.
["undefined", "NaN"],
Expand Down
3 changes: 3 additions & 0 deletions JSTests/stress/arith-sin-on-various-types.js
Expand Up @@ -3,6 +3,9 @@
//@ defaultNoEagerRun
"use strict";

if (typeof $vm != "undefined" && !$vm.useJIT())
$vm.exit();

let sinOfFour = Math.sin(4);

let validInputTestCases = [
Expand Down
3 changes: 3 additions & 0 deletions JSTests/stress/arith-sinh-on-various-types.js
Expand Up @@ -3,6 +3,9 @@
//@ defaultNoEagerRun
"use strict";

if (typeof $vm != "undefined" && !$vm.useJIT())
$vm.exit();

let sinhOfFour = Math.sinh(4);

let validInputTestCases = [
Expand Down
3 changes: 3 additions & 0 deletions JSTests/stress/arith-sqrt-on-various-types.js
Expand Up @@ -3,6 +3,9 @@
//@ defaultNoEagerRun
"use strict";

if (typeof $vm != "undefined" && !$vm.useJIT())
$vm.exit();

let validInputTestCases = [
// input as string, expected result as string.
["undefined", "NaN"],
Expand Down
3 changes: 3 additions & 0 deletions JSTests/stress/arith-tan-on-various-types.js
Expand Up @@ -3,6 +3,9 @@
//@ defaultNoEagerRun
"use strict";

if (typeof $vm != "undefined" && !$vm.useJIT())
$vm.exit();

let tanOfFour = Math.tan(4);

let validInputTestCases = [
Expand Down
3 changes: 3 additions & 0 deletions JSTests/stress/arith-tanh-on-various-types.js
Expand Up @@ -3,6 +3,9 @@
//@ defaultNoEagerRun
"use strict";

if (typeof $vm != "undefined" && !$vm.useJIT())
$vm.exit();

let tanhOfFour = Math.tanh(4);

let validInputTestCases = [
Expand Down
3 changes: 3 additions & 0 deletions JSTests/stress/arith-trunc-on-various-types.js
Expand Up @@ -3,6 +3,9 @@
//@ defaultNoEagerRun
"use strict";

if (typeof $vm != "undefined" && !$vm.useJIT())
$vm.exit();

let validInputTestCases = [
// input as string, expected result as string.
["undefined", "NaN"],
Expand Down
11 changes: 9 additions & 2 deletions JSTests/stress/array-slice-cow.js
Expand Up @@ -3,6 +3,8 @@ function shouldBe(actual, expected) {
throw new Error('bad value: ' + actual);
}

var allowDoubleShape = $vm.allowDoubleShape();

function testInt32()
{
var array = [0, 1, 2, 3];
Expand All @@ -17,8 +19,13 @@ function testDouble()
{
var array = [0.1, 1.1, 2.1, 3.1];
var slice = array.slice(1);
shouldBe($vm.indexingMode(array), "CopyOnWriteArrayWithDouble");
shouldBe($vm.indexingMode(slice), "ArrayWithDouble");
if (allowDoubleShape) {
shouldBe($vm.indexingMode(array), "CopyOnWriteArrayWithDouble");
shouldBe($vm.indexingMode(slice), "ArrayWithDouble");
} else {
shouldBe($vm.indexingMode(array), "CopyOnWriteArrayWithContiguous");
shouldBe($vm.indexingMode(slice), "ArrayWithContiguous");
}
return slice;
}
noInline(testDouble);
Expand Down
12 changes: 10 additions & 2 deletions JSTests/stress/arrayprofile-should-not-convert-get-by-val-cow.js
Expand Up @@ -3,6 +3,8 @@ function assertEq(a, b) {
throw new Error("values not the same: " + a + " and " + b);
}

var allowDoubleShape = $vm.allowDoubleShape();

function withArrayArgInt32(i, array) {
let result = array[i];
assertEq($vm.indexingMode(array), "CopyOnWriteArrayWithInt32");
Expand All @@ -19,14 +21,20 @@ noInline(withArrayLiteralInt32);

function withArrayArgDouble(i, array) {
let result = array[i];
assertEq($vm.indexingMode(array), "CopyOnWriteArrayWithDouble");
if (allowDoubleShape)
assertEq($vm.indexingMode(array), "CopyOnWriteArrayWithDouble");
else
assertEq($vm.indexingMode(array), "CopyOnWriteArrayWithContiguous");
}
noInline(withArrayArgDouble);

function withArrayLiteralDouble(i) {
let array = [0,1.3145,2];
let result = array[i];
assertEq($vm.indexingMode(array), "CopyOnWriteArrayWithDouble");
if (allowDoubleShape)
assertEq($vm.indexingMode(array), "CopyOnWriteArrayWithDouble");
else
assertEq($vm.indexingMode(array), "CopyOnWriteArrayWithContiguous");
}
noInline(withArrayLiteralDouble);

Expand Down
3 changes: 3 additions & 0 deletions JSTests/stress/bit-op-with-object-returning-int32.js
@@ -1,4 +1,7 @@
//@ skip if not $jitTests
if (typeof $vm != "undefined" && !$vm.useJIT())
$vm.exit();

function assert(a, e) {
if (a !== e)
throw new Error("Expected: " + e + " but got: " + a);
Expand Down
2 changes: 2 additions & 0 deletions JSTests/stress/bitwise-not-fixup-rules.js
@@ -1,4 +1,6 @@
//@ skip unless $jitTests
if (typeof $vm != "undefined" && !$vm.useJIT())
$vm.exit();

function assert(a, e) {
if (a !== e)
Expand Down
3 changes: 3 additions & 0 deletions JSTests/stress/compare-strict-eq-on-various-types.js
Expand Up @@ -2,6 +2,9 @@
//@ defaultNoEagerRun
"use strict";

if (typeof $vm != "undefined" && !$vm.useJIT())
$vm.exit();

function opaqueKitString() {
return "Kit";
}
Expand Down
Expand Up @@ -4,6 +4,9 @@ function shouldBe(actual, expected) {
throw new Error('bad value: ' + actual);
}

if (!$vm.useJIT())
$vm.exit();

var putter = function(o) {
o._unsupported = not_string;
}
Expand Down
3 changes: 3 additions & 0 deletions JSTests/stress/int8-repeat-in-then-out-of-bounds.js
@@ -1,5 +1,8 @@
//@ if $jitTests then defaultNoEagerRun(*NO_CJIT_OPTIONS) else skip end

if (typeof $vm != "undefined" && !$vm.useJIT())
$vm.exit();

function foo(a, inBounds) {
a[0] = 1;
if (!inBounds) {
Expand Down

0 comments on commit c8ec8e9

Please sign in to comment.