[pypy-commit] stmgc c7: performance: not always do a safe-point in stm_allocate() (still missing a way to request it though)

2014-02-05 Thread Remi Meier
Author: Remi Meier
Branch: c7
Changeset: r701:4313bc715c7e
Date: 2014-02-05 09:18 +0100
http://bitbucket.org/pypy/stmgc/changeset/4313bc715c7e/

Log:performance: not always do a safe-point in stm_allocate() (still
missing a way to request it though)

diff --git a/c7/nursery.c b/c7/nursery.c
--- a/c7/nursery.c
+++ b/c7/nursery.c
@@ -177,6 +177,13 @@
 
 localchar_t *collect_and_reserve(size_t size)
 {
+/* reset nursery_current (left invalid by the caller) */
+_STM_TL->nursery_current -= size;
+
+/* XXX: check for requested safe-point (by setting nursery_current
+   too high or similar) */
+
+
 _stm_start_safe_point(0);/* don't release the COLLECT lock,
that needs to be done afterwards if
we want a major collection */
@@ -196,16 +203,12 @@
 {
 object_t *result;
 
-_stm_start_safe_point(LOCK_COLLECT);
-/* all collections may happen here */
-_stm_stop_safe_point(LOCK_COLLECT);
-
 assert(_STM_TL->active);
 assert(size % 8 == 0);
 assert(16 <= size);
 
 /* XXX move out of fastpath */
-if (size >= NURSERY_SECTION) {
+if (UNLIKELY(size >= NURSERY_SECTION)) {
 /* allocate large objects outside the nursery immediately,
otherwise they may trigger too many minor collections
and degrade performance */
@@ -231,7 +234,6 @@
 assert((uintptr_t)new_current < (1L << 32));
 
 if ((uintptr_t)new_current > FIRST_AFTER_NURSERY_PAGE * 4096) {
-_STM_TL->nursery_current = current; /* reset for nursery-clearing in 
minor_collect!! */
 current = collect_and_reserve(size);
 }
 
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] lang-smalltalk default: add shebang to targets

2014-02-05 Thread krono
Author: Tobias Pape 
Branch: 
Changeset: r594:63f6f3f9b38f
Date: 2014-02-05 09:59 +0100
http://bitbucket.org/pypy/lang-smalltalk/changeset/63f6f3f9b38f/

Log:add shebang to targets

diff --git a/targetimageloadingsmalltalk.py b/targetimageloadingsmalltalk.py
old mode 100644
new mode 100755
--- a/targetimageloadingsmalltalk.py
+++ b/targetimageloadingsmalltalk.py
@@ -1,3 +1,4 @@
+#! /usr/bin/env python
 import sys, time
 import os
 
diff --git a/targettinybenchsmalltalk.py b/targettinybenchsmalltalk.py
old mode 100644
new mode 100755
--- a/targettinybenchsmalltalk.py
+++ b/targettinybenchsmalltalk.py
@@ -1,3 +1,4 @@
+#! /usr/bin/env python
 import os, sys
 from spyvm import model, interpreter, primitives, shadow, constants
 from spyvm.tool.analyseimage import create_squeakimage, create_testimage
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] stmgc c7: simple n-queens demo for duhton

2014-02-05 Thread Remi Meier
Author: Remi Meier
Branch: c7
Changeset: r702:ff1022e19989
Date: 2014-02-05 10:57 +0100
http://bitbucket.org/pypy/stmgc/changeset/ff1022e19989/

Log:simple n-queens demo for duhton

diff --git a/duhton/demo/nqueens.duh b/duhton/demo/nqueens.duh
new file mode 100644
--- /dev/null
+++ b/duhton/demo/nqueens.duh
@@ -0,0 +1,85 @@
+
+
+
+
+
+(setq count (container 0))
+
+(defun abs (i)
+  (if (<= 0 i)
+  i
+(- 0 i)))
+
+(defun attacks (hist col i j)
+  (|| (== (get hist j) i)
+  (== (abs (- (get hist j) i))
+  (- col j)))
+  )
+
+(defun print_solution (hist n)
+  (print (quote solution) n)
+  (setq i 0)
+  (while (< i n)
+(setq line (list))
+(setq j 0)
+(while (< j n)
+  (if (== j (get hist i))
+  (append line (quote Q))
+(if (== 0 (% (+ i j) 2))
+(append line (quote .))
+  (append line (quote ,))
+  )
+)
+  (setq j (+ j 1))
+  )
+
+(print line)
+(setq i (+ i 1))
+)
+  )
+
+(defun solve (n col hist)
+  (if (== col n)
+  (progn
+(set count (+ (get count) 1))
+(print_solution hist n)
+)
+
+;; else
+(setq i 0)
+(while (< i n)
+  (setq j 0)
+  (while (&& (< j col)
+ (not (attacks hist col i j)))
+(setq j (+ j 1))
+)
+
+  (if (>= j col)
+  (progn
+(set hist col i)
+(solve n (+ col 1) hist)
+))
+  
+  (setq i (+ i 1))
+  )
+)
+  )
+
+
+
+(defun clean_list (n)
+  (setq i n)
+  (setq res (list))
+  (while (> i 0)
+(append res 0)
+(setq i (- i 1))
+)
+  res
+  )
+
+
+
+(setq n 8)
+(solve n 0 (clean_list n))
+(print (quote solutions:) (get count))
+
diff --git a/duhton/demo/sort.duh b/duhton/demo/sort.duh
--- a/duhton/demo/sort.duh
+++ b/duhton/demo/sort.duh
@@ -173,7 +173,7 @@
 
 (setq current (time))
 (print (quote before-random))
-(setq cs (random_list 20))
+(setq cs (random_list 30))
 (print (quote time-random:) (- (time) current))
 
 ;; (print_list cs)
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] stmgc c7: fix missing read-barrier in duhton

2014-02-05 Thread Remi Meier
Author: Remi Meier
Branch: c7
Changeset: r704:679c5904557a
Date: 2014-02-05 13:48 +0100
http://bitbucket.org/pypy/stmgc/changeset/679c5904557a/

Log:fix missing read-barrier in duhton

diff --git a/c7/core.c b/c7/core.c
--- a/c7/core.c
+++ b/c7/core.c
@@ -124,6 +124,7 @@
 uintptr_t lock_idx = (((uintptr_t)obj) >> 4) - READMARKER_START;
 uint8_t lock_num = _STM_TL->thread_num + 1;
 uint8_t prev_owner;
+uint8_t retries = 0;
  retry:
 do {
 prev_owner = __sync_val_compare_and_swap(&write_locks[lock_idx],
@@ -142,14 +143,18 @@
 _stm_stop_safe_point(0);
 goto retry;
 }
-/* XX */
-//_stm_start_semi_safe_point();
-//usleep(1);
-//_stm_stop_semi_safe_point();
-// try again XXX
+
+
+if (retries < 1) {
+_stm_start_safe_point(0);
+usleep(1);
+_stm_stop_safe_point(0);
+retries++;
+goto retry;
+}
+
 stm_abort_transaction();
 /* XXX: only abort if we are younger */
-spin_loop();
 } while (1);
 
 /* remove the write-barrier ONLY if we have the write-lock */
diff --git a/duhton/demo/synth.duh b/duhton/demo/synth.duh
new file mode 100644
--- /dev/null
+++ b/duhton/demo/synth.duh
@@ -0,0 +1,88 @@
+
+
+
+(defun clean_list (n)
+  (setq i n)
+  (setq res (list))
+  (while (> i 0)
+(append res 0)
+(setq i (- i 1))
+)
+  res
+  )
+
+
+(setq _rand (container (list 133542157 362436069 521288629 88675123)))
+(defun xor128 ()
+  (setq lst (get _rand))
+  (setq x (get lst 0))
+  (setq y (get lst 1))
+  (setq z (get lst 2))
+  (setq w (get lst 3))
+  
+  (setq t (^ x (<< x 11)))
+  (setq x y)
+  (setq y z)
+  (setq z w)
+
+  (setq w (^ w (^ (>> w 19) (^ t (>> t 8)
+  (set lst 0 x)
+  (set lst 1 y)
+  (set lst 2 z)
+  (set lst 3 w)
+  w
+  )
+
+
+(defun random_list (n max)
+  (setq i n)
+  (setq res (list))
+  (while (> i 0)
+(append res (% (xor128) max))
+(setq i (- i 1))
+)
+  res
+  )
+
+
+
+
+(defun worker (shared private)
+  (setq i 1)
+  (while (< i 1)
+;; every 200th modification is on 'shared'
+(if (== (% i 200) 0)
+(set shared (+ (get shared) 1))
+  (set private (+ (get private) 1))
+  )
+
+(setq i (+ i 1))
+)
+  )
+
+
+
+(setq N 800)
+(setq RAND_MAX 10)
+(setq CONFL_IF_BELOW 1)
+
+
+(setq shared (container 0))
+
+(setq rand-list (random_list N RAND_MAX))
+(setq i 0)
+(while (< i N)
+  (setq private (container 0))
+  (if (< (get rand-list i) CONFL_IF_BELOW)
+  ;; conflicting transaction
+  (transaction worker shared private)
+;; else non-conflicting
+(transaction worker private private)
+)
+
+  (setq i (+ i 1))
+  )
+
+(run-transactions)
+(print (quote shared) (get shared))
+
diff --git a/duhton/transaction.c b/duhton/transaction.c
--- a/duhton/transaction.c
+++ b/duhton/transaction.c
@@ -93,7 +93,7 @@
 stm_start_inevitable_transaction();
 
 root = du_pending_transactions;
-/* _du_read1(root); IMMUTABLE */
+_du_read1(root);/* not immutable... */
 
 if (root->cdr != Du_None) {
 DuObject *cell = root->cdr;
@@ -135,8 +135,9 @@
 stm_thread_local_obj = NULL;
 
 while (__builtin_setjmp(here) == 1) { }
-stm_start_transaction(&here);
-
+//stm_start_transaction(&here);
+stm_start_inevitable_transaction();
+
 /* _du_read1(pending); IMMUTABLE */
 DuObject *result = _DuCons_CAR(pending);
 DuObject *next = _DuCons_NEXT(pending);
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] stmgc c7: add parallel version of n-queens

2014-02-05 Thread Remi Meier
Author: Remi Meier
Branch: c7
Changeset: r703:852f9a4772d4
Date: 2014-02-05 13:02 +0100
http://bitbucket.org/pypy/stmgc/changeset/852f9a4772d4/

Log:add parallel version of n-queens

diff --git a/duhton/demo/nqueens.duh b/duhton/demo/nqueens.duh
--- a/duhton/demo/nqueens.duh
+++ b/duhton/demo/nqueens.duh
@@ -3,13 +3,33 @@
 
 
 
-(setq count (container 0))
 
 (defun abs (i)
   (if (<= 0 i)
   i
 (- 0 i)))
 
+(defun clean_list (n)
+  (setq i n)
+  (setq res (list))
+  (while (> i 0)
+(append res 0)
+(setq i (- i 1))
+)
+  res
+  )
+
+(defun copy_list (xs)
+  (setq res (list))
+  (setq idx 0)
+  (while (< idx (len xs))
+(append res (get xs idx))
+(setq idx (+ idx 1))
+)
+  res
+  )
+
+
 (defun attacks (hist col i j)
   (|| (== (get hist j) i)
   (== (abs (- (get hist j) i))
@@ -38,11 +58,11 @@
 )
   )
 
-(defun solve (n col hist)
+(defun solve (n col hist count)
   (if (== col n)
   (progn
 (set count (+ (get count) 1))
-(print_solution hist n)
+;; (print_solution hist n)
 )
 
 ;; else
@@ -57,7 +77,7 @@
   (if (>= j col)
   (progn
 (set hist col i)
-(solve n (+ col 1) hist)
+(solve n (+ col 1) hist count)
 ))
   
   (setq i (+ i 1))
@@ -66,20 +86,63 @@
   )
 
 
+(defun solve_parallel (n col hist count)
+  (if (== col n)
+  (progn
+(set count (+ (get count) 1))
+;; (print_solution hist n)
+)
 
-(defun clean_list (n)
-  (setq i n)
-  (setq res (list))
-  (while (> i 0)
-(append res 0)
-(setq i (- i 1))
+;; else
+(setq i 0)
+(setq transaction-limit 1)
+(if (== col transaction-limit)
+(setq counts (list)))
+
+(while (< i n)
+  (setq j 0)
+  (while (&& (< j col)
+ (not (attacks hist col i j)))
+(setq j (+ j 1))
+)
+
+  (if (>= j col)
+  (progn
+(set hist col i)
+(if (== col transaction-limit)
+(progn
+  (setq new_cont (container 0))
+  (append counts new_cont)
+  (transaction solve n (+ col 1) (copy_list hist) new_cont)
+  )
+  (solve_parallel n (+ col 1) hist count)
+  )
+)
+)
+  ;; iterator
+  (setq i (+ i 1))
+  )
+
+(if (== col transaction-limit)
+(progn
+  (run-transactions)
+  (setq i 0)
+  (while (< i (len counts))
+(set count (+ (get count) (get (get counts i
+(setq i (+ i 1))
+)
+  )
+  )
 )
-  res
   )
 
 
 
-(setq n 8)
-(solve n 0 (clean_list n))
+
+
+(setq count (container 0))
+
+(setq n 11)
+(solve_parallel n 0 (clean_list n) count)
 (print (quote solutions:) (get count))
 
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] stmgc c7: implement requesting of safe-points and older-transaction-succeeds in write-write conflicts

2014-02-05 Thread Remi Meier
Author: Remi Meier
Branch: c7
Changeset: r705:d7f5d26b082d
Date: 2014-02-05 14:52 +0100
http://bitbucket.org/pypy/stmgc/changeset/d7f5d26b082d/

Log:implement requesting of safe-points and older-transaction-succeeds
in write-write conflicts

diff --git a/c7/core.c b/c7/core.c
--- a/c7/core.c
+++ b/c7/core.c
@@ -21,6 +21,7 @@
 static int num_threads_started;
 uint8_t write_locks[READMARKER_END - READMARKER_START];
 volatile uint8_t inevitable_lock __attribute__((aligned(64))); /* cache-line 
alignment */
+long global_age = 0;
 
 struct _thread_local1_s* _stm_dbg_get_tl(int thread)
 {
@@ -134,18 +135,16 @@
 if ((!prev_owner) || (prev_owner == lock_num))
 break;
 
-if (_STM_TL->active == 2) {
+struct _thread_local1_s* other_tl = _stm_dbg_get_tl(prev_owner - 1);
+if ((_STM_TL->age < other_tl->age) || (_STM_TL->active == 2)) {
 /* we must succeed! */
-_stm_dbg_get_tl(prev_owner - 1)->need_abort = 1;
+other_tl->need_abort = 1;
 _stm_start_safe_point(0);
 /* XXX: not good, maybe should be signalled by other thread */
 usleep(1);
 _stm_stop_safe_point(0);
 goto retry;
-}
-
-
-if (retries < 1) {
+} else if (retries < 1) {
 _stm_start_safe_point(0);
 usleep(1);
 _stm_stop_safe_point(0);
@@ -176,8 +175,8 @@
 _stm_restore_local_state(thread_num);
 
 _STM_TL->nursery_current = (localchar_t*)(FIRST_NURSERY_PAGE * 4096);
-memset((void*)real_address((object_t*)_STM_TL->nursery_current), 0x0,
-   (FIRST_AFTER_NURSERY_PAGE - FIRST_NURSERY_PAGE) * 4096); /* clear 
nursery */
+
memset((void*)real_address((object_t*)CLEAR_SYNC_REQUEST(_STM_TL->nursery_current)),
+   0x0, (FIRST_AFTER_NURSERY_PAGE - FIRST_NURSERY_PAGE) * 4096); /* 
clear nursery */
 
 _STM_TL->shadow_stack = NULL;
 _STM_TL->shadow_stack_base = NULL;
@@ -386,6 +385,8 @@
 _STM_TL->jmpbufptr = jmpbufptr;
 _STM_TL->active = 1;
 _STM_TL->need_abort = 0;
+/* global_age is approximate -> no synchronization required */
+_STM_TL->age = global_age++;
 
 fprintf(stderr, "%c", 'S'+_STM_TL->thread_num*32);
 }
diff --git a/c7/core.h b/c7/core.h
--- a/c7/core.h
+++ b/c7/core.h
@@ -94,6 +94,10 @@
 jmpbufptr_t *jmpbufptr;
 uint8_t transaction_read_version;
 
+/* unsynchronized/inaccurate start age of transaction
+   XXX: may be replaced with size_of(read/write-set) */
+long age;
+
 /* static threads, not pthreads */
 int thread_num;
 char *thread_base;
@@ -105,7 +109,10 @@
 object_t **shadow_stack;
 object_t **shadow_stack_base;
 
-localchar_t *nursery_current;
+union {
+localchar_t *nursery_current;
+uint32_t nursery_current_halfwords[2];
+};
 
 struct stm_list_s *modified_objects;
 
diff --git a/c7/nursery.c b/c7/nursery.c
--- a/c7/nursery.c
+++ b/c7/nursery.c
@@ -166,7 +166,7 @@
 /* clear nursery */
 localchar_t *nursery_base = (localchar_t*)(FIRST_NURSERY_PAGE * 4096);
 memset((void*)real_address((object_t*)nursery_base), 0x0,
-   _STM_TL->nursery_current - nursery_base);
+   CLEAR_SYNC_REQUEST(_STM_TL->nursery_current) - nursery_base);
 _STM_TL->nursery_current = nursery_base;
 }
 
@@ -177,23 +177,33 @@
 
 localchar_t *collect_and_reserve(size_t size)
 {
+localchar_t *new_current = _STM_TL->nursery_current;
+
+while (((uintptr_t)new_current > FIRST_AFTER_NURSERY_PAGE * 4096)
+   && _STM_TL->nursery_current_halfwords[1]) {
+
+_STM_TL->nursery_current_halfwords[1] = 0;
+_stm_start_safe_point(0);
+/* no collect, it would mess with nursery_current */
+_stm_stop_safe_point(0);
+
+new_current = _STM_TL->nursery_current;
+}
+
+if (!((uintptr_t)new_current > FIRST_AFTER_NURSERY_PAGE * 4096)) {
+/* after safe-point, new_current is actually fine again */
+return new_current - size;
+}
+
 /* reset nursery_current (left invalid by the caller) */
 _STM_TL->nursery_current -= size;
 
-/* XXX: check for requested safe-point (by setting nursery_current
-   too high or similar) */
-
-
-_stm_start_safe_point(0);/* don't release the COLLECT lock,
-   that needs to be done afterwards if
-   we want a major collection */
 minor_collect();
-_stm_stop_safe_point(0);
 
 /* XXX: if we_want_major_collect: acquire EXCLUSIVE & COLLECT lock
and do it */
 
-localchar_t *current = _STM_TL->nursery_current;
+localchar_t *current = CLEAR_SYNC_REQUEST(_STM_TL->nursery_current);
 _STM_TL->nursery_current = current + size;
 return current;
 }
@@ -231,7 +241,6 @@
 localchar_t *current = _STM_TL->nursery_current;
 localchar_t *new_current = current + size;
 _STM_TL->nursery_curr

[pypy-commit] pypy precompiled-headers: percolate keword changes to darwin

2014-02-05 Thread mattip
Author: Matti Picus 
Branch: precompiled-headers
Changeset: r69083:8ceff85c1482
Date: 2014-02-05 22:26 +0200
http://bitbucket.org/pypy/pypy/changeset/8ceff85c1482/

Log:percolate keword changes to darwin

diff --git a/rpython/translator/platform/darwin.py 
b/rpython/translator/platform/darwin.py
--- a/rpython/translator/platform/darwin.py
+++ b/rpython/translator/platform/darwin.py
@@ -50,14 +50,17 @@
 return ["-Wl,-exported_symbols_list,%s" % (response_file,)]
 
 def gen_makefile(self, cfiles, eci, exe_name=None, path=None,
- shared=False, cfile_precompilation=None):
+ shared=False, headers_to_precompile=[],
+ no_precompile_cfiles = []):
 # ensure frameworks are passed in the Makefile
 fs = self._frameworks(eci.frameworks)
 if len(fs) > 0:
 # concat (-framework, FrameworkName) pairs
 self.extra_libs += tuple(map(" ".join, zip(fs[::2], fs[1::2])))
 mk = super(Darwin, self).gen_makefile(cfiles, eci, exe_name, path,
-  shared, cfile_precompilation)
+shared=shared,
+headers_to_precompile=headers_to_precompile,
+no_precompile_cfiles = no_precompile_cfiles)
 return mk
 
 
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy precompiled-headers: copy seperate_module_files even when no makefile is used

2014-02-05 Thread mattip
Author: Matti Picus 
Branch: precompiled-headers
Changeset: r69082:8c1b2356d7bd
Date: 2014-02-05 22:01 +0200
http://bitbucket.org/pypy/pypy/changeset/8c1b2356d7bd/

Log:copy seperate_module_files even when no makefile is used

diff --git a/rpython/translator/c/dlltool.py b/rpython/translator/c/dlltool.py
--- a/rpython/translator/c/dlltool.py
+++ b/rpython/translator/c/dlltool.py
@@ -31,6 +31,8 @@
 extsymeci = ExternalCompilationInfo(export_symbols=export_symbols)
 self.eci = self.eci.merge(extsymeci)
 files = [self.c_source_filename] + self.extrafiles
+files += self.eventually_copy(self.eci.separate_module_files)
+self.eci.separate_module_files = ()
 oname = self.name
 self.so_name = self.translator.platform.compile(files, self.eci,
 standalone=False,
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy precompiled-headers: implement for posix, fix test for posix and pep8 cleanup

2014-02-05 Thread mattip
Author: Matti Picus 
Branch: precompiled-headers
Changeset: r69084:7fb7c9228605
Date: 2014-02-05 23:38 +0200
http://bitbucket.org/pypy/pypy/changeset/7fb7c9228605/

Log:implement for posix, fix test for posix and pep8 cleanup

diff --git a/rpython/translator/platform/posix.py 
b/rpython/translator/platform/posix.py
--- a/rpython/translator/platform/posix.py
+++ b/rpython/translator/platform/posix.py
@@ -158,16 +158,29 @@
 ('CC_LINK', eci.use_cpp_linker and 'g++' or '$(CC)'),
 ('LINKFILES', eci.link_files),
 ]
-for args in definitions:
-m.definition(*args)
 
 rules = [
 ('all', '$(DEFAULT_TARGET)', []),
 ('$(TARGET)', '$(OBJECTS)', '$(CC_LINK) $(LDFLAGSEXTRA) -o $@ 
$(OBJECTS) $(LIBDIRS) $(LIBS) $(LINKFILES) $(LDFLAGS)'),
-('%.o', '%.c', '$(CC) $(CFLAGS) $(CFLAGSEXTRA) -o $@ -c $< 
$(INCLUDEDIRS)'),
 ('%.o', '%.cxx', '$(CXX) $(CFLAGS) $(CFLAGSEXTRA) -o $@ -c $< 
$(INCLUDEDIRS)'),
 ]
 
+if len(headers_to_precompile)>0:
+stdafx_h = path.join('stdafx.h')
+txt  = '#ifndef PYPY_STDAFX_H\n'
+txt += '#define PYPY_STDAFX_H\n'
+txt += '\n'.join(['#include "' + m.pathrel(c) + '"' for c in 
headers_to_precompile])
+txt += '\n#endif\n'
+stdafx_h.write(txt)
+rules.append(('$(OBJECTS)', 'stdafx.h.gch', []))
+rules.append(('%.h.gch', '%.h',
+'$(CC) $(CFLAGS) $(CFLAGSEXTRA) -o $@ -c $< 
$(INCLUDEDIRS)'))
+rules.append(('%.o', '%.c', '$(CC) $(CFLAGS) $(CFLAGSEXTRA) 
-include stdafx.h -o $@ -c $< $(INCLUDEDIRS)'))
+else:
+rules.append(('%.o', '%.c', '$(CC) $(CFLAGS) $(CFLAGSEXTRA) -o $@ 
-c $< $(INCLUDEDIRS)'))
+
+for args in definitions:
+m.definition(*args)
 for rule in rules:
 m.rule(*rule)
 
diff --git a/rpython/translator/platform/test/test_makefile.py 
b/rpython/translator/platform/test/test_makefile.py
--- a/rpython/translator/platform/test/test_makefile.py
+++ b/rpython/translator/platform/test/test_makefile.py
@@ -6,6 +6,13 @@
 from StringIO import StringIO
 import re, sys
 
+import time
+if sys.platform == 'win32':
+get_time = time.clock
+else:
+get_time = time.time
+
+
 def test_simple_makefile():
 m = Makefile()
 m.definition('CC', 'xxx')
@@ -31,7 +38,7 @@
 m.write(s)
 val = s.getvalue()
 assert not re.search('CC += +xxx', val, re.M)
-assert re.search('CC += +yyy', val, re.M)
+assert re.search('CC += +yyy', val, re.M)
 
 class TestMakefile(object):
 platform = host
@@ -41,13 +48,13 @@
 assert res.out == expected
 if self.strict_on_stderr:
 assert res.err == ''
-assert res.returncode == 0
-
+assert res.returncode == 0
+
 def test_900_files(self):
 txt = '#include \n'
 for i in range(900):
 txt += 'int func%03d();\n' % i
-txt += 'int main() {\nint j=0;'
+txt += 'int main() {\nint j=0;'
 for i in range(900):
 txt += 'j += func%03d();\n' % i
 txt += 'printf("%d\\n", j);\n'
@@ -71,7 +78,6 @@
 self.check_res(res, '%d\n' %sum(range(900)))
 
 def test_precompiled_headers(self):
-import time
 tmpdir = udir.join('precompiled_headers').ensure(dir=1)
 # Create an eci that should not use precompiled headers
 eci = ExternalCompilationInfo(include_dirs=[tmpdir])
@@ -79,7 +85,7 @@
 eci.separate_module_files = [main_c]
 ncfiles = 10
 nprecompiled_headers = 20
-txt = ''
+txt = '#include \n'
 for i in range(ncfiles):
 txt += "int func%03d();\n" % i
 txt += "\nint main(int argc, char * argv[])\n"
@@ -97,8 +103,8 @@
 for j in range(3000):
 txt += "int pcfunc%03d_%03d();\n" %(i, j)
 txt += '#endif'
-pch_name.write(txt)
-cfiles_precompiled_headers.append(pch_name)
+pch_name.write(txt)
+cfiles_precompiled_headers.append(pch_name)
 # Create some cfiles with headers we want precompiled
 cfiles = []
 for i in range(ncfiles):
@@ -108,18 +114,18 @@
 txt += '#include "%s"\n' % pch_name
 txt += "int func%03d(){ return %d;};\n" % (i, i)
 c_name.write(txt)
-cfiles.append(c_name)
+cfiles.append(c_name)
 if sys.platform == 'win32':
 clean = ('clean', '', 'for %f in ( $(OBJECTS) $(TARGET) ) do @if 
exist %f del /f %f')
-else:
+else:
 clean = ('clean', '', 'rm -f $(OBJECTS) $(TARGET) ')
 #write a non-precompiled header makefile
 mk = self.platform.gen_makefile(cfiles, eci, path=tmpdir)
 mk.rule(*clean)
 mk.write()
-t0 = time.clock()
+t0 = 

[pypy-commit] pypy default: get source information for UnionErrors arising from non-RPython PBCs (such as ['a', 1])

2014-02-05 Thread rlamy
Author: Ronan Lamy 
Branch: 
Changeset: r69085:437833a4447c
Date: 2014-02-06 01:16 +
http://bitbucket.org/pypy/pypy/changeset/437833a4447c/

Log:get source information for UnionErrors arising from non-RPython PBCs
(such as ['a', 1])

diff --git a/rpython/annotator/annrpython.py b/rpython/annotator/annrpython.py
--- a/rpython/annotator/annrpython.py
+++ b/rpython/annotator/annrpython.py
@@ -582,18 +582,18 @@
 
 def consider_op(self, block, opindex):
 op = block.operations[opindex]
-argcells = [self.binding(a) for a in op.args]
+try:
+argcells = [self.binding(a) for a in op.args]
 
-# let's be careful about avoiding propagated SomeImpossibleValues
-# to enter an op; the latter can result in violations of the
-# more general results invariant: e.g. if SomeImpossibleValue enters 
is_
-#  is_(SomeImpossibleValue, None) -> SomeBool
-#  is_(SomeInstance(not None), None) -> SomeBool(const=False) ...
-# boom -- in the assert of setbinding()
-for arg in argcells:
-if isinstance(arg, annmodel.SomeImpossibleValue):
-raise BlockedInference(self, op, opindex)
-try:
+# let's be careful about avoiding propagated SomeImpossibleValues
+# to enter an op; the latter can result in violations of the
+# more general results invariant: e.g. if SomeImpossibleValue 
enters is_
+#  is_(SomeImpossibleValue, None) -> SomeBool
+#  is_(SomeInstance(not None), None) -> SomeBool(const=False) ...
+# boom -- in the assert of setbinding()
+for arg in argcells:
+if isinstance(arg, annmodel.SomeImpossibleValue):
+raise BlockedInference(self, op, opindex)
 resultcell = op.consider(self, *argcells)
 except annmodel.AnnotatorError as e: # note that UnionError is a 
subclass
 graph = self.bookkeeper.position_key[0]
diff --git a/rpython/annotator/test/test_annrpython.py 
b/rpython/annotator/test/test_annrpython.py
--- a/rpython/annotator/test/test_annrpython.py
+++ b/rpython/annotator/test/test_annrpython.py
@@ -4139,6 +4139,16 @@
 a.build_types(f, [str])
 assert ("Cannot prove that the object is callable" in exc.value.msg)
 
+def test_UnionError_on_PBC(self):
+l = ['a', 1]
+def f(x):
+l.append(x)
+a = self.RPythonAnnotator()
+with py.test.raises(annmodel.UnionError) as excinfo:
+a.build_types(f, [int])
+assert 'Happened at file' in excinfo.value.source
+assert 'Known variable annotations:' in excinfo.value.source
+
 def test_str_format_error(self):
 def f(s, x):
 return s.format(x)
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy precompiled-headers: precompiled headers define _GNU_SOURCE

2014-02-05 Thread mattip
Author: Matti Picus 
Branch: precompiled-headers
Changeset: r69086:4853ab8f1bf9
Date: 2014-02-06 06:03 +0200
http://bitbucket.org/pypy/pypy/changeset/4853ab8f1bf9/

Log:precompiled headers define _GNU_SOURCE

diff --git a/rpython/translator/c/src/profiling.c 
b/rpython/translator/c/src/profiling.c
--- a/rpython/translator/c/src/profiling.c
+++ b/rpython/translator/c/src/profiling.c
@@ -3,10 +3,7 @@
 
 /* Linux GCC implementation */
 
-#ifndef _GNU_SOURCE
-#define _GNU_SOURCE
 #include 
-#endif
 
 static cpu_set_t base_cpu_set;
 static int profiling_setup = 0;
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit