Author: Richard Plangger <planri...@gmail.com>
Branch: new-jit-log
Changeset: r84395:0324cb4dabc8
Date: 2016-05-10 14:48 +0200
http://bitbucket.org/pypy/pypy/changeset/0324cb4dabc8/

Log:    merged default, removed jitlog marker .h file

diff --git a/pypy/module/cpyext/ndarrayobject.py 
b/pypy/module/cpyext/ndarrayobject.py
--- a/pypy/module/cpyext/ndarrayobject.py
+++ b/pypy/module/cpyext/ndarrayobject.py
@@ -26,6 +26,8 @@
 ARRAY_CARRAY       = ARRAY_C_CONTIGUOUS | ARRAY_BEHAVED
 ARRAY_DEFAULT      = ARRAY_CARRAY
 
+npy_intpp = rffi.CArrayPtr(Py_ssize_t)
+
 
 HEADER = 'pypy_numpy.h'
 @cpython_api([PyObject], rffi.INT_real, error=CANNOT_FAIL, header=HEADER)
@@ -196,15 +198,15 @@
             order=order, owning=owning, w_subtype=w_subtype)
 
 
-@cpython_api([Py_ssize_t, rffi.LONGP, Py_ssize_t], PyObject, header=HEADER)
+@cpython_api([Py_ssize_t, npy_intpp, Py_ssize_t], PyObject, header=HEADER)
 def _PyArray_SimpleNew(space, nd, dims, typenum):
     return simple_new(space, nd, dims, typenum)
 
-@cpython_api([Py_ssize_t, rffi.LONGP, Py_ssize_t, rffi.VOIDP], PyObject, 
header=HEADER)
+@cpython_api([Py_ssize_t, npy_intpp, Py_ssize_t, rffi.VOIDP], PyObject, 
header=HEADER)
 def _PyArray_SimpleNewFromData(space, nd, dims, typenum, data):
     return simple_new_from_data(space, nd, dims, typenum, data, owning=False)
 
-@cpython_api([Py_ssize_t, rffi.LONGP, Py_ssize_t, rffi.VOIDP], PyObject, 
header=HEADER)
+@cpython_api([Py_ssize_t, npy_intpp, Py_ssize_t, rffi.VOIDP], PyObject, 
header=HEADER)
 def _PyArray_SimpleNewFromDataOwning(space, nd, dims, typenum, data):
     # Variant to take over ownership of the memory, equivalent to:
     #     PyObject *arr = PyArray_SimpleNewFromData(nd, dims, typenum, data);
@@ -212,7 +214,7 @@
     return simple_new_from_data(space, nd, dims, typenum, data, owning=True)
 
 
