Upload Kmake

This commit is contained in:
Gorochu
2026-05-26 23:36:42 -07:00
parent ba051b2f74
commit 555ec72358
41615 changed files with 13344630 additions and 1 deletions

View File

@ -0,0 +1,76 @@
// Copyright 2018 the V8 project authors. All rights reserved.
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following
// disclaimer in the documentation and/or other materials provided
// with the distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Flags: --expose-async-hooks
// Check for invalid arguments handling
(function() {
assertTrue(async_hooks.hasOwnProperty('createHook'),
'Async hooks missing createHook method');
assertThrows(() => async_hooks.createHook());
assertThrows(() => async_hooks.createHook(123));
assertThrows(() => async_hooks.createHook('str'));
})();
// Check for correct API methods
(function() {
assertTrue(async_hooks.hasOwnProperty('executionAsyncId'),
'Async hooks missing executionAsyncId method');
assertTrue(async_hooks.hasOwnProperty('triggerAsyncId'),
'Async hooks missing triggerAsyncId method');
let ah = async_hooks.createHook({});
assertTrue(ah.hasOwnProperty('enable'), 'Async hooks missing enable method');
assertTrue(ah.hasOwnProperty('disable'),
'Async hooks missing disable method');
})();
// Check for correct enabling/disabling of async hooks
(function() {
let storedPromise;
let ah = async_hooks.createHook({
init(asyncId, type, triggerAsyncId, resource) {
storedPromise = resource.promise || resource;
}
});
ah.enable();
let createdPromise = new Promise(function(resolve) {
resolve(42);
});
assertSame(storedPromise, createdPromise,
"Async hooks weren't enabled correctly");
ah.disable();
createdPromise = Promise.resolve(52);
assertNotSame(storedPromise, createdPromise,
"Async hooks weren't disabled correctly");
ah.enable();
createdPromise = Promise.resolve(62);
assertSame(storedPromise, createdPromise,
"Async hooks weren't enabled correctly");
})();

View File

@ -0,0 +1,74 @@
// Copyright 2018 the V8 project authors. All rights reserved.
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following
// disclaimer in the documentation and/or other materials provided
// with the distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Flags: --expose-async-hooks
// Check for async/await asyncIds relation
(function() {
let asyncIds = [], triggerIds = [];
let ah = async_hooks.createHook({
init(asyncId, type, triggerAsyncId, resource) {
if (type !== 'PROMISE') {
return;
}
asyncIds.push(asyncId);
triggerIds.push(triggerAsyncId);
},
});
ah.enable();
// Simplified version of Node.js util.promisify(setTimeout),
// but d8 ignores the timeout of setTimeout.
function sleep0() {
const promise = new Promise(function(resolve, reject) {
try {
setTimeout((err, ...values) => {
if (err) {
reject(err);
} else {
resolve(values[0]);
}
}, 0);
} catch (err) {
reject(err);
}
});
return promise;
}
async function foo() {
await sleep0();
}
assertPromiseResult(
foo().then(function() {
assertEquals(triggerIds[2], asyncIds[1]);
assertEquals(triggerIds[3], asyncIds[0]);
assertEquals(triggerIds[4], asyncIds[3]);
assertEquals(triggerIds[6], asyncIds[5]);
}));
})();

View File

@ -0,0 +1,52 @@
// Copyright 2018 the V8 project authors. All rights reserved.
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following
// disclaimer in the documentation and/or other materials provided
// with the distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Flags: --expose-async-hooks
// Check for chained promises asyncIds relation
(function() {
let asyncIds = [], triggerIds = [];
let ah = async_hooks.createHook({
init(asyncId, type, triggerAsyncId, resource) {
asyncIds.push(asyncId);
triggerIds.push(triggerAsyncId);
},
});
ah.enable();
let createdPromise = new Promise(function(resolve) {
resolve(42);
}).then(function() {
assertEquals(3, asyncIds.length, 'Exactly 3 promises should be inited');
assertEquals(3, triggerIds.length, 'Exactly 3 promises should be inited');
assertEquals(triggerIds[1], asyncIds[0],
"Parent promise asyncId doesn't correspond to child triggerAsyncId");
}).catch((err) => {
setTimeout(() => {
throw err;
}, 0);
});
})();

