Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream'
Browse files Browse the repository at this point in the history
  • Loading branch information
Jarred-Sumner committed Aug 27, 2024
2 parents 21fc366 + 1baa85f commit 5108824
Show file tree
Hide file tree
Showing 3,454 changed files with 138,039 additions and 35,631 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
2 changes: 1 addition & 1 deletion Configurations/Version.xcconfig
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

MAJOR_VERSION = 620;
MINOR_VERSION = 1;
TINY_VERSION = 4;
TINY_VERSION = 6;
MICRO_VERSION = 0;
NANO_VERSION = 0;
FULL_VERSION = $(MAJOR_VERSION).$(MINOR_VERSION).$(TINY_VERSION);
Expand Down
12 changes: 12 additions & 0 deletions JSTests/microbenchmarks/regexp-match-alphanumeric.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
(function() {
var result = 0;
var n = 10000000;
let src = "foo bar BAZ1 23% 456q Uu X {Xyzz y78} 9 $$$0Abc";
for (let i = 0; i < n; ++i) {
let re = /[A-Za-z0-9]{3,4}/g;
while (re.test(src))
++result;
}
if (result != n * 7) /* Expect [foo, bar, BAZ1, 456q, Xyzz, y78, 0Abc] */
throw "Error: bad result: " + result;
})();
12 changes: 12 additions & 0 deletions JSTests/microbenchmarks/regexp-match-multiple-single-chars.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
(function() {
var result = 0;
var n = 10000000;
let src = "foo bar BAZ1 23% 456q Uu X {Xyzz y78} 9 $$$0Abc";
for (let i = 0; i < n; ++i) {
let re = /[AaCeGgJjMmNnQqTtWwZz]/g;
while (re.test(src))
++result;
}
if (result != n * 7) /* Expect [a, A, Z, q, z, z, A] */
throw "Error: bad result: " + result;
})();
31 changes: 31 additions & 0 deletions JSTests/microbenchmarks/regexp-match-separators.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
(function() {
var result = 0;
var n = 1000000;
let src = `
function cross(vec<float, 3> a, vec<float, 3> b) {
vec<float, 3> result = {
a.y * b.z - a.z * b.y,
a.z * b.x - a.x * b.z,
a.x * b.y - a.y * b.x
};
return result;
}
function dot(vec<float, 3> a, vec<float, 3> b) {
return a.x * b.x + a.y * b.y + a.z * b.z;
}
function test() {
vec<float, 3> a = { 1, 2, 3 };
vec<float, 3> b = { 400, 500, 600 };
vec<float, 3> c = cross(a, b);
assert(dot(a, c) == 0);
assert(dot(b, c) == 0);
}
`;
for (let i = 0; i < n; ++i) {
let re = /[\(\)\{\}\[\]\<\>\,\.\;]/g;
while (re.test(src))
++result;
}
if (result != n * 89)
throw "Error: bad result: " + result;
})();
48 changes: 48 additions & 0 deletions JSTests/stress/atomics-ops-sign-extend-not-bit-mask.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
//@ requireOptions("--jitPolicyScale=0.001")

function opt16() {
const arr = new Int16Array([-1, 1]);
if (Atomics.and(arr, 0, 0) !== -1)
throw new Error();

if (Atomics.and(arr, 1, 0) !== 1)
throw new Error();
}
noInline(opt16);

function optU16() {
const arr = new Uint16Array([-1, 1]);
if (Atomics.and(arr, 0, 0) !== 65535)
throw new Error();

if (Atomics.and(arr, 1, 0) !== 1)
throw new Error();
}
noInline(optU16);

function opt8() {
const arr = new Int8Array([-1, 1]);
if (Atomics.and(arr, 0, 0) !== -1)
throw new Error();

if (Atomics.and(arr, 1, 0) !== 1)
throw new Error();
}
noInline(opt8);

function optU8() {
const arr = new Uint8Array([-1, 1]);
if (Atomics.and(arr, 0, 0) !== 255)
throw new Error();

if (Atomics.and(arr, 1, 0) !== 1)
throw new Error();
}
noInline(optU8);

for (let i = 0; i < 1e3; i++) {
opt16();
optU16();
opt8();
optU8();
}
10 changes: 0 additions & 10 deletions JSTests/stress/date-to-temporal-instant.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,7 @@ function shouldThrow(func, errorType, message) {
shouldBe(epochDateInstant.toString(), epochInstant.toString());
shouldBe(epochDateInstant.epochNanoseconds, epochInstant.epochNanoseconds);

shouldBe(epochDateInstant.epochSeconds, 0);
shouldBe(epochDateInstant.epochMilliseconds, 0);
shouldBe(epochDateInstant.epochMicroseconds, 0n);
shouldBe(epochDateInstant.epochNanoseconds, 0n);

}
Expand All @@ -54,9 +52,7 @@ function shouldThrow(func, errorType, message) {
shouldBe(dateToInstant.toString(), temporalInstant.toString());
shouldBe(dateToInstant.epochNanoseconds, temporalInstant.epochNanoseconds);

shouldBe(dateToInstant.epochSeconds, 1_000_000_000);
shouldBe(dateToInstant.epochMilliseconds, 1_000_000_000_000);
shouldBe(dateToInstant.epochMicroseconds, 1_000_000_000_000_000n);
shouldBe(dateToInstant.epochNanoseconds, 1_000_000_000_000_000_000n);
}

