Nix flake for RPython interpreters
修訂 | 80c99cc8a914a06c83177bc3ae6ddf2432b6175f (tree) |
---|---|
時間 | 2024-04-20 12:01:52 |
作者 | Corbin <cds@corb...> |
Commiter | Corbin |
bf: Better JIT debugging; one more peephole.
@@ -14,9 +14,8 @@ def opEq(ops1, ops2): | ||
14 | 14 | if op is not ops2[i]: return False |
15 | 15 | return True |
16 | 16 | |
17 | -def printableProgram(program): return program.asStr() | |
18 | - | |
19 | -jitdriver = JitDriver(greens=['program'], reds=['position', 'tape'], | |
17 | +def printableProgram(pc, loop): return loop.ops[pc].asStr() | |
18 | +jitdriver = JitDriver(greens=['pc', 'loop'], reds=['position', 'tape'], | |
20 | 19 | get_printable_location=printableProgram) |
21 | 20 | |
22 | 21 | class Op(object): |
@@ -86,9 +85,12 @@ class Loop(Op): | ||
86 | 85 | return '[' + '; '.join([op.asStr() for op in self.ops]) + ']' |
87 | 86 | def runOn(self, tape, position): |
88 | 87 | while tape[position]: |
89 | - jitdriver.jit_merge_point(program=self, | |
90 | - position=position, tape=tape) | |
91 | - for op in self.ops: position = op.runOn(tape, position) | |
88 | + i = 0 | |
89 | + while i < len(self.ops): | |
90 | + jitdriver.jit_merge_point(pc=i, loop=self, | |
91 | + position=position, tape=tape) | |
92 | + position = self.ops[i].runOn(tape, position) | |
93 | + i += 1 | |
92 | 94 | return position |
93 | 95 | loopCache = [] |
94 | 96 | def loop(ops): |
@@ -106,6 +108,7 @@ def peep(ops): | ||
106 | 108 | temp = shift(temp.width + op.width) |
107 | 109 | elif isinstance(temp, Add) and isinstance(op, Add): |
108 | 110 | temp = add(temp.imm + op.imm) |
111 | + elif isinstance(temp, Add) and op is Zero: temp = Zero | |
109 | 112 | else: |
110 | 113 | rv.append(temp) |
111 | 114 | temp = op |