@@ -67,10 +67,17 @@ pub trait Space<VM: VMBinding>: 'static + SFT + Sync + Downcast {
67
67
/// avoid arithmatic overflow. If we have to do computation in the allocation fastpath and
68
68
/// overflow happens there, there is nothing we can do about it.
69
69
/// Return a boolean to indicate if we will be out of memory, determined by the check.
70
- fn will_oom_on_acquire ( & self , tls : VMThread , size : usize , allow_oom_call : bool ) -> bool {
70
+ fn will_oom_on_acquire ( & self , size : usize ) -> bool {
71
71
let max_pages = self . get_gc_trigger ( ) . policy . get_max_heap_size_in_pages ( ) ;
72
72
let requested_pages = size >> LOG_BYTES_IN_PAGE ;
73
- if requested_pages > max_pages {
73
+ requested_pages > max_pages
74
+ }
75
+
76
+ /// Check if the requested `size` is an obvious out-of-memory case using
77
+ /// [`Self::will_oom_on_acquire`] and, if it is, call `Collection::out_of_memory`. Return the
78
+ /// result of `will_oom_on_acquire`.
79
+ fn handle_obvious_oom_request ( & self , tls : VMThread , size : usize , allow_oom_call : bool ) -> bool {
80
+ if self . will_oom_on_acquire ( size) {
74
81
if allow_oom_call {
75
82
VM :: VMCollection :: out_of_memory (
76
83
tls,
@@ -90,7 +97,7 @@ pub trait Space<VM: VMBinding>: 'static + SFT + Sync + Downcast {
90
97
) ;
91
98
92
99
debug_assert ! (
93
- !self . will_oom_on_acquire( tls , pages << LOG_BYTES_IN_PAGE , !no_gc_on_fail ) ,
100
+ !self . will_oom_on_acquire( pages << LOG_BYTES_IN_PAGE ) ,
94
101
"The requested pages is larger than the max heap size. Is will_go_oom_on_acquire used before acquring memory?"
95
102
) ;
96
103
0 commit comments