mirror of
https://github.com/nodejs/node.git
synced 2026-11-09 15:11:11 -05:00
src: port bootstrap/cache.js to C++
This allows us to query the categories of modules in C++ so we can implement the code cache generator in C++ that does not depend on a Node.js binary. PR-URL: https://github.com/nodejs/node/pull/27046 Refs: https://github.com/nodejs/node/issues/21563 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
This commit is contained in:
7 files changed
+140
-107
No files matched your search
@@ -7,22 +7,15 @@
|
||||
|
||||
const { isMainThread } = require('../common');
|
||||
const assert = require('assert');
|
||||
const {
|
||||
cachableBuiltins,
|
||||
cannotBeRequired
|
||||
} = require('internal/bootstrap/cache');
|
||||
|
||||
const {
|
||||
internalBinding
|
||||
} = require('internal/test/binding');
|
||||
const {
|
||||
getCacheUsage
|
||||
getCacheUsage,
|
||||
moduleCategories: { canBeRequired, cannotBeRequired }
|
||||
} = internalBinding('native_module');
|
||||
|
||||
for (const key of cachableBuiltins) {
|
||||
if (!isMainThread && key === 'trace_events') {
|
||||
continue; // Cannot load trace_events in workers
|
||||
}
|
||||
for (const key of canBeRequired) {
|
||||
require(key);
|
||||
}
|
||||
|
||||
@@ -60,7 +53,7 @@ if (process.config.variables.node_code_cache_path === undefined) {
|
||||
);
|
||||
|
||||
for (const key of loadedModules) {
|
||||
if (cannotBeRequired.includes(key)) {
|
||||
if (cannotBeRequired.has(key)) {
|
||||
assert(compiledWithoutCache.has(key),
|
||||
`"${key}" should've been compiled without code cache`);
|
||||
} else {
|
||||
|
||||
Reference in new issue
Block a user