Author: Carl Friedrich Bolz-Tereick <cfb...@gmx.de> Branch: py3.6-wordcode Changeset: r94579:4b61cd94d616 Date: 2018-05-14 14:54 +0200 http://bitbucket.org/pypy/pypy/changeset/4b61cd94d616/
Log: start adapting the interpreter to wordcode diff --git a/pypy/interpreter/generator.py b/pypy/interpreter/generator.py --- a/pypy/interpreter/generator.py +++ b/pypy/interpreter/generator.py @@ -166,16 +166,20 @@ # Normal case: the call above raises Yield. # We reach this point if the iterable is exhausted. last_instr = jit.promote(frame.last_instr) + assert last_instr & 1 == 0 assert last_instr >= 0 - return r_uint(last_instr + 1) + return r_uint(last_instr + 2) if isinstance(w_arg_or_err, SApplicationException): return frame.handle_generator_error(w_arg_or_err.operr) last_instr = jit.promote(frame.last_instr) if last_instr != -1: + assert last_instr & 1 == 0 frame.pushvalue(w_arg_or_err) - return r_uint(last_instr + 1) + return r_uint(last_instr + 2) + else: + return r_uint(0) def next_yield_from(self, frame, w_yf, w_inputvalue_or_err): """Fetch the next item of the current 'yield from', push it on diff --git a/pypy/interpreter/pyframe.py b/pypy/interpreter/pyframe.py --- a/pypy/interpreter/pyframe.py +++ b/pypy/interpreter/pyframe.py @@ -774,6 +774,7 @@ block.cleanupstack(self) self.getorcreatedebug().f_lineno = new_lineno + assert new_lasti & 1 == 0 self.last_instr = new_lasti def get_last_lineno(self): diff --git a/pypy/interpreter/pyopcode.py b/pypy/interpreter/pyopcode.py --- a/pypy/interpreter/pyopcode.py +++ b/pypy/interpreter/pyopcode.py @@ -62,6 +62,7 @@ co_code = pycode.co_code try: while True: + assert next_instr & 1 == 0 next_instr = self.handle_bytecode(co_code, next_instr, ec) except ExitFrame: return self.popvalue() @@ -152,22 +153,17 @@ @jit.unroll_safe def dispatch_bytecode(self, co_code, next_instr, ec): while True: + assert next_instr & 1 == 0 self.last_instr = intmask(next_instr) if jit.we_are_jitted(): ec.bytecode_only_trace(self) else: ec.bytecode_trace(self) next_instr = r_uint(self.last_instr) + assert next_instr & 1 == 0 opcode = ord(co_code[next_instr]) - next_instr += 1 - - if opcode >= HAVE_ARGUMENT: - lo = ord(co_code[next_instr]) - hi = ord(co_code[next_instr+1]) - next_instr += 2 - oparg = (hi * 256) | lo - else: - oparg = 0 + oparg = ord(co_code[next_instr + 1]) + next_instr += 2 # note: the structure of the code here is such that it makes # (after translation) a big "if/elif" chain, which is then @@ -175,12 +171,11 @@ while opcode == opcodedesc.EXTENDED_ARG.index: opcode = ord(co_code[next_instr]) + arg = ord(co_code[next_instr + 1]) if opcode < HAVE_ARGUMENT: raise BytecodeCorruption - lo = ord(co_code[next_instr+1]) - hi = ord(co_code[next_instr+2]) - next_instr += 3 - oparg = (oparg * 65536) | (hi * 256) | lo + next_instr += 2 + oparg = (oparg << 8) | arg if opcode == opcodedesc.RETURN_VALUE.index: w_returnvalue = self.popvalue() _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit