[pypy-commit] lang-smalltalk default: merge default

2013-05-03 Thread timfel
Author: Tim Felgentreff timfelgentr...@gmail.com
Branch: 
Changeset: r366:daca802d08e8
Date: 2013-05-03 13:36 +0200
http://bitbucket.org/pypy/lang-smalltalk/changeset/daca802d08e8/

Log:merge default

diff --git a/benchmarks.py b/benchmarks.py
--- a/benchmarks.py
+++ b/benchmarks.py
@@ -30,13 +30,19 @@
 benchmarks = output.split('\n')
 for s in benchmarks:
 if ';' in s:
-name, time = s.split(';')
-self.add(executable, name, time)
+results = s.split(';')
+if len(results) == 2:
+self.add(executable, *results)
+elif len(results) == 4:
+self.add(executble, *results)
 
-def add(self, executable, benchmark, result):
+def add(self, executable, benchmark, result, min=None, max=None):
 print Saving result %s for executable %s, benchmark %s % (
 result, executable, benchmark)
-data = self.build_data(executable, benchmark, result)
+if min is max is None:
+data = self.build_data(executable, benchmark, result)
+else:
+data = self.build_extended_data(executable, benchmark, result, 
min, max)
 params = urllib.urlencode(data)
 response = None
 print Saving result for executable %s, revision %s, benchmark %s % (
@@ -89,7 +95,13 @@
 # 'max': 4001.6, # Optional. Default is blank
 # 'min': 3995.1, # Optional. Default is blank
 # }
-
+def build_data_extended(self, executable, benchmark, result, min, max):
+return dict(self.build_data(executable, benchmark, result),
+**{
+'min': str(min),
+'max': str(max)
+}
+)
 
 class Archive(object):
 def __init__(self, filename, target, func):
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] lang-smalltalk default: merge default

2013-04-30 Thread timfel
Author: Tim Felgentreff timfelgentr...@gmail.com
Branch: 
Changeset: r361:d8c5396941c4
Date: 2013-04-30 16:45 +0200
http://bitbucket.org/pypy/lang-smalltalk/changeset/d8c5396941c4/

Log:merge default

diff --git a/benchmarks.py b/benchmarks.py
--- a/benchmarks.py
+++ b/benchmarks.py
@@ -194,6 +194,12 @@
 coglinux/squeak,
 cogurl,
 callback=update_image
+),
+Executable(
+stackvm,
+stackvm/bin/squeak,
+
http://squeakvm.org/unix/release/Squeak-4.10.2.2614-linux_i386.tar.gz;,
+callback=(lambda x: subprocess.Popen([mv, 
Squeak-4.10.2.2614-linux_i386, stackvm]).wait())
 )
 ],
 arguments=['-vm-display-X11', '-headless', images/%s.image % 
SqueakImage, '../benchmarks.st'],
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] lang-smalltalk default: merge default

2013-04-12 Thread timfel
Author: Tim Felgentreff timfelgentr...@gmail.com
Branch: 
Changeset: r261:6194910649dc
Date: 2013-04-12 10:28 +0200
http://bitbucket.org/pypy/lang-smalltalk/changeset/6194910649dc/

Log:merge default

diff --git a/BitBltSim.19.cs b/BitBltSim.19.cs
--- a/BitBltSim.19.cs
+++ b/BitBltSim.19.cs
@@ -94,7 +94,8 @@
simDestRaster _ destForm width - 1 // WordSize + 1.
sourceForm notNil
ifTrue: [simSourceBits _ sourceForm bits.
-   simSourceRaster _ sourceForm width - 1 // 
WordSize + 1].
+   simSourceRaster _ sourceForm width - 1 // 
WordSize + 1]
+   ifFalse: [simSourceRaster _ 0].
halftoneForm notNil
ifTrue: [simHalftoneBits _ halftoneForm bits].
simSkew _ (simSx - simDx) bitAnd: WordSize0.
@@ -118,45 +119,37 @@
 
 !BitBlt methodsFor: 'simulation' stamp: 'tfel 3/17/2013 16:17'!
 copyLoop
