Produce a clean copy of the bytecode suitable for serialization (marshal) and `co_code`. Specialized opcodes are mapped back to their base variants via `deoptimize()` and all CACHE entries are zeroed.
(&self)
| 786 | /// (marshal) and `co_code`. Specialized opcodes are mapped back to their |
| 787 | /// base variants via `deoptimize()` and all CACHE entries are zeroed. |
| 788 | pub fn original_bytes(&self) -> Vec<u8> { |
| 789 | let len = self.len(); |
| 790 | let mut out = Vec::with_capacity(len * 2); |
| 791 | let mut i = 0; |
| 792 | while i < len { |
| 793 | let op = self.read_op(i).deoptimize(); |
| 794 | let arg = self.read_arg(i); |
| 795 | let caches = op.cache_entries(); |
| 796 | out.push(u8::from(op)); |
| 797 | out.push(u8::from(arg)); |
| 798 | // Zero-fill all CACHE entries (counter + cached data) |
| 799 | for _ in 0..caches { |
| 800 | i += 1; |
| 801 | out.push(0); // op = Cache = 0 |
| 802 | out.push(0); // arg = 0 |
| 803 | } |
| 804 | i += 1; |
| 805 | } |
| 806 | out |
| 807 | } |
| 808 | |
| 809 | /// Initialize adaptive warmup counters for all cacheable instructions. |
| 810 | /// Called lazily at RESUME (first execution of a code object). |
no test coverage detected