Expand All @@ -67,9 +63,7 @@ function shouldThrow(func, errorType, message) {
shouldBe(dateToInstant.toString(), temporalInstant.toString());
shouldBe(dateToInstant.epochNanoseconds, temporalInstant.epochNanoseconds);

shouldBe(dateToInstant.epochSeconds, -1_000_000_000);
shouldBe(dateToInstant.epochMilliseconds, -1_000_000_000_000);
shouldBe(dateToInstant.epochMicroseconds, -1_000_000_000_000_000n);
shouldBe(dateToInstant.epochNanoseconds, -1_000_000_000_000_000_000n);
}

Expand All @@ -80,9 +74,7 @@ function shouldThrow(func, errorType, message) {
shouldBe(dateToInstant.toString(), temporalInstant.toString());
shouldBe(dateToInstant.epochNanoseconds, temporalInstant.epochNanoseconds);

shouldBe(dateToInstant.epochSeconds, 86400_0000_0000);
shouldBe(dateToInstant.epochMilliseconds, 86400_0000_0000_000);
shouldBe(dateToInstant.epochMicroseconds, 86400_0000_0000_000_000n);
shouldBe(dateToInstant.epochNanoseconds, 86400_0000_0000_000_000_000n);
}

Expand All @@ -93,8 +85,6 @@ function shouldThrow(func, errorType, message) {
shouldBe(dateToInstant.toString(), temporalInstant.toString());
shouldBe(dateToInstant.epochNanoseconds, temporalInstant.epochNanoseconds);

shouldBe(dateToInstant.epochSeconds, -86400_0000_0000);
shouldBe(dateToInstant.epochMilliseconds, -86400_0000_0000_000);
shouldBe(dateToInstant.epochMicroseconds, -86400_0000_0000_000_000n);
shouldBe(dateToInstant.epochNanoseconds, -86400_0000_0000_000_000_000n);
}
2 changes: 1 addition & 1 deletion JSTests/stress/intl-durationformat-format-to-parts.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ if (Intl.DurationFormat) {
{
var fmt = new Intl.DurationFormat('en-US', { style: 'digital', fractionalDigits: 9, millseconds: 'numeric' });
shouldBeOneOf(JSON.stringify(fmt.formatToParts({ hours: 7, minutes: 8, seconds: 9, milliseconds: 123, microseconds: 456, nanoseconds: 789 })), [
`[{"type":"integer","value":"7","unit":"hour"},{"type":"literal","value":":"},{"type":"integer","value":"08","unit":"minute"},{"type":"literal","value":":"},{"type":"integer","value":"09","unit":"second"},{"type":"decimal","value":".","unit":"second"},{"type":"fraction","value":"123456788","unit":"second"}]`
`[{"type":"integer","value":"7","unit":"hour"},{"type":"literal","value":":"},{"type":"integer","value":"08","unit":"minute"},{"type":"literal","value":":"},{"type":"integer","value":"09","unit":"second"},{"type":"decimal","value":".","unit":"second"},{"type":"fraction","value":"123456789","unit":"second"}]`
]);
}
}
24 changes: 24 additions & 0 deletions JSTests/stress/iterator-prototype-constructor-new.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
//@ requireOptions("--useIteratorHelpers=1")

function assert(a, b) {
if (a !== b)
throw new Error("Expected: " + b + " but got: " + a);
}

function assertThrows(expectedError, f) {
try {
f();
} catch (e) {
assert(e instanceof expectedError, true);
}
}

// https://tc39.es/proposal-iterator-helpers/#sec-iterator
assertThrows(TypeError, function () {
new Iterator();
});

// https://tc39.es/proposal-iterator-helpers/#sec-iterator
class MyIterator extends Iterator {};
const myIterator = new MyIterator();
assert(myIterator instanceof Iterator, true);
19 changes: 19 additions & 0 deletions JSTests/stress/iterator-prototype-constructor-setter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//@ requireOptions("--useIteratorHelpers=1")

function assert(a, b) {
if (a !== b)
throw new Error("Expected: " + b + " but got: " + a);
}

function assertThrows(expectedError, f) {
try {
f();
} catch (e) {
assert(e instanceof expectedError, true);
}
}

