summaryrefslogtreecommitdiff
path: root/runtime/js
diff options
context:
space:
mode:
Diffstat (limited to 'runtime/js')
-rw-r--r--runtime/js/30_os.js10
-rw-r--r--runtime/js/90_deno_ns.js1
-rw-r--r--runtime/js/99_main.js32
3 files changed, 29 insertions, 14 deletions
diff --git a/runtime/js/30_os.js b/runtime/js/30_os.js
index afb5aa4e0..f026940ca 100644
--- a/runtime/js/30_os.js
+++ b/runtime/js/30_os.js
@@ -24,15 +24,6 @@
return core.opSync("op_system_memory_info");
}
- function systemCpuInfo() {
- const { cores, speed } = core.opSync("op_system_cpu_info");
- // Map nulls to undefined for compatibility
- return {
- cores: cores ?? undefined,
- speed: speed ?? undefined,
- };
- }
-
// This is an internal only method used by the test harness to override the
// behavior of exit when the exit sanitizer is enabled.
let exitHandler = null;
@@ -89,7 +80,6 @@
exit,
osRelease,
systemMemoryInfo,
- systemCpuInfo,
hostname,
loadavg,
};
diff --git a/runtime/js/90_deno_ns.js b/runtime/js/90_deno_ns.js
index e4d0b00f2..27900431f 100644
--- a/runtime/js/90_deno_ns.js
+++ b/runtime/js/90_deno_ns.js
@@ -118,7 +118,6 @@
hostname: __bootstrap.os.hostname,
osRelease: __bootstrap.os.osRelease,
systemMemoryInfo: __bootstrap.os.systemMemoryInfo,
- systemCpuInfo: __bootstrap.os.systemCpuInfo,
applySourceMap: __bootstrap.errorStack.opApplySourceMap,
formatDiagnostics: __bootstrap.errorStack.opFormatDiagnostics,
sleepSync: __bootstrap.timers.sleepSync,
diff --git a/runtime/js/99_main.js b/runtime/js/99_main.js
index a48105559..16a444098 100644
--- a/runtime/js/99_main.js
+++ b/runtime/js/99_main.js
@@ -247,6 +247,8 @@ delete Object.prototype.__proto__;
const navigator = webidl.createBranded(Navigator);
+ let numCpus;
+
ObjectDefineProperties(Navigator.prototype, {
gpu: {
configurable: true,
@@ -256,6 +258,14 @@ delete Object.prototype.__proto__;
return webgpu.gpu;
},
},
+ hardwareConcurrency: {
+ configurable: true,
+ enumerable: true,
+ get() {
+ webidl.assertBranded(this, Navigator);
+ return numCpus;
+ },
+ },
});
class WorkerNavigator {
@@ -279,6 +289,14 @@ delete Object.prototype.__proto__;
return webgpu.gpu;
},
},
+ hardwareConcurrency: {
+ configurable: true,
+ enumerable: true,
+ get() {
+ webidl.assertBranded(this, Navigator);
+ return numCpus;
+ },
+ },
});
// https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope
@@ -491,12 +509,13 @@ delete Object.prototype.__proto__;
pid,
ppid,
unstableFlag,
+ cpuCount,
} = runtimeOptions;
if (locationHref != null) {
location.setLocationHref(locationHref);
}
-
+ numCpus = cpuCount;
registerErrors();
const internalSymbol = Symbol("Deno.internal");
@@ -566,10 +585,17 @@ delete Object.prototype.__proto__;
runtimeOptions,
internalName ?? name,
);
- const { unstableFlag, pid, noColor, args, location: locationHref } =
- runtimeOptions;
+ const {
+ unstableFlag,
+ pid,
+ noColor,
+ args,
+ location: locationHref,
+ cpuCount,
+ } = runtimeOptions;
location.setLocationHref(locationHref);
+ numCpus = cpuCount;
registerErrors();
pollForMessages();