aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2023-04-28 18:57:00 -0700
committerGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2023-04-28 18:57:00 -0700
commit98583972df9da54010805daae6cf557bc1064e9d (patch)
treefee49e4c2a591d28c463a914c8844e952fc93e1e
parent994c715700555fab33e1d73b7ac3d2941e674559 (diff)
downloadbun-98583972df9da54010805daae6cf557bc1064e9d.tar.gz
bun-98583972df9da54010805daae6cf557bc1064e9d.tar.zst
bun-98583972df9da54010805daae6cf557bc1064e9d.zip
cargo cult some code from JSC
-rw-r--r--src/bun.js/bindings/JSBundlerPlugin.cpp11
-rw-r--r--src/bun.js/bindings/JSBundlerPlugin.h2
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 <JavaScriptCore/LazyProperty.h>
#include <JavaScriptCore/LazyPropertyInlines.h>
#include <JavaScriptCore/VMTrapsInlines.h>
-
+#include <JavaScriptCore/YarrMatchingContextHolder.h>
namespace Bun {
#define WRAP_BUNDLER_PLUGIN(argName) jsNumber(bitwise_cast<double>(reinterpret_cast<uintptr_t>(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)