From db69c4edabf03c2d4bf5119d5b307bdd3a5c7cbe Mon Sep 17 00:00:00 2001 From: nsfisis Date: Wed, 13 Mar 2024 23:40:46 +0900 Subject: perf: optimize memory.init/table.init --- src/Execution/MemInst.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/Execution/MemInst.php') diff --git a/src/Execution/MemInst.php b/src/Execution/MemInst.php index ae3809d..20a0e29 100644 --- a/src/Execution/MemInst.php +++ b/src/Execution/MemInst.php @@ -29,6 +29,21 @@ final class MemInst return count($this->data) * self::PAGE_SIZE; } + /** + * @param list $data + */ + public function copyData(array $data, int $src, int $dst, int $len): void + { + assert(0 <= $len); + assert(0 <= $src); + assert(0 <= $dst); + assert($src + $len <= count($data)); + assert($dst + $len <= $this->size()); + for ($i = 0; $i < $len; $i++) { + $this->storeByte($dst + $i, $data[$src + $i]); + } + } + /** * @return ?S32 */ -- cgit v1.2.3-70-g09d2