Skip to content

Commit

Permalink
Add option to force HaveABadTime mode all the time for testing.
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=261059
rdar://114858622

Reviewed by Yusuke Suzuki.

Added the --alwaysHaveABadTime option, which will make is easier to test HaveABadTime mode
by enabling the option in one of the JSC stress tests configurations.

Also skipped some tests that rely on HaveABadTime mode or expected Array IndexingTypes.

Fixed out-of-memory-handle-in-join.js to always trigger a rope resolution.  The test is
relying on Array.prototype.join() to throw an OOME due to rope resolution.  However, join's
slow path does not do rope resolution in this one scenario.  So, we change the test so that
it yields the same result regardless of whether join's fast or slow path is taken.

Skipped the array-unshift-should-not-race-against-compiler-thread.js test because it runs
prohibitively slow when in HaveABadTime mode.

These tests were skipped on armv7 or mips because they were failing on those bots presumably
due to memory exhaustion or timeouts:
    JSTests/microbenchmarks/large-empty-array-join-resolve-rope.js
    JSTests/microbenchmarks/large-empty-array-join.js
    JSTests/microbenchmarks/u16-string-index-of-1000001-404.js
    JSTests/microbenchmarks/u16-string-index-of-1000001-beg.js
    JSTests/microbenchmarks/u16-string-index-of-1000001-end.js
    JSTests/microbenchmarks/u16-string-index-of-1000001-mid.js

* JSTests/microbenchmarks/large-empty-array-join-resolve-rope.js:
* JSTests/microbenchmarks/large-empty-array-join.js:
* JSTests/microbenchmarks/u16-string-index-of-1000001-404.js:
* JSTests/microbenchmarks/u16-string-index-of-1000001-beg.js:
* JSTests/microbenchmarks/u16-string-index-of-1000001-end.js:
* JSTests/microbenchmarks/u16-string-index-of-1000001-mid.js:
* JSTests/stress/array-slice-cow.js:
* JSTests/stress/array-unshift-should-not-race-against-compiler-thread.js:
* JSTests/stress/arrayprofile-should-not-convert-get-by-val-cow.js:
* JSTests/stress/dollarVM-have-a-bad-time-no-params.js:
* JSTests/stress/dollarVM-have-a-bad-time-works-for-non-global-object-params.js:
* JSTests/stress/out-of-memory-handle-in-join.js:
(shouldThrow):
* JSTests/stress/regress-189028.js:
* JSTests/stress/typed-array-from-array-iterator-protocol.js:
* Source/JavaScriptCore/runtime/JSGlobalObject.cpp:
(JSC::JSGlobalObject::init):
* Source/JavaScriptCore/runtime/OptionsList.h:
* Tools/Scripts/run-jsc-stress-tests:

Canonical link: https://commits.webkit.org/267584@main
  • Loading branch information
Mark Lam committed Sep 2, 2023
1 parent ddb67f5 commit de60094
Show file tree
Hide file tree
Showing 17 changed files with 36 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
//@ skip if $model == "Apple Watch Series 3" # added by mark-jsc-stress-test.py
//@ $skipModes << :lockdown if $architecture == "mips"

const array = [];
for (let i = 0; i < 100; ++i)
array.push(new Array(1e4).join('—' + i).slice(1));
1 change: 1 addition & 0 deletions JSTests/microbenchmarks/large-empty-array-join.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//@ skip if $model == "Apple Watch Series 3" # added by mark-jsc-stress-test.py
//@ $skipModes << :lockdown if $memoryLimited or $architecture == "mips"
const array = [];
for (let i = 0; i < 100; ++i)
array.push(new Array(1e6).join('—' + i));
2 changes: 2 additions & 0 deletions JSTests/microbenchmarks/u16-string-index-of-1000001-404.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//@ $skipModes << :lockdown if $architecture == "mips"

