From 98583972df9da54010805daae6cf557bc1064e9d Mon Sep 17 00:00:00 2001 From: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> Date: Fri, 28 Apr 2023 18:57:00 -0700 Subject: cargo cult some code from JSC --- src/bun.js/bindings/JSBundlerPlugin.cpp | 11 ++++++----- src/bun.js/bindings/JSBundlerPlugin.h | 2 +- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/bun.js/bindings/JSBundlerPlugin.cpp b/src/bun.js/bindings/JSBundlerPlugin.cpp index bff8ebd0d..5f1d5c96b 100644 --- a/src/bun.js/bindings/JSBundlerPlugin.cpp +++ b/src/bun.js/bindings/JSBundlerPlugin.cpp @@ -22,7 +22,7 @@ #include #include #include - +#include namespace Bun { #define WRAP_BUNDLER_PLUGIN(argName) jsNumber(bitwise_cast(reinterpret_cast(argName))) @@ -52,13 +52,12 @@ void BundlerPlugin::NamespaceList::append(JSC::VM& vm, JSC::RegExp* filter, Stri filter->flags().contains(Yarr::Flags::IgnoreCase) ? Yarr::TextCaseSensitivity::TextCaseInsensitive : Yarr::TextCaseSensitivity::TextCaseInsensitive, filter->multiline() ? Yarr::MultilineMode::MultilineEnabled : Yarr::MultilineMode::MultilineDisabled, filter->eitherUnicode() ? Yarr::UnicodeMode::UnicodeAwareMode : Yarr::UnicodeMode::UnicodeUnawareMode); - nsGroup->append(WTFMove(regex)); } -bool BundlerPlugin::anyMatchesCrossThread(const ZigString* namespaceStr, const ZigString* path, bool isOnLoad) +bool BundlerPlugin::anyMatchesCrossThread(JSC::VM& vm, const ZigString* namespaceStr, const ZigString* path, bool isOnLoad) { - + constexpr bool usesPatternContextBuffer = false; if (isOnLoad) { if (this->onLoad.fileNamespace.isEmpty() && this->onLoad.namespaces.isEmpty()) return false; @@ -75,6 +74,7 @@ bool BundlerPlugin::anyMatchesCrossThread(const ZigString* namespaceStr, const Z auto pathString = Zig::toString(*path); for (auto& filter : filters) { + Yarr::MatchingContextHolder regExpContext(vm, usesPatternContextBuffer, nullptr, Yarr::MatchFrom::CompilerThread); if (filter.match(pathString) > -1) { return true; } @@ -96,6 +96,7 @@ bool BundlerPlugin::anyMatchesCrossThread(const ZigString* namespaceStr, const Z auto& filters = *group; for (auto& filter : filters) { + Yarr::MatchingContextHolder regExpContext(vm, usesPatternContextBuffer, nullptr, Yarr::MatchFrom::CompilerThread); if (filter.match(pathString) > -1) { return true; } @@ -276,7 +277,7 @@ void JSBundlerPlugin::finishCreation(JSC::VM& vm) extern "C" bool JSBundlerPlugin__anyMatches(Bun::JSBundlerPlugin* pluginObject, const ZigString* namespaceString, const ZigString* path, bool isOnLoad) { - return pluginObject->plugin.anyMatchesCrossThread(namespaceString, path, isOnLoad); + return pluginObject->plugin.anyMatchesCrossThread(pluginObject->vm(), namespaceString, path, isOnLoad); } extern "C" void JSBundlerPlugin__matchOnLoad(JSC::JSGlobalObject* globalObject, Bun::JSBundlerPlugin* plugin, const ZigString* namespaceString, const ZigString* path, void* context, uint8_t defaultLoaderId) diff --git a/src/bun.js/bindings/JSBundlerPlugin.h b/src/bun.js/bindings/JSBundlerPlugin.h index 6434aab1b..08aa1d140 100644 --- a/src/bun.js/bindings/JSBundlerPlugin.h +++ b/src/bun.js/bindings/JSBundlerPlugin.h @@ -42,7 +42,7 @@ public: }; public: - bool anyMatchesCrossThread(const ZigString* namespaceStr, const ZigString* path, bool isOnLoad); + bool anyMatchesCrossThread(JSC::VM&, const ZigString* namespaceStr, const ZigString* path, bool isOnLoad); void tombstone() { tombstoned = true; } BundlerPlugin(void* config, BunPluginTarget target) -- cgit v1.2.3