[pypy-svn] r31934 - in pypy/dist/pypy: bin interpreter objspace/std objspace/std/test
benyoung at codespeak.net
benyoung at codespeak.net
Fri Sep 1 17:00:54 CEST 2006
Author: benyoung
Date: Fri Sep 1 17:00:40 2006
New Revision: 31934
Modified:
pypy/dist/pypy/bin/py.py
pypy/dist/pypy/interpreter/baseobjspace.py
pypy/dist/pypy/interpreter/pyopcode.py
pypy/dist/pypy/objspace/std/dictmultiobject.py
pypy/dist/pypy/objspace/std/test/test_dictmultiobject.py
Log:
Update bytecode reporting. Should now work when compiled as well
Modified: pypy/dist/pypy/bin/py.py
==============================================================================
--- pypy/dist/pypy/bin/py.py (original)
+++ pypy/dist/pypy/bin/py.py Fri Sep 1 17:00:40 2006
@@ -145,13 +145,6 @@
space.finish()
main.run_toplevel(space, doit, verbose=Options.verbose)
- if space.config.objspace.logbytecodes:
- import dis
- counts = space.bytecodecounts.items()
- counts.sort(key = (lambda x: (-x[1], x[0])))
- print [(dis.opname[opcode], count) for opcode, count in counts]
- print [opcode for opcode, count in counts]
-
return exit_status
##def main_(argv=None):
Modified: pypy/dist/pypy/interpreter/baseobjspace.py
==============================================================================
--- pypy/dist/pypy/interpreter/baseobjspace.py (original)
+++ pypy/dist/pypy/interpreter/baseobjspace.py Fri Sep 1 17:00:40 2006
@@ -166,7 +166,17 @@
if self.config.objspace.std.withdictmeasurement:
from pypy.objspace.std.dictmultiobject import report
report()
+ if self.config.objspace.logbytecodes:
+ self.reportbytecodecounts()
+ def reportbytecodecounts(self):
+ os.write(2, "Starting bytecode report.\n")
+ fd = os.open('bytecode.txt', os.O_CREAT|os.O_WRONLY|os.O_TRUNC, 0644)
+ for opcode, count in self.bytecodecounts.items():
+ os.write(fd, str(opcode) + ", " + str(count) + "\n")
+ os.close(fd)
+ os.write(2, "Reporting done.\n")
+
def __repr__(self):
try:
return self._this_space_repr_
Modified: pypy/dist/pypy/interpreter/pyopcode.py
==============================================================================
--- pypy/dist/pypy/interpreter/pyopcode.py (original)
+++ pypy/dist/pypy/interpreter/pyopcode.py Fri Sep 1 17:00:40 2006
@@ -417,7 +417,7 @@
def STORE_NAME(f, varindex):
w_varname = f.getname_w(varindex)
w_newvalue = f.valuestack.pop()
- f.space.setitem(f.w_locals, w_varname, w_newvalue)
+ f.space.set_str_keyed_item(f.w_locals, w_varname, w_newvalue)
def DELETE_NAME(f, varindex):
w_varname = f.getname_w(varindex)
@@ -456,7 +456,7 @@
def STORE_GLOBAL(f, nameindex):
w_varname = f.getname_w(nameindex)
w_newvalue = f.valuestack.pop()
- f.space.setitem(f.w_globals, w_varname, w_newvalue)
+ f.space.set_str_keyed_item(f.w_globals, w_varname, w_newvalue)
def DELETE_GLOBAL(f, nameindex):
w_varname = f.getname_w(nameindex)
@@ -535,25 +535,25 @@
def cmp_exc_match(f, w_1, w_2):
return f.space.newbool(f.space.exception_match(w_1, w_2))
- compare_dispatch_table = {
- 0: cmp_lt, # "<"
- 1: cmp_le, # "<="
- 2: cmp_eq, # "=="
- 3: cmp_ne, # "!="
- 4: cmp_gt, # ">"
- 5: cmp_ge, # ">="
- 6: cmp_in,
- 7: cmp_not_in,
- 8: cmp_is,
- 9: cmp_is_not,
- 10: cmp_exc_match,
- }
+ compare_dispatch_table = [
+ cmp_lt, # "<"
+ cmp_le, # "<="
+ cmp_eq, # "=="
+ cmp_ne, # "!="
+ cmp_gt, # ">"
+ cmp_ge, # ">="
+ cmp_in,
+ cmp_not_in,
+ cmp_is,
+ cmp_is_not,
+ cmp_exc_match,
+ ]
def COMPARE_OP(f, testnum):
w_2 = f.valuestack.pop()
w_1 = f.valuestack.pop()
try:
testfn = f.compare_dispatch_table[testnum]
- except KeyError:
+ except IndexError:
raise pyframe.BytecodeCorruption, "bad COMPARE_OP oparg"
w_result = testfn(f, w_1, w_2)
f.valuestack.push(w_result)
Modified: pypy/dist/pypy/objspace/std/dictmultiobject.py
==============================================================================
--- pypy/dist/pypy/objspace/std/dictmultiobject.py (original)
+++ pypy/dist/pypy/objspace/std/dictmultiobject.py Fri Sep 1 17:00:40 2006
@@ -577,13 +577,13 @@
def report():
if not DictInfo._dict_infos:
return
- os.write(2, "starting to report!\n")
+ os.write(2, "Starting multidict report.\n")
fd = os.open('dictinfo.txt', os.O_CREAT|os.O_WRONLY|os.O_TRUNC, 0644)
for info in DictInfo._dict_infos:
os.write(fd, '------------------\n')
_report_one(fd, info)
os.close(fd)
- os.write(2, "reporting done!\n")
+ os.write(2, "Reporting done.\n")
class W_DictMultiObject(W_Object):
from pypy.objspace.std.dicttype import dict_typedef as typedef
Modified: pypy/dist/pypy/objspace/std/test/test_dictmultiobject.py
==============================================================================
--- pypy/dist/pypy/objspace/std/test/test_dictmultiobject.py (original)
+++ pypy/dist/pypy/objspace/std/test/test_dictmultiobject.py Fri Sep 1 17:00:40 2006
@@ -52,8 +52,8 @@
self.space = FakeSpace()
self.space.DictObjectCls = W_DictMultiObject
self.space.emptydictimpl = EmptyDictImplementation(self.space)
- self.string = self.space.str_w("fish")
- self.string2 = self.space.str_w("fish2")
+ self.string = self.space.wrap("fish")
+ self.string2 = self.space.wrap("fish2")
self.impl = self.get_impl()
def get_impl(self):
@@ -66,7 +66,7 @@
assert self.impl.get(self.string) == 1000
def test_setitem_str(self):
- assert self.impl.setitem_str(self.string, 1000) is self.impl
+ assert self.impl.setitem_str(self.space.str_w(self.string), 1000) is self.impl
assert self.impl.length() == 1
assert self.impl.get(self.string) == 1000
More information about the Pypy-commit
mailing list