[pypy-commit] pypy jitlog-32bit: backward incompatible change (fine, because jitlog is not officially released yet) adds machine to the header of the file
plan_rich
pypy.commits at gmail.com
Wed Jul 27 07:22:52 EDT 2016
Author: Richard Plangger <planrichi at gmail.com>
Branch: jitlog-32bit
Changeset: r85873:66d565a40b09
Date: 2016-07-27 13:22 +0200
http://bitbucket.org/pypy/pypy/changeset/66d565a40b09/
Log: backward incompatible change (fine, because jitlog is not officially
released yet) adds machine to the header of the file adapt test to
check if resops are encoded properly
diff --git a/pypy/module/_jitlog/test/test__jitlog.py b/pypy/module/_jitlog/test/test__jitlog.py
--- a/pypy/module/_jitlog/test/test__jitlog.py
+++ b/pypy/module/_jitlog/test/test__jitlog.py
@@ -1,8 +1,9 @@
-
import sys
+import platform
from rpython.tool.udir import udir
from pypy.tool.pytest.objspace import gettestobjspace
from rpython.rlib.rjitlog import rjitlog as jl
+from rpython.jit.metainterp.resoperation import opname
class AppTestJitLog(object):
spaceconfig = {'usemodules': ['_jitlog', 'struct']}
@@ -12,6 +13,11 @@
cls.w_mark_header = cls.space.wrap(jl.MARK_JITLOG_HEADER)
cls.w_version = cls.space.wrap(jl.JITLOG_VERSION_16BIT_LE)
cls.w_is_32bit = cls.space.wrap(sys.maxint == 2**31-1)
+ cls.w_machine = cls.space.wrap(platform.machine())
+ cls.w_resops = cls.space.newdict()
+ space = cls.space
+ for key, value in opname.items():
+ space.setitem(cls.w_resops, space.wrap(key), space.wrap(value))
def test_enable(self):
import _jitlog, struct
@@ -25,8 +31,22 @@
assert fd.read(1) == self.mark_header
assert fd.read(2) == self.version
assert bool(ord(fd.read(1))) == self.is_32bit
+ strcount, = struct.unpack('<i', fd.read(4))
+ machine = fd.read(strcount)
+ assert machine == self.machine
+ # resoperations
count, = struct.unpack('<h', fd.read(2))
+ opnames = set()
for i in range(count):
opnum = struct.unpack('<h', fd.read(2))
- strcount = struct.unpack('<i', fd.read(4))
- fd.read(strcount)
+ strcount, = struct.unpack('<i', fd.read(4))
+ opname = fd.read(strcount)
+ opnames.append((opnum, opname))
+
+ for opnum, opname in opnames:
+ # must be known resoperation
+ assert opnum in self.resops
+ # the name must equal
+ assert self.resops[opnum] == opname
+
+
diff --git a/rpython/rlib/rjitlog/rjitlog.py b/rpython/rlib/rjitlog/rjitlog.py
--- a/rpython/rlib/rjitlog/rjitlog.py
+++ b/rpython/rlib/rjitlog/rjitlog.py
@@ -3,6 +3,7 @@
import weakref
import struct
import os
+import platform
from rpython.rlib import jit
from rpython.tool.udir import udir
from rpython.tool.version import rpythonroot
@@ -282,14 +283,16 @@
IS_32_BIT = sys.maxint == 2**31-1
+MACHINE_NAME = platform.machine()
+
def assemble_header():
version = JITLOG_VERSION_16BIT_LE
count = len(resoperations.opname)
is_32bit = chr(0x1)
if not IS_32_BIT:
is_32bit = chr(0x0)
- content = [version, is_32bit, MARK_RESOP_META,
- encode_le_16bit(count)]
+ content = [version, is_32bit, encode_str(MACHINE_NAME),
+ MARK_RESOP_META, encode_le_16bit(count)]
for opnum, opname in resoperations.opname.items():
content.append(encode_le_16bit(opnum))
content.append(encode_str(opname.lower()))
More information about the pypy-commit
mailing list