PVM
op
¶
Bases: Enum
This enum serves as a readable lookup for the different opcodes defined in gp::
Source code in pyjamaz/pvm/constants.py
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 | |
InstructionType
¶
Bases: Enum
This enum serves as classification for how instructions should be decoded
Source code in pyjamaz/pvm/constants.py
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | |
PVMProgram
dataclass
¶
Bases: Serializable
Source code in pyjamaz/pvm/types.py
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 | |
name: str = ''
class-attribute
instance-attribute
¶
GP-0.7.2-eq:A.42 | Initializing of memory pages
init_registers(arguments: bytes) -> List[int]
staticmethod
¶
GP-0.7.2-eq:A.43
Source code in pyjamaz/pvm/types.py
129 130 131 132 133 134 135 136 137 138 139 | |
from_serialized_bytes(serialized_program: bytes, argument_contents: bytes, name: Optional[str]) -> Optional[PVMProgram]
classmethod
¶
GP-0.7.2-eq:A.37 (function_Y)
Source code in pyjamaz/pvm/types.py
142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 | |
to_serialized_bytes() -> bytes
¶
GP-0.7.2-eq:A.37 (Y)
Source code in pyjamaz/pvm/types.py
215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 | |
PVMMemory
dataclass
¶
Source code in pyjamaz/pvm/memory.py
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 | |
read_bytes(address: int, length: int, padding: int = None) -> bytes
¶
Source code in pyjamaz/pvm/memory.py
196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 | |
write_bytes(address: int, content: bytes) -> None
¶
Source code in pyjamaz/pvm/memory.py
236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 | |
zone_size(items: int) -> int
staticmethod
¶
GP-0.7.2-eq:A.40 (Z)
Source code in pyjamaz/pvm/memory.py
327 328 329 330 331 332 | |
reverse_bytes(x)
¶
Reverse the byte order of a 64-bit integer (endianness swap).
Converts between big-endian and little-endian representations. Example: 0x0123456789ABCDEF -> 0xEFCDAB8967452301
Note: Optimized using Python's built-in bytes operations. Provides ~4x speedup over bitwise operations.
Source code in pyjamaz/pvm/interpreters/cpython/defs.py
81 82 83 84 85 86 87 88 89 90 91 92 | |
pvm_smod(a: int, b: int) -> int
¶
Signed modulo operation optimized using conditional branching to avoid function call overhead.
Returns a % b with sign of a preserved. Special case: if b == 0, returns a.
Note: Optimized using conditional branching instead of abs() and sign functions for ~18% performance improvement.
Source code in pyjamaz/pvm/interpreters/cpython/defs.py
115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 | |
pvm_rtz_div(a: int, b: int) -> int
¶
Truncated division (rounds toward zero).
Returns the quotient of a/b rounded toward zero. Examples: 7/3=2, -7/3=-2, 7/-3=-2, -7/-3=2
Note: Optimized using conditional branching to avoid abs() and divmod() overhead. Provides ~1.4x speedup while maintaining exact correctness for all integer values. This approach avoids floating point precision issues with very large integers.
Source code in pyjamaz/pvm/interpreters/cpython/defs.py
143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 | |
pvm_X(x: int, n: int) -> int
¶
Sign extend a number to two's complement form for value X and number of bytes n
Optimized version using bit operations.
Source code in pyjamaz/pvm/interpreters/cpython/defs.py
167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 | |
pvm_Z(a: int, n: int) -> int
¶
Interpret the low n bytes of a as a signed two's-complement integer.
Source code in pyjamaz/pvm/interpreters/cpython/defs.py
231 232 233 234 235 236 237 238 239 240 241 | |
page_size(bytes: int) -> int
¶
GP-0.7.2-eq:A.40 (P)
Source code in pyjamaz/pvm/memory_section_abstract.py
15 16 17 18 19 | |
umul64wide_jit(a: U64, b: U64) -> (U64, U64)
¶
Unsigned 64x64 -> (hi, lo) as uint64s.
Source code in pyjamaz/pvm/interpreters/numba/defs.py
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | |
imul64wide_jit(a: I64, b: I64) -> (U64, U64)
¶
Signed 64x64 -> (hi, lo) representing 128-bit two's-complement product.
Source code in pyjamaz/pvm/interpreters/numba/defs.py
56 57 58 59 60 61 62 63 64 65 66 67 | |
smul_u64wide_jit(a: I64, b: U64) -> (U64, U64)
¶
Signed * Unsigned -> (hi, lo), two's-complement.
Source code in pyjamaz/pvm/interpreters/numba/defs.py
70 71 72 73 74 75 76 77 | |
rori64_jit(x: U64, shift_amount: U64) -> U64
¶
Rotate right for 64-bit integers.
Source code in pyjamaz/pvm/interpreters/numba/defs.py
80 81 82 83 | |
roli64_jit(x: U64, shift_amount: U64) -> U64
¶
Rotate left for 64-bit integers.
Source code in pyjamaz/pvm/interpreters/numba/defs.py
86 87 88 89 | |
rori32_jit(x: U32, shift_amount: U32) -> U32
¶
Rotate right for 32-bit integers.
Source code in pyjamaz/pvm/interpreters/numba/defs.py
92 93 94 95 | |
roli32_jit(x: U32, shift_amount: U32) -> U32
¶
Rotate left for 32-bit integers.
Source code in pyjamaz/pvm/interpreters/numba/defs.py
98 99 100 101 | |
pvm_smod_jit(a: I64, b: I64) -> I64
¶
Signed modulo operation (truncated modulo). Returns a % b with sign of a preserved. Special case: if b == 0, returns a.
Source code in pyjamaz/pvm/interpreters/numba/defs.py
104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 | |
pvm_rtz_div_jit(a: I64, b: I64) -> I64
¶
Truncated division (rounds toward zero). Uses floor division with adjustment to avoid overflow when negating INT64_MIN.
Source code in pyjamaz/pvm/interpreters/numba/defs.py
132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 | |
pvm_Z_jit(a: U64, n: U64) -> I64
¶
Unsigned->signed conversion for n bytes (1..8). Returns I64 with proper two's-complement sign extension without Python big-ints.
Source code in pyjamaz/pvm/interpreters/numba/defs.py
208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 | |
count_leading_zeroes_jit(value: U64, max_bits: U8) -> U64
¶
Count-leading-zeroes with explicit 64-bit masking and shifts. Matches Python implementation for max_bits in {32,64}.
Source code in pyjamaz/pvm/interpreters/numba/defs.py
238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 | |
pvm_Z_inv_jit(a: I64, n: U8) -> U64
¶
Signed to unsigned.
Source code in pyjamaz/pvm/interpreters/numba/defs.py
298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 | |
mem_write_jit(addr: U64, value: U64, bytes_to_write: U8, section_starts, section_ends, section_arrays, section_access) -> (I32, U64)
¶
Returns (status:I32, fault_addr:U64) where status==0 on success, -1 on page fault, -2 on panic. fault_addr is set to the first failing byte address (page aligned) on page fault. GP-0.7.2-eq:A.7 - Addresses below 2^16 are invalid and cause panic.
Source code in pyjamaz/pvm/interpreters/numba/defs.py
371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 | |
mem_read_jit(addr: U64, bytes_to_read: U8, section_starts, section_ends, section_arrays, section_access) -> (I32, U64)
¶
Returns (status:I32, value_or_fault:U64) where status==0 on success, -1 on page-fault, -2 on panic. On success, second element is the read value. On page fault, second element is the page aligned fault address. GP-0.7.2-eq:A.7 - Addresses below 2^16 are invalid and cause panic.
Source code in pyjamaz/pvm/interpreters/numba/defs.py
452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 | |