From f39448c5a3804f823e367d97cd5e862b016cb8aa Mon Sep 17 00:00:00 2001 From: Andy Wingo Date: Sat, 5 Dec 2009 11:30:09 +0100 Subject: [PATCH] remove a bunch of needless scm_permanent_object calls * libguile/array-handle.c: * libguile/bytevectors.c: * libguile/deprecated.c: * libguile/eval.c: * libguile/feature.c: * libguile/filesys.c: * libguile/gc.c: * libguile/gdbint.c: * libguile/goops.c: * libguile/instructions.c: * libguile/load.c: * libguile/modules.c: * libguile/numbers.c: * libguile/options.c: * libguile/ports.c: * libguile/scmsigs.c: * libguile/srcprop.c: * libguile/srfi-4.c: * libguile/stacks.c: * libguile/threads.c: * libguile/vm.c: Remove calls to scm_permanent_object, as they are no longer needed with the BDW GC. --- libguile/array-handle.c | 3 +- libguile/bytevectors.c | 4 +-- libguile/deprecated.c | 10 +++--- libguile/eval.c | 1 - libguile/feature.c | 4 +-- libguile/filesys.c | 2 +- libguile/gc.c | 2 +- libguile/gdbint.c | 2 +- libguile/goops.c | 77 +++++++++++------------------------------ libguile/instructions.c | 3 +- libguile/load.c | 2 +- libguile/modules.c | 21 +++++------ libguile/numbers.c | 5 ++- libguile/options.c | 3 +- libguile/ports.c | 10 +++--- libguile/scmsigs.c | 6 ++-- libguile/srcprop.c | 5 ++- libguile/srfi-4.c | 12 +++---- libguile/stacks.c | 6 ++-- libguile/threads.c | 5 ++- libguile/vm.c | 8 ++--- 21 files changed, 68 insertions(+), 123 deletions(-) diff --git a/libguile/array-handle.c b/libguile/array-handle.c index cd5a46698..ec3127a4a 100644 --- a/libguile/array-handle.c +++ b/libguile/array-handle.c @@ -132,8 +132,7 @@ void scm_init_array_handle (void) { #define DEFINE_ARRAY_TYPE(tag, TAG) \ - scm_i_array_element_types[SCM_ARRAY_ELEMENT_TYPE_##TAG] \ - = (scm_permanent_object (scm_from_locale_symbol (#tag))) + scm_i_array_element_types[SCM_ARRAY_ELEMENT_TYPE_##TAG] = scm_from_locale_symbol (#tag) scm_i_array_element_types[SCM_ARRAY_ELEMENT_TYPE_SCM] = SCM_BOOL_T; DEFINE_ARRAY_TYPE (a, CHAR); diff --git a/libguile/bytevectors.c b/libguile/bytevectors.c index 992fa3fd2..63fdb5ca3 100644 --- a/libguile/bytevectors.c +++ b/libguile/bytevectors.c @@ -2206,9 +2206,9 @@ scm_bootstrap_bytevectors (void) scm_gc_protect_object (make_bytevector (0, SCM_ARRAY_ELEMENT_TYPE_VU8)); #ifdef WORDS_BIGENDIAN - scm_i_native_endianness = scm_permanent_object (scm_from_locale_symbol ("big")); + scm_i_native_endianness = scm_from_locale_symbol ("big"); #else - scm_i_native_endianness = scm_permanent_object (scm_from_locale_symbol ("little")); + scm_i_native_endianness = scm_from_locale_symbol ("little"); #endif scm_c_register_extension ("libguile", "scm_init_bytevectors", diff --git a/libguile/deprecated.c b/libguile/deprecated.c index 9364a6939..6025c7baf 100644 --- a/libguile/deprecated.c +++ b/libguile/deprecated.c @@ -249,15 +249,13 @@ static SCM try_module_autoload_var; static void init_module_stuff () { -#define PERM(x) scm_permanent_object(x) - if (module_prefix == SCM_BOOL_F) { - module_prefix = PERM (scm_list_2 (scm_sym_app, scm_sym_modules)); - make_modules_in_var = PERM (scm_c_lookup ("make-modules-in")); + module_prefix = scm_list_2 (scm_sym_app, scm_sym_modules); + make_modules_in_var = scm_c_lookup ("make-modules-in"); beautify_user_module_x_var = - PERM (scm_c_lookup ("beautify-user-module!")); - try_module_autoload_var = PERM (scm_c_lookup ("try-module-autoload")); + scm_c_lookup ("beautify-user-module!"); + try_module_autoload_var = scm_c_lookup ("try-module-autoload"); } } diff --git a/libguile/eval.c b/libguile/eval.c index 4525e4faa..eb56f4ab7 100644 --- a/libguile/eval.c +++ b/libguile/eval.c @@ -926,7 +926,6 @@ scm_init_eval () scm_listofnull = scm_list_1 (SCM_EOL); f_apply = scm_c_define_gsubr ("apply", 2, 0, 1, scm_apply); - scm_permanent_object (f_apply); scm_tc16_boot_closure = scm_make_smob_type ("boot-closure", 0); scm_set_smob_apply (scm_tc16_boot_closure, boot_closure_apply, 0, 0, 1); diff --git a/libguile/feature.c b/libguile/feature.c index 9ef4b658e..700740319 100644 --- a/libguile/feature.c +++ b/libguile/feature.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1995,1996,1998,1999,2000,2001,2002, 2003, 2004, 2006, 2007 Free Software Foundation, Inc. +/* Copyright (C) 1995,1996,1998,1999,2000,2001,2002, 2003, 2004, 2006, 2007, 2009 Free Software Foundation, Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License @@ -99,7 +99,7 @@ SCM_DEFINE (scm_set_program_arguments_scm, "set-program-arguments", 1, 0, 0, void scm_init_feature() { - progargs_fluid = scm_permanent_object (scm_make_fluid ()); + progargs_fluid = scm_make_fluid (); features_var = scm_c_define ("*features*", SCM_EOL); #ifndef _Windows diff --git a/libguile/filesys.c b/libguile/filesys.c index 311f1efab..e60efddcf 100644 --- a/libguile/filesys.c +++ b/libguile/filesys.c @@ -1712,7 +1712,7 @@ scm_init_filesys () scm_set_smob_free (scm_tc16_dir, scm_dir_free); scm_set_smob_print (scm_tc16_dir, scm_dir_print); - scm_dot_string = scm_permanent_object (scm_from_locale_string (".")); + scm_dot_string = scm_from_locale_string ("."); #ifdef O_RDONLY scm_c_define ("O_RDONLY", scm_from_int (O_RDONLY)); diff --git a/libguile/gc.c b/libguile/gc.c index dedbd28e0..b2960b1d4 100644 --- a/libguile/gc.c +++ b/libguile/gc.c @@ -817,7 +817,7 @@ scm_init_gc () { /* `GC_INIT ()' was invoked in `scm_storage_prehistory ()'. */ - scm_after_gc_hook = scm_permanent_object (scm_make_hook (SCM_INUM0)); + scm_after_gc_hook = scm_make_hook (SCM_INUM0); scm_c_define ("after-gc-hook", scm_after_gc_hook); gc_async = scm_c_make_gsubr ("%gc-thunk", 0, 0, 0, gc_async_thunk); diff --git a/libguile/gdbint.c b/libguile/gdbint.c index 351b7ba6e..7cc9535d7 100644 --- a/libguile/gdbint.c +++ b/libguile/gdbint.c @@ -166,7 +166,7 @@ gdb_read (char *str) } } gdb_result = ans; - /* Protect answer from future GC */ + /* Protect answer from future GC (FIXME: still needed with BDW-GC?) */ if (SCM_NIMP (ans)) scm_permanent_object (ans); exit: diff --git a/libguile/goops.c b/libguile/goops.c index 18332168f..f3a28d93d 100644 --- a/libguile/goops.c +++ b/libguile/goops.c @@ -879,9 +879,7 @@ create_basic_classes (void) /**** ****/ SCM cs = scm_from_locale_string (SCM_CLASS_CLASS_LAYOUT); SCM name = scm_from_locale_symbol (""); - scm_class_class = scm_permanent_object (scm_make_vtable_vtable (cs, - SCM_INUM0, - SCM_EOL)); + scm_class_class = scm_make_vtable_vtable (cs, SCM_INUM0, SCM_EOL); SCM_SET_CLASS_FLAGS (scm_class_class, (SCM_CLASSF_GOOPS_OR_VALID | SCM_CLASSF_METACLASS)); @@ -903,19 +901,15 @@ create_basic_classes (void) /**** ****/ name = scm_from_locale_symbol (""); - scm_class_top = scm_permanent_object (scm_basic_make_class (scm_class_class, - name, - SCM_EOL, - SCM_EOL)); + scm_class_top = scm_basic_make_class (scm_class_class, name, + SCM_EOL, SCM_EOL); DEFVAR(name, scm_class_top); /**** ****/ name = scm_from_locale_symbol (""); - scm_class_object = scm_permanent_object (scm_basic_make_class (scm_class_class, - name, - scm_list_1 (scm_class_top), - SCM_EOL)); + scm_class_object = scm_basic_make_class (scm_class_class, name, + scm_list_1 (scm_class_top), SCM_EOL); DEFVAR (name, scm_class_object); @@ -1630,10 +1624,6 @@ scm_change_object_class (SCM obj, SCM old_class SCM_UNUSED, SCM new_class) SCM_KEYWORD (k_name, "name"); -SCM_SYMBOL (sym_no_method, "no-method"); - -static SCM list_of_no_method; - SCM_GLOBAL_SYMBOL (scm_sym_args, "args"); @@ -2268,12 +2258,9 @@ make_stdcls (SCM *var, char *name, SCM meta, SCM super, SCM slots) { SCM tmp = scm_from_locale_symbol (name); - *var = scm_permanent_object (scm_basic_make_class (meta, - tmp, - scm_is_pair (super) - ? super - : scm_list_1 (super), - slots)); + *var = scm_basic_make_class (meta, tmp, + scm_is_pair (super) ? super : scm_list_1 (super), + slots); DEFVAR(tmp, *var); } @@ -2467,12 +2454,8 @@ make_class_from_template (char const *template, char const *type_name, SCM super else name = SCM_GOOPS_UNBOUND; - class = scm_permanent_object (scm_basic_make_class (applicablep - ? scm_class_procedure_class - : scm_class_class, - name, - supers, - SCM_EOL)); + class = scm_basic_make_class (applicablep ? scm_class_procedure_class : scm_class_class, + name, supers, SCM_EOL); /* Only define name if doesn't already exist. */ if (!SCM_GOOPS_UNBOUNDP (name) @@ -2495,12 +2478,8 @@ make_class_from_symbol (SCM type_name_sym, SCM supers, int applicablep) else name = SCM_GOOPS_UNBOUND; - class = scm_permanent_object (scm_basic_make_class (applicablep - ? scm_class_procedure_class - : scm_class_class, - name, - supers, - SCM_EOL)); + class = scm_basic_make_class (applicablep ? scm_class_procedure_class : scm_class_class, + name, supers, SCM_EOL); /* Only define name if doesn't already exist. */ if (!SCM_GOOPS_UNBOUNDP (name) @@ -2710,23 +2689,17 @@ SCM_DEFINE (scm_sys_goops_loaded, "%goops-loaded", 0, 0, 0, { goops_loaded_p = 1; var_compute_applicable_methods = - scm_permanent_object - (scm_module_variable (scm_module_goops, sym_compute_applicable_methods)); + scm_module_variable (scm_module_goops, sym_compute_applicable_methods); var_slot_unbound = - scm_permanent_object - (scm_module_variable (scm_module_goops, sym_slot_unbound)); + scm_module_variable (scm_module_goops, sym_slot_unbound); var_slot_missing = - scm_permanent_object - (scm_module_variable (scm_module_goops, sym_slot_missing)); + scm_module_variable (scm_module_goops, sym_slot_missing); var_compute_cpl = - scm_permanent_object - (scm_module_variable (scm_module_goops, sym_compute_cpl)); + scm_module_variable (scm_module_goops, sym_compute_cpl); var_no_applicable_method = - scm_permanent_object - (scm_module_variable (scm_module_goops, sym_no_applicable_method)); + scm_module_variable (scm_module_goops, sym_no_applicable_method); var_change_class = - scm_permanent_object - (scm_module_variable (scm_module_goops, sym_change_class)); + scm_module_variable (scm_module_goops, sym_change_class); setup_extended_primitive_generics (); return SCM_UNSPECIFIED; } @@ -2739,18 +2712,12 @@ scm_init_goops_builtins (void) { scm_module_goops = scm_current_module (); - /* Not really necessary right now, but who knows... - */ - scm_permanent_object (scm_module_goops); - goops_rstate = scm_c_make_rstate ("GOOPS", 5); #include "libguile/goops.x" - list_of_no_method = scm_permanent_object (scm_list_1 (sym_no_method)); - hell = scm_calloc (hell_size * sizeof (*hell)); - hell_mutex = scm_permanent_object (scm_make_mutex ()); + hell_mutex = scm_make_mutex (); create_basic_classes (); create_standard_classes (); @@ -2760,10 +2727,8 @@ scm_init_goops_builtins (void) { SCM name = scm_from_locale_symbol ("no-applicable-method"); - scm_no_applicable_method - = scm_permanent_object (scm_make (scm_list_3 (scm_class_generic, - k_name, - name))); + scm_no_applicable_method = + scm_make (scm_list_3 (scm_class_generic, k_name, name)); DEFVAR (name, scm_no_applicable_method); } diff --git a/libguile/instructions.c b/libguile/instructions.c index c870b319b..c8d95cc9b 100644 --- a/libguile/instructions.c +++ b/libguile/instructions.c @@ -67,8 +67,7 @@ fetch_instruction_table () { table[i].opcode = i; if (table[i].name) - table[i].symname = - scm_permanent_object (scm_from_locale_symbol (table[i].name)); + table[i].symname = scm_from_locale_symbol (table[i].name); else table[i].symname = SCM_BOOL_F; } diff --git a/libguile/load.c b/libguile/load.c index fd3626f1a..c150030b1 100644 --- a/libguile/load.c +++ b/libguile/load.c @@ -881,7 +881,7 @@ init_build_info () void scm_init_load () { - scm_listofnullstr = scm_permanent_object (scm_list_1 (scm_nullstr)); + scm_listofnullstr = scm_list_1 (scm_nullstr); scm_loc_load_path = SCM_VARIABLE_LOC (scm_c_define ("%load-path", SCM_EOL)); scm_loc_load_extensions = SCM_VARIABLE_LOC (scm_c_define ("%load-extensions", diff --git a/libguile/modules.c b/libguile/modules.c index c48c2e8a0..58c524877 100644 --- a/libguile/modules.c +++ b/libguile/modules.c @@ -862,8 +862,7 @@ SCM_SYMBOL (scm_sym_system_module, "system-module"); void scm_modules_prehistory () { - scm_pre_modules_obarray - = scm_permanent_object (scm_c_make_hash_table (1533)); + scm_pre_modules_obarray = scm_c_make_hash_table (1533); } void @@ -875,24 +874,22 @@ scm_init_modules () scm_tc16_eval_closure = scm_make_smob_type ("eval-closure", 0); scm_set_smob_apply (scm_tc16_eval_closure, scm_eval_closure_lookup, 2, 0, 0); - the_module = scm_permanent_object (scm_make_fluid ()); + the_module = scm_make_fluid (); } static void scm_post_boot_init_modules () { -#define PERM(x) scm_permanent_object(x) - SCM module_type = SCM_VARIABLE_REF (scm_c_lookup ("module-type")); scm_module_tag = (SCM_CELL_WORD_1 (module_type) + scm_tc3_struct); - resolve_module_var = PERM (scm_c_lookup ("resolve-module")); - process_define_module_var = PERM (scm_c_lookup ("process-define-module")); - process_use_modules_var = PERM (scm_c_lookup ("process-use-modules")); - module_export_x_var = PERM (scm_c_lookup ("module-export!")); - the_root_module_var = PERM (scm_c_lookup ("the-root-module")); - default_duplicate_binding_procedures_var = - PERM (scm_c_lookup ("default-duplicate-binding-procedures")); + resolve_module_var = scm_c_lookup ("resolve-module"); + process_define_module_var = scm_c_lookup ("process-define-module"); + process_use_modules_var = scm_c_lookup ("process-use-modules"); + module_export_x_var = scm_c_lookup ("module-export!"); + the_root_module_var = scm_c_lookup ("the-root-module"); + default_duplicate_binding_procedures_var = + scm_c_lookup ("default-duplicate-binding-procedures"); scm_module_system_booted_p = 1; } diff --git a/libguile/numbers.c b/libguile/numbers.c index b61b3a765..6232ddc6c 100644 --- a/libguile/numbers.c +++ b/libguile/numbers.c @@ -6604,11 +6604,10 @@ scm_init_numbers () } #ifdef DBL_DIG /* hard code precision for base 10 if the preprocessor tells us to... */ - scm_dblprec[10-2] = (DBL_DIG > 20) ? 20 : DBL_DIG; + scm_dblprec[10-2] = (DBL_DIG > 20) ? 20 : DBL_DIG; #endif - exactly_one_half = scm_permanent_object (scm_divide (SCM_I_MAKINUM (1), - SCM_I_MAKINUM (2))); + exactly_one_half = scm_divide (SCM_I_MAKINUM (1), SCM_I_MAKINUM (2)); #include "libguile/numbers.x" } diff --git a/libguile/options.c b/libguile/options.c index ee7001a8c..ba2e95e4c 100644 --- a/libguile/options.c +++ b/libguile/options.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1995,1996,1998,2000,2001, 2006, 2008 Free Software Foundation +/* Copyright (C) 1995,1996,1998,2000,2001, 2006, 2008, 2009 Free Software Foundation * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License @@ -281,7 +281,6 @@ scm_init_opts (SCM (*func) (SCM), scm_t_option options[]) { SCM name = scm_from_locale_symbol (options[i].name); options[i].name = (char *) SCM_UNPACK (name); - scm_permanent_object (name); } func (SCM_UNDEFINED); } diff --git a/libguile/ports.c b/libguile/ports.c index 5500e1084..f56c0927e 100644 --- a/libguile/ports.c +++ b/libguile/ports.c @@ -2333,12 +2333,12 @@ scm_init_ports () scm_tc16_void_port = scm_make_port_type ("void", fill_input_void_port, write_void_port); - cur_inport_fluid = scm_permanent_object (scm_make_fluid ()); - cur_outport_fluid = scm_permanent_object (scm_make_fluid ()); - cur_errport_fluid = scm_permanent_object (scm_make_fluid ()); - cur_loadport_fluid = scm_permanent_object (scm_make_fluid ()); + cur_inport_fluid = scm_make_fluid (); + cur_outport_fluid = scm_make_fluid (); + cur_errport_fluid = scm_make_fluid (); + cur_loadport_fluid = scm_make_fluid (); - scm_i_port_weak_hash = scm_permanent_object (scm_make_weak_key_hash_table (SCM_I_MAKINUM(31))); + scm_i_port_weak_hash = scm_make_weak_key_hash_table (SCM_I_MAKINUM(31)); #include "libguile/ports.x" diff --git a/libguile/scmsigs.c b/libguile/scmsigs.c index f38d15c75..699a6de83 100644 --- a/libguile/scmsigs.c +++ b/libguile/scmsigs.c @@ -668,10 +668,8 @@ scm_init_scmsigs () signal_handlers = SCM_VARIABLE_LOC (scm_c_define ("signal-handlers", scm_c_make_vector (NSIG, SCM_BOOL_F))); - signal_handler_asyncs = - scm_permanent_object (scm_c_make_vector (NSIG, SCM_BOOL_F)); - signal_handler_threads = - scm_permanent_object (scm_c_make_vector (NSIG, SCM_BOOL_F)); + signal_handler_asyncs = scm_c_make_vector (NSIG, SCM_BOOL_F); + signal_handler_threads = scm_c_make_vector (NSIG, SCM_BOOL_F); for (i = 0; i < NSIG; i++) { diff --git a/libguile/srcprop.c b/libguile/srcprop.c index 110386465..f9d5ed18b 100644 --- a/libguile/srcprop.c +++ b/libguile/srcprop.c @@ -331,9 +331,8 @@ scm_init_srcprop () scm_source_whash = scm_make_weak_key_hash_table (scm_from_int (2047)); scm_c_define ("source-whash", scm_source_whash); - scm_last_alist_filename - = scm_permanent_object (scm_cons (SCM_EOL, - scm_acons (SCM_EOL, SCM_EOL, SCM_EOL))); + scm_last_alist_filename = scm_cons (SCM_EOL, + scm_acons (SCM_EOL, SCM_EOL, SCM_EOL)); #include "libguile/srcprop.x" } diff --git a/libguile/srfi-4.c b/libguile/srfi-4.c index af8eaa3c3..b24799104 100644 --- a/libguile/srfi-4.c +++ b/libguile/srfi-4.c @@ -895,14 +895,10 @@ scm_init_srfi_4 (void) scm_set_smob_print (scm_tc16_uvec, uvec_print); #if SCM_HAVE_T_INT64 == 0 - scm_uint64_min = - scm_permanent_object (scm_from_int (0)); - scm_uint64_max = - scm_permanent_object (scm_c_read_string ("18446744073709551615")); - scm_int64_min = - scm_permanent_object (scm_c_read_string ("-9223372036854775808")); - scm_int64_max = - scm_permanent_object (scm_c_read_string ("9223372036854775807")); + scm_uint64_min = scm_from_int (0); + scm_uint64_max = scm_c_read_string ("18446744073709551615"); + scm_int64_min = scm_c_read_string ("-9223372036854775808"); + scm_int64_max = scm_c_read_string ("9223372036854775807"); #endif #define REGISTER(tag, TAG) \ diff --git a/libguile/stacks.c b/libguile/stacks.c index 21c288fcf..60f0159f3 100644 --- a/libguile/stacks.c +++ b/libguile/stacks.c @@ -375,10 +375,8 @@ SCM_DEFINE (scm_stack_length, "stack-length", 1, 0, 0, void scm_init_stacks () { - scm_stack_type = - scm_permanent_object - (scm_make_vtable (scm_from_locale_string (SCM_STACK_LAYOUT), - SCM_UNDEFINED)); + scm_stack_type = scm_make_vtable (scm_from_locale_string (SCM_STACK_LAYOUT), + SCM_UNDEFINED); scm_set_struct_vtable_name_x (scm_stack_type, scm_from_locale_symbol ("stack")); #include "libguile/stacks.x" diff --git a/libguile/threads.c b/libguile/threads.c index bf2fdb226..f9344e46f 100644 --- a/libguile/threads.c +++ b/libguile/threads.c @@ -1947,15 +1947,14 @@ scm_init_threads () guilify_self_2 (SCM_BOOL_F); threads_initialized_p = 1; - dynwind_critical_section_mutex = - scm_permanent_object (scm_make_recursive_mutex ()); + dynwind_critical_section_mutex = scm_make_recursive_mutex (); } void scm_init_threads_default_dynamic_state () { SCM state = scm_make_dynamic_state (scm_current_dynamic_state ()); - scm_i_default_dynamic_state = scm_permanent_object (state); + scm_i_default_dynamic_state = state; } void diff --git a/libguile/vm.c b/libguile/vm.c index 37f74e582..0e511f608 100644 --- a/libguile/vm.c +++ b/libguile/vm.c @@ -212,7 +212,7 @@ vm_make_boot_program (long nargs) { int i; for (i = 0; i < NUM_BOOT_PROGS; i++) - programs[i] = scm_permanent_object (really_make_boot_program (i)); + programs[i] = really_make_boot_program (i); } if (SCM_LIKELY (nargs < NUM_BOOT_PROGS)) @@ -685,9 +685,9 @@ scm_bootstrap_vm (void) scm_c_make_gsubr ("load-compiled/vm", 1, 0, 0, scm_load_compiled_with_vm)); - sym_vm_run = scm_permanent_object (scm_from_locale_symbol ("vm-run")); - sym_vm_error = scm_permanent_object (scm_from_locale_symbol ("vm-error")); - sym_debug = scm_permanent_object (scm_from_locale_symbol ("debug")); + sym_vm_run = scm_from_locale_symbol ("vm-run"); + sym_vm_error = scm_from_locale_symbol ("vm-error"); + sym_debug = scm_from_locale_symbol ("debug"); scm_c_register_extension ("libguile", "scm_init_vm", (scm_t_extension_init_func)scm_init_vm, NULL); -- 2.20.1