Author: Brian Kearns <[email protected]>
Branch: improve-consecutive-dict-lookups
Changeset: r70029:0f464df7cb9f
Date: 2014-03-17 15:41 -0400
http://bitbucket.org/pypy/pypy/changeset/0f464df7cb9f/

Log:    cleanup/reduce diff with default

diff --git a/rpython/jit/metainterp/optimizeopt/heap.py 
b/rpython/jit/metainterp/optimizeopt/heap.py
--- a/rpython/jit/metainterp/optimizeopt/heap.py
+++ b/rpython/jit/metainterp/optimizeopt/heap.py
@@ -302,13 +302,12 @@
         self.emit_operation(op)
 
     def _optimize_CALL_DICT_LOOKUP(self, op):
-        args = self.optimizer.make_args_key(op)
         descr = op.getdescr().get_extra_info().extradescr
         if descr in self.cached_dict_reads:
             d = self.cached_dict_reads[descr]
         else:
-            d = args_dict()
-            self.cached_dict_reads[descr] = d
+            d = self.cached_dict_reads[descr] = args_dict()
+        args = self.optimizer.make_args_key(op)
         try:
             res_v = d[args]
         except KeyError:
diff --git a/rpython/jit/metainterp/test/test_dict.py 
b/rpython/jit/metainterp/test/test_dict.py
--- a/rpython/jit/metainterp/test/test_dict.py
+++ b/rpython/jit/metainterp/test/test_dict.py
@@ -212,7 +212,6 @@
         self.check_simple_loop(call=1, getinteriorfield_gc=2,
                                guard_no_exception=1)
 
-
     def test_ordered_dict_two_lookups(self):
         driver = JitDriver(greens = [], reds = 'auto')
         d = OrderedDict()
@@ -273,6 +272,7 @@
         assert res == f(10)
         self.check_simple_loop(call=3)
 
+
 class TestLLtype(DictTests, LLJitMixin):
     pass
 
diff --git a/rpython/rtyper/lltypesystem/rbuilder.py 
b/rpython/rtyper/lltypesystem/rbuilder.py
--- a/rpython/rtyper/lltypesystem/rbuilder.py
+++ b/rpython/rtyper/lltypesystem/rbuilder.py
@@ -85,6 +85,13 @@
         ll_builder.used = needed
 
     @staticmethod
+    def ll_append_char(ll_builder, char):
+        if ll_builder.used == ll_builder.allocated:
+            ll_builder.grow(ll_builder, 1)
+        ll_builder.buf.chars[ll_builder.used] = char
+        ll_builder.used += 1
+
+    @staticmethod
     def ll_append_slice(ll_builder, ll_str, start, end):
         needed = end - start
         used = ll_builder.used
@@ -106,7 +113,6 @@
         ll_builder.used = used
 
     @staticmethod
-    @enforceargs(None, None, int)
     def ll_append_charpsize(ll_builder, charp, size):
         used = ll_builder.used
         if used + size > ll_builder.allocated:
@@ -132,14 +138,6 @@
         return ll_builder != nullptr(cls.lowleveltype.TO)
 
 class StringBuilderRepr(BaseStringBuilderRepr):
-    @staticmethod
-    @enforceargs(None, lltype.Char)
-    def ll_append_char(ll_builder, char):
-        if ll_builder.used == ll_builder.allocated:
-            ll_builder.grow(ll_builder, 1)
-        ll_builder.buf.chars[ll_builder.used] = char
-        ll_builder.used += 1
-
     lowleveltype = lltype.Ptr(STRINGBUILDER)
     basetp = STR
     mallocfn = staticmethod(rstr.mallocstr)
@@ -150,15 +148,6 @@
     )
 
 class UnicodeBuilderRepr(BaseStringBuilderRepr):
-
-    @staticmethod
-    @enforceargs(None, lltype.UniChar)
-    def ll_append_char(ll_builder, char):
-        if ll_builder.used == ll_builder.allocated:
-            ll_builder.grow(ll_builder, 1)
-        ll_builder.buf.chars[ll_builder.used] = char
-        ll_builder.used += 1
-
     lowleveltype = lltype.Ptr(UNICODEBUILDER)
     basetp = UNICODE
     mallocfn = staticmethod(rstr.mallocunicode)
diff --git a/rpython/rtyper/lltypesystem/rstr.py 
b/rpython/rtyper/lltypesystem/rstr.py
--- a/rpython/rtyper/lltypesystem/rstr.py
+++ b/rpython/rtyper/lltypesystem/rstr.py
@@ -4,7 +4,7 @@
 from rpython.rlib import jit, types
 from rpython.rlib.debug import ll_assert
 from rpython.rlib.objectmodel import (malloc_zero_filled, we_are_translated,
-    _hash_string, keepalive_until_here, specialize, enforceargs)
+    _hash_string, keepalive_until_here, specialize)
 from rpython.rlib.signature import signature
 from rpython.rlib.rarithmetic import ovfcheck
 from rpython.rtyper.error import TyperError
@@ -121,10 +121,9 @@
         llmemory.raw_memcopy(srcbuf, dst, llmemory.sizeof(CHAR_TP) * length)
         # end of "no GC" section
         keepalive_until_here(dst)
+    copy_raw_to_string._always_inline_ = True
     copy_raw_to_string = func_with_new_name(copy_raw_to_string,
                                               'copy_raw_to_%s' % name)
-    copy_raw_to_string._always_inline_ = True
-    copy_raw_to_string._annenforceargs_ = (None, None, int, int)
 
     return copy_string_to_raw, copy_raw_to_string, copy_string_contents
 
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to