[pure-lang-svn] SF.net SVN: pure-lang:[462] pure/trunk
Status: Beta
Brought to you by:
agraef
|
From: <ag...@us...> - 2008-08-10 21:33:33
|
Revision: 462
http://pure-lang.svn.sourceforge.net/pure-lang/?rev=462&view=rev
Author: agraef
Date: 2008-08-10 21:33:41 +0000 (Sun, 10 Aug 2008)
Log Message:
-----------
Overhaul of list/tuple generation code.
Modified Paths:
--------------
pure/trunk/ChangeLog
pure/trunk/interpreter.cc
pure/trunk/interpreter.hh
Modified: pure/trunk/ChangeLog
===================================================================
--- pure/trunk/ChangeLog 2008-08-10 20:21:23 UTC (rev 461)
+++ pure/trunk/ChangeLog 2008-08-10 21:33:41 UTC (rev 462)
@@ -4,7 +4,9 @@
evaluations and variable definitions of constant expressions.
* interpreter.cc (codegen): Fixed memory leak caused by the new
- list and tuple code. Reported by Jiri Spitz.
+ list and tuple code. Reported by Jiri Spitz. We now also impose a
+ minimum size for speeding up the generated code for smaller list
+ and tuple sizes.
2008-08-09 Albert Graef <Dr....@t-...>
Modified: pure/trunk/interpreter.cc
===================================================================
--- pure/trunk/interpreter.cc 2008-08-10 20:21:23 UTC (rev 461)
+++ pure/trunk/interpreter.cc 2008-08-10 21:33:41 UTC (rev 462)
@@ -3880,7 +3880,6 @@
interactive session. */
expr f; uint32_t n = count_args(x, f);
Value *v; Env *e;
- exprl xs;
if (f.tag() == EXPR::FVAR && (v = funcall(f.vtag(), f.vidx(), n, x)))
// local function call
return v;
@@ -3910,22 +3909,32 @@
argv.push_back(body);
act_env().CreateCall(module->getFunction("pure_new_args"), argv);
return call("pure_catch", handler, body);
- } else if (x.is_list(xs) || x.is_pair() && x.is_tuple(xs)) {
- // optimize the case of proper lists and tuples
- size_t i = 0, n = xs.size();
- vector<Value*> argv(n+1);
- argv[0] = UInt(n);
- for (exprl::iterator it = xs.begin(), end = xs.end(); it != end; it++)
- argv[++i] = codegen(*it);
- act_env().CreateCall(module->getFunction("pure_new_args"), argv);
- v = act_env().CreateCall
- (module->getFunction(x.is_pair()?"pure_tuplel":"pure_listl"), argv);
- vector<Value*> argv1;
- argv1.push_back(NullExprPtr);
- argv1.insert(argv1.end(), argv.begin(), argv.end());
- act_env().CreateCall(module->getFunction("pure_free_args"), argv1);
- return v;
} else {
+#if LIST_KLUDGE>0
+ /* Alternative code for proper lists and tuples, which considerably
+ speeds up compilation for larger sequences. See the comments at the
+ beginning of interpreter.hh for details. */
+ exprl xs;
+ if ((x.is_list(xs) || x.is_pair() && x.is_tuple(xs)) &&
+ xs.size() >= LIST_KLUDGE) {
+ size_t i = 0, n = xs.size();
+ vector<Value*> argv(n+1);
+ argv[0] = UInt(n);
+ for (exprl::iterator it = xs.begin(), end = xs.end(); it != end;
+ it++)
+ argv[++i] = codegen(*it);
+ act_env().CreateCall(module->getFunction("pure_new_args"), argv);
+ v = act_env().CreateCall
+ (module->getFunction(x.is_pair()?"pure_tuplel":"pure_listl"),
+ argv);
+ vector<Value*> argv1;
+ argv1.push_back(NullExprPtr);
+ argv1.insert(argv1.end(), argv.begin(), argv.end());
+ act_env().CreateCall(module->getFunction("pure_free_args"), argv1);
+ return v;
+ }
+ xs.clear();
+#endif
// ordinary function application
Value *u = codegen(x.xval1()), *v = codegen(x.xval2());
return apply(u, v);
Modified: pure/trunk/interpreter.hh
===================================================================
--- pure/trunk/interpreter.hh 2008-08-10 20:21:23 UTC (rev 461)
+++ pure/trunk/interpreter.hh 2008-08-10 21:33:41 UTC (rev 462)
@@ -29,6 +29,14 @@
get tail call elimination. */
#define USE_FASTCC 1
+/* Alternative code generation for the case of proper lists and tuples. This
+ is a kludge to work around performance issues with the JIT which (as of
+ LLVM 2.3) gets very slow with deeply nested call graphs. The code enabled
+ with this option here is actually less efficient for small list/tuple
+ values, which is why we impose a lower bound on the list/tuple size (10 by
+ default, use 0 to disable this option). */
+#define LIST_KLUDGE 10
+
using namespace std;
/* The Pure interpreter. */
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|