Author: Armin Rigo <ar...@tunes.org>
Branch: reverse-debugger
Changeset: r86175:9dbb62851b3f
Date: 2016-08-12 18:52 +0200
http://bitbucket.org/pypy/pypy/changeset/9dbb62851b3f/

Log:    Next emulation (we'll see how far it makes sense to continue)

diff --git a/rpython/rlib/revdb.py b/rpython/rlib/revdb.py
--- a/rpython/rlib/revdb.py
+++ b/rpython/rlib/revdb.py
@@ -236,3 +236,7 @@
 def emulate_modf(x):
     return (llop.revdb_modf(lltype.Float, x, 0),
             llop.revdb_modf(lltype.Float, x, 1))
+
+def emulate_frexp(x):
+    return (llop.revdb_frexp(lltype.Float, x, 0),
+            int(llop.revdb_frexp(lltype.Float, x, 1)))
diff --git a/rpython/rtyper/lltypesystem/lloperation.py 
b/rpython/rtyper/lltypesystem/lloperation.py
--- a/rpython/rtyper/lltypesystem/lloperation.py
+++ b/rpython/rtyper/lltypesystem/lloperation.py
@@ -587,6 +587,7 @@
     'revdb_strtod':         LLOp(sideeffects=False),
     'revdb_dtoa':           LLOp(sideeffects=False),
     'revdb_modf':           LLOp(sideeffects=False),
+    'revdb_frexp':          LLOp(sideeffects=False),
 }
 # ***** Run test_lloperation after changes. *****
 
diff --git a/rpython/rtyper/lltypesystem/module/ll_math.py 
b/rpython/rtyper/lltypesystem/module/ll_math.py
--- a/rpython/rtyper/lltypesystem/module/ll_math.py
+++ b/rpython/rtyper/lltypesystem/module/ll_math.py
@@ -185,6 +185,8 @@
         mantissa = x
         exponent = 0
     else:
+        if revdb.flag_io_disabled():
+            return revdb.emulate_frexp(x)
         exp_p = lltype.malloc(rffi.INTP.TO, 1, flavor='raw')
         try:
             mantissa = math_frexp(x, exp_p)
diff --git a/rpython/translator/revdb/src-revdb/revdb_include.h 
b/rpython/translator/revdb/src-revdb/revdb_include.h
--- a/rpython/translator/revdb/src-revdb/revdb_include.h
+++ b/rpython/translator/revdb/src-revdb/revdb_include.h
@@ -243,6 +243,13 @@
         r = (index == 0) ? _r0 : _r1;                                   \
     } while (0)
 
+#define OP_REVDB_FREXP(x, index, r)                                     \
+    do {                                                                \
+        double _r0; int _r1;                                            \
+        _r0 = frexp(x, &_r1);                                           \
+        r = (index == 0) ? _r0 : _r1;                                   \
+    } while (0)
+
 
 RPY_EXTERN void rpy_reverse_db_flush(void);  /* must be called with the lock */
 RPY_EXTERN void rpy_reverse_db_fetch(const char *file, int line);
diff --git a/rpython/translator/revdb/test/test_process.py 
b/rpython/translator/revdb/test/test_process.py
--- a/rpython/translator/revdb/test/test_process.py
+++ b/rpython/translator/revdb/test/test_process.py
@@ -52,6 +52,9 @@
                 valx, valy = math.modf(val)
                 revdb.send_output(rdtoa.dtoa(valx) + '\n')
                 revdb.send_output(rdtoa.dtoa(valy) + '\n')
+                xx, yy = math.frexp(val)
+                revdb.send_output(rdtoa.dtoa(xx) + '\n')
+                revdb.send_output('%d\n' % yy)
                 return
             else:
                 assert False
@@ -210,4 +213,4 @@
         group = ReplayProcessGroup(str(self.exename), self.rdbname)
         with stdout_capture() as buf:
             group.print_cmd('2.35')
-        assert buf.getvalue() == "0.35\n2.0\n"
+        assert buf.getvalue() == "0.35\n2.0\n0.5875\n2\n"
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to