From f632ef49a7d5465943ac7ac7c666c0490887caad Mon Sep 17 00:00:00 2001 From: Matthias Andreas Benkard Date: Wed, 13 Aug 2008 00:43:48 +0200 Subject: Revert "MLKCompiledClosure: Always indirect through a function pointer before doing a call." This reverts commit dfe50b2e72ddbd0148870748975f00e7fc662314. --- MLKCompiledClosure.m | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) (limited to 'MLKCompiledClosure.m') diff --git a/MLKCompiledClosure.m b/MLKCompiledClosure.m index 5dbf6dd..c2ab290 100644 --- a/MLKCompiledClosure.m +++ b/MLKCompiledClosure.m @@ -38,10 +38,7 @@ _data = data; _dataLength = dataLength; - _ownPointer = YES; - - _code = malloc (sizeof (id (*)())); - *_code = code; + _code = code; for (i = 0; i < _dataLength; i++) { @@ -89,7 +86,7 @@ format:@"FFI type is invalid (this is probably a bug)."]; } - ffi_call (&cif, FFI_FN (*_code), &return_value, (void**)argv); + ffi_call (&cif, FFI_FN (_code), &return_value, (void**)argv); // FIXME return [NSArray arrayWithObject:nullify(return_value)]; @@ -111,16 +108,11 @@ [super dealloc]; - // FIXME: Decrease refcount of *_code. Note: When releasing *_code, - // also release _code regardless of whether we own it. - + // FIXME: Decrease refcount of _code. for (i = 0; i < _dataLength; i++) { LRELEASE (_data[i]); } free (_data); - - if (_ownPointer) - free (_code); } @end -- cgit v1.2.3 From 33d61cbd7c4017d4f7832b331721cf00000a8c0b Mon Sep 17 00:00:00 2001 From: Matthias Andreas Benkard Date: Fri, 15 Aug 2008 23:22:41 +0200 Subject: MLKCompiledClosure: Add debugging messages. --- MLKCompiledClosure.m | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'MLKCompiledClosure.m') diff --git a/MLKCompiledClosure.m b/MLKCompiledClosure.m index c2ab290..6737acc 100644 --- a/MLKCompiledClosure.m +++ b/MLKCompiledClosure.m @@ -86,9 +86,16 @@ format:@"FFI type is invalid (this is probably a bug)."]; } + NSLog (@"Calling %p (argc = %d)", _code, argc); + _code(0, MLKEndOfArgumentsMarker); + for (i = 0; i < argc; i++) + { + NSLog (@"Argument %d: %p", i, *((void**)argv[i])); + } + ffi_call (&cif, FFI_FN (_code), &return_value, (void**)argv); - // FIXME + // FIXME: multiple values return [NSArray arrayWithObject:nullify(return_value)]; } -- cgit v1.2.3 From 291c50e6fc89dea5d2e0ba731a2188a4ccacbd06 Mon Sep 17 00:00:00 2001 From: Matthias Andreas Benkard Date: Sat, 16 Aug 2008 13:43:42 +0200 Subject: MLKCompiledClosure: Fix an off-by-one error in argument handling. --- MLKCompiledClosure.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'MLKCompiledClosure.m') diff --git a/MLKCompiledClosure.m b/MLKCompiledClosure.m index 6737acc..85b1bf5 100644 --- a/MLKCompiledClosure.m +++ b/MLKCompiledClosure.m @@ -72,7 +72,7 @@ for (i = 1; i < argc - 1; i++) { arg_types[i] = &ffi_type_pointer; - argpointers[i-1] = denullify([arguments objectAtIndex:i]); + argpointers[i-1] = denullify([arguments objectAtIndex:(i-1)]); argv[i] = &argpointers[i-1]; } -- cgit v1.2.3 From 6f05d2a89573bd0cb6bb93d8c5a900254e711339 Mon Sep 17 00:00:00 2001 From: Matthias Andreas Benkard Date: Sat, 16 Aug 2008 15:25:26 +0200 Subject: MLKCompiledClosure: Remove debugging call to _code. --- MLKCompiledClosure.m | 1 - 1 file changed, 1 deletion(-) (limited to 'MLKCompiledClosure.m') diff --git a/MLKCompiledClosure.m b/MLKCompiledClosure.m index 85b1bf5..6eb9154 100644 --- a/MLKCompiledClosure.m +++ b/MLKCompiledClosure.m @@ -87,7 +87,6 @@ } NSLog (@"Calling %p (argc = %d)", _code, argc); - _code(0, MLKEndOfArgumentsMarker); for (i = 0; i < argc; i++) { NSLog (@"Argument %d: %p", i, *((void**)argv[i])); -- cgit v1.2.3 From be719f278f6b7c58cb2f0dfbd6edce19a3df85cc Mon Sep 17 00:00:00 2001 From: Matthias Andreas Benkard Date: Sat, 16 Aug 2008 15:28:10 +0200 Subject: LLVM compiler: Remove various debugging messages. --- MLKCompiledClosure.m | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'MLKCompiledClosure.m') diff --git a/MLKCompiledClosure.m b/MLKCompiledClosure.m index 6eb9154..c9f1e97 100644 --- a/MLKCompiledClosure.m +++ b/MLKCompiledClosure.m @@ -86,11 +86,11 @@ format:@"FFI type is invalid (this is probably a bug)."]; } - NSLog (@"Calling %p (argc = %d)", _code, argc); - for (i = 0; i < argc; i++) - { - NSLog (@"Argument %d: %p", i, *((void**)argv[i])); - } +// NSLog (@"Calling %p (argc = %d)", _code, argc); +// for (i = 0; i < argc; i++) +// { +// NSLog (@"Argument %d: %p", i, *((void**)argv[i])); +// } ffi_call (&cif, FFI_FN (_code), &return_value, (void**)argv); -- cgit v1.2.3 From 79abb06fbce7ee8f72556ededeee3eb88baf2fc8 Mon Sep 17 00:00:00 2001 From: Matthias Andreas Benkard Date: Sat, 16 Aug 2008 18:42:30 +0200 Subject: MLKCompiledClosure: Add accessors. --- MLKCompiledClosure.m | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'MLKCompiledClosure.m') diff --git a/MLKCompiledClosure.m b/MLKCompiledClosure.m index c9f1e97..73f308b 100644 --- a/MLKCompiledClosure.m +++ b/MLKCompiledClosure.m @@ -108,6 +108,16 @@ return [NSString stringWithFormat:@"", self]; } +-(id (*)()) code +{ + return _code; +} + +-(void *) closureData +{ + return _data; +} + -(void) dealloc { int i; -- cgit v1.2.3