View File

@ -0,0 +1,77 @@
// Copyright 2018 the V8 project authors. All rights reserved.
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following
// disclaimer in the documentation and/or other materials provided
// with the distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Flags: --expose-async-hooks
// Check for correct execution of available hooks and asyncIds
(function() {
let calledHooks = [];
let rootAsyncId = 0;
let ah = async_hooks.createHook({
init: function init(asyncId, type, triggerAsyncId, resource) {
if (type !== 'PROMISE') {
return;
}
if (triggerAsyncId === 0) {
rootAsyncId = asyncId;
}
calledHooks.push(['init', asyncId]);
},
promiseResolve: function promiseResolve(asyncId) {
calledHooks.push(['resolve', asyncId]);
},
before: function before(asyncId) {
calledHooks.push(['before', asyncId]);
},
after: function after(asyncId) {
calledHooks.push(['after', asyncId]);
},
});
ah.enable();
new Promise(function(resolve) {
resolve(42);
}).then(function() {
// [hook type, async Id]
const expectedHooks = [
['init', rootAsyncId], // the promise that we create initially
['resolve', rootAsyncId],
['init', rootAsyncId + 1], // the chained promise with the assertions
['init', rootAsyncId + 2], // the chained promise from the catch block
['before', rootAsyncId + 1],
// ['after', rootAsyncId + 1] will get called after the assertions
];
assertArrayEquals(expectedHooks, calledHooks,
'Mismatch in async hooks execution order');
}).catch((err) => {
setTimeout(() => {
throw err;
}, 0);
});
})();

View File

@ -0,0 +1,74 @@
// Copyright 2018 the V8 project authors. All rights reserved.
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following
// disclaimer in the documentation and/or other materials provided
// with the distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Flags: --expose-async-hooks
// Check for executionAsyncId/triggerAsyncId when chained promises and
// async/await are combined
(function() {
let p;
let outerExecutionAsyncId = -1, outerTriggerAsyncId = -1;
function inIrrelevantContext(resolve) {
resolve(42);
}
function inContext1(foo) {
foo();
}
function inContext2(foo) {
foo();
}
outerExecutionAsyncId = async_hooks.executionAsyncId();
outerTriggerAsyncId = async_hooks.triggerAsyncId();
inContext1(() => {
p = new Promise(resolve => {
assertEquals(outerExecutionAsyncId, async_hooks.executionAsyncId());
assertEquals(outerTriggerAsyncId, async_hooks.triggerAsyncId());
inIrrelevantContext(resolve);
}).then(() => {
assertNotEquals(outerExecutionAsyncId, async_hooks.executionAsyncId());
assertNotEquals(outerTriggerAsyncId, async_hooks.triggerAsyncId());
}).catch((err) => {
setTimeout(() => {
throw err;
}, 0);
});
});
inContext2(async () => {
assertEquals(outerExecutionAsyncId, async_hooks.executionAsyncId());
assertEquals(outerTriggerAsyncId, async_hooks.triggerAsyncId());
await p;
assertNotEquals(outerExecutionAsyncId, async_hooks.executionAsyncId());
assertNotEquals(outerTriggerAsyncId, async_hooks.triggerAsyncId());
});
})();

View File

@ -0,0 +1,13 @@
// 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: --expose-async-hooks
const failing_proxy = new Proxy({}, new Proxy({}, {
get() {
throw "No trap should fire";
}
}));
assertThrows(() => async_hooks.createHook(failing_proxy));

View File

@ -0,0 +1,20 @@
// Copyright 2023 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: --expose-async-hooks --expose-gc
let v0 = [];
let v1 = 1;
let v2 = async_hooks.createHook({
after: () => {
async_hooks.createHook(v1);
gc();
}
});
v2.enable();
new Promise(v3 => v3(42)).then(() => { }).catch(() => { });
v1 = v0;

View File

@ -0,0 +1,18 @@
// Copyright 2023 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: --expose-async-hooks
let arr = [];
let hook = async_hooks.createHook({
init() {
d8.terminate();
arr.push();
}
});
hook.enable();
async function async_f() {}
async_f().then();
async_hooks.createHook({init() {}});