From: Iain Barnett on 10 Aug 2010 10:04 Hi, I read in the first answer here http://stackoverflow.com/questions/824562/does-ruby-perform-tail-call-optimization that tail recursion is not on by default and is enabled by uncommenting a line in the source before compilation. Is this still true, and is there anyway to tell if it's on or not in a particular installation? Regards, Iain
From: Joseph E. Savard on 10 Aug 2010 11:43 Its commented out. See vm_opts.h. As far as sensing it in Ruby I would think ruby-1.9.2-rc2.tar.bz2> Snippet of vm_opts.h below: #ifndef RUBY_VM_OPTS_H #define RUBY_VM_OPTS_H /* Compile options. * You can change these options at runtime by VM::CompileOption. * Following definitions are default values. */ #define OPT_TRACE_INSTRUCTION 1 #define OPT_TAILCALL_OPTIMIZATION 0 #define OPT_PEEPHOLE_OPTIMIZATION 1 #define OPT_SPECIALISED_INSTRUCTION 1 #define OPT_INLINE_CONST_CACHE 1 RUN TIME OPTIONS could be interesting to play with. You appear to loose the promise of portability. See iseq.c (Interesting rb_compile_option_t ) static rb_compile_option_t COMPILE_OPTION_DEFAULT = { OPT_INLINE_CONST_CACHE, /* int inline_const_cache; */ OPT_PEEPHOLE_OPTIMIZATION, /* int peephole_optimization; */ OPT_TAILCALL_OPTIMIZATION, /* int tailcall_optimization */ OPT_SPECIALISED_INSTRUCTION, /* int specialized_instruction; */ OPT_OPERANDS_UNIFICATION, /* int operands_unification; */ OPT_INSTRUCTIONS_UNIFICATION, /* int instructions_unification; */ OPT_STACK_CACHING, /* int stack_caching; */ OPT_TRACE_INSTRUCTION, /* int trace_instruction */ }; > From: Iain Barnett <iainspeed(a)gmail.com> > Reply-To: <ruby-talk(a)ruby-lang.org> > Date: Tue, 10 Aug 2010 23:04:50 +0900 > To: ruby-talk ML <ruby-talk(a)ruby-lang.org> > Subject: Tail recursion with 1.9 > > Hi, > > I read in the first answer here > http://stackoverflow.com/questions/824562/does-ruby-perform-tail-call-optimiza > tion that tail recursion is not on by default and is enabled by uncommenting a > line in the source before compilation. Is this still true, and is there anyway > to tell if it's on or not in a particular installation? > > > Regards, > Iain
From: Iain Barnett on 12 Aug 2010 17:52 On 10 Aug 2010, at 16:43, Joseph E. Savard wrote: > Its commented out. > > See vm_opts.h. > > As far as sensing it in Ruby I would think > > ruby-1.9.2-rc2.tar.bz2> > > Snippet of vm_opts.h below: > > #ifndef RUBY_VM_OPTS_H > #define RUBY_VM_OPTS_H > > /* Compile options. > * You can change these options at runtime by VM::CompileOption. > * Following definitions are default values. > */ > > #define OPT_TRACE_INSTRUCTION 1 > #define OPT_TAILCALL_OPTIMIZATION 0 > #define OPT_PEEPHOLE_OPTIMIZATION 1 > #define OPT_SPECIALISED_INSTRUCTION 1 > #define OPT_INLINE_CONST_CACHE 1 > > RUN TIME OPTIONS could be interesting to play with. You appear to loose the > promise of portability. > > See iseq.c (Interesting rb_compile_option_t ) > > static rb_compile_option_t COMPILE_OPTION_DEFAULT = { > OPT_INLINE_CONST_CACHE, /* int inline_const_cache; */ > OPT_PEEPHOLE_OPTIMIZATION, /* int peephole_optimization; */ > OPT_TAILCALL_OPTIMIZATION, /* int tailcall_optimization */ > OPT_SPECIALISED_INSTRUCTION, /* int specialized_instruction; */ > OPT_OPERANDS_UNIFICATION, /* int operands_unification; */ > OPT_INSTRUCTIONS_UNIFICATION, /* int instructions_unification; */ > OPT_STACK_CACHING, /* int stack_caching; */ > OPT_TRACE_INSTRUCTION, /* int trace_instruction */ > }; > Thanks for the reply. Finally got 1.9.1-p429 to compile, and I set #define OPT_TAILCALL_OPTIMIZATION 1 before compiling, which hopefully is right, I don't know C. Do you know any way I can check it's definitely on, aside from attempting to blow the stack with something hugely recursive? Iain
From: Benoit Daloze on 12 Aug 2010 18:11 On 12 August 2010 23:52, Iain Barnett <iainspeed(a)gmail.com> wrote: > > > > On 10 Aug 2010, at 16:43, Joseph E. Savard wrote: > >> Its commented out. >> >> See vm_opts.h. >> >> As far as sensing it in Ruby I would think >> >> ruby-1.9.2-rc2.tar.bz2> >> >> Snippet of vm_opts.h below: >> >> #ifndef RUBY_VM_OPTS_H >> #define RUBY_VM_OPTS_H >> >> /* Compile options. >> * You can change these options at runtime by VM::CompileOption. >> * Following definitions are default values. >> */ >> >> #define OPT_TRACE_INSTRUCTION 1 >> #define OPT_TAILCALL_OPTIMIZATION 0 >> #define OPT_PEEPHOLE_OPTIMIZATION 1 >> #define OPT_SPECIALISED_INSTRUCTION 1 >> #define OPT_INLINE_CONST_CACHE 1 >> >> RUN TIME OPTIONS could be interesting to play with. You appear to loose the >> promise of portability. >> >> See iseq.c (Interesting rb_compile_option_t ) >> >> static rb_compile_option_t COMPILE_OPTION_DEFAULT = { >> OPT_INLINE_CONST_CACHE, /* int inline_const_cache; */ >> OPT_PEEPHOLE_OPTIMIZATION, /* int peephole_optimization; */ >> OPT_TAILCALL_OPTIMIZATION, /* int tailcall_optimization */ >> OPT_SPECIALISED_INSTRUCTION, /* int specialized_instruction; */ >> OPT_OPERANDS_UNIFICATION, /* int operands_unification; */ >> OPT_INSTRUCTIONS_UNIFICATION, /* int instructions_unification; */ >> OPT_STACK_CACHING, /* int stack_caching; */ >> OPT_TRACE_INSTRUCTION, /* int trace_instruction */ >> }; >> > > Thanks for the reply. Finally got 1.9.1-p429 to compile, and I set #define OPT_TAILCALL_OPTIMIZATION 1 before compiling, which hopefully is right, I don't know C. > > Do you know any way I can check it's definitely on, aside from attempting to blow the stack with something hugely recursive? > > Iain > You should probably dig deeper in your own link :) There is a link on the stackoverflow's question: http://redmine.ruby-lang.org/issues/show/1256 The third reply from Nobu might help you ;) Regards, B.D.
From: Iain Barnett on 12 Aug 2010 18:24 On 12 Aug 2010, at 23:11, Benoit Daloze wrote: > > You should probably dig deeper in your own link :) > > There is a link on the stackoverflow's question: > http://redmine.ruby-lang.org/issues/show/1256 > The third reply from Nobu might help you ;) > > Regards, > B.D. > Thanks. I had already read that, but my brain dumps any information that I can't use at that particular moment :) $ irb > RubyVM::InstructionSequence.compile_option[:tailcall_optimization] => true Regards, Iain
|
Pages: 1 Prev: NEWBIE: Ruby & XML Next: rubyscript2exe: adding version, vendor, etc to exe resource |