[pypy-svn] r40591 - in pypy/branch/jit-virtual-world/pypy/translator: cli oosupport oosupport/test_template

ac at codespeak.net ac at codespeak.net
Fri Mar 16 17:49:33 CET 2007


Author: ac
Date: Fri Mar 16 17:49:30 2007
New Revision: 40591

Modified:
   pypy/branch/jit-virtual-world/pypy/translator/cli/opcodes.py
   pypy/branch/jit-virtual-world/pypy/translator/oosupport/metavm.py
   pypy/branch/jit-virtual-world/pypy/translator/oosupport/test_template/operations.py
Log:
is_early_constant for  cli.

Modified: pypy/branch/jit-virtual-world/pypy/translator/cli/opcodes.py
==============================================================================
--- pypy/branch/jit-virtual-world/pypy/translator/cli/opcodes.py	(original)
+++ pypy/branch/jit-virtual-world/pypy/translator/cli/opcodes.py	Fri Mar 16 17:49:30 2007
@@ -3,8 +3,9 @@
      CastWeakAdrToPtr, MapException, Box, Unbox, NewArray, GetArrayElem, SetArrayElem,\
      TypeOf
 from pypy.translator.oosupport.metavm import PushArg, PushAllArgs, StoreResult, InstructionList,\
-    New, RuntimeNew, CastTo
+    New, RuntimeNew, CastTo, PushPrimitive
 from pypy.translator.cli.cts import WEAKREF
+from pypy.rpython.ootypesystem import ootype
 
 # some useful instruction patterns
 Not = ['ldc.i4.0', 'ceq']
@@ -225,6 +226,7 @@
     'cast_float_to_int':        'conv.i4',
     'cast_float_to_uint':       'conv.i4',
     'truncate_longlong_to_int': 'conv.i4',
+    'is_early_constant':        [PushPrimitive(ootype.Bool, False)]
 }
 
 for key, value in opcodes.iteritems():

Modified: pypy/branch/jit-virtual-world/pypy/translator/oosupport/metavm.py
==============================================================================
--- pypy/branch/jit-virtual-world/pypy/translator/oosupport/metavm.py	(original)
+++ pypy/branch/jit-virtual-world/pypy/translator/oosupport/metavm.py	Fri Mar 16 17:49:30 2007
@@ -242,6 +242,14 @@
         for arg in op.args:
             generator.load(arg)
 
+class PushPrimitive(MicroInstruction):
+    def __init__(self, TYPE, value):
+        self.TYPE = TYPE
+        self.value = value
+
+    def render(self, generator, op):
+        generator.push_primitive_constant(self.TYPE, self.value)
+        
 class _StoreResult(MicroInstruction):
     def render(self, generator, op):
         generator.store(op.result)
@@ -433,3 +441,4 @@
 RuntimeNew = _RuntimeNew()
 OOString = _OOString()
 CastTo = _CastTo()
+

Modified: pypy/branch/jit-virtual-world/pypy/translator/oosupport/test_template/operations.py
==============================================================================
--- pypy/branch/jit-virtual-world/pypy/translator/oosupport/test_template/operations.py	(original)
+++ pypy/branch/jit-virtual-world/pypy/translator/oosupport/test_template/operations.py	Fri Mar 16 17:49:30 2007
@@ -190,3 +190,12 @@
         def fn(x, y):
             return bool(x)
         self._check_all(fn)
+
+    def test_is_early_constant(self):
+        from pypy.rlib import objectmodel
+        def f(x):
+            if objectmodel._is_early_constant(x):
+                return 42
+            return 0
+        assert self.interpret(f, [5]) == 0
+



More information about the Pypy-commit mailing list