diff options
| author | Divy Srivastava <dj.srivastava23@gmail.com> | 2023-02-17 18:48:09 +0530 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-02-17 18:48:09 +0530 |
| commit | f8435d20b0e9408e50bfb24793becc0e476cc285 (patch) | |
| tree | 221044e2b0dbc7bbabe0f12412ddedeb4daf4851 /ext/node/polyfills/v8.ts | |
| parent | 7ce1a68637840c5800d48abf275f4385c80f5658 (diff) | |
feat(ext/node): implement `node:v8` (#17806)
Closes https://github.com/denoland/deno/issues/17115
Implements `cachedDataVersionTag` and `getHeapStatistics`.
Diffstat (limited to 'ext/node/polyfills/v8.ts')
| -rw-r--r-- | ext/node/polyfills/v8.ts | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/ext/node/polyfills/v8.ts b/ext/node/polyfills/v8.ts index f186ff023..c7875e654 100644 --- a/ext/node/polyfills/v8.ts +++ b/ext/node/polyfills/v8.ts @@ -3,8 +3,10 @@ import { notImplemented } from "internal:deno_node/polyfills/_utils.ts"; +const { ops } = globalThis.__bootstrap.core; + export function cachedDataVersionTag() { - notImplemented("v8.cachedDataVersionTag"); + return ops.op_v8_cached_data_version_tag(); } export function getHeapCodeStatistics() { notImplemented("v8.getHeapCodeStatistics"); @@ -15,9 +17,30 @@ export function getHeapSnapshot() { export function getHeapSpaceStatistics() { notImplemented("v8.getHeapSpaceStatistics"); } + +const buffer = new Float64Array(14); + export function getHeapStatistics() { - notImplemented("v8.getHeapStatistics"); + ops.op_v8_get_heap_statistics(buffer); + + return { + total_heap_size: buffer[0], + total_heap_size_executable: buffer[1], + total_physical_size: buffer[2], + total_available_size: buffer[3], + used_heap_size: buffer[4], + heap_size_limit: buffer[5], + malloced_memory: buffer[6], + peak_malloced_memory: buffer[7], + does_zap_garbage: buffer[8], + number_of_native_contexts: buffer[9], + number_of_detached_contexts: buffer[10], + total_global_handles_size: buffer[11], + used_global_handles_size: buffer[12], + external_memory: buffer[13], + }; } + export function setFlagsFromString() { notImplemented("v8.setFlagsFromString"); } |