function bench(string, func)
{
for (var i = 0; i < 1000; ++i)
Expand Down
2 changes: 2 additions & 0 deletions JSTests/microbenchmarks/u16-string-index-of-1000001-beg.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//@ $skipModes << :lockdown if $architecture == "mips"

function bench(string, func)
{
for (var i = 0; i < 1000; ++i)
Expand Down
2 changes: 2 additions & 0 deletions JSTests/microbenchmarks/u16-string-index-of-1000001-end.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//@ $skipModes << :lockdown if $architecture == "mips"

function bench(string, func)
{
for (var i = 0; i < 1000; ++i)
Expand Down
2 changes: 2 additions & 0 deletions JSTests/microbenchmarks/u16-string-index-of-1000001-mid.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//@ $skipModes << :lockdown if $architecture == "mips"

function bench(string, func)
{
for (var i = 0; i < 1000; ++i)
Expand Down
2 changes: 2 additions & 0 deletions JSTests/stress/array-slice-cow.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//@ $skipModes << :lockdown

function shouldBe(actual, expected) {
if (actual !== expected)
throw new Error('bad value: ' + actual);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//@ $skipModes << :lockdown

let x = [];
for (let i = 0; i < 30; ++i) {
for (let j = 0; j < 20000; ++j) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//@ $skipModes << :lockdown

function assertEq(a, b) {
if (a !== b)
throw new Error("values not the same: " + a + " and " + b);
Expand Down
2 changes: 2 additions & 0 deletions JSTests/stress/dollarVM-have-a-bad-time-no-params.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//@ $skipModes << :lockdown

if ($vm.isHavingABadTime())
throw new Error();
$vm.haveABadTime();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//@ $skipModes << :lockdown

let OtherArray = $vm.createGlobalObject().Array;
if ($vm.isHavingABadTime(OtherArray))
throw new Error();
Expand Down
5 changes: 4 additions & 1 deletion JSTests/stress/out-of-memory-handle-in-join.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,8 @@ function shouldThrow(func, errorMessage) {

shouldThrow(() => {
let x = { toString: () => ''.padEnd(2 ** 31 - 1, 10..toLocaleString()) };
[x].join();
let y = [x].join();
// This is to force the resolution of the rope returned by x.toString() so that we'll
// get the OOME even if the slowJoin path is taken.
y[y.length - 1];
}, `RangeError: Out of memory`);
2 changes: 2 additions & 0 deletions JSTests/stress/regress-189028.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//@ $skipModes << :lockdown

function assert(x, y) {
if (x != y) {
$vm.print("actual: ", x);
Expand Down
2 changes: 2 additions & 0 deletions JSTests/stress/typed-array-from-array-iterator-protocol.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//@ $skipModes << :lockdown

function shouldBe(actual, expected) {
if (actual !== expected)
throw new Error('bad value: ' + actual);
Expand Down
5 changes: 4 additions & 1 deletion Source/JavaScriptCore/runtime/JSGlobalObject.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2007-2022 Apple Inc. All rights reserved.
* Copyright (C) 2007-2023 Apple Inc. All rights reserved.
* Copyright (C) 2008 Cameron Zwarich (cwzwarich@uwaterloo.ca)
*
* Redistribution and use in source and binary forms, with or without
Expand Down Expand Up @@ -1820,6 +1820,9 @@ capitalName ## Constructor* lowerName ## Constructor = featureFlag ? capitalName
}

fixupPrototypeChainWithObjectPrototype(vm);

if (UNLIKELY(Options::alwaysHaveABadTime()))
this->haveABadTime(vm);
}

bool JSGlobalObject::put(JSCell* cell, JSGlobalObject* globalObject, PropertyName propertyName, JSValue value, PutPropertySlot& slot)
Expand Down
1 change: 1 addition & 0 deletions Source/JavaScriptCore/runtime/OptionsList.h
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,7 @@ bool canUseWebAssemblyFastMemory();
v(Bool, forceWeakRandomSeed, false, Normal, nullptr) \
v(Unsigned, forcedWeakRandomSeed, 0, Normal, nullptr) \
\
v(Bool, alwaysHaveABadTime, false, Normal, "debugging option to test HaveABadTime mode") \
v(Bool, allowDoubleShape, true, Normal, "debugging option to test disabling use of DoubleShape") \
v(Bool, useZombieMode, false, Normal, "debugging option to scribble over dead objects with 0xbadbeef0") \
v(Bool, useImmortalObjects, false, Normal, "debugging option to keep all objects alive forever") \
Expand Down
3 changes: 2 additions & 1 deletion Tools/Scripts/run-jsc-stress-tests
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby

# Copyright (C) 2013-2022 Apple Inc. All rights reserved.
# Copyright (C) 2013-2023 Apple Inc. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
Expand Down Expand Up @@ -1307,6 +1307,7 @@ BASE_MODES = [
"--useLLIntICs=false",
"--useZombieMode=true",
"--allowDoubleShape=false",
"--alwaysHaveABadTime=true",
]
],
[
Expand Down

0 comments on commit de60094

Please sign in to comment.