-   | prevWord thisWord skewWord mergeMask
- halftoneWord mergeWord |
-   1 to: simH do: here is the vertical loop
+   | prevWord thisWord skewWord mergeMask halftoneWord mergeWord 
noSimSkewMask |
+   noSimSkewMask _ simSkewMask bitInvert32.
+   1 to: simH do: 
[:i | 
-   (halftoneForm notNil)
-   ifTrue:
-   XXX Accessing simHalftoneBits with wrap-around 
... different from BlueBook
-   [halftoneWord _ simHalftoneBits at: (1 + (simDy 
\\ simHalftoneBits size)).
+   halftoneForm notNil
+   ifTrue: 
+   [halftoneWord _ simHalftoneBits at: 1 + (simDy 
\\ simHalftoneBits size).
simDy _ simDy + simVDir]
ifFalse: [halftoneWord _ AllOnes].
skewWord _ halftoneWord.
simPreload
-   ifTrue: [prevWord _ simSourceBits at: simSourceIndex + 
1.
-   load the 32bit shifter. TODO: check if 
this is WordSize dependent
-   simSourceIndex _ simSourceIndex + 
simHDir]
+   ifTrue: 
+   [prevWord _ simSourceBits at: simSourceIndex + 
1.
+   simSourceIndex _ simSourceIndex + simHDir]
ifFalse: [prevWord _ 0].
mergeMask _ simMask1.
-   1 to: simNWords do: here is the inner horizontal loop
-   [:word |
-   sourceForm notNil if source is used
-   ifTrue:
-   [prevWord _ prevWord bitAnd: 
simSkewMask.
-   XXX: Hack to work around 
out-of-bounds access
-   thisWord := simSourceBits at: 
(simSourceIndex \\ simSourceBits size) + 1.
-   
 pick up next word
-   skewWord _
-   prevWord bitOr: (thisWord 
bitAnd: simSkewMask bitInvert32).
-   prevWord _ thisWord.
-   Change from BB: bitAnd: AllOnes to 
stay in word bounds
-   skewWord _ ((skewWord bitShift: 
simSkew) bitAnd: AllOnes) bitOr:
-   
(skewWord bitShift: simSkew - WordSize)].
-   
WordSize-bit rotate
-   mergeWord _ self merge: (skewWord bitAnd: halftoneWord)
-   with: 
(simDestBits at: simDestIndex + 1).
-   simDestBits
-   at: simDestIndex + 1
-   put: ((mergeMask bitAnd: mergeWord)
-   bitOr: 
(mergeMask bitInvert32
-   bitAnd: 
(simDestBits at: simDestIndex + 1))).
+   1 to: simNWords do: 
+   [:word | 
+   sourceForm notNil
+   ifTrue: 
+   [thisWord _ (simSourceIndex = 0 or: 
[simSourceIndex = simSourceBits size])
+   ifTrue: 
[simSourceBits at: 1]
+   ifFalse: 
[simSourceBits at: simSourceIndex + 1].
+   prevWord _ (prevWord bitAnd: 
simSkewMask) bitShift: simSkew.
+   skewWord _ prevWord bitOr: ((thisWord 
bitAnd: noSimSkewMask) bitShift: 

[pypy-commit] lang-smalltalk default: Merge default

2013-03-08 Thread timfel
Author: Tim Felgentreff timfelgentr...@gmail.com
Branch: 
Changeset: r142:189f3b3f83e5
Date: 2013-03-08 10:16 +0100
http://bitbucket.org/pypy/lang-smalltalk/changeset/189f3b3f83e5/

Log:Merge default

diff --git a/.hgignore b/.hgignore
--- a/.hgignore
+++ b/.hgignore
@@ -1,3 +1,7 @@
 syntax: glob
 *.py[co]
 *~
+pypy-c-jit-62116-b027d4428675-linux
+images/Squeak*
+targetimageloadingsmalltalk-c
+images/package-cache
diff --git a/images/minitest.image b/images/minitest.image
index 
5753d32adc6e5ca83c6b7bf990258090ca1812d7..11fbf4e52f946020cefb4e771afc7a950f001596
GIT binary patch

[cut]

diff --git a/spyvm/interpreter.py b/spyvm/interpreter.py
--- a/spyvm/interpreter.py
+++ b/spyvm/interpreter.py
@@ -33,7 +33,7 @@
 get_printable_location=get_printable_location
 )
 
-def __init__(self, space, image=None, image_name=, max_stack_depth=500):
+def __init__(self, space, image=None, image_name=, max_stack_depth=100):
 self.space = space
 self.image = image
 self.image_name = image_name
@@ -72,10 +72,17 @@
 s_new_context.push(nlr.value)
 
 def c_loop(self, s_context):
+# padding = ' ' * (self.max_stack_depth - self.remaining_stack_depth)
+# print padding + s_context.short_str()
+old_pc = 0
 while True:
 pc = s_context._pc
 method = s_context.s_method()
-
+if pc  old_pc:
+self.jit_driver.can_enter_jit(
+pc=pc, self=self, method=method,
+s_context=s_context)
+old_pc = pc
 self.jit_driver.jit_merge_point(
 pc=pc, self=self, method=method,
 s_context=s_context)
diff --git a/spyvm/shadow.py b/spyvm/shadow.py
--- a/spyvm/shadow.py
+++ b/spyvm/shadow.py
@@ -532,6 +532,7 @@
 self._temps_and_stack[ptr] = w_v
 self._stack_ptr = ptr + 1
 
+@jit.unroll_safe
 def push_all(self, lst):
 for elt in lst:
 self.push(elt)
@@ -690,6 +691,10 @@
 # A blockcontext doesn't have any temps
 return 0
 
+def short_str(self):
+return 'BlockContext of %s (%i)' % 
(self.w_method().get_identifier_string(),
+self.pc() + 1)
+
 class MethodContextShadow(ContextPartShadow):
 _attr_ = ['w_closure_or_nil', '_w_receiver', '__w_method']
 
@@ -836,6 +841,10 @@
 retval += \nStack   :  + str(self.stack())
 return retval
 
+def short_str(self):
+block = '[] of' if self.is_closure_context() else ''
+return '%s %s (%i)' % (block, self.w_method().get_identifier_string(), 
self.pc() + 1)
+
 class CompiledMethodShadow(object):
 _immutable_fields_ = [_w_self, bytecode,
   literals[*], bytecodeoffset,
diff --git a/spyvm/test/jit.py b/spyvm/test/jit.py
--- a/spyvm/test/jit.py
+++ b/spyvm/test/jit.py
@@ -4,7 +4,7 @@
 # view jit.
 #
 
-import sys
+import sys, os
 from rpython import conftest
 class o:
 view = False
@@ -15,8 +15,9 @@
 
 
 from spyvm import model, interpreter, primitives, shadow
-from spyvm import objspace
+from spyvm import objspace, squeakimage
 from spyvm.tool.analyseimage import create_squeakimage, create_testimage
+from rpython.rlib.streamio import open_file_as_stream
 
 
 mockclass = objspace.bootstrap_class
@@ -46,7 +47,7 @@
 # Tests
 #
 
-# sys.setrecursionlimit(10)
+sys.setrecursionlimit(5000)
 
 class TestLLtype(LLJitMixin):
 
@@ -54,19 +55,12 @@
 
 from spyvm import objspace
 space = objspace.ObjSpace()
+
 image = create_testimage(space)
 interp = interpreter.Interpreter(space, image)
-
-
-counter = 0
-
-w_selector = interp.perform(space.wrap_string(loopTest), asSymbol)
-w_object = model.W_SmallInteger(0)
-s_class = w_object.shadow_of_my_class(space)
-s_method = s_class.lookup(w_selector)
-s_frame = s_method.create_frame(space, w_object, [])
-
+w_selector = interp.perform(space.wrap_string('loopTest'), asSymbol)
+assert isinstance(w_selector, model.W_BytesObject)
 def interp_w():
-interp.loop(s_frame.w_self())
+interp.perform(model.W_SmallInteger(1000), w_selector)
 
 self.meta_interp(interp_w, [], listcomp=True, listops=True, 
backendopt=True, inline=True)
diff --git a/targetimageloadingsmalltalk.py b/targetimageloadingsmalltalk.py
--- a/targetimageloadingsmalltalk.py
+++ b/targetimageloadingsmalltalk.py
@@ -11,10 +11,12 @@
 def _run_benchmark(interp, number, benchmark):
 w_object = model.W_SmallInteger(number)
 try:
-interp.perform(w_object, benchmark)
+w_result = interp.perform(w_object, benchmark)
 except interpreter.ReturnFromTopLevel, e:
 w_result = e.object
+if w_result:
 assert isinstance(w_result, model.W_BytesObject)
+print '\n'
 print w_result.as_string()
 return 0
 return -1

[pypy-commit] lang-smalltalk default: merge default

2013-03-08 Thread timfel
Author: Tim Felgentreff timfelgentr...@gmail.com
Branch: 
Changeset: r156:c0b6fb0e6d02
Date: 2013-03-08 18:03 +0100
http://bitbucket.org/pypy/lang-smalltalk/changeset/c0b6fb0e6d02/

Log:merge default

diff --git a/spyvm/constants.py b/spyvm/constants.py
--- a/spyvm/constants.py
+++ b/spyvm/constants.py
@@ -1,3 +1,4 @@
+from rpython.rlib.jit import elidable
 # ___
 # Slot Names
 
diff --git a/spyvm/model.py b/spyvm/model.py
--- a/spyvm/model.py
+++ b/spyvm/model.py
@@ -365,6 +365,10 @@
 from spyvm.shadow import MethodDictionaryShadow
 return self.as_special_get_shadow(space, MethodDictionaryShadow)
 
+def as_cached_object_get_shadow(self, space):
+from spyvm.shadow import CachedObjectShadow
+return self.as_special_get_shadow(space, CachedObjectShadow)
+
 def become(self, w_other):
 if not isinstance(w_other, W_PointersObject):
 return False
diff --git a/spyvm/objspace.py b/spyvm/objspace.py
--- a/spyvm/objspace.py
+++ b/spyvm/objspace.py
@@ -162,7 +162,8 @@
 @specialize.arg(1)
 def get_special_selector(self, selector):
 i0 = constants.find_selectorindex(selector)
-return self.w_special_selectors.at0(self, i0)
+self.w_special_selectors.as_cached_object_get_shadow(self)
+return self.w_special_selectors.fetch(self, i0)
 
 # methods for wrapping and unwrapping stuff
 
diff --git a/spyvm/shadow.py b/spyvm/shadow.py
--- a/spyvm/shadow.py
+++ b/spyvm/shadow.py
@@ -892,3 +892,31 @@
 s_new = MethodContextShadow.make_context(
 space, self, receiver, arguments, sender)
 return s_new
+
+class Version:
+pass
+
+class CachedObjectShadow(AbstractCachingShadow):
+_immutable_fields_ = ['version?']
+
+def __init__(self, space, w_self):
+AbstractCachingShadow.__init__(self, space, w_self)
+self.version = Version()
+
+def fetch(self, n0):
+jit.promote(self)
+version = self.version
+jit.promote(version)
+return self.safe_fetch(n0, version)
+
+@jit.elidable
+def safe_fetch(self, n0, version):
+assert version is self.version
+return self._w_self._fetch(n0)
+
+def store(self, n0, w_value):
+self.version = Version()
+return self._w_self._store(n0, w_value)
+
+def update_shadow(self):
+self.version = Version()
\ No newline at end of file
diff --git a/spyvm/squeakimage.py b/spyvm/squeakimage.py
--- a/spyvm/squeakimage.py
+++ b/spyvm/squeakimage.py
@@ -491,6 +491,9 @@
 self.w_object = objectmodel.instantiate(model.W_CompiledMethod)
 else:
 assert 0, not reachable
+else:
+#XXX invalidate shadow here
+pass
 return self.w_object
 
 def fillin_w_object(self):
diff --git a/spyvm/test/jit.py b/spyvm/test/jit.py
--- a/spyvm/test/jit.py
+++ b/spyvm/test/jit.py
@@ -58,7 +58,7 @@
 
 image = create_testimage(space)
 interp = interpreter.Interpreter(space, image)
-w_selector = interp.perform(space.wrap_string('loopTest'), asSymbol)
+w_selector = interp.perform(space.wrap_string('loopTest3'), asSymbol)
 assert isinstance(w_selector, model.W_BytesObject)
 def interp_w():
 interp.perform(model.W_SmallInteger(1000), w_selector)
diff --git a/spyvm/test/test_miniimage.py b/spyvm/test/test_miniimage.py
--- a/spyvm/test/test_miniimage.py
+++ b/spyvm/test/test_miniimage.py
@@ -47,9 +47,9 @@
 def test_read_header():
 reader = open_miniimage(space)
 reader.read_header()
-assert reader.endofmemory == 0x93174
-assert reader.oldbaseaddress == 0x6649000
-assert reader.specialobjectspointer == 0x6668380
+assert reader.endofmemory == 655196
+assert reader.oldbaseaddress == -1220960256
+assert reader.specialobjectspointer == -1220832384
 
 def test_read_all_header(): 
 reader = open_miniimage(space)
diff --git a/spyvm/test/test_shadow.py b/spyvm/test/test_shadow.py
--- a/spyvm/test/test_shadow.py
+++ b/spyvm/test/test_shadow.py
@@ -207,3 +207,13 @@
 
 shadow = w_compiledmethod.as_compiledmethod_get_shadow(space)
 assert shadow.bytecode == abx
+
+def test_cached_object_shadow():
+w_o = space.wrap_list([0, 1, 2, 3, 4, 5, 6, 7])
+s_o = w_o.as_cached_object_get_shadow(space)
+version = s_o.version
+for i in range(w_o.size()):
+assert w_o.at0(space, i) == i
+w_o.atput0(space, 0, 8)
+assert version is not s_o.version
+assert w_o.at0(space, 0) == 8
\ No newline at end of file
diff --git a/spyvm/todo.txt b/spyvm/todo.txt
--- a/spyvm/todo.txt
+++ b/spyvm/todo.txt
@@ -44,3 +44,18 @@
 Shadows:
 [ ] Fix invalidation of methoddictshadow when the w_self of its values array 
changes
 
+
+Optimizations:
+use integer tagging primitives to get more compact code:
+def wrap_int(self, val):
+from rpython.rlib 

[pypy-commit] lang-smalltalk default: merge default

2013-02-18 Thread krono
Author: Tobias Pape tob...@netshed.de
Branch: 
Changeset: r35:f0ea960b893b
Date: 2013-02-18 15:06 +0100
http://bitbucket.org/pypy/lang-smalltalk/changeset/f0ea960b893b/

Log:merge default

diff --git a/spyvm/interpreter.py b/spyvm/interpreter.py
--- a/spyvm/interpreter.py
+++ b/spyvm/interpreter.py
@@ -1,9 +1,7 @@
 import py
 from spyvm.shadow import ContextPartShadow, MethodContextShadow, 
BlockContextShadow
-from spyvm import model, constants, primitives
-from spyvm.shadow import ContextPartShadow
-from spyvm import conftest
-from spyvm import wrapper
+from spyvm import model, constants, primitives, conftest, wrapper
+from spyvm.tool.bitmanipulation import splitter
 
 from rpython.rlib import jit
 from rpython.rlib import objectmodel, unroll
@@ -370,9 +368,41 @@
 def popStackBytecode(self, interp):
 self.pop()
 
+# closure bytecodes
+def pushNewArrayPopIntoArray(self, interp):
+popIntoArray, arraySize = splitter[1, 7](self.getbytecode())
+newArray = None
+#if popIntoArray == 1:
+#newArray = 
interp.space.wrap_list(self.pop_and_return_n(arraySize))
+#else:
+#newArray = 
interp.space.w_Array.as_class_get_shadow(interp.space).new(arraySize)
+self.push(newArray)
+raise MissingBytecode(not yet implemented: pushNewArray)
+
 def experimentalBytecode(self, interp):
 raise MissingBytecode(experimentalBytecode)
 
+def pushTempAtInTempVectorAt(self, interp):
+k = self.getbytecode()
+j = self.getbytecode()
+raise MissingBytecode(not yet implemented: pushTempAt k 
inTempVectorAt j)
+
+def storeTempAtInTempVectorAt(self, interp):
+k = self.getbytecode()
+j = self.getbytecode()
+raise MissingBytecode(not yet implemented: storeTempAt k 
inTempVectorAt j)
+
+def popAndStoreTempAtInTempVectorAt(self, interp):
+k = self.getbytecode()
+j = self.getbytecode()
+raise MissingBytecode(not yet implemented: popAndstoreTempAt k 
inTempVectorAt j)
+
+def pushClosureNumCopiedNumArgsBlockSize(self, interp):
+l, k = splitter[4, 4](self.getbytecode())
+j = self.getbytecode()
+i = self.getbytecode()
+raise MissingBytecode(not yet implemented: pushClosureNumCopied l 
numArgs k blockSize ij)
+
 def jump(self,offset):
 self.store_pc(self.pc() + offset)
 
@@ -505,7 +535,12 @@
 (135, popStackBytecode),
 (136, duplicateTopBytecode),
 (137, pushActiveContextBytecode),
-(138, 143, experimentalBytecode),
+(138, pushNewArrayPopIntoArray),
+(139, experimentalBytecode),
+(140, pushTempAtInTempVectorAt),
+(141, storeTempAtInTempVectorAt),
+(142, popAndStoreTempAtInTempVectorAt),
+(143, pushClosureNumCopiedNumArgsBlockSize),
 (144, 151, shortUnconditionalJump),
 (152, 159, shortConditionalJump),
 (160, 167, longUnconditionalJump),
diff --git a/spyvm/objspace.py b/spyvm/objspace.py
--- a/spyvm/objspace.py
+++ b/spyvm/objspace.py
@@ -205,9 +205,9 @@
 a wrapped smalltalk array
 
 lstlen = len(lst_w)
-res = self.w_Array.as_class_get_shadow().new(lstlen)
+res = self.w_Array.as_class_get_shadow(self).new(lstlen)
 for i in range(lstlen):
-res.storevarpointer(i, lit[i])
+res.storevarpointer(i, lst_w[i])
 return res
 
 def unwrap_int(self, w_value):
diff --git a/spyvm/targettinybenchsmalltalk.py 
b/spyvm/targettinybenchsmalltalk.py
--- a/spyvm/targettinybenchsmalltalk.py
+++ b/spyvm/targettinybenchsmalltalk.py
@@ -1,6 +1,6 @@
 import os, sys
 from spyvm import model, interpreter, primitives, shadow, constants
-from spyvm.tool.analyseimage import create_squeakimage
+from spyvm.tool.analyseimage import create_squeakimage, create_testimage
 
 from rpython.jit.codewriter.policy import JitPolicy
 
@@ -19,13 +19,13 @@
 def tinyBenchmarks():
 from spyvm import objspace
 space = objspace.ObjSpace()
-image = create_squeakimage(space)
+image = create_testimage(space)
 interp = interpreter.Interpreter(space)
 
 w_object = model.W_SmallInteger(0)
 
 s_class = w_object.shadow_of_my_class(space)
-w_method = s_class.lookup(tinyBenchmarks)
+w_method = s_class.lookup(loopTest)
 
 assert w_method
 w_frame = w_method.create_frame(space, w_object, [])
diff --git a/spyvm/test/jit.py b/spyvm/test/jit.py
--- a/spyvm/test/jit.py
+++ b/spyvm/test/jit.py
@@ -16,7 +16,7 @@
 
 from spyvm import model, interpreter, primitives, shadow
 from spyvm import objspace
-from spyvm.tool.analyseimage import create_testimage
+from spyvm.tool.analyseimage import create_squeakimage, create_testimage
 
 
 mockclass = objspace.bootstrap_class
@@ -77,5 +77,4 @@
 def interp_w():
 interp.interpret()
 
-self.meta_interp(interp_w, [], listcomp=True, listops=True,