From: Ian Hulin Date: Thu, 8 Jul 2010 22:54:20 +0000 (-0700) Subject: T1155: Remove MODULE_GC_KLUDGE blocks. X-Git-Tag: release/2.13.28-1~8 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=4065bcebbff7bde77a2e821db2c0c76a25c187c6;p=lilypond.git T1155: Remove MODULE_GC_KLUDGE blocks. These conditional compilation blocks were needed to support Guile V1.6. Also rename ly_make_anonymous_module to ly_make_module. (Modified the original patch to remove tab->space conversions.) Signed-off-by: Patrick McCarty --- diff --git a/lily/book.cc b/lily/book.cc index f4dd09362c..efd26d44eb 100644 --- a/lily/book.cc +++ b/lily/book.cc @@ -61,13 +61,13 @@ Book::Book (Book const &s) paper_ = s.paper_->clone (); paper_->unprotect (); } - + input_location_ = make_input (*s.origin ()); - header_ = ly_make_anonymous_module (false); + header_ = ly_make_module (false); if (ly_is_module (s.header_)) ly_module_copy (header_, s.header_); - + SCM *t = &scores_; for (SCM p = s.scores_; scm_is_pair (p); p = scm_cdr (p)) { @@ -112,7 +112,7 @@ Book::mark_smob (SCM s) scm_gc_mark (book->scores_); scm_gc_mark (book->bookparts_); scm_gc_mark (book->input_location_); - + return book->header_; } @@ -141,7 +141,7 @@ Book::set_parent (Book *parent) /* Copy the header block of the parent */ if (ly_is_module (parent->header_)) { - SCM tmp_header = ly_make_anonymous_module (false); + SCM tmp_header = ly_make_module (false); ly_module_copy (tmp_header, parent->header_); if (ly_is_module (header_)) ly_module_copy (tmp_header, header_); @@ -158,7 +158,7 @@ Book::add_scores_to_bookpart () { if (scm_is_pair (scores_)) { - /* If scores have been added to this book, add them to a child + /* If scores have been added to this book, add them to a child * book part */ Book *part = new Book; part->set_parent (this); @@ -185,7 +185,7 @@ Book::error_found () if (Score *score = unsmob_score (scm_car (s))) if (score->error_found_) return true; - + for (SCM part = bookparts_; scm_is_pair (part); part = scm_cdr (part)) if (Book *bookpart = unsmob_book (scm_car (part))) if (bookpart->error_found ()) @@ -228,11 +228,11 @@ Book::process_score (SCM s, Paper_book *output_paper_book, Output_def *layout) { SCM outputs = score ->book_rendering (output_paper_book->paper_, layout); - + while (scm_is_pair (outputs)) { Music_output *output = unsmob_music_output (scm_car (outputs)); - + if (Performance *perf = dynamic_cast (output)) output_paper_book->add_performance (perf->self_scm ()); else if (Paper_score *pscore = dynamic_cast (output)) @@ -241,7 +241,7 @@ Book::process_score (SCM s, Paper_book *output_paper_book, Output_def *layout) output_paper_book->add_score (score->get_header ()); output_paper_book->add_score (pscore->self_scm ()); } - + outputs = scm_cdr (outputs); } } @@ -250,7 +250,7 @@ Book::process_score (SCM s, Paper_book *output_paper_book, Output_def *layout) output_paper_book->add_score (scm_car (s)); else assert (0); - + } /* Concatenate all score or book part outputs into a Paper_book diff --git a/lily/include/ly-module.hh b/lily/include/ly-module.hh index 0a7fdc8726..89fbbefa80 100644 --- a/lily/include/ly-module.hh +++ b/lily/include/ly-module.hh @@ -22,7 +22,7 @@ #include "config.hh" #include "lily-guile.hh" -SCM ly_make_anonymous_module (bool safe); +SCM ly_make_module (bool safe); SCM ly_module_copy (SCM dest, SCM src); SCM ly_module_2_alist (SCM mod); SCM ly_module_lookup (SCM module, SCM sym); @@ -30,8 +30,7 @@ SCM ly_modules_lookup (SCM modules, SCM sym, SCM); SCM ly_module_symbols (SCM mod); void ly_reexport_module (SCM mod); inline bool ly_is_module (SCM x) { return SCM_MODULEP (x); } -SCM ly_clear_anonymous_modules (); -void clear_anonymous_modules (); + SCM ly_use_module (SCM mod, SCM used); /* For backward compatability with Guile 1.8 */ @@ -40,7 +39,6 @@ typedef SCM (*scm_t_hash_fold_fn) (GUILE_ELLIPSIS); typedef SCM (*scm_t_hash_handle_fn) (GUILE_ELLIPSIS); #endif -#define MODULE_GC_KLUDGE #endif /* LY_MODULE_HH */ diff --git a/lily/lily-lexer.cc b/lily/lily-lexer.cc index d3673f2cdf..5a34d60bbe 100644 --- a/lily/lily-lexer.cc +++ b/lily/lily-lexer.cc @@ -109,7 +109,7 @@ Lily_lexer::Lily_lexer (Sources *sources, Lily_parser *parser) chord_repetition_ = Chord_repetition (); smobify_self (); - add_scope (ly_make_anonymous_module (false)); + add_scope (ly_make_module (false)); push_note_state (scm_c_make_hash_table (0)); chordmodifier_tab_ = scm_make_vector (scm_from_int (1), SCM_EOL); } @@ -136,7 +136,7 @@ Lily_lexer::Lily_lexer (Lily_lexer const &src, Lily_parser *parser) SCM *tail = &scopes; for (SCM s = src.scopes_; scm_is_pair (s); s = scm_cdr (s)) { - SCM newmod = ly_make_anonymous_module (false); + SCM newmod = ly_make_module (false); ly_module_copy (newmod, scm_car (s)); *tail = scm_cons (newmod, SCM_EOL); tail = SCM_CDRLOC (*tail); diff --git a/lily/lily-parser.cc b/lily/lily-parser.cc index 6d3e13072a..4d4b3ac33e 100644 --- a/lily/lily-parser.cc +++ b/lily/lily-parser.cc @@ -64,7 +64,7 @@ Lily_parser::Lily_parser (Lily_parser const &src) { lexer_ = new Lily_lexer (*src.lexer_, this); } - + lexer_->unprotect (); } @@ -97,7 +97,7 @@ Lily_parser::print_smob (SCM s, SCM port, scm_print_state*) void Lily_parser::parse_file (string init, string name, string out_name) { - // TODO: use $parser + // TODO: use $parser lexer_->set_identifier (ly_symbol2scm ("parser"), self_scm ()); output_basename_ = out_name; @@ -142,12 +142,12 @@ Lily_parser::parse_file (string init, string name, string out_name) void Lily_parser::parse_string (string ly_code) { - // TODO: use $parser + // TODO: use $parser lexer_->set_identifier (ly_symbol2scm ("parser"), self_scm ()); lexer_->main_input_name_ = ""; - lexer_->is_main_input_ = true; + lexer_->is_main_input_ = true; lexer_->new_input (lexer_->main_input_name_, ly_code, sources_); SCM mod = lexer_->set_current_scope (); @@ -173,7 +173,7 @@ Lily_parser::clear () lexer_->remove_scope (); } - lexer_ = 0; + lexer_ = 0; } char const * @@ -204,7 +204,7 @@ IMPLEMENT_DEFAULT_EQUAL_P (Lily_parser); /**************************************************************** - OUTPUT-DEF + OUTPUT-DEF ****************************************************************/ Output_def * @@ -214,7 +214,7 @@ get_layout (Lily_parser *parser) Output_def *layout = unsmob_output_def (id); layout = layout ? layout->clone () : new Output_def; layout->set_variable (ly_symbol2scm ("is-layout"), SCM_BOOL_T); - + return layout; } @@ -288,13 +288,13 @@ get_header (Lily_parser *parser) ly_module_copy (nid, id); id = nid; } - + return id; } -SCM +SCM Lily_parser::make_scope () const { - SCM module = ly_make_anonymous_module (be_safe_global); - return module; + SCM module = ly_make_module (be_safe_global); + return module; } diff --git a/lily/ly-module.cc b/lily/ly-module.cc index 7a64410364..42ff2f8b06 100644 --- a/lily/ly-module.cc +++ b/lily/ly-module.cc @@ -23,36 +23,9 @@ #include "std-string.hh" #include "protected-scm.hh" -#ifdef MODULE_GC_KLUDGE -Protected_scm anonymous_modules = SCM_EOL; -bool perform_gc_kludge; -#endif - -void -clear_anonymous_modules () -{ -#ifdef MODULE_GC_KLUDGE - for (SCM s = anonymous_modules; - scm_is_pair (s); - s = scm_cdr (s)) - { - SCM module = scm_car (s); - SCM closure = SCM_MODULE_EVAL_CLOSURE (module); - SCM prop = scm_procedure_property (closure, ly_symbol2scm ("module")); - - if (ly_is_module (prop)) - { - scm_set_procedure_property_x (closure, ly_symbol2scm ("module"), - SCM_BOOL_F); - } - } - - anonymous_modules = SCM_EOL; -#endif -} SCM -ly_make_anonymous_module (bool safe) +ly_make_module (bool safe) { SCM mod = SCM_EOL; if (!safe) @@ -74,10 +47,6 @@ ly_make_anonymous_module (bool safe) mod = scm_call_0 (proc); } -#ifdef MODULE_GC_KLUDGE - if (perform_gc_kludge) - anonymous_modules = scm_cons (mod, anonymous_modules); -#endif return mod; } diff --git a/lily/module-scheme.cc b/lily/module-scheme.cc index b58bf15ffb..72a32e4801 100644 --- a/lily/module-scheme.cc +++ b/lily/module-scheme.cc @@ -53,17 +53,6 @@ LY_DEFINE (ly_module_copy, "ly:module-copy", return SCM_UNSPECIFIED; } -LY_DEFINE (ly_clear_anonymous_modules, "ly:clear-anonymous-modules", - 0, 0, 0, (), - "Plug a GUILE 1.6 and 1.7 memory leak by breaking a weak" - " reference pointer cycle explicitly.") -{ -#ifdef MODULE_GC_KLUDGE - clear_anonymous_modules (); -#endif - - return SCM_UNSPECIFIED; -} /* Lookup SYM, but don't give error when it is not defined. */ SCM diff --git a/lily/output-def.cc b/lily/output-def.cc index 252bcd2f19..1d94cba652 100644 --- a/lily/output-def.cc +++ b/lily/output-def.cc @@ -42,7 +42,7 @@ Output_def::Output_def () smobify_self (); - scope_ = ly_make_anonymous_module (false); + scope_ = ly_make_module (false); } Output_def::Output_def (Output_def const &s) @@ -52,7 +52,7 @@ Output_def::Output_def (Output_def const &s) smobify_self (); input_origin_ = s.input_origin_; - scope_ = ly_make_anonymous_module (false); + scope_ = ly_make_module (false); if (ly_is_module (s.scope_)) ly_module_copy (scope_, s.scope_); } diff --git a/lily/score.cc b/lily/score.cc index fb537a3db2..31550fbbe7 100644 --- a/lily/score.cc +++ b/lily/score.cc @@ -94,7 +94,7 @@ Score::Score (Score const &s) error_found_ = s.error_found_; smobify_self (); - input_location_ = make_input (*s.origin ()); + input_location_ = make_input (*s.origin ()); Music *m = unsmob_music (s.music_); if (m) @@ -111,7 +111,7 @@ Score::Score (Score const &s) defs_.push_back (copy); copy->unprotect (); } - header_ = ly_make_anonymous_module (false); + header_ = ly_make_module (false); if (ly_is_module (s.header_)) ly_module_copy (header_, s.header_); } diff --git a/scm/lily.scm b/scm/lily.scm index 67958290d8..c0c1f44256 100644 --- a/scm/lily.scm +++ b/scm/lily.scm @@ -682,7 +682,7 @@ PIDs or the number of the process." (eval-string (ly:command-line-code)) (if (ly:get-option 'help) (begin (ly:option-usage) - (ly:exit 0 #t ))) + (ly:exit 0 #t))) (if (ly:get-option 'show-available-fonts) (begin (ly:font-config-display-fonts) (ly:exit 0 #t))) @@ -798,7 +798,6 @@ PIDs or the number of the process." (for-each (lambda (s) (ly:set-option (car s) (cdr s))) all-settings) - (ly:clear-anonymous-modules) (ly:set-option 'debug-gc-assert-parsed-dead #t) (gc) (ly:set-option 'debug-gc-assert-parsed-dead #f)