| 
1 | 1 | //! Working with GC `array` objects.  | 
2 | 2 | 
  | 
3 |  | -use crate::runtime::vm::VMGcRef;  | 
4 |  | -use crate::store::StoreId;  | 
 | 3 | +use crate::runtime::vm::{VMGcRef, VMStore};  | 
 | 4 | +use crate::store::{StoreId, StoreResourceLimiter};  | 
5 | 5 | use crate::vm::{self, VMArrayRef, VMGcHeader};  | 
6 | 6 | use crate::{AnyRef, FieldType};  | 
7 | 7 | use crate::{  | 
@@ -297,9 +297,15 @@ impl ArrayRef {  | 
297 | 297 |         elem: &Val,  | 
298 | 298 |         len: u32,  | 
299 | 299 |     ) -> Result<Rooted<ArrayRef>> {  | 
300 |  | -        let store = store.as_context_mut().0;  | 
 | 300 | +        let (mut limiter, store) = store.as_context_mut().0.resource_limiter_and_store_opaque();  | 
301 | 301 |         assert!(!store.async_support());  | 
302 |  | -        vm::assert_ready(Self::_new_async(store, allocator, elem, len))  | 
 | 302 | +        vm::assert_ready(Self::_new_async(  | 
 | 303 | +            store,  | 
 | 304 | +            limiter.as_mut(),  | 
 | 305 | +            allocator,  | 
 | 306 | +            elem,  | 
 | 307 | +            len,  | 
 | 308 | +        ))  | 
303 | 309 |     }  | 
304 | 310 | 
 
  | 
305 | 311 |     /// Asynchronously allocate a new `array` of the given length, with every  | 
@@ -341,17 +347,19 @@ impl ArrayRef {  | 
341 | 347 |         elem: &Val,  | 
342 | 348 |         len: u32,  | 
343 | 349 |     ) -> Result<Rooted<ArrayRef>> {  | 
344 |  | -        Self::_new_async(store.as_context_mut().0, allocator, elem, len).await  | 
 | 350 | +        let (mut limiter, store) = store.as_context_mut().0.resource_limiter_and_store_opaque();  | 
 | 351 | +        Self::_new_async(store, limiter.as_mut(), allocator, elem, len).await  | 
345 | 352 |     }  | 
346 | 353 | 
 
  | 
347 | 354 |     pub(crate) async fn _new_async(  | 
348 | 355 |         store: &mut StoreOpaque,  | 
 | 356 | +        limiter: Option<&mut StoreResourceLimiter<'_>>,  | 
349 | 357 |         allocator: &ArrayRefPre,  | 
350 | 358 |         elem: &Val,  | 
351 | 359 |         len: u32,  | 
352 | 360 |     ) -> Result<Rooted<ArrayRef>> {  | 
353 | 361 |         store  | 
354 |  | -            .retry_after_gc_async((), |store, ()| {  | 
 | 362 | +            .retry_after_gc_async(limiter, (), |store, ()| {  | 
355 | 363 |                 Self::new_from_iter(store, allocator, RepeatN(elem, len))  | 
356 | 364 |             })  | 
357 | 365 |             .await  | 
@@ -445,9 +453,14 @@ impl ArrayRef {  | 
445 | 453 |         allocator: &ArrayRefPre,  | 
446 | 454 |         elems: &[Val],  | 
447 | 455 |     ) -> Result<Rooted<ArrayRef>> {  | 
448 |  | -        let store = store.as_context_mut().0;  | 
 | 456 | +        let (mut limiter, store) = store.as_context_mut().0.resource_limiter_and_store_opaque();  | 
449 | 457 |         assert!(!store.async_support());  | 
450 |  | -        vm::assert_ready(Self::_new_fixed_async(store, allocator, elems))  | 
 | 458 | +        vm::assert_ready(Self::_new_fixed_async(  | 
 | 459 | +            store,  | 
 | 460 | +            limiter.as_mut(),  | 
 | 461 | +            allocator,  | 
 | 462 | +            elems,  | 
 | 463 | +        ))  | 
451 | 464 |     }  | 
452 | 465 | 
 
  | 
453 | 466 |     /// Asynchronously allocate a new `array` containing the given elements.  | 
@@ -491,16 +504,18 @@ impl ArrayRef {  | 
491 | 504 |         allocator: &ArrayRefPre,  | 
492 | 505 |         elems: &[Val],  | 
493 | 506 |     ) -> Result<Rooted<ArrayRef>> {  | 
494 |  | -        Self::_new_fixed_async(store.as_context_mut().0, allocator, elems).await  | 
 | 507 | +        let (mut limiter, store) = store.as_context_mut().0.resource_limiter_and_store_opaque();  | 
 | 508 | +        Self::_new_fixed_async(store, limiter.as_mut(), allocator, elems).await  | 
495 | 509 |     }  | 
496 | 510 | 
 
  | 
497 | 511 |     pub(crate) async fn _new_fixed_async(  | 
498 | 512 |         store: &mut StoreOpaque,  | 
 | 513 | +        limiter: Option<&mut StoreResourceLimiter<'_>>,  | 
499 | 514 |         allocator: &ArrayRefPre,  | 
500 | 515 |         elems: &[Val],  | 
501 | 516 |     ) -> Result<Rooted<ArrayRef>> {  | 
502 | 517 |         store  | 
503 |  | -            .retry_after_gc_async((), |store, ()| {  | 
 | 518 | +            .retry_after_gc_async(limiter, (), |store, ()| {  | 
504 | 519 |                 Self::new_from_iter(store, allocator, elems.iter())  | 
505 | 520 |             })  | 
506 | 521 |             .await  | 
 | 
0 commit comments