// see https://tc39.es/proposal-iterator-helpers/#sec-set-iteratorprototype-constructor
assertThrows(TypeError, function () {
Iterator.prototype.constructor = {};
});
19 changes: 19 additions & 0 deletions JSTests/stress/iterator-prototype-to-string-tag-basic-setter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//@ requireOptions("--useIteratorHelpers=1")

function assert(a, b) {
if (a !== b)
throw new Error("Expected: " + b + " but got: " + a);
}

function assertThrows(expectedError, f) {
try {
f();
} catch (e) {
assert(e instanceof expectedError, true);
}
}

// see https://tc39.es/proposal-iterator-helpers/#sec-set-iteratorprototype-@@tostringtag
assertThrows(TypeError, function () {
Iterator.prototype[Symbol.toStringTag] = "foo";
});
33 changes: 33 additions & 0 deletions JSTests/stress/json-stringify-inspector-check.js

Large diffs are not rendered by default.

80 changes: 80 additions & 0 deletions JSTests/stress/regress-277219.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
function testScopeRestorationAfterExceptionInTry() {
try {
{
let x = 1;
var captureX = function() { print(x) };
throw new Error("foo");
}
} catch {
shouldBe(typeof x, "undefined");
} finally {
x
}
}

function testScopeRestorationAfterExceptionInTry2() {
try {
for (let x of [1, 2, 3]) {
var captureX = function() { print(x) };
throw new Error("foo");
}
} catch {
shouldBe(typeof x, "undefined");
} finally {
x
}
}

function testScopeRestorationAfterExceptionInCatch() {
try {
throw new Error("foo");
} catch (error) {
{
let x = 1;
var captureX = function() { print(x) };
throw new Error("foo");
}
} finally {
shouldBe(typeof x, "undefined");
x
}
}

function testScopeRestorationAfterExceptionInCatch2() {
try {
throw new Error("foo");
} catch {
for (let x of [1, 2, 3]) {
var captureX = function() { print(x) };
throw new Error("foo");
}
} finally {
shouldBe(typeof x, "undefined");
x
}
}

function shouldBe(actual, expected) {
if (actual !== expected)
throw new Error(`Bad value: ${actual}!`);
}

function shouldThrow(func, expectedMessage) {
let errorThrown = false;
try {
func();
} catch (error) {
errorThrown = true;
if (error.toString() !== expectedMessage)
throw new Error(`Bad error: ${error}`);
}
if (!errorThrown)
throw new Error(`Didn't throw!`);
}

for (var i = 0; i < 1e4; i++) {
shouldThrow(testScopeRestorationAfterExceptionInTry, "ReferenceError: Can't find variable: x");
shouldThrow(testScopeRestorationAfterExceptionInTry2, "ReferenceError: Can't find variable: x");
shouldThrow(testScopeRestorationAfterExceptionInCatch, "ReferenceError: Can't find variable: x");
shouldThrow(testScopeRestorationAfterExceptionInCatch2, "ReferenceError: Can't find variable: x");
}
33 changes: 33 additions & 0 deletions JSTests/stress/runString-returns-globalThis-not-globalObject.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// This shouldn't crash.

try {
function F() {
return runString();
}
class C extends F {
"undefined" = this;
}
new C();
} catch { }

var custom = $vm.createCustomTestGetterSetter();

try {
function F2() {
return $vm.custom.customAccessorGlobalObject;
}
class C2 extends F2 {
"undefined" = this;
}
new C2();
} catch { }

try {
function F3() {
return $vm.custom.customValueGlobalObject;
}
class C3 extends F3 {
"undefined" = this;
}
new C3();
} catch { }
33 changes: 33 additions & 0 deletions JSTests/stress/sampling-profiler-line-column.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
function shouldBe(actual, expected) {
if (actual !== expected)
throw new Error('bad value: ' + actual);
}
(function () {
if (!platformSupportsSamplingProfiler())
return;

load("./sampling-profiler/samplingProfiler.js", "caller relative");

function test() {
var res = 0;
for (let i = 0; i < 1000; ++i)
res += Math.tan(i);
return res;
}
noInline(test);

const timeToFail = 50000;
let startTime = Date.now();
do {
test();
let data = samplingProfilerStackTraces();
for (let trace of data.traces) {
for (let frame of trace.frames) {
if (frame.name === 'test' && (frame.line >= 11 && frame.line <= 16) && (frame.column >= 5 && frame.line <= 38))
return;
}
}
} while (Date.now() - startTime < timeToFail);
let stacktraces = samplingProfilerStackTraces();
throw new Error(`Bad stack trace ${JSON.stringify(stacktraces)}`);
}());
Loading

0 comments on commit 5108824

Please sign in to comment.