-@cpython_api([rffi.VOIDP, Py_ssize_t, rffi.LONGP, Py_ssize_t, rffi.LONGP,
+@cpython_api([rffi.VOIDP, Py_ssize_t, npy_intpp, Py_ssize_t, npy_intpp,
     rffi.VOIDP, Py_ssize_t, Py_ssize_t, PyObject], PyObject, header=HEADER)
 def _PyArray_New(space, subtype, nd, dims, typenum, strides, data, itemsize, 
flags, obj):
     if strides:
diff --git a/pypy/module/cpyext/test/test_typeobject.py 
b/pypy/module/cpyext/test/test_typeobject.py
--- a/pypy/module/cpyext/test/test_typeobject.py
+++ b/pypy/module/cpyext/test/test_typeobject.py
@@ -1,3 +1,4 @@
+from pypy.interpreter import gateway
 from rpython.rtyper.lltypesystem import rffi
 from pypy.module.cpyext.test.test_cpyext import AppTestCpythonExtensionBase
 from pypy.module.cpyext.test.test_api import BaseApiTest
@@ -391,6 +392,14 @@
         api.Py_DecRef(ref)
 
 class AppTestSlots(AppTestCpythonExtensionBase):
+    def setup_class(cls):
+        AppTestCpythonExtensionBase.setup_class.im_func(cls)
+        def _check_type_object(w_X):
+            assert w_X.is_cpytype()
+            assert not w_X.is_heaptype()
+        cls.w__check_type_object = cls.space.wrap(
+            gateway.interp2app(_check_type_object))
+
     def test_some_slots(self):
         module = self.import_extension('foo', [
             ("test_type", "METH_O",
@@ -1023,3 +1032,56 @@
                 break
             self.debug_collect()
         assert module.getCounter() == 7070
+
+    def test_tp_call_reverse(self):
+        module = self.import_extension('foo', [
+           ("new_obj", "METH_NOARGS",
+            '''
+                PyObject *obj;
+                Foo_Type.tp_flags = Py_TPFLAGS_DEFAULT;
+                Foo_Type.tp_call = &my_tp_call;
+                if (PyType_Ready(&Foo_Type) < 0) return NULL;
+                obj = PyObject_New(PyObject, &Foo_Type);
+                return obj;
+            '''
+            )],
+            '''
+            static PyObject *
+            my_tp_call(PyObject *self, PyObject *args, PyObject *kwds)
+            {
+                return PyInt_FromLong(42);
+            }
+            static PyTypeObject Foo_Type = {
+                PyVarObject_HEAD_INIT(NULL, 0)
+                "foo.foo",
+            };
+            ''')
+        x = module.new_obj()
+        assert x() == 42
+        assert x(4, bar=5) == 42
+
+    def test_custom_metaclass(self):
+        module = self.import_extension('foo', [
+           ("getMetaClass", "METH_NOARGS",
+            '''
+                PyObject *obj;
+                FooType_Type.tp_flags = Py_TPFLAGS_DEFAULT;
+                FooType_Type.tp_base = &PyType_Type;
+                if (PyType_Ready(&FooType_Type) < 0) return NULL;
+                Py_INCREF(&FooType_Type);
+                return (PyObject *)&FooType_Type;
+            '''
+            )],
+            '''
+            static PyTypeObject FooType_Type = {
+                PyVarObject_HEAD_INIT(NULL, 0)
+                "foo.Type",
+            };
+            ''')
+        FooType = module.getMetaClass()
+        if not self.runappdirect:
+            self._check_type_object(FooType)
+        class X(object):
+            __metaclass__ = FooType
+        print repr(X)
+        X()
diff --git a/pypy/module/cpyext/typeobject.py b/pypy/module/cpyext/typeobject.py
--- a/pypy/module/cpyext/typeobject.py
+++ b/pypy/module/cpyext/typeobject.py
@@ -405,8 +405,7 @@
 
         W_TypeObject.__init__(self, space, name,
             bases_w or [space.w_object], dict_w, force_new_layout=new_layout)
-        if not space.is_true(space.issubtype(self, space.w_type)):
-            self.flag_cpytype = True
+        self.flag_cpytype = True
         self.flag_heaptype = False
         # if a sequence or a mapping, then set the flag to force it
         if pto.c_tp_as_sequence and pto.c_tp_as_sequence.c_sq_item:
diff --git a/pypy/module/micronumpy/ufuncs.py b/pypy/module/micronumpy/ufuncs.py
--- a/pypy/module/micronumpy/ufuncs.py
+++ b/pypy/module/micronumpy/ufuncs.py
@@ -1521,7 +1521,8 @@
 # Instantiated in cpyext/ndarrayobject. It is here since ufunc calls
 # set_dims_and_steps, otherwise ufunc, ndarrayobject would have circular
 # imports
-npy_intpp = rffi.INTPTR_T
+Py_ssize_t = lltype.Typedef(rffi.SSIZE_T, 'Py_ssize_t')
+npy_intpp = rffi.CArrayPtr(Py_ssize_t)
 LONG_SIZE = LONG_BIT / 8
 CCHARP_SIZE = _get_bitsize('P') / 8
 
diff --git a/rpython/jit/backend/x86/assembler.py 
b/rpython/jit/backend/x86/assembler.py
--- a/rpython/jit/backend/x86/assembler.py
+++ b/rpython/jit/backend/x86/assembler.py
@@ -489,7 +489,6 @@
         frame_info = self.datablockwrapper.malloc_aligned(
             jitframe.JITFRAMEINFO_SIZE, alignment=WORD)
         clt.frame_info = rffi.cast(jitframe.JITFRAMEINFOPTR, frame_info)
-        clt.allgcrefs = []
         clt.frame_info.clear() # for now
 
         if log:
diff --git a/rpython/jit/metainterp/pyjitpl.py 
b/rpython/jit/metainterp/pyjitpl.py
--- a/rpython/jit/metainterp/pyjitpl.py
+++ b/rpython/jit/metainterp/pyjitpl.py
@@ -1753,7 +1753,6 @@
 class MetaInterpStaticData(object):
     logger_noopt = None
     logger_ops = None
-    jitlog = None
 
     def __init__(self, cpu, options,
                  ProfilerClass=EmptyProfiler, warmrunnerdesc=None):
diff --git a/rpython/memory/gc/incminimark.py b/rpython/memory/gc/incminimark.py
--- a/rpython/memory/gc/incminimark.py
+++ b/rpython/memory/gc/incminimark.py
@@ -568,14 +568,14 @@
         # set up extra stuff for PYPY_GC_DEBUG.
         MovingGCBase.post_setup(self)
         if self.DEBUG and llarena.has_protect:
-            # gc debug mode: allocate 23 nurseries instead of just 1,
+            # gc debug mode: allocate 7 nurseries instead of just 1,
             # and use them alternatively, while mprotect()ing the unused
             # ones to detect invalid access.
             debug_start("gc-debug")
             self.debug_rotating_nurseries = lltype.malloc(
-                NURSARRAY, 22, flavor='raw', track_allocation=False)
+                NURSARRAY, 6, flavor='raw', track_allocation=False)
             i = 0
-            while i < 22:
+            while i < 6:
                 nurs = self._alloc_nursery()
                 llarena.arena_protect(nurs, self._nursery_memory_size(), True)
                 self.debug_rotating_nurseries[i] = nurs
@@ -1731,7 +1731,6 @@
                 llarena.arena_reset(prev, pinned_obj_size, 3)
             else:
                 llarena.arena_reset(prev, pinned_obj_size, 0)
-            # XXX: debug_rotate_nursery missing here
             #
             # clean up object's flags
             obj = cur + size_gc_header
@@ -1747,6 +1746,8 @@
         # reset everything after the last pinned object till the end of the 
arena
         if self.gc_nursery_debug:
             llarena.arena_reset(prev, self.nursery + self.nursery_size - prev, 
3)
+            if not nursery_barriers.non_empty():   # no pinned objects
+                self.debug_rotate_nursery()
         else:
             llarena.arena_reset(prev, self.nursery + self.nursery_size - prev, 
0)
         #
@@ -1756,7 +1757,6 @@
         self.nursery_barriers = nursery_barriers
         self.surviving_pinned_objects.delete()
         #
-        # XXX gc-minimark-pinning does a debug_rotate_nursery() here (groggi)
         self.nursery_free = self.nursery
         self.nursery_top = self.nursery_barriers.popleft()
         #
diff --git a/rpython/rlib/rvmprof/src/vmprof_common.h 
b/rpython/rlib/rvmprof/src/vmprof_common.h
--- a/rpython/rlib/rvmprof/src/vmprof_common.h
+++ b/rpython/rlib/rvmprof/src/vmprof_common.h
@@ -7,7 +7,11 @@
 static long profile_interval_usec = 0;
 static int opened_profile(char *interp_name);
 
-#include "vmprof_markers.h"
+#define MARKER_STACKTRACE '\x01'
+#define MARKER_VIRTUAL_IP '\x02'
+#define MARKER_TRAILER '\x03'
+#define MARKER_INTERP_NAME '\x04'   /* deprecated */
+#define MARKER_HEADER '\x05'
 
 #define VERSION_BASE '\x00'
 #define VERSION_THREAD_ID '\x01'
@@ -78,6 +82,10 @@
     int n = 0;
     intptr_t addr = 0;
     int bottom_jitted = 0;
+
+    if (stack == NULL)
+        return 0;
+
     // check if the pc is in JIT
 #ifdef PYPY_JIT_CODEMAP
     if (pypy_find_codemap_at_addr((intptr_t)pc, &addr)) {
@@ -107,7 +115,12 @@
 #ifndef RPYTHON_LL2CTYPES
 static vmprof_stack_t *get_vmprof_stack(void)
 {
-    return RPY_THREADLOCALREF_GET(vmprof_tl_stack);
+    struct pypy_threadlocal_s *tl;
+    _OP_THREADLOCALREF_ADDR_SIGHANDLER(tl);
+    if (tl == NULL)
+        return NULL;
+    else
+        return tl->vmprof_tl_stack;
 }
 #else
 static vmprof_stack_t *get_vmprof_stack(void)
diff --git a/rpython/rlib/rvmprof/src/vmprof_markers.h 
b/rpython/rlib/rvmprof/src/vmprof_markers.h
deleted file mode 100644
--- a/rpython/rlib/rvmprof/src/vmprof_markers.h
+++ /dev/null
@@ -1,10 +0,0 @@
-#pragma once
-
-#define MARKER_STACKTRACE '\x01'
-#define MARKER_VIRTUAL_IP '\x02'
-#define MARKER_TRAILER '\x03'
-#define MARKER_INTERP_NAME '\x04'   /* deprecated */
-#define MARKER_HEADER '\x05'
-
-#define MARKER_JITLOG_META '\x06'
-
diff --git a/rpython/rlib/test/test_rmmap.py b/rpython/rlib/test/test_rmmap.py
--- a/rpython/rlib/test/test_rmmap.py
+++ b/rpython/rlib/test/test_rmmap.py
@@ -296,7 +296,7 @@
         f = open(self.tmpname + "l2", "w+")
         f.write("foobar")
         f.flush()
-        m = mmap.mmap(f.fileno(), 6, prot=~mmap.PROT_WRITE)
+        m = mmap.mmap(f.fileno(), 6, prot=mmap.PROT_READ|mmap.PROT_EXEC)
         py.test.raises(RTypeError, m.check_writeable)
         py.test.raises(RTypeError, m.check_writeable)
         m.close()
diff --git a/rpython/rtyper/lltypesystem/rffi.py 
b/rpython/rtyper/lltypesystem/rffi.py
--- a/rpython/rtyper/lltypesystem/rffi.py
+++ b/rpython/rtyper/lltypesystem/rffi.py
@@ -475,7 +475,7 @@
 TYPES += ['signed char', 'unsigned char',
           'long long', 'unsigned long long',
           'size_t', 'time_t', 'wchar_t',
-          'uintptr_t', 'intptr_t',
+          'uintptr_t', 'intptr_t',    # C note: these two are _integer_ types
           'void*']    # generic pointer type
 
 # This is a bit of a hack since we can't use rffi_platform here.
diff --git a/rpython/translator/c/src/threadlocal.h 
b/rpython/translator/c/src/threadlocal.h
--- a/rpython/translator/c/src/threadlocal.h
+++ b/rpython/translator/c/src/threadlocal.h
@@ -53,6 +53,13 @@
             r = _RPython_ThreadLocals_Build();  \
     } while (0)
 
+#define _OP_THREADLOCALREF_ADDR_SIGHANDLER(r)   \
+    do {                                        \
+        r = (char *)&pypy_threadlocal;          \
+        if (pypy_threadlocal.ready != 42)       \
+            r = NULL;                           \
+    } while (0)
+
 #define RPY_THREADLOCALREF_ENSURE()             \
     if (pypy_threadlocal.ready != 42)           \
         (void)_RPython_ThreadLocals_Build();
@@ -87,6 +94,11 @@
             r = _RPython_ThreadLocals_Build();  \
     } while (0)
 
+#define _OP_THREADLOCALREF_ADDR_SIGHANDLER(r)   \
+    do {                                        \
+        r = (char *)_RPy_ThreadLocals_Get();    \
+    } while (0)
+
 #define RPY_THREADLOCALREF_ENSURE()             \
     if (!_RPy_ThreadLocals_Get())               \
         (void)_RPython_ThreadLocals_Build();
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to