1 # Copyright (C) 2001-2008, The Perl Foundation.
6 config/auto/jit - JIT Capability
10 Determines whether there is JIT capability available. Use the
11 C<--jitcapable> and C<--execcapable> options to override the default
12 value calculated specifically for your CPU architecture and operating
15 Code formerly found in this step class used to determine characteristics
16 of the CPU has been moved into the preceding step class, auto::arch.
26 use base
qw(Parrot::Configure::Step);
28 use Parrot
::Configure
::Utils
qw(copy_if_diff);
33 $data{description
} = q{Determining architecture, OS and JIT capability};
35 $data{jit_is_working
} = {
43 my ( $self, $conf ) = @_;
45 if ( $conf->options->get('miniparrot') ) {
46 $self->set_result('skipped');
50 my $verbose = $conf->options->get('verbose');
51 $verbose and print "\n";
53 my $cpuarch = $conf->data->get('cpuarch');
54 my $osname = $conf->data->get('osname');
56 my $jitbase = 'src/jit'; # base path for jit sources
58 my $corejit = "$jitbase/$cpuarch/core.jit";
59 print( qq{-e
$corejit = },
60 -e
$corejit ?
'yes' : 'no', "\n" )
66 # Just because there is a "$jitbase/$cpuarch/core.jit" file,
67 # doesn't mean the JIT is working on that platform.
68 # So build JIT per default only on platforms where JIT in known
69 # to work. Building JIT on other platform most likely breaks the build.
70 # Developer can always call: Configure.pl --jitcapable
71 # This was discussed in RT #43145 (which has been resolved).
72 if ( $self->{jit_is_working
}->{$cpuarch} ) {
77 if ( $cpuarch eq 'i386' && $osname eq 'darwin' ) {
82 my $jitarchname = "$cpuarch-$osname";
83 my $sjit = "$jitbase/$cpuarch/$jitarchname.s";
84 my $asm = "$jitbase/$cpuarch/asm.s";
86 copy_if_diff
( $sjit, "src/asmfun.s" );
87 $conf->data->set( asmfun_o
=> 'src/asmfun$(O)' );
90 copy_if_diff
( $asm, "src/asmfun.s" );
91 $conf->data->set( asmfun_o
=> 'src/asmfun$(O)' );
94 $conf->data->set( asmfun_o
=> '' );
97 # let developers override the default JIT capability
98 $jitcapable = $conf->options->get('jitcapable')
99 if defined $conf->options->get('jitcapable');
102 my ( $jitcpuarch, $jitosname ) = split( /-/, $jitarchname );
105 jitarchname
=> $jitarchname,
106 jitcpuarch
=> $jitcpuarch,
107 jitcpu
=> uc($jitcpuarch),
108 jitosname
=> uc($jitosname),
110 cc_hasjit
=> " -DHAS_JIT -D\U$jitcpuarch",
112 '$(SRC_DIR)/jit$(O) $(SRC_DIR)/jit_cpu$(O) $(SRC_DIR)/jit_debug$(O) $(SRC_DIR)/jit_debug_xcoff$(O)'
116 if ( ( $jitcpuarch eq 'i386' )
117 || ( $jitcpuarch eq 'ppc' )
118 || ( $jitcpuarch eq 'arm' ) )
121 unless ( ( $osname eq 'openbsd' )
122 || ( $osname eq 'freebsd' )
123 || ( $osname eq 'netbsd' )
124 || ( $osname eq 'linux' )
125 || ( $osname eq 'darwin' )
126 || ( $osname eq 'cygwin' )
127 || ( $osname eq 'MSWin32' ) )
132 $execcapable = $conf->options->get('execcapable')
133 if defined $conf->options->get('execcapable');
134 _handle_execcapable
($conf, $execcapable);
136 # test for executable malloced memory
137 if ( -e
"config/auto/jit/test_exec_$osname.in" ) {
138 print " (has_exec_protect " if $verbose;
139 $conf->cc_gen("config/auto/jit/test_exec_$osname.in");
140 eval { $conf->cc_build(); };
142 print " $@) " if $verbose;
145 if ( $conf->cc_run(0) !~ /ok/ && $conf->cc_run(1) =~ /ok/ ) {
146 $conf->data->set( has_exec_protect
=> 1 );
147 print "yes) " if $verbose;
150 print "no) " if $verbose;
156 # RT #43146 use executable memory for this test if needed
158 # test for some instructions
159 if ( $jitcpuarch eq 'i386' ) {
160 $conf->cc_gen('config/auto/jit/test_c.in');
161 eval { $conf->cc_build(); };
162 unless ( $@
|| $conf->cc_run() !~ /ok/ ) {
163 $conf->data->set( jit_i386
=> 'fcomip' );
170 jitarchname
=> 'nojit',
171 jitcpuarch
=> $cpuarch,
173 jitosname
=> $osname,
187 sub _handle_execcapable
{
188 my ($conf, $execcapable) = @_;
190 my $cpuarch = $conf->data->get('cpuarch');
193 '$(SRC_DIR)/jit.h $(INC_DIR)/exec.h $(SRC_DIR)/exec_dep.h $(SRC_DIR)/exec_save.h',
195 '$(SRC_DIR)/exec$(O) $(SRC_DIR)/exec_cpu$(O) $(SRC_DIR)/exec_dep$(O) $(SRC_DIR)/exec_save$(O)',
197 "\$(SRC_DIR)/exec_dep.c : \$(SRC_DIR)/jit/$cpuarch/exec_dep.c\n"
198 . "\t\$(CP) \$(SRC_DIR)/jit/$cpuarch/exec_dep.c \$(SRC_DIR)/exec_dep.c",
217 # cperl-indent-level: 4
220 # vim: expandtab shiftwidth=4: