Hi pypy ! I'm still exploring rpython and I face a problem when adding a jit to an interpreter. In Assembler class (pypy.jit.codewriter.assembler), in emit_const method, it seems to be assumed that there is no more than 256 constants. (constant seems to be accessed in a array with a 1 byte index).
If I try to translate an interpreter with more than 256 constant objects (like string ?), I get this error : [translation:ERROR] Error: [translation:ERROR] Traceback (most recent call last): [translation:ERROR] File "/home/olivier/workspace/talstai_ext/pypy-1.6-src/pypy/translator/goal/translate.py", line 308, in main [translation:ERROR] drv.proceed(goals) [translation:ERROR] File "/home/olivier/workspace/talstai_ext/pypy-1.6-src/pypy/translator/driver.py", line 810, in proceed [translation:ERROR] return self._execute(goals, task_skip = self._maybe_skip()) [translation:ERROR] File "/home/olivier/workspace/talstai_ext/pypy-1.6-src/pypy/translator/tool/taskengine.py", line 116, in _execute [translation:ERROR] res = self._do(goal, taskcallable, *args, **kwds) [translation:ERROR] File "/home/olivier/workspace/talstai_ext/pypy-1.6-src/pypy/translator/driver.py", line 286, in _do [translation:ERROR] res = func() [translation:ERROR] File "/home/olivier/workspace/talstai_ext/pypy-1.6-src/pypy/translator/driver.py", line 397, in task_pyjitpl_lltype [translation:ERROR] backend_name=self.config.translation.jit_backend, inline=True) [translation:ERROR] File "/home/olivier/workspace/talstai_ext/pypy-1.6-src/pypy/jit/metainterp/warmspot.py", line 42, in apply_jit [translation:ERROR] **kwds) [translation:ERROR] File "/home/olivier/workspace/talstai_ext/pypy-1.6-src/pypy/jit/metainterp/warmspot.py", line 199, in __init__ [translation:ERROR] self.codewriter.make_jitcodes(verbose=verbose) [translation:ERROR] File "/home/olivier/workspace/talstai_ext/pypy-1.6-src/pypy/jit/codewriter/codewriter.py", line 72, in make_jitcodes [translation:ERROR] self.transform_graph_to_jitcode(graph, jitcode, verbose) [translation:ERROR] File "/home/olivier/workspace/talstai_ext/pypy-1.6-src/pypy/jit/codewriter/codewriter.py", line 61, in transform_graph_to_jitcode [translation:ERROR] self.assembler.assemble(ssarepr, jitcode) [translation:ERROR] File "/home/olivier/workspace/talstai_ext/pypy-1.6-src/pypy/jit/codewriter/assembler.py", line 35, in assemble [translation:ERROR] self.write_insn(insn) [translation:ERROR] File "/home/olivier/workspace/talstai_ext/pypy-1.6-src/pypy/jit/codewriter/assembler.py", line 135, in write_insn [translation:ERROR] is_short = self.emit_const(x, kind, allow_short=True) [translation:ERROR] File "/home/olivier/workspace/talstai_ext/pypy-1.6-src/pypy/jit/codewriter/assembler.py", line 108, in emit_const [translation:ERROR] self.code.append(chr(self.constants_dict[key])) [translation:ERROR] ValueError: character code not in range(256) With this snippet of code : self.constants_dict[key] = 256 - len(constants) If len(constants) is 257, then self.constants_dict[key] is -1 and chr(-1) raise the ValueError. I attached a (really) stupid example to reproduce. When I browse pypy sources in rpython, I can't believe there is less than 256 constants of type 'ref'. What do you think ? Did I miss something ? Thanks ! Zariko.
#!/usr/bin/env python import sys from pypy.rlib.jit import JitDriver jitdriver = JitDriver(greens=['pc', 'opcode'], reds=['program']) def mainloop(program): pc = 0 while True: opcode = program[pc] jitdriver.jit_merge_point(pc=pc, opcode=opcode, program=program) if opcode == 0: raise Exception("Opcode not implemented : 0") elif opcode == 1: raise Exception("Opcode not implemented : 1") elif opcode == 2: raise Exception("Opcode not implemented : 2") elif opcode == 3: raise Exception("Opcode not implemented : 3") elif opcode == 4: raise Exception("Opcode not implemented : 4") elif opcode == 5: raise Exception("Opcode not implemented : 5") elif opcode == 6: raise Exception("Opcode not implemented : 6") elif opcode == 7: raise Exception("Opcode not implemented : 7") elif opcode == 8: raise Exception("Opcode not implemented : 8") elif opcode == 9: raise Exception("Opcode not implemented : 9") elif opcode == 10: raise Exception("Opcode not implemented : 10") elif opcode == 11: raise Exception("Opcode not implemented : 11") elif opcode == 12: raise Exception("Opcode not implemented : 12") elif opcode == 13: raise Exception("Opcode not implemented : 13") elif opcode == 14: raise Exception("Opcode not implemented : 14") elif opcode == 15: raise Exception("Opcode not implemented : 15") elif opcode == 16: raise Exception("Opcode not implemented : 16") elif opcode == 17: raise Exception("Opcode not implemented : 17") elif opcode == 18: raise Exception("Opcode not implemented : 18") elif opcode == 19: raise Exception("Opcode not implemented : 19") elif opcode == 20: raise Exception("Opcode not implemented : 20") elif opcode == 21: raise Exception("Opcode not implemented : 21") elif opcode == 22: raise Exception("Opcode not implemented : 22") elif opcode == 23: raise Exception("Opcode not implemented : 23") elif opcode == 24: raise Exception("Opcode not implemented : 24") elif opcode == 25: raise Exception("Opcode not implemented : 25") elif opcode == 26: raise Exception("Opcode not implemented : 26") elif opcode == 27: raise Exception("Opcode not implemented : 27") elif opcode == 28: raise Exception("Opcode not implemented : 28") elif opcode == 29: raise Exception("Opcode not implemented : 29") elif opcode == 30: raise Exception("Opcode not implemented : 30") elif opcode == 31: raise Exception("Opcode not implemented : 31") elif opcode == 32: raise Exception("Opcode not implemented : 32") elif opcode == 33: raise Exception("Opcode not implemented : 33") elif opcode == 34: raise Exception("Opcode not implemented : 34") elif opcode == 35: raise Exception("Opcode not implemented : 35") elif opcode == 36: raise Exception("Opcode not implemented : 36") elif opcode == 37: raise Exception("Opcode not implemented : 37") elif opcode == 38: raise Exception("Opcode not implemented : 38") elif opcode == 39: raise Exception("Opcode not implemented : 39") elif opcode == 40: raise Exception("Opcode not implemented : 40") elif opcode == 41: raise Exception("Opcode not implemented : 41") elif opcode == 42: raise Exception("Opcode not implemented : 42") elif opcode == 43: raise Exception("Opcode not implemented : 43") elif opcode == 44: raise Exception("Opcode not implemented : 44") elif opcode == 45: raise Exception("Opcode not implemented : 45") elif opcode == 46: raise Exception("Opcode not implemented : 46") elif opcode == 47: raise Exception("Opcode not implemented : 47") elif opcode == 48: raise Exception("Opcode not implemented : 48") elif opcode == 49: raise Exception("Opcode not implemented : 49") elif opcode == 50: raise Exception("Opcode not implemented : 50") elif opcode == 51: raise Exception("Opcode not implemented : 51") elif opcode == 52: raise Exception("Opcode not implemented : 52") elif opcode == 53: raise Exception("Opcode not implemented : 53") elif opcode == 54: raise Exception("Opcode not implemented : 54") elif opcode == 55: raise Exception("Opcode not implemented : 55") elif opcode == 56: raise Exception("Opcode not implemented : 56") elif opcode == 57: raise Exception("Opcode not implemented : 57") elif opcode == 58: raise Exception("Opcode not implemented : 58") elif opcode == 59: raise Exception("Opcode not implemented : 59") elif opcode == 60: raise Exception("Opcode not implemented : 60") elif opcode == 61: raise Exception("Opcode not implemented : 61") elif opcode == 62: raise Exception("Opcode not implemented : 62") elif opcode == 63: raise Exception("Opcode not implemented : 63") elif opcode == 64: raise Exception("Opcode not implemented : 64") elif opcode == 65: raise Exception("Opcode not implemented : 65") elif opcode == 66: raise Exception("Opcode not implemented : 66") elif opcode == 67: raise Exception("Opcode not implemented : 67") elif opcode == 68: raise Exception("Opcode not implemented : 68") elif opcode == 69: raise Exception("Opcode not implemented : 69") elif opcode == 70: raise Exception("Opcode not implemented : 70") elif opcode == 71: raise Exception("Opcode not implemented : 71") elif opcode == 72: raise Exception("Opcode not implemented : 72") elif opcode == 73: raise Exception("Opcode not implemented : 73") elif opcode == 74: raise Exception("Opcode not implemented : 74") elif opcode == 75: raise Exception("Opcode not implemented : 75") elif opcode == 76: raise Exception("Opcode not implemented : 76") elif opcode == 77: raise Exception("Opcode not implemented : 77") elif opcode == 78: raise Exception("Opcode not implemented : 78") elif opcode == 79: raise Exception("Opcode not implemented : 79") elif opcode == 80: raise Exception("Opcode not implemented : 80") elif opcode == 81: raise Exception("Opcode not implemented : 81") elif opcode == 82: raise Exception("Opcode not implemented : 82") elif opcode == 83: raise Exception("Opcode not implemented : 83") elif opcode == 84: raise Exception("Opcode not implemented : 84") elif opcode == 85: raise Exception("Opcode not implemented : 85") elif opcode == 86: raise Exception("Opcode not implemented : 86") elif opcode == 87: raise Exception("Opcode not implemented : 87") elif opcode == 88: raise Exception("Opcode not implemented : 88") elif opcode == 89: raise Exception("Opcode not implemented : 89") elif opcode == 90: raise Exception("Opcode not implemented : 90") elif opcode == 91: raise Exception("Opcode not implemented : 91") elif opcode == 92: raise Exception("Opcode not implemented : 92") elif opcode == 93: raise Exception("Opcode not implemented : 93") elif opcode == 94: raise Exception("Opcode not implemented : 94") elif opcode == 95: raise Exception("Opcode not implemented : 95") elif opcode == 96: raise Exception("Opcode not implemented : 96") elif opcode == 97: raise Exception("Opcode not implemented : 97") elif opcode == 98: raise Exception("Opcode not implemented : 98") elif opcode == 99: raise Exception("Opcode not implemented : 99") elif opcode == 100: raise Exception("Opcode not implemented : 100") elif opcode == 101: raise Exception("Opcode not implemented : 101") elif opcode == 102: raise Exception("Opcode not implemented : 102") elif opcode == 103: raise Exception("Opcode not implemented : 103") elif opcode == 104: raise Exception("Opcode not implemented : 104") elif opcode == 105: raise Exception("Opcode not implemented : 105") elif opcode == 106: raise Exception("Opcode not implemented : 106") elif opcode == 107: raise Exception("Opcode not implemented : 107") elif opcode == 108: raise Exception("Opcode not implemented : 108") elif opcode == 109: raise Exception("Opcode not implemented : 109") elif opcode == 110: raise Exception("Opcode not implemented : 110") elif opcode == 111: raise Exception("Opcode not implemented : 111") elif opcode == 112: raise Exception("Opcode not implemented : 112") elif opcode == 113: raise Exception("Opcode not implemented : 113") elif opcode == 114: raise Exception("Opcode not implemented : 114") elif opcode == 115: raise Exception("Opcode not implemented : 115") elif opcode == 116: raise Exception("Opcode not implemented : 116") elif opcode == 117: raise Exception("Opcode not implemented : 117") elif opcode == 118: raise Exception("Opcode not implemented : 118") elif opcode == 119: raise Exception("Opcode not implemented : 119") elif opcode == 120: raise Exception("Opcode not implemented : 120") elif opcode == 121: raise Exception("Opcode not implemented : 121") elif opcode == 122: raise Exception("Opcode not implemented : 122") elif opcode == 123: raise Exception("Opcode not implemented : 123") elif opcode == 124: raise Exception("Opcode not implemented : 124") elif opcode == 125: raise Exception("Opcode not implemented : 125") elif opcode == 126: raise Exception("Opcode not implemented : 126") elif opcode == 127: raise Exception("Opcode not implemented : 127") elif opcode == 128: raise Exception("Opcode not implemented : 128") elif opcode == 129: raise Exception("Opcode not implemented : 129") elif opcode == 130: raise Exception("Opcode not implemented : 130") elif opcode == 131: raise Exception("Opcode not implemented : 131") elif opcode == 132: raise Exception("Opcode not implemented : 132") elif opcode == 133: raise Exception("Opcode not implemented : 133") elif opcode == 134: raise Exception("Opcode not implemented : 134") elif opcode == 135: raise Exception("Opcode not implemented : 135") elif opcode == 136: raise Exception("Opcode not implemented : 136") elif opcode == 137: raise Exception("Opcode not implemented : 137") elif opcode == 138: raise Exception("Opcode not implemented : 138") elif opcode == 139: raise Exception("Opcode not implemented : 139") elif opcode == 140: raise Exception("Opcode not implemented : 140") elif opcode == 141: raise Exception("Opcode not implemented : 141") elif opcode == 142: raise Exception("Opcode not implemented : 142") elif opcode == 143: raise Exception("Opcode not implemented : 143") elif opcode == 144: raise Exception("Opcode not implemented : 144") elif opcode == 145: raise Exception("Opcode not implemented : 145") elif opcode == 146: raise Exception("Opcode not implemented : 146") elif opcode == 147: raise Exception("Opcode not implemented : 147") elif opcode == 148: raise Exception("Opcode not implemented : 148") elif opcode == 149: raise Exception("Opcode not implemented : 149") elif opcode == 150: raise Exception("Opcode not implemented : 150") elif opcode == 151: raise Exception("Opcode not implemented : 151") elif opcode == 152: raise Exception("Opcode not implemented : 152") elif opcode == 153: raise Exception("Opcode not implemented : 153") elif opcode == 154: raise Exception("Opcode not implemented : 154") elif opcode == 155: raise Exception("Opcode not implemented : 155") elif opcode == 156: raise Exception("Opcode not implemented : 156") elif opcode == 157: raise Exception("Opcode not implemented : 157") elif opcode == 158: raise Exception("Opcode not implemented : 158") elif opcode == 159: raise Exception("Opcode not implemented : 159") elif opcode == 160: raise Exception("Opcode not implemented : 160") elif opcode == 161: raise Exception("Opcode not implemented : 161") elif opcode == 162: raise Exception("Opcode not implemented : 162") elif opcode == 163: raise Exception("Opcode not implemented : 163") elif opcode == 164: raise Exception("Opcode not implemented : 164") elif opcode == 165: raise Exception("Opcode not implemented : 165") elif opcode == 166: raise Exception("Opcode not implemented : 166") elif opcode == 167: raise Exception("Opcode not implemented : 167") elif opcode == 168: raise Exception("Opcode not implemented : 168") elif opcode == 169: raise Exception("Opcode not implemented : 169") elif opcode == 170: raise Exception("Opcode not implemented : 170") elif opcode == 171: raise Exception("Opcode not implemented : 171") elif opcode == 172: raise Exception("Opcode not implemented : 172") elif opcode == 173: raise Exception("Opcode not implemented : 173") elif opcode == 174: raise Exception("Opcode not implemented : 174") elif opcode == 175: raise Exception("Opcode not implemented : 175") elif opcode == 176: raise Exception("Opcode not implemented : 176") elif opcode == 177: raise Exception("Opcode not implemented : 177") elif opcode == 178: raise Exception("Opcode not implemented : 178") elif opcode == 179: raise Exception("Opcode not implemented : 179") elif opcode == 180: raise Exception("Opcode not implemented : 180") elif opcode == 181: raise Exception("Opcode not implemented : 181") elif opcode == 182: raise Exception("Opcode not implemented : 182") elif opcode == 183: raise Exception("Opcode not implemented : 183") elif opcode == 184: raise Exception("Opcode not implemented : 184") elif opcode == 185: raise Exception("Opcode not implemented : 185") elif opcode == 186: raise Exception("Opcode not implemented : 186") elif opcode == 187: raise Exception("Opcode not implemented : 187") elif opcode == 188: raise Exception("Opcode not implemented : 188") elif opcode == 189: raise Exception("Opcode not implemented : 189") elif opcode == 190: raise Exception("Opcode not implemented : 190") elif opcode == 191: raise Exception("Opcode not implemented : 191") elif opcode == 192: raise Exception("Opcode not implemented : 192") elif opcode == 193: raise Exception("Opcode not implemented : 193") elif opcode == 194: raise Exception("Opcode not implemented : 194") elif opcode == 195: raise Exception("Opcode not implemented : 195") elif opcode == 196: raise Exception("Opcode not implemented : 196") elif opcode == 197: raise Exception("Opcode not implemented : 197") elif opcode == 198: raise Exception("Opcode not implemented : 198") elif opcode == 199: raise Exception("Opcode not implemented : 199") elif opcode == 200: raise Exception("Opcode not implemented : 200") elif opcode == 201: raise Exception("Opcode not implemented : 201") elif opcode == 202: raise Exception("Opcode not implemented : 202") elif opcode == 203: raise Exception("Opcode not implemented : 203") elif opcode == 204: raise Exception("Opcode not implemented : 204") elif opcode == 205: raise Exception("Opcode not implemented : 205") elif opcode == 206: raise Exception("Opcode not implemented : 206") elif opcode == 207: raise Exception("Opcode not implemented : 207") elif opcode == 208: raise Exception("Opcode not implemented : 208") elif opcode == 209: raise Exception("Opcode not implemented : 209") elif opcode == 210: raise Exception("Opcode not implemented : 210") elif opcode == 211: raise Exception("Opcode not implemented : 211") elif opcode == 212: raise Exception("Opcode not implemented : 212") elif opcode == 213: raise Exception("Opcode not implemented : 213") elif opcode == 214: raise Exception("Opcode not implemented : 214") elif opcode == 215: raise Exception("Opcode not implemented : 215") elif opcode == 216: raise Exception("Opcode not implemented : 216") elif opcode == 217: raise Exception("Opcode not implemented : 217") elif opcode == 218: raise Exception("Opcode not implemented : 218") elif opcode == 219: raise Exception("Opcode not implemented : 219") elif opcode == 220: raise Exception("Opcode not implemented : 220") elif opcode == 221: raise Exception("Opcode not implemented : 221") elif opcode == 222: raise Exception("Opcode not implemented : 222") elif opcode == 223: raise Exception("Opcode not implemented : 223") elif opcode == 224: raise Exception("Opcode not implemented : 224") elif opcode == 225: raise Exception("Opcode not implemented : 225") elif opcode == 226: raise Exception("Opcode not implemented : 226") elif opcode == 227: raise Exception("Opcode not implemented : 227") elif opcode == 228: raise Exception("Opcode not implemented : 228") elif opcode == 229: raise Exception("Opcode not implemented : 229") elif opcode == 230: raise Exception("Opcode not implemented : 230") elif opcode == 231: raise Exception("Opcode not implemented : 231") elif opcode == 232: raise Exception("Opcode not implemented : 232") elif opcode == 233: raise Exception("Opcode not implemented : 233") elif opcode == 234: raise Exception("Opcode not implemented : 234") elif opcode == 235: raise Exception("Opcode not implemented : 235") elif opcode == 236: raise Exception("Opcode not implemented : 236") elif opcode == 237: raise Exception("Opcode not implemented : 237") elif opcode == 238: raise Exception("Opcode not implemented : 238") elif opcode == 239: raise Exception("Opcode not implemented : 239") elif opcode == 240: raise Exception("Opcode not implemented : 240") elif opcode == 241: raise Exception("Opcode not implemented : 241") elif opcode == 242: raise Exception("Opcode not implemented : 242") elif opcode == 243: raise Exception("Opcode not implemented : 243") elif opcode == 244: raise Exception("Opcode not implemented : 244") elif opcode == 245: raise Exception("Opcode not implemented : 245") elif opcode == 246: raise Exception("Opcode not implemented : 246") elif opcode == 247: raise Exception("Opcode not implemented : 247") elif opcode == 248: raise Exception("Opcode not implemented : 248") elif opcode == 249: raise Exception("Opcode not implemented : 249") elif opcode == 250: raise Exception("Opcode not implemented : 250") elif opcode == 251: raise Exception("Opcode not implemented : 251") elif opcode == 252: raise Exception("Opcode not implemented : 252") elif opcode == 253: raise Exception("Opcode not implemented : 253") elif opcode == 254: raise Exception("Opcode not implemented : 254") elif opcode == 255: raise Exception("Opcode not implemented : 255") elif opcode == 256: raise Exception("Opcode not implemented : 256") elif opcode == 257: raise Exception("Opcode not implemented : 257") elif opcode == 258: raise Exception("Opcode not implemented : 258") elif opcode == 259: raise Exception("Opcode not implemented : 259") elif opcode == 260: raise Exception("Opcode not implemented : 260") elif opcode == 261: raise Exception("Opcode not implemented : 261") elif opcode == 262: raise Exception("Opcode not implemented : 262") elif opcode == 263: raise Exception("Opcode not implemented : 263") elif opcode == 264: raise Exception("Opcode not implemented : 264") elif opcode == 999: return 0 pc += 1 def run(): program = [] for i in range(0, 1000): program.append(i) return mainloop(program) def entry_point(argv): return run() def target(*args): return entry_point, None def jitpolicy(driver): from pypy.jit.codewriter.policy import JitPolicy return JitPolicy() if __name__ == "__main__": entry_point(sys.argv)
_______________________________________________ pypy-dev mailing list pypy-dev@python.org http://mail.python.org/mailman/listinfo/pypy-dev