Ticket #490: gc_options_remove.diff
File gc_options_remove.diff, 7.2 KB (added by jkeenan, 13 years ago) |
---|
-
lib/Parrot/Configure/Options/Conf.pm
94 94 --cgoto=0 Don't build cgoto core - recommended when short of mem 95 95 --jitcapable Use JIT 96 96 --execcapable Use JIT to emit a native executable 97 --gc=(type) Determine the type of garbage collection98 type=(gc|libc|malloc|malloc-trace) default is gc99 97 --without-threads Build parrot without thread support 100 98 101 99 External Library Options: -
lib/Parrot/Configure/Options/Conf/Shared.pm
29 29 fatal 30 30 fatal-step 31 31 floatval 32 gc33 32 help 34 33 icu-config 35 34 icuheaders -
Configure.pl
355 355 356 356 Use JIT to emit a native executable. 357 357 358 =item C<--gc=(type)>359 360 Determine the type of garbage collection. The value for C<type> should be one361 of: C<gc>, C<libc>, C<malloc> or C<malloc-trace>. The default is C<gc>.362 363 358 =back 364 359 365 360 =head2 International Components For Unicode (ICU) Options -
t/steps/auto/gc-01.t
5 5 6 6 use strict; 7 7 use warnings; 8 use Test::More tests => 35;8 use Test::More tests => 8; 9 9 use lib qw( lib t/configure/testlib ); 10 10 use_ok('config::auto::gc'); 11 11 use Parrot::Configure; … … 48 48 "Got expected value for 'gc_flag'"); 49 49 } 50 50 51 $conf->replenish($serialized);52 53 ########### --gc=gc ###########54 55 ($args, $step_list_ref) = process_options( {56 argv => [ q{--gc=gc} ],57 mode => q{configure},58 } );59 $conf->options->set( %{$args} );60 $step = test_step_constructor_and_description($conf);61 my $ret = $step->runstep($conf);62 ok( $ret, "runstep() returned true value" );63 is($conf->data->get('gc_flag'), q{},64 "Got expected value for 'gc_flag'");65 66 $conf->replenish($serialized);67 68 ########### --gc=libc ###########69 70 ($args, $step_list_ref) = process_options( {71 argv => [ q{--gc=libc} ],72 mode => q{configure},73 } );74 $conf->options->set( %{$args} );75 $step = test_step_constructor_and_description($conf);76 $conf->data->set('i_malloc' => 1);77 $ret = $step->runstep($conf);78 ok( $ret, "runstep() returned true value" );79 is($conf->data->get('gc_flag'), '-DGC_IS_MALLOC',80 "Got expected value for 'gc_flag'");81 is($conf->data->get('malloc_header'), 'malloc.h',82 "Got expected value for 'malloc_header'");83 84 $conf->replenish($serialized);85 86 ########### --gc=libc ###########87 88 ($args, $step_list_ref) = process_options( {89 argv => [ q{--gc=libc} ],90 mode => q{configure},91 } );92 $conf->options->set( %{$args} );93 $step = test_step_constructor_and_description($conf);94 $conf->data->set('i_malloc' => undef);95 $ret = $step->runstep($conf);96 ok( $ret, "runstep() returned true value" );97 is($conf->data->get('gc_flag'), '-DGC_IS_MALLOC',98 "Got expected value for 'gc_flag'");99 is($conf->data->get('malloc_header'), 'stdlib.h',100 "Got expected value for 'malloc_header'");101 102 $conf->replenish($serialized);103 104 ########### --gc=malloc ###########105 106 ($args, $step_list_ref) = process_options( {107 argv => [ q{--gc=malloc} ],108 mode => q{configure},109 } );110 $conf->options->set( %{$args} );111 $step = test_step_constructor_and_description($conf);112 $ret = $step->runstep($conf);113 ok( $ret, "runstep() returned true value" );114 is($conf->data->get('gc_flag'), '-DGC_IS_MALLOC',115 "Got expected value for 'gc_flag'");116 117 $conf->replenish($serialized);118 119 ########### --gc=malloc-trace ###########120 121 ($args, $step_list_ref) = process_options( {122 argv => [ q{--gc=malloc-trace} ],123 mode => q{configure},124 } );125 $conf->options->set( %{$args} );126 $step = test_step_constructor_and_description($conf);127 $ret = $step->runstep($conf);128 ok( $ret, "runstep() returned true value" );129 is($conf->data->get('gc_flag'), '-DGC_IS_MALLOC',130 "Got expected value for 'gc_flag'");131 132 51 pass("Completed all tests in $0"); 133 52 134 53 ################### DOCUMENTATION ################### 135 54 136 55 =head1 NAME 137 56 138 auto /gc-01.t - test auto::gc57 auto_gc-01.t - test auto::gc 139 58 140 59 =head1 SYNOPSIS 141 60 -
config/auto/gc.pm
7 7 8 8 =head1 DESCRIPTION 9 9 10 Checks whether the C<--gc> command-line option was passed to F<Configure.pl> 11 and sets the memory allocator accordingly. 10 Sets memory allocator. 12 11 13 Eventually, C<--gc> will be able to take any of the following values: 12 Currently, we have only one choice: the memory allocator in F<src/gc/resources.c>. 14 13 15 =over 14 In the future, we will have a C<--gc> command-line option which will enable 15 the configurer to choose among the default and: 16 16 17 = item C<gc>17 =over4 18 18 19 The default. Use the memory allocator in F<src/resources.c>.20 21 19 =item C<libc> 22 20 23 21 Use the C library C<malloc> along with F<src/gc/res_lea.c>. … … 36 34 37 35 =back 38 36 39 So, for the time being, only the default value works.40 41 37 =cut 42 38 43 39 package auto::gc; … … 49 45 50 46 use Parrot::Configure::Utils ':auto'; 51 47 52 53 # valid libc/malloc/malloc-trace/gc54 48 sub _init { 55 49 my $self = shift; 56 50 my %data; … … 62 56 sub runstep { 63 57 my ( $self, $conf ) = @_; 64 58 65 my $gc = $conf->options->get('gc');59 my $gc = 'gc'; 66 60 67 # default is GC in alloc_resources.c 68 $gc = 'gc' unless defined $gc; 69 70 if ( $gc =~ /^malloc(?:-trace)?$/ ) { 71 $conf->data->set( 72 TEMP_gc_c => <<"EOF", 73 \$(SRC_DIR)/$gc\$(O): \$(GENERAL_H_FILES) \$(SRC_DIR)/$gc.c 74 \$(SRC_DIR)/gc/res_lea\$(O): \$(GENERAL_H_FILES) \$(SRC_DIR)/gc/res_lea.c 75 EOF 76 TEMP_gc_o => "\$(SRC_DIR)\/$gc\$(O) \$(SRC_DIR)/gc/res_lea\$(O)", 77 gc_flag => '-DGC_IS_MALLOC', 78 ); 79 } 80 elsif ( $gc eq 'libc' ) { 81 $conf->data->set( 82 TEMP_gc_c => <<"EOF", 83 \$(SRC_DIR)/gc/res_lea\$(O): \$(GENERAL_H_FILES) \$(SRC_DIR)/gc/res_lea.c 84 EOF 85 TEMP_gc_o => "\$(SRC_DIR)/gc/res_lea\$(O)", 86 gc_flag => '-DGC_IS_MALLOC', 87 ); 88 # tests mallinfo after allocation of 128 bytes 89 if ( $conf->data->get('i_malloc') ) { 90 $conf->data->set( malloc_header => 'malloc.h' ); 91 } 92 else { 93 $conf->data->set( malloc_header => 'stdlib.h' ); 94 } 95 } 96 else { 97 $gc = 'gc'; 98 $conf->data->set( 99 TEMP_gc_c => <<"EOF", 61 $conf->data->set( 62 TEMP_gc_c => <<"EOF", 100 63 \$(SRC_DIR)/gc/alloc_resources\$(O): \$(GENERAL_H_FILES) \$(SRC_DIR)/gc/alloc_resources.c 101 64 EOF 102 TEMP_gc_o => "\$(SRC_DIR)/gc/alloc_resources\$(O)", 103 gc_flag => '', 104 ); 105 } 65 TEMP_gc_o => "\$(SRC_DIR)/gc/resources\$(O)", 66 gc_flag => '', 67 ); 106 68 print(" ($gc) ") if $conf->options->get('verbose'); 107 69 108 70 return 1;