skip zero words when iterating words in MemMMap
authorJacob Lifshay <programmerjake@gmail.com>
Mon, 25 Sep 2023 22:29:25 +0000 (15:29 -0700)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Tue, 26 Sep 2023 21:11:44 +0000 (22:11 +0100)
src/openpower/decoder/isa/mem.py

index fccd9c1b6c855f20464d826749cf1c050e0b3c39..a32f47fbf49ee40b6c8fd7d0a7fc0d1549111a09 100644 (file)
@@ -403,8 +403,16 @@ class MemMMap(MemCommon):
         block[block_addr:block_addr + self.bytes_per_word] = bytes_
 
     def word_idxs(self):
+        zeros = bytes(self.bytes_per_word)
         for page_idx in self.modified_pages:
             start = self.mmap_page_idx_to_addr(page_idx)
+            block, block_addr = self.__access_addr_range(
+                start, _MMAP_PAGE_SIZE, _MMapPageFlags.R)
             end = start + _MMAP_PAGE_SIZE
-            yield from range(start // self.bytes_per_word,
-                             end // self.bytes_per_word)
+            for word_idx in range(start // self.bytes_per_word,
+                                    end // self.bytes_per_word):
+                next_block_addr = block_addr + self.bytes_per_word
+                bytes_ = block[block_addr:next_block_addr]
+                block_addr = next_block_addr
+                if bytes_ != zeros:
+                    yield word_idx