[pypy-svn] r21352 - in pypy/dist/pypy/translator/llvm: . module
rxe at codespeak.net
rxe at codespeak.net
Tue Dec 20 16:10:06 CET 2005
Author: rxe
Date: Tue Dec 20 16:10:04 2005
New Revision: 21352
Modified:
pypy/dist/pypy/translator/llvm/externs2ll.py
pypy/dist/pypy/translator/llvm/gc.py
pypy/dist/pypy/translator/llvm/genllvm.py
pypy/dist/pypy/translator/llvm/module/boehm.h
pypy/dist/pypy/translator/llvm/module/genexterns.c
Log:
* Make extern code a little less boehm specific
* Actually really cache our generated ll file for externs while running tests
Modified: pypy/dist/pypy/translator/llvm/externs2ll.py
==============================================================================
--- pypy/dist/pypy/translator/llvm/externs2ll.py (original)
+++ pypy/dist/pypy/translator/llvm/externs2ll.py Tue Dec 20 16:10:04 2005
@@ -146,7 +146,7 @@
includestr += "-I %s " % ii
return includestr
-def generate_llfile(db, extern_decls, entrynode, standalone):
+def generate_llfile(db, extern_decls, entrynode, standalone, gcpolicy):
ccode = []
function_names = []
@@ -178,7 +178,14 @@
else:
assert False, "unhandled extern_decls %s %s %s" % (c_name, type(obj), obj)
- # start building our source
+
+ # include this early to get constants and macros for any further includes
+ ccode.append('#include <Python.h>\n')
+
+ # ask gcpolicy for any code needed
+ ccode.append('%s\n' % gcpolicy.genextern_code())
+
+ # append our source file
ccode = "".join(ccode)
ccode += open(get_genexterns_path()).read()
Modified: pypy/dist/pypy/translator/llvm/gc.py
==============================================================================
--- pypy/dist/pypy/translator/llvm/gc.py (original)
+++ pypy/dist/pypy/translator/llvm/gc.py Tue Dec 20 16:10:04 2005
@@ -5,6 +5,9 @@
def __init__(self):
raise Exception, 'GcPolicy should not be used directly'
+ def genextern_code(self):
+ return ""
+
def gc_libraries(self):
return []
@@ -50,6 +53,9 @@
def __init__(self):
self.n_malloced = 0
+ def genextern_code(self):
+ return '#include "boehm.h"'
+
def gc_libraries(self):
return ['gc', 'pthread'] # XXX on windows?
Modified: pypy/dist/pypy/translator/llvm/genllvm.py
==============================================================================
--- pypy/dist/pypy/translator/llvm/genllvm.py (original)
+++ pypy/dist/pypy/translator/llvm/genllvm.py Tue Dec 20 16:10:04 2005
@@ -171,11 +171,12 @@
# we only cache the llexterns to make tests run faster
if self.llexterns_header is None:
assert self.llexterns_functions is None
- self.llexterns_header, self.llexterns_functions = \
+ GenLLVM.llexterns_header, GenLLVM.llexterns_functions = \
generate_llfile(self.db,
self.extern_decls,
self.entrynode,
- self.standalone)
+ self.standalone,
+ self.gcpolicy)
def create_codewriter(self):
# prevent running the same function twice in a test
Modified: pypy/dist/pypy/translator/llvm/module/boehm.h
==============================================================================
--- pypy/dist/pypy/translator/llvm/module/boehm.h (original)
+++ pypy/dist/pypy/translator/llvm/module/boehm.h Tue Dec 20 16:10:04 2005
@@ -1,3 +1,5 @@
+// XXX use some form of "configure" script
+// disable this for boehm compiled without threading
#define USING_THREADED_BOEHM
#ifdef USING_THREADED_BOEHM
@@ -22,8 +24,8 @@
}
extern GC_all_interior_pointers;
- char *RPython_StartupCode() {
- GC_all_interior_pointers = 0;
+
+// startup specific code for boehm
+#define __GC_STARTUP_CODE__ \
+ GC_all_interior_pointers = 0; \
GC_init();
- return LLVM_RPython_StartupCode();
-}
Modified: pypy/dist/pypy/translator/llvm/module/genexterns.c
==============================================================================
--- pypy/dist/pypy/translator/llvm/module/genexterns.c (original)
+++ pypy/dist/pypy/translator/llvm/module/genexterns.c Tue Dec 20 16:10:04 2005
@@ -16,9 +16,6 @@
RPyListOfString *_RPyListOfString_New(int);
void _RPyListOfString_SetItem(RPyListOfString *, int, RPyString *);
-// include this to get constants and macros for below includes
-#include <Python.h>
-
// overflows/zeros/values raising operations
#include "raisingop.h"
@@ -47,7 +44,7 @@
return NULL;
}
-
+// raw malloc code
char *raw_malloc(int size) {
return malloc(size);
}
@@ -62,8 +59,13 @@
char *LLVM_RPython_StartupCode();
-// boehm includes
-#include "boehm.h"
+char *RPython_StartupCode() {
+
+ // is there any garbage collection / memory management initialisation
+ __GC_STARTUP_CODE__
+
+ return LLVM_RPython_StartupCode();
+}
#ifdef ENTRY_POINT_DEFINED
More information about the Pypy-commit
mailing list