Skip to content

Commit

Permalink
Merge branch 'WebKit:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
Jarred-Sumner authored Aug 30, 2024
2 parents 3f9ba9b + 1c1d099 commit 147ed53
Show file tree
Hide file tree
Showing 3,229 changed files with 20,045 additions and 47,389 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
2 changes: 2 additions & 0 deletions JSTests/stress/in-by-val-profile.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions JSTests/stress/sampling-profiler-wasm-name-section.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
//@ skip if ["arm"].include?($architecture)
//@ skip if $platform == "tvos" || $platform == "watchos"
//@ runDefault

// This test is statistical, and without optimizing Wasm tiers the likelihood
// of hitting the deepest expected stack trace is very low, so disable.
// FIXME: remove when 32-bit platforms support optimizing Wasm tiers
//@ skip if ["arm"].include?($architecture)
//
//@ runDefault

/*
This test loads a WebAssembly file compiled by Emscripten with:
Expand Down
1 change: 1 addition & 0 deletions JSTests/stress/sampling-profiler-wasm.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//@ skip if $architecture == "arm"
//@ skip if $platform == "tvos" || $platform == "watchos"
//@ runDefault

if (platformSupportsSamplingProfiler() && $vm.isWasmSupported()) {
Expand Down
19 changes: 19 additions & 0 deletions JSTests/stress/too-large-base64-string.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//@ skip if $memoryLimited
function shouldThrow(func, errorMessage) {
var errorThrown = false;
var error = null;
try {
func();
} catch (e) {
errorThrown = true;
error = e;
}
if (!errorThrown)
throw new Error('not thrown');
if (String(error) !== errorMessage)
throw new Error(`bad error: ${String(error)}`);
}

shouldThrow(() => {
(new Uint8Array(2**31)).toBase64();
}, `RangeError: Out of memory: generated stirng is too long`);
117 changes: 117 additions & 0 deletions JSTests/stress/yield-await-class-field-initializer-expr.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
// Tests for 'yield' and 'await' inside class field initializers, where the class is declared inside
// async and generator functions.
const verbose = false;

const wrappers = ['none', 'generator', 'async'];
const fieldModifiers = ['', 'static'];
const fieldInitExprs = ['yield', 'yield 42', 'function() { yield 21; }', 'await', 'await 3', '() => await 7', 'function() { await 9; }'];

function genTestCases() {
let cases = [];
for (const wrapper of wrappers) {
for (const fieldModifier of fieldModifiers) {
for (const fieldInitExpr of fieldInitExprs) {
cases.push({ wrapper, fieldModifier, fieldInitExpr });
}
}
}
return cases;
}

function genTestScript(c) {
let tabs = 0;
let script = "";

function append(line) {
for (t = 0; t < tabs; t++)
script += ' ';
script += line + '\n';
}

switch (c.wrapper) {
case 'generator':
append('function * g() {');
break;
case 'async':
append('async function f() {');
break;
case 'none':
break;
}
tabs++;
append('class C {');
tabs++;
append(`${c.fieldModifier} f = ${c.fieldInitExpr};`);
tabs--;
append('}');
tabs--;
if (c.wrapper !== 'none') append('}');
return script;
}

function expected(c, result, error) {
if (c.fieldInitExpr === 'await') {
// 'await' will parse as an identifier.
if (c.wrapper === 'none' && c.fieldModifier === 'static') {
// In this case, 'await' as identifier produces a ReferenceError.
return result === null && error instanceof ReferenceError;
}
// In these cases, 'await' as identifier has value 'undefined').
return result === undefined && error === null;
}
// All other cases should result in a SyntaxError.
return result === null && error instanceof SyntaxError;
}

// Verify that 'await' and 'yield' do not parse as keywords (directly) inside class field initializers.
function testNegativeCases() {
cases = genTestCases();

for (const c of cases) {
let script = genTestScript(c);
let result = null;
let error = null;
try {
result = eval(script);
} catch (e) {
error = e;
}

if (verbose || !expected(c, result, error)) {
print(`Case: ${c.wrapper}:${c.fieldModifier}:${c.fieldInitExpr}`);
print(`Script:\n${script}`);
print(`Result: ${result}`);
print(`Error: ${error}\n`);
}
}
}

// Verify that 'await' and 'yield' work inside anonymous async / generator functions
// used as class field initializers.
function testPositiveCases() {
function assertEq(got, expected) {
if (got !== expected) {
throw Error(`Got: ${got}, Expected: ${expected}`);
}
}

class C {
asyncFn0 = async y => await y;
asyncFn1 = async () => { return await 5 };
asyncFn2 = async function(x) { return await x; };

yieldFn0 = function* () { yield 9; };
yieldFn1 = async function* () { yield await 11; };
};
let c = new C();

c.asyncFn0(3).then(x => assertEq(x, 3));
c.asyncFn1().then(x => assertEq(x, 5));
c.asyncFn2(7).then(x => assertEq(x, 7));

assertEq(c.yieldFn0().next().value, 9);
c.yieldFn1().next().then(x => assertEq(x.value, 11));
}

testNegativeCases();
testPositiveCases();
11 changes: 11 additions & 0 deletions JSTests/wasm/tail-call-spec-harness/async_index.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,15 @@ function eq_externref(x, y) {
function eq_funcref(x, y) {
return x === y ? 1 : 0;
}
let hostrefs = {};
let hostsym = Symbol("hostref");
function hostref(s) {
if (! (s in hostrefs)) hostrefs[s] = {[hostsym]: s};
return hostrefs[s];
}
function eq_ref(x, y) {
return x === y ? 1 : 0;
}

// Default imports.
var registry = {};
Expand All @@ -91,6 +100,8 @@ function reinitializeRegistry() {
is_funcref: is_funcref,
eq_externref: eq_externref,
eq_funcref: eq_funcref,
hostref: hostref,
eq_ref: eq_ref,
print: console.log.bind(console),
print_i32: console.log.bind(console),
print_i32_f32: console.log.bind(console),
Expand Down
11 changes: 11 additions & 0 deletions JSTests/wasm/tail-call-spec-harness/sync_index.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,15 @@ function eq_externref(x, y) {
function eq_funcref(x, y) {
return x === y ? 1 : 0;
}
let hostrefs = {};
let hostsym = Symbol("hostref");
function hostref(s) {
if (! (s in hostrefs)) hostrefs[s] = {[hostsym]: s};
return hostrefs[s];
}
function eq_ref(x, y) {
return x === y ? 1 : 0;
}

let $$;

Expand All @@ -101,6 +110,8 @@ function reinitializeRegistry() {
is_funcref: is_funcref,
eq_externref: eq_externref,
eq_funcref: eq_funcref,
hostref: hostref,
eq_ref: eq_ref,
print: console.log.bind(console),
print_i32: console.log.bind(console),
print_i32_f32: console.log.bind(console),
Expand Down
7 changes: 0 additions & 7 deletions JSTests/wasm/tail-call-spec-harness/wasm-constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,6 @@

// Flags: --expose-wasm

let hostrefs = {};
let hostsym = Symbol("hostref");
function hostref(s) {
if (! (s in hostrefs)) hostrefs[s] = {[hostsym]: s};
return hostrefs[s];
}

function bytes() {
var buffer = new ArrayBuffer(arguments.length);
var view = new Uint8Array(buffer);
Expand Down
Loading

0 comments on commit 147ed53

Please sign in to comment.