From 2be07a1b9bade3f88cbec570a64a40dd5642d41a Mon Sep 17 00:00:00 2001 From: Fabian Date: Tue, 27 Aug 2024 13:44:05 +0200 Subject: [PATCH] Use at least 64mb of memory if initrd is used --- src/cpu.js | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/cpu.js b/src/cpu.js index f92aa3b447..cc7d69c213 100644 --- a/src/cpu.js +++ b/src/cpu.js @@ -702,16 +702,17 @@ CPU.prototype.reset_memory = function() this.mem8.fill(0); }; -/** @export */ -CPU.prototype.create_memory = function(size) +CPU.prototype.create_memory = function(size, minimum_size) { - if(size < 1024 * 1024) + if(size < minimum_size) { - size = 1024 * 1024; + size = minimum_size; + dbg_log("Rounding memory size up to " + size, LOG_CPU); } else if((size | 0) < 0) { size = Math.pow(2, 31) - MMAP_BLOCK_SIZE; + dbg_log("Rounding memory size down to " + size, LOG_CPU); } size = ((size - 1) | (MMAP_BLOCK_SIZE - 1)) + 1 | 0; @@ -730,8 +731,10 @@ CPU.prototype.create_memory = function(size) CPU.prototype.init = function(settings, device_bus) { - this.create_memory(typeof settings.memory_size === "number" ? - settings.memory_size : 1024 * 1024 * 64); + this.create_memory( + settings.memory_size || 64 * 1024 * 1024, + settings.initrd ? 64 * 1024 * 1024 : 1024 * 1024, + ); if(settings.disable_jit) {