Skip to content

Commit b6c2e3f

Browse files
committed
Update to new heap statistics API
1 parent 8960fec commit b6c2e3f

2 files changed

Lines changed: 5 additions & 9 deletions

File tree

‎crates/static-analysis-kernel/src/analysis/ddsa_lib/resource_watchdog.rs‎

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@ impl V8ResourceWatchdog {
3737
Arc::clone(&timeout_condvar),
3838
);
3939

40-
let mut stats = v8::HeapStatistics::default();
41-
isolate.get_heap_statistics(&mut stats);
40+
let stats = isolate.get_heap_statistics();
4241
let initial_heap_limit = stats.heap_size_limit();
4342

4443
let heap_limit_cb =
@@ -299,8 +298,7 @@ impl HeapLimitGuard {
299298
let boxed_box = Box::new(near_heap_limit_cb);
300299
let boxed_callback_ptr = Box::into_raw(boxed_box);
301300
let isolate_ptr: *const v8::Isolate = &*isolate;
302-
let mut stats = v8::HeapStatistics::default();
303-
isolate.get_heap_statistics(&mut stats);
301+
let stats = isolate.get_heap_statistics();
304302
let initial_limit = stats.heap_size_limit();
305303

306304
let guard = Self {
@@ -462,8 +460,7 @@ pub(crate) mod tests {
462460
/// Returns the percentage difference between the isolate's current heap limit
463461
/// and the expected heap limit.
464462
fn heap_limit_diff(isolate: &mut v8::Isolate, expected: usize) -> f32 {
465-
let mut stats = v8::HeapStatistics::default();
466-
isolate.get_heap_statistics(&mut stats);
463+
let stats = isolate.get_heap_statistics();
467464
let current_limit = stats.heap_size_limit() as isize;
468465
let diff = current_limit.abs_diff(expected as isize);
469466
diff as f32 / expected as f32

‎crates/static-analysis-kernel/src/analysis/ddsa_lib/runtime.rs‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1579,12 +1579,11 @@ function visit(captures) {
15791579
#[test]
15801580
fn make_base_deno_core_runtime_set_heap_limit() {
15811581
const MAX_BYTES: usize = 16 * 1024 * 1024;
1582-
let mut heap_stats = v8::HeapStatistics::default();
15831582
let _v8 = cfg_test_v8();
15841583
for size in [MAX_BYTES, MAX_BYTES * 2] {
15851584
let mut rt = make_base_deno_core_runtime(vec![], Some(size));
1586-
rt.v8_isolate().get_heap_statistics(&mut heap_stats);
1587-
assert_eq!(heap_stats.heap_size_limit(), size);
1585+
let stats = rt.v8_isolate().get_heap_statistics();
1586+
assert_eq!(stats.heap_size_limit(), size);
15881587
}
15891588
}
15901589

0 commit comments

Comments
 (0)