Instead of polyfilling it with vm.SourceTextModule, use a built-in source text module loader so that we can also build the code cache for it at build tiem to embed the code cache for them in the binary. Drive-by: instead of inferring how to compile a particular built-in at run time, do the inferring at build time, so the function-based built-ins can be compiled using parameters quickly looked up from a static map, and the builtins that should be compiled as source text modules are known internally based on extension in the source code (at run time, the extensions are all removed). PR-URL: https://github.com/nodejs/node/pull/60518 Reviewed-By: Aditi Singh <aditisingh1400@gmail.com> Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com>
32 lines
889 B
C++
32 lines
889 B
C++
#include "node_builtins.h"
|
|
#include "node_threadsafe_cow-inl.h"
|
|
|
|
#include "gtest/gtest.h"
|
|
#include "node_test_fixture.h"
|
|
|
|
#include <string>
|
|
|
|
using node::builtins::BuiltinLoader;
|
|
using node::builtins::BuiltinSourceMap;
|
|
|
|
class PerProcessTest : public ::testing::Test {
|
|
protected:
|
|
static const BuiltinSourceMap get_sources_for_test() {
|
|
return *BuiltinLoader().source_.read();
|
|
}
|
|
};
|
|
|
|
namespace {
|
|
|
|
TEST_F(PerProcessTest, EmbeddedSources) {
|
|
const auto& sources = PerProcessTest::get_sources_for_test();
|
|
ASSERT_TRUE(std::any_of(sources.cbegin(), sources.cend(), [](auto p) {
|
|
return p.second.source.is_one_byte();
|
|
})) << "BuiltinLoader::source_ should have some 8bit items";
|
|
|
|
ASSERT_TRUE(std::any_of(sources.cbegin(), sources.cend(), [](auto p) {
|
|
return !p.second.source.is_one_byte();
|
|
})) << "BuiltinLoader::source_ should have some 16bit items";
|
|
}
|
|
|
|
} // end namespace
|