• R/O
  • HTTP
  • SSH
  • HTTPS

提交

標籤
無標籤

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Nix flake for RPython interpreters


Commit MetaInfo

修訂80c99cc8a914a06c83177bc3ae6ddf2432b6175f (tree)
時間2024-04-20 12:01:52
作者Corbin <cds@corb...>
CommiterCorbin

Log Message

bf: Better JIT debugging; one more peephole.

Change Summary

差異

--- a/bf/bf.py
+++ b/bf/bf.py
@@ -14,9 +14,8 @@ def opEq(ops1, ops2):
1414 if op is not ops2[i]: return False
1515 return True
1616
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'],
2019 get_printable_location=printableProgram)
2120
2221 class Op(object):
@@ -86,9 +85,12 @@ class Loop(Op):
8685 return '[' + '; '.join([op.asStr() for op in self.ops]) + ']'
8786 def runOn(self, tape, position):
8887 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
9294 return position
9395 loopCache = []
9496 def loop(ops):
@@ -106,6 +108,7 @@ def peep(ops):
106108 temp = shift(temp.width + op.width)
107109 elif isinstance(temp, Add) and isinstance(op, Add):
108110 temp = add(temp.imm + op.imm)
111+ elif isinstance(temp, Add) and op is Zero: temp = Zero
109112 else:
110113 rv.append(temp)
111114 temp = op