[pypy-svn] r65000 - in pypy/branch/pyjitpl5/pypy/jit/backend/llvm: . test
arigo at codespeak.net
arigo at codespeak.net
Sun May 3 16:50:34 CEST 2009
Author: arigo
Date: Sun May 3 16:50:33 2009
New Revision: 65000
Modified:
pypy/branch/pyjitpl5/pypy/jit/backend/llvm/llvm_rffi.py
pypy/branch/pyjitpl5/pypy/jit/backend/llvm/test/test_llvm_rffi.py
Log:
Some freeing of temporary values, at least.
Modified: pypy/branch/pyjitpl5/pypy/jit/backend/llvm/llvm_rffi.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/backend/llvm/llvm_rffi.py (original)
+++ pypy/branch/pyjitpl5/pypy/jit/backend/llvm/llvm_rffi.py Sun May 3 16:50:33 2009
@@ -58,6 +58,9 @@
# ____________________________________________________________
+LLVMDisposeMessage = llexternal('LLVMDisposeMessage', [rffi.CCHARP],
+ lltype.Void)
+
LLVMModuleCreateWithName = llexternal('LLVMModuleCreateWithName',
[rffi.CCHARP],
LLVMModuleRef)
@@ -91,6 +94,8 @@
[LLVMBuilderRef, # builder
LLVMBasicBlockRef], # block
lltype.Void)
+LLVMDisposeBuilder = llexternal('LLVMDisposeBuilder', [LLVMBuilderRef],
+ lltype.Void)
LLVMBuildRet = llexternal('LLVMBuildRet', [LLVMBuilderRef, # builder,
LLVMValueRef], # result
@@ -112,6 +117,8 @@
rffi.ULONGLONG, # value
rffi.INT], # flag: is_signed
LLVMGenericValueRef)
+LLVMDisposeGenericValue = llexternal('LLVMDisposeGenericValue',
+ [LLVMGenericValueRef], lltype.Void)
LLVMGenericValueToInt = llexternal('LLVMGenericValueToInt',
[LLVMGenericValueRef,
Modified: pypy/branch/pyjitpl5/pypy/jit/backend/llvm/test/test_llvm_rffi.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/backend/llvm/test/test_llvm_rffi.py (original)
+++ pypy/branch/pyjitpl5/pypy/jit/backend/llvm/test/test_llvm_rffi.py Sun May 3 16:50:33 2009
@@ -3,7 +3,7 @@
def test_from_llvm_py_example_1():
- # NOTE: no GC so far!!!!!!!!!
+ # NOTE: minimal GC (some objects are never freed)
# Create an (empty) module.
my_module = LLVMModuleCreateWithName("my_module")
@@ -41,6 +41,7 @@
# a ret instruction to return.
tmp = LLVMBuildAdd(builder, f_arg_0, f_arg_1, "tmp")
LLVMBuildRet(builder, tmp)
+ LLVMDisposeBuilder(builder)
# We've completed the definition now! Let's see the LLVM assembly
# language representation of what we've created: (it goes to stderr)
@@ -67,12 +68,15 @@
# or complain on platforms that don't support it.
ee_out = lltype.malloc(rffi.CArray(LLVMExecutionEngineRef), 1, flavor='raw')
error_out = lltype.malloc(rffi.CArray(rffi.CCHARP), 1, flavor='raw')
+ error_out[0] = lltype.nullptr(rffi.CCHARP.TO)
try:
error = LLVMCreateJITCompiler(ee_out, mp, True, error_out)
if rffi.cast(lltype.Signed, error) != 0:
raise LLVMException(rffi.charp2str(error_out[0]))
ee = ee_out[0]
finally:
+ if error_out[0]:
+ LLVMDisposeMessage(error_out[0])
lltype.free(error_out, flavor='raw')
lltype.free(ee_out, flavor='raw')
@@ -83,9 +87,12 @@
# Now let's compile and run!
retval = LLVMRunFunction(ee, f_sum, 2, args)
+ LLVMDisposeGenericValue(args[1])
+ LLVMDisposeGenericValue(args[0])
lltype.free(args, flavor='raw')
# The return value is also GenericValue. Let's check it.
ulonglong = LLVMGenericValueToInt(retval, True)
+ LLVMDisposeGenericValue(retval)
res = rffi.cast(lltype.Signed, ulonglong)
assert res == 142
More information about the Pypy-commit
mailing list