[pypy-svn] r18397 - in pypy/dist/pypy/translator/c: . src
tismer at codespeak.net
tismer at codespeak.net
Tue Oct 11 15:03:08 CEST 2005
Author: tismer
Date: Tue Oct 11 15:03:06 2005
New Revision: 18397
Modified:
pypy/dist/pypy/translator/c/genc.py
pypy/dist/pypy/translator/c/src/ll_stackless.h
pypy/dist/pypy/translator/c/stackless.py
Log:
modified things for source splitting a bit.
Modified: pypy/dist/pypy/translator/c/genc.py
==============================================================================
--- pypy/dist/pypy/translator/c/genc.py (original)
+++ pypy/dist/pypy/translator/c/genc.py Tue Oct 11 15:03:06 2005
@@ -158,7 +158,7 @@
funcnodes.append(node)
else:
othernodes.append(node)
- if len(funcnodes) >= SPLIT_CRITERIA:
+ if 1 or len(funcnodes) >= SPLIT_CRITERIA:##!!
self.one_source_file = False
self.funcnodes = funcnodes
self.othernodes = othernodes
Modified: pypy/dist/pypy/translator/c/src/ll_stackless.h
==============================================================================
--- pypy/dist/pypy/translator/c/src/ll_stackless.h (original)
+++ pypy/dist/pypy/translator/c/src/ll_stackless.h Tue Oct 11 15:03:06 2005
@@ -18,14 +18,31 @@
int signature;
};
+#include "slp_defs.h"
+
+/* prototypes */
+
+extern slp_frame_t* slp_frame_stack_top;
+extern slp_frame_t* slp_frame_stack_bottom;
+extern int slp_restart_substate;
+extern long slp_retval_long;
+extern double slp_retval_double;
+extern void *slp_retval_voidptr;
+
+slp_frame_t* slp_new_frame(int size, int state);
+long LL_stackless_stack_frames_depth(void);
+void slp_main_loop(void);
+
+#ifndef PYPY_NOT_MAIN_FILE
+
+/* implementations */
+
slp_frame_t* slp_frame_stack_top = NULL;
slp_frame_t* slp_frame_stack_bottom = NULL;
int slp_restart_substate;
long slp_retval_long;
double slp_retval_double;
void *slp_retval_voidptr;
-slp_frame_t* slp_new_frame(int size, int state);
-
slp_frame_t* slp_new_frame(int size, int state)
{
@@ -41,7 +58,8 @@
long LL_stackless_stack_frames_depth(void)
{
- if (slp_frame_stack_top) goto resume;
+ if (slp_frame_stack_top)
+ goto resume;
slp_frame_stack_top = slp_frame_stack_bottom =
slp_new_frame(sizeof(slp_frame_t), 0);
@@ -62,9 +80,6 @@
}
}
-
-#include "slp_defs.h"
-
#include "slp_state_decoding.h"
@@ -125,4 +140,6 @@
return result;
}
+#endif /* PYPY_NOT_MAIN_FILE */
+
#endif USE_STACKLESS
Modified: pypy/dist/pypy/translator/c/stackless.py
==============================================================================
--- pypy/dist/pypy/translator/c/stackless.py (original)
+++ pypy/dist/pypy/translator/c/stackless.py Tue Oct 11 15:03:06 2005
@@ -46,7 +46,15 @@
def writefiles(self, sg):
# generate slp_defs.h
- f = sg.makefile('slp_defs.h')
+ fi = sg.makefile('slp_defs.h')
+ cname = 'slp_impl.c'
+ assert sg.uniquecname(cname) == cname
+ fc = sg.makefile(cname)
+ print >> fc, '#define PYPY_NOT_MAIN_FILE'
+ print >> fc, '#include "common_header.h"'
+ for line in sg.preimpl:
+ print >> fc, line
+ print >> fc, '#include "src/g_include.h"'
items = self.frame_types.items()
items.sort()
for (n_integers, n_floats, n_pointers), structname in items:
@@ -59,7 +67,7 @@
fields = []
for type, varname in zip(types, varnames):
fields.append('%s %s;' % (type, varname))
- print >> f, 'struct %s { slp_frame_t header; %s };' % (
+ print >> fi, 'struct %s { slp_frame_t header; %s };' % (
structname, ' '.join(fields))
arguments = ['int state']
@@ -69,6 +77,7 @@
saving_lines.append('((struct %s*) f)->%s = %s;' % (
structname, varname, varname))
+ head = 'void *save_%(name)s(%(arguments)s);'
code = str(py.code.Source('''
void *save_%(name)s(%(arguments)s)
{
@@ -79,18 +88,21 @@
return NULL;
}
'''))
- print >> f, code % {'name': structname,
- 'arguments': ', '.join(arguments),
- 'saving_lines': '\n '.join(saving_lines)}
- f.close()
+ argdict = {'name': structname,
+ 'arguments': ', '.join(arguments),
+ 'saving_lines': '\n '.join(saving_lines)}
+ print >> fi, head % argdict
+ print >> fc, code % argdict
+ fi.close()
+ fc.close()
# generate slp_signatures.h
- f = sg.makefile('slp_signatures.h')
+ fi = sg.makefile('slp_signatures.h')
items = [(num, FUNC) for (FUNC, num) in self.allsignatures.items()]
items.sort()
for num, FUNC in items:
# 'FUNC' is a lltype.FuncType instance
- print >> f, 'case %d:' % num
+ print >> fi, 'case %d:' % num
# XXX '0' is hopefully fine for a dummy value of any type
# for most compilers
dummyargs = ['0'] * len(FUNC.ARGS)
@@ -103,19 +115,19 @@
callexpr = '%s = (%s) %s' % (globalretvalvarname,
globalretvalvartype,
callexpr)
- print >> f, '\t' + callexpr
- print >> f, '\tbreak;'
- print >> f
- f.close()
+ print >> fi, '\t' + callexpr
+ print >> fi, '\tbreak;'
+ print >> fi
+ fi.close()
# generate slp_state_decoding.h
- f = sg.makefile('slp_state_decoding.h')
- print >> f, 'static struct slp_state_decoding_entry_s',
- print >> f, 'slp_state_decoding_table[] = {'
+ fi = sg.makefile('slp_state_decoding.h')
+ print >> fi, 'static struct slp_state_decoding_entry_s',
+ print >> fi, 'slp_state_decoding_table[] = {'
for i, (functionname, signum) in enumerate(self.decode_table):
- print >> f, '/* %d */ { %s, %d },' % (i, functionname, signum)
- print >> f, '};'
- f.close()
+ print >> fi, '/* %d */ { %s, %d },' % (i, functionname, signum)
+ print >> fi, '};'
+ fi.close()
class SlpFunctionCodeGenerator(FunctionCodeGenerator):
More information about the Pypy-commit
mailing list