[pypy-svn] r47987 - in pypy/dist/pypy/lang/smalltalk: . tool
tverwaes at codespeak.net
tverwaes at codespeak.net
Thu Oct 25 21:19:05 CEST 2007
Author: tverwaes
Date: Thu Oct 25 21:19:03 2007
New Revision: 47987
Modified:
pypy/dist/pypy/lang/smalltalk/interpreter.py
pypy/dist/pypy/lang/smalltalk/model.py
pypy/dist/pypy/lang/smalltalk/squeakimage.py
pypy/dist/pypy/lang/smalltalk/tool/analyseimage.py
Log:
fixed supersends coming from compiledmethods loaded from image
(fetching compiledin from assoc at the end of the literals)
Modified: pypy/dist/pypy/lang/smalltalk/interpreter.py
==============================================================================
--- pypy/dist/pypy/lang/smalltalk/interpreter.py (original)
+++ pypy/dist/pypy/lang/smalltalk/interpreter.py Thu Oct 25 21:19:03 2007
@@ -121,7 +121,7 @@
receiver, receiver.shadow_of_my_class())
def _sendSuperSelector(self, selector, argcount, interp):
- s_compiledin = self.w_method().w_compiledin.as_class_get_shadow()
+ s_compiledin = self.w_method().compiledin().as_class_get_shadow()
self._sendSelector(selector, argcount, interp, self.w_receiver,
s_compiledin.s_superclass)
Modified: pypy/dist/pypy/lang/smalltalk/model.py
==============================================================================
--- pypy/dist/pypy/lang/smalltalk/model.py (original)
+++ pypy/dist/pypy/lang/smalltalk/model.py Thu Oct 25 21:19:03 2007
@@ -205,6 +205,7 @@
The trailer has two variant formats. In the first variant, the last byte is at least 252 and the last four bytes represent a source pointer into one of the sources files (see #sourcePointer). In the second variant, the last byte is less than 252, and the last several bytes are a compressed version of the names of the method's temporary variables. The number of bytes used for this purpose is the value of the last byte in the method.
"""
+
def __init__(self, literalsize, bytes, argsize=0,
tempsize=0, primitive=0, w_compiledin=None):
self.literals = [None] * literalsize
@@ -214,6 +215,13 @@
self.tempsize = tempsize
self.primitive = primitive
+ def compiledin(self):
+ if self.w_compiledin == None:
+ # Last of the literals is an association with compiledin
+ # as a class
+ self.w_compiledin = self.literals[-1].fetch(constants.ASSOCIATION_VALUE_INDEX)
+ return self.w_compiledin
+
def getclass(self):
from pypy.lang.smalltalk.classtable import w_CompiledMethod
return w_CompiledMethod
Modified: pypy/dist/pypy/lang/smalltalk/squeakimage.py
==============================================================================
--- pypy/dist/pypy/lang/smalltalk/squeakimage.py (original)
+++ pypy/dist/pypy/lang/smalltalk/squeakimage.py Thu Oct 25 21:19:03 2007
@@ -386,8 +386,6 @@
primitive = primitive)
w_compiledmethod.literals = literals
-
-
class ImageChunk(object):
def __init__(self, size, format, classid, hash12):
self.size = size
Modified: pypy/dist/pypy/lang/smalltalk/tool/analyseimage.py
==============================================================================
--- pypy/dist/pypy/lang/smalltalk/tool/analyseimage.py (original)
+++ pypy/dist/pypy/lang/smalltalk/tool/analyseimage.py Thu Oct 25 21:19:03 2007
@@ -7,7 +7,7 @@
from pypy.lang.smalltalk import classtable
from pypy.lang.smalltalk import interpreter
-mini_image = py.magic.autopath().dirpath().dirpath().join('tool/squeak3.9.image')
+mini_image = py.magic.autopath().dirpath().dirpath().join('mini.image')
def get_miniimage():
return squeakimage.ImageReader(squeakimage.Stream(mini_image.open()))
@@ -27,85 +27,43 @@
print each.shadow_of_my_class()
print each.as_string()
-def testCompiledMethods():
+def tinyBenchmarks():
image = create_squeakimage()
- amethod = None
-
- w_smallint_class = image.special(constants.SO_SMALLINTEGER_CLASS)
-
interp = interpreter.Interpreter()
- amethod = w_smallint_class.lookup("abs")
- # First literal of the abs method is
- # a real smalltalk int
- w_frame = amethod.create_frame(model.W_SmallInteger(3), [])
- interp.activeContext = w_frame
-
- print amethod
-
- while True:
- try:
- interp.step()
- print interp.activeContext.stack
- except interpreter.ReturnFromTopLevel, e:
- return e.object
-
-def testDoesNotUnderstand():
- image = create_squeakimage()
- amethod = None
-
- w_doesnot = image.special(constants.SO_DOES_NOT_UNDERSTAND)
- w_object = objtable.wrap_int(3)
- w_message_class = image.special(constants.SO_MESSAGE_CLASS)
- s_message_class = w_message_class.as_class_get_shadow()
-
- #Build message argument
- w_message = s_message_class.new(1)
- w_message.store(constants.MESSAGE_SELECTOR_INDEX, objtable.wrap_string("zork"))
- w_aarray = classtable.w_Array.as_class_get_shadow().new(0)
- w_message.store(constants.MESSAGE_ARGUMENTS_INDEX, w_aarray)
- if s_message_class.instsize() > constants.MESSAGE_LOOKUP_CLASS_INDEX:
- w_message.store(constants.MESSAGE_LOOKUP_CLASS_INDEX, w_object.getclass())
+ w_object = model.W_SmallInteger(0)
+ # Should get this from w_object
+ w_smallint_class = image.special(constants.SO_SMALLINTEGER_CLASS)
s_class = w_object.shadow_of_my_class()
- w_method = s_class.lookup(w_doesnot)
-
- interp = interpreter.Interpreter()
+ w_method = s_class.lookup("tinyBenchmarks")
- # First literal of the abs method is
- # a real smalltalk int
- w_frame = w_method.create_frame(w_object, [w_message])
- print "WFRAME: %r" % (w_frame,)
+ assert w_method
+ w_frame = w_method.create_frame(w_object, [])
interp.w_active_context = w_frame
print w_method
+ print "Going to execute %d toplevel bytecodes" % (len(w_method.bytes),)
+ counter = 0
while True:
try:
- print "Stackbefore: %r" % (interp.w_active_context.stack,)
interp.step()
- print "Stackafter: %r" % (interp.w_active_context.stack,)
+ print interp.w_active_context.stack
+ if interp.w_active_context == w_frame:
+ counter += 1
+ print "Executing toplevel bytecode nr: %d of %d" % (counter, len(w_method.bytes))
except interpreter.ReturnFromTopLevel, e:
- return e.object
+ assert e.object.value == abs(int)
+ return
-def testSelector():
- image = create_squeakimage()
- w_doesnot = image.special(constants.SO_DOES_NOT_UNDERSTAND)
- assert repr(w_doesnot.shadow_of_my_class()) == "<ClassShadow Symbol>"
- print w_doesnot.getclass().fetch(constants.CLASS_METHODDICT_INDEX).shadow_of_my_class().instance_kind
- print w_doesnot.getclass().fetch(constants.CLASS_METHODDICT_INDEX).shadow_of_my_class().instance_size
- print
- print w_doesnot.getclass().fetch(constants.CLASS_METHODDICT_INDEX)._vars
- print
- print w_doesnot.getclass().fetch(constants.CLASS_METHODDICT_INDEX)._vars[constants.METHODDICT_NAMES_INDEX:]
- print
- print w_doesnot.getclass().fetch(constants.CLASS_METHODDICT_INDEX)._vars[constants.METHODDICT_VALUES_INDEX]._vars
def test_do():
#testSelector()
- printStringsInImage()
+ #printStringsInImage()
#testDoesNotUnderstand()
+ tinyBenchmarks()
if __name__ == '__main__':
test_do()
More information about the Pypy-commit
mailing list