summaryrefslogtreecommitdiff
path: root/ext/node/ops/v8.rs
diff options
context:
space:
mode:
authorBartek IwaƄczuk <biwanczuk@gmail.com>2023-04-24 12:22:21 +0200
committerGitHub <noreply@github.com>2023-04-24 12:22:21 +0200
commit1f0360c07382dbd86066d1aa8aa4bae34aff18c5 (patch)
treecc82d00aea829f0b3d3949f40df9696b099ee662 /ext/node/ops/v8.rs
parent28e2c7204fe02304a8fc3339d7758eec0f64f723 (diff)
refactor(ext/node): reorganize ops (#18799)
Move all op related code of "ext/node" to "ext/node/ops" module. These files were unnecessarily scattered around the extension.
Diffstat (limited to 'ext/node/ops/v8.rs')
-rw-r--r--ext/node/ops/v8.rs29
1 files changed, 29 insertions, 0 deletions
diff --git a/ext/node/ops/v8.rs b/ext/node/ops/v8.rs
new file mode 100644
index 000000000..5307f7107
--- /dev/null
+++ b/ext/node/ops/v8.rs
@@ -0,0 +1,29 @@
+// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
+use deno_core::op;
+use deno_core::v8;
+
+#[op]
+fn op_v8_cached_data_version_tag() -> u32 {
+ v8::script_compiler::cached_data_version_tag()
+}
+
+#[op(v8)]
+fn op_v8_get_heap_statistics(scope: &mut v8::HandleScope, buffer: &mut [f64]) {
+ let mut stats = v8::HeapStatistics::default();
+ scope.get_heap_statistics(&mut stats);
+
+ buffer[0] = stats.total_heap_size() as f64;
+ buffer[1] = stats.total_heap_size_executable() as f64;
+ buffer[2] = stats.total_physical_size() as f64;
+ buffer[3] = stats.total_available_size() as f64;
+ buffer[4] = stats.used_heap_size() as f64;
+ buffer[5] = stats.heap_size_limit() as f64;
+ buffer[6] = stats.malloced_memory() as f64;
+ buffer[7] = stats.peak_malloced_memory() as f64;
+ buffer[8] = stats.does_zap_garbage() as f64;
+ buffer[9] = stats.number_of_native_contexts() as f64;
+ buffer[10] = stats.number_of_detached_contexts() as f64;
+ buffer[11] = stats.total_global_handles_size() as f64;
+ buffer[12] = stats.used_global_handles_size() as f64;
+ buffer[13] = stats.external_memory() as f64;
+}