diff options
| author | snek <snek@deno.com> | 2024-07-31 16:22:34 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-07-31 23:22:34 +0000 |
| commit | f57745fe2106a4d26dd2209e1b2cacb2d6430245 (patch) | |
| tree | f3ea0c476940b296ec3cc507adca05088ed947be /ext/node_resolver | |
| parent | fbcd250bc8ffb3b577afca7131d1d37f55eb47a2 (diff) | |
feat: upgrade V8 to 12.8 (#24693)
- upgrade to v8 12.8
- optimizes DataView bigint methods
- fixes global interceptors
- includes CPED methods for ALS
- fix global resolution
- makes global resolution consistent using host_defined_options.
originally a separate patch but due to the global interceptor bug it
needs to be included in this pr for all tests to pass.
Diffstat (limited to 'ext/node_resolver')
| -rw-r--r-- | ext/node_resolver/resolution.rs | 24 | ||||
| -rw-r--r-- | ext/node_resolver/sync.rs | 63 |
2 files changed, 1 insertions, 86 deletions
diff --git a/ext/node_resolver/resolution.rs b/ext/node_resolver/resolution.rs index 772bc5d34..ae791e312 100644 --- a/ext/node_resolver/resolution.rs +++ b/ext/node_resolver/resolution.rs @@ -1,7 +1,6 @@ // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. use std::borrow::Cow; -use std::collections::HashMap; use std::path::Path; use std::path::PathBuf; @@ -138,38 +137,17 @@ pub type NodeResolverRc<TEnv> = crate::sync::MaybeArc<NodeResolver<TEnv>>; pub struct NodeResolver<TEnv: NodeResolverEnv> { env: TEnv, npm_resolver: NpmResolverRc, - in_npm_package_cache: crate::sync::MaybeArcMutex<HashMap<String, bool>>, } impl<TEnv: NodeResolverEnv> NodeResolver<TEnv> { pub fn new(env: TEnv, npm_resolver: NpmResolverRc) -> Self { - Self { - env, - npm_resolver, - in_npm_package_cache: crate::sync::MaybeArcMutex::new(HashMap::new()), - } + Self { env, npm_resolver } } pub fn in_npm_package(&self, specifier: &Url) -> bool { self.npm_resolver.in_npm_package(specifier) } - pub fn in_npm_package_with_cache(&self, specifier: Cow<str>) -> bool { - let mut cache = self.in_npm_package_cache.lock(); - - if let Some(result) = cache.get(specifier.as_ref()) { - return *result; - } - - let result = if let Ok(specifier) = Url::parse(&specifier) { - self.npm_resolver.in_npm_package(&specifier) - } else { - false - }; - cache.insert(specifier.into_owned(), result); - result - } - /// This function is an implementation of `defaultResolve` in /// `lib/internal/modules/esm/resolve.js` from Node. pub fn resolve( diff --git a/ext/node_resolver/sync.rs b/ext/node_resolver/sync.rs index f6689a56a..3c4729aa2 100644 --- a/ext/node_resolver/sync.rs +++ b/ext/node_resolver/sync.rs @@ -6,79 +6,16 @@ pub use inner::*; mod inner { #![allow(clippy::disallowed_types)] - use std::ops::Deref; - use std::ops::DerefMut; pub use std::sync::Arc as MaybeArc; - pub struct MaybeArcMutexGuard<'lock, T>(std::sync::MutexGuard<'lock, T>); - - impl<'lock, T> Deref for MaybeArcMutexGuard<'lock, T> { - type Target = std::sync::MutexGuard<'lock, T>; - fn deref(&self) -> &std::sync::MutexGuard<'lock, T> { - &self.0 - } - } - - impl<'lock, T> DerefMut for MaybeArcMutexGuard<'lock, T> { - fn deref_mut(&mut self) -> &mut std::sync::MutexGuard<'lock, T> { - &mut self.0 - } - } - - #[derive(Debug)] - pub struct MaybeArcMutex<T>(std::sync::Arc<std::sync::Mutex<T>>); - impl<T> MaybeArcMutex<T> { - pub fn new(val: T) -> Self { - Self(std::sync::Arc::new(std::sync::Mutex::new(val))) - } - } - - impl<'lock, T> MaybeArcMutex<T> { - pub fn lock(&'lock self) -> MaybeArcMutexGuard<'lock, T> { - MaybeArcMutexGuard(self.0.lock().unwrap()) - } - } - pub use core::marker::Send as MaybeSend; pub use core::marker::Sync as MaybeSync; } #[cfg(not(feature = "sync"))] mod inner { - use std::ops::Deref; - use std::ops::DerefMut; - pub use std::rc::Rc as MaybeArc; - pub struct MaybeArcMutexGuard<'lock, T>(std::cell::RefMut<'lock, T>); - - impl<'lock, T> Deref for MaybeArcMutexGuard<'lock, T> { - type Target = std::cell::RefMut<'lock, T>; - fn deref(&self) -> &std::cell::RefMut<'lock, T> { - &self.0 - } - } - - impl<'lock, T> DerefMut for MaybeArcMutexGuard<'lock, T> { - fn deref_mut(&mut self) -> &mut std::cell::RefMut<'lock, T> { - &mut self.0 - } - } - - #[derive(Debug)] - pub struct MaybeArcMutex<T>(std::rc::Rc<std::cell::RefCell<T>>); - impl<T> MaybeArcMutex<T> { - pub fn new(val: T) -> Self { - Self(std::rc::Rc::new(std::cell::RefCell::new(val))) - } - } - - impl<'lock, T> MaybeArcMutex<T> { - pub fn lock(&'lock self) -> MaybeArcMutexGuard<'lock, T> { - MaybeArcMutexGuard(self.0.borrow_mut()) - } - } - pub trait MaybeSync {} impl<T> MaybeSync for T where T: ?Sized {} pub trait MaybeSend {} |
