Author: David Malcolm <dmalc...@redhat.com>
Branch: libgccjit-backend
Changeset: r75245:a87b97f2b383
Date: 2014-12-24 05:20 -0500
http://bitbucket.org/pypy/pypy/changeset/a87b97f2b383/

Log:    Provide a way to turn off the comments

        Running pytest under the profile module shows >50% wallclock time
        spent in str2charp, much of that in Block.add_comment.

diff --git a/rpython/jit/backend/libgccjit/assembler.py 
b/rpython/jit/backend/libgccjit/assembler.py
--- a/rpython/jit/backend/libgccjit/assembler.py
+++ b/rpython/jit/backend/libgccjit/assembler.py
@@ -123,7 +123,7 @@
         self.set_handler(handler)
 
     def set_handler(self, handler):
-        print('set_handler(%r)' % handler)
+        #print('set_handler(%r)' % handler)
 
         # We want to write the equivalent of:
         #    (*fn_ptr_ptr) = handler;
@@ -172,6 +172,8 @@
         eci = make_eci()
         self.lib = Library(eci)
 
+        self.add_comments = 1
+
     def make_context(self):
         self.ctxt = 
Context.acquire(self.lib)#self.lib.gcc_jit_context_acquire()
         if 0:
@@ -190,11 +192,11 @@
             self.ctxt.set_int_option(
                 self.lib.GCC_JIT_INT_OPTION_OPTIMIZATION_LEVEL,
                 r_int(2))
-        if 1:
+        if 0:
             self.ctxt.set_bool_option(
                 self.lib.GCC_JIT_BOOL_OPTION_KEEP_INTERMEDIATES,
                 r_int(1))
-        if 1:
+        if 0:
             self.ctxt.set_bool_option(
                 self.lib.GCC_JIT_BOOL_OPTION_DUMP_EVERYTHING,
                 r_int(1))
@@ -269,7 +271,8 @@
         self.datablockwrapper.done()      # finish using cpu.asmmemmgr
         self.datablockwrapper = None
 
-        self.ctxt.dump_to_file("/tmp/%s.c" % loopname, r_int(1))
+        if 1:
+            self.ctxt.dump_to_file("/tmp/%s.c" % loopname, r_int(1))
 
         #raise foo
 
@@ -306,7 +309,8 @@
 
         self.make_function(name, inputargs, operations)
 
-        self.ctxt.dump_to_file("/tmp/%s.c" % name, r_int(1))
+        if 1:
+            self.ctxt.dump_to_file("/tmp/%s.c" % name, r_int(1))
         jit_result = self.ctxt.compile()
         self.ctxt.release()
 
@@ -413,11 +417,13 @@
             #print(dir(op))
             #print(repr(op.getopname()))
             text += '\t%s\n' % op
-        self.b_current.add_comment(str(text))
+        if self.add_comments:
+            self.b_current.add_comment(str(text))
 
         # Get initial values from input args:
         for idx, arg in enumerate(inputargs):
-            self.b_current.add_comment("inputargs[%i]: %s" % (idx, arg))
+            if self.add_comments:
+                self.b_current.add_comment("inputargs[%i]: %s" % (idx, arg))
             # (gdb) p *(double*)&jitframe->arg0
             # $7 = 10.5
             # (gdb) p *(double*)&jitframe->arg1
@@ -442,7 +448,8 @@
             #print(dir(op))
             #print(repr(op.getopname()))
             # Add a comment describing this ResOperation
-            self.b_current.add_comment(str(op))
+            if self.add_comments:
+                self.b_current.add_comment(str(op))
 
             # Compile the operation itself...
             methname = 'emit_%s' % op.getopname()
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to