I recently resumed work on refactoring and testing of the Parrot
configuration steps.  The attached patch represents work done in the
last two weeks in the 'autojit' branch.

As with other config steps, the approach was to refactor code out of
runstep() into internal subroutines, then to test the hell out of those
subs.  As a result, statement test coverage has increased to 99%, though
the branch and condition coverage will be lower due to the many C probes
within runstep().

Please give this a whirl.  I will apply in 2-3 days if there is no
objection.

Thank you very much.
kid51

Index: MANIFEST
===================================================================
--- MANIFEST    (.../trunk)     (revision 28733)
+++ MANIFEST    (.../branches/autojit)  (revision 29114)
@@ -1,7 +1,7 @@
 # ex: set ro:
 # $Id$
 #
-# generated by tools/dev/mk_manifest_and_skip.pl Fri Jun 27 01:45:45 2008 UT
+# generated by tools/dev/mk_manifest_and_skip.pl Sun Jul  6 16:43:10 2008 UT
 #
 # See tools/dev/install_files.pl for documentation on the
 # format of this file.
@@ -3684,6 +3684,7 @@
 t/steps/auto_isreg-03.t                                     []
 t/steps/auto_jit-01.t                                       []
 t/steps/auto_jit-02.t                                       []
+t/steps/auto_jit-03.t                                       []
 t/steps/auto_macports-01.t                                  []
 t/steps/auto_macports-02.t                                  []
 t/steps/auto_macports-03.t                                  []
Index: t/steps/auto_jit-02.t
===================================================================
--- t/steps/auto_jit-02.t       (.../trunk)     (revision 28733)
+++ t/steps/auto_jit-02.t       (.../branches/autojit)  (revision 29114)
@@ -5,14 +5,19 @@
 
 use strict;
 use warnings;
-use Test::More tests =>  13;
+use Test::More tests =>  32;
 use Carp;
+use Cwd;
+use File::Path qw( mkpath );
+use File::Temp qw( tempdir );
+use File::Spec;
 use lib qw( lib t/configure/testlib );
 use_ok('config::init::defaults');
 use_ok('config::auto::jit');
 use Parrot::Configure;
 use Parrot::Configure::Options qw( process_options );
 use Parrot::Configure::Test qw( test_step_thru_runstep);
+use IO::CaptureOutput qw( capture );
 
 my $args = process_options(
     {
@@ -38,6 +43,181 @@
 ok( defined $step, "$step_name constructor returned defined value" );
 isa_ok( $step, $step_name );
 
+########### _check_jitcapability() ###########
+
+my $cwd = cwd();
+{
+    my $tdir = tempdir( CLEANUP => 1 );
+    chdir $tdir or croak "Unable to change to temporary directory";
+    my $jitbase = 'foo';
+    my $cpuarch = 'bar';
+    my $osname = 'baz';
+    my $corejitdir = File::Spec->catdir ( $jitbase, $cpuarch );
+    mkpath( $corejitdir, 0, 755 ) or croak "Unable to make testing directory";
+    my $corejit = File::Spec->catfile( $jitbase, $cpuarch, q{core.jit} );
+    is( $step->_check_jitcapability($corejit, $cpuarch, $osname), 0,
+        "Got expected value for _check_jitcapability(): no core.jit case");
+
+    chdir $cwd or croak "Unable to change back to starting directory";
+}
+
+{
+    my $tdir = tempdir( CLEANUP => 1 );
+    chdir $tdir or croak "Unable to change to temporary directory";
+    my $jitbase = 'foo';
+    my $cpuarch = 'bar';
+    my $osname = 'baz';
+    my $corejitdir = File::Spec->catdir ( $jitbase, $cpuarch );
+    mkpath( $corejitdir, 0, 755 ) or croak "Unable to make testing directory";
+    my $corejit = File::Spec->catfile( $jitbase, $cpuarch, q{core.jit} );
+    open my $FH, '>', $corejit
+        or croak "Unable to open handle to file for testing";
+    print $FH qq{Hello, JIT\n};
+    close $FH or croak "Unable to close handle to file for testing";
+    is( $step->_check_jitcapability($corejit, $cpuarch, $osname), 0,
+        "Got expected value for _check_jitcapability(): no JIT on this 
architecture case");
+
+    chdir $cwd or croak "Unable to change back to starting directory";
+}
+
+{
+    my $tdir = tempdir( CLEANUP => 1 );
+    chdir $tdir or croak "Unable to change to temporary directory";
+    my $jitbase = 'foo';
+    my $cpuarch = 'bar';
+    my $osname = 'baz';
+    my $corejitdir = File::Spec->catdir ( $jitbase, $cpuarch );
+    mkpath( $corejitdir, 0, 755 ) or croak "Unable to make testing directory";
+    my $corejit = File::Spec->catfile( $jitbase, $cpuarch, q{core.jit} );
+    open my $FH, '>', $corejit
+        or croak "Unable to open handle to file for testing";
+    print $FH qq{Hello, JIT\n};
+    close $FH or croak "Unable to close handle to file for testing";
+    my $orig = $step->{jit_is_working};
+    $step->{jit_is_working} = { $cpuarch => 1 };
+    is( $step->_check_jitcapability($corejit, $cpuarch, $osname), 1,
+        "Got expected value for _check_jitcapability(): mock JIT case");
+    $step->{jit_is_working} = $orig;
+
+    chdir $cwd or croak "Unable to change back to starting directory";
+}
+
+{
+    my $tdir = tempdir( CLEANUP => 1 );
+    chdir $tdir or croak "Unable to change to temporary directory";
+    my $jitbase = 'foo';
+    my $cpuarch = 'i386';
+    my $osname = 'darwin';
+    my $corejitdir = File::Spec->catdir ( $jitbase, $cpuarch );
+    mkpath( $corejitdir, 0, 755 ) or croak "Unable to make testing directory";
+    my $corejit = File::Spec->catfile( $jitbase, $cpuarch, q{core.jit} );
+    open my $FH, '>', $corejit
+        or croak "Unable to open handle to file for testing";
+    print $FH qq{Hello, JIT\n};
+    close $FH or croak "Unable to close handle to file for testing";
+    my $orig = $step->{jit_is_working};
+    $step->{jit_is_working} = { $cpuarch => 1 };
+    is( $step->_check_jitcapability($corejit, $cpuarch, $osname), 0,
+        "Got expected value for _check_jitcapability(): mock darwin-i386 
case");
+    $step->{jit_is_working} = $orig;
+
+    chdir $cwd or croak "Unable to change back to starting directory";
+}
+
+########### _handle_asm() ###########
+
+{
+    my $tdir = tempdir( CLEANUP => 1 );
+    chdir $tdir or croak "Unable to change to temporary directory";
+    my $jitbase = 'foo';
+    my $cpuarch = 'bar';
+    my $jitarchname = "${cpuarch}-baz";
+    my $asmdir = File::Spec->catdir( $jitbase, $cpuarch );
+    mkpath( $asmdir, 0, 755 ) or croak "Unable to make testing directory";
+    mkpath( q{src}, 0, 755 ) or croak "Unable to make testing directory";
+
+    ok(auto::jit::_handle_asm( {
+        conf        => $conf,
+        jitbase     => $jitbase,
+        cpuarch     => $cpuarch,
+        jitarchname => $jitarchname,
+    } ), "_handle_asm() returned successfully");
+    is( $conf->data->get( 'asmfun_o' ), q{},
+        "Got expected value for asmfun_o: no asm case");
+    $conf->data->set( asmfun_o => undef ); # reset for next test
+
+    chdir $cwd or croak "Unable to change back to starting directory";
+}
+
+{
+    my $tdir = tempdir( CLEANUP => 1 );
+    chdir $tdir or croak "Unable to change to temporary directory";
+    my $jitbase = 'foo';
+    my $cpuarch = 'bar';
+    my $jitarchname = "${cpuarch}-baz";
+    my $asmdir = File::Spec->catdir( $jitbase, $cpuarch );
+    mkpath( $asmdir, 0, 755 ) or croak "Unable to make testing directory";
+    mkpath( q{src}, 0, 755 ) or croak "Unable to make testing directory";
+
+    my $sjit =
+        File::Spec->catfile( $jitbase, $cpuarch, qq{${jitarchname}.s} );
+    open my $FH, '>', $sjit
+        or croak "Unable to open handle to file for testing";
+    print $FH qq{Hello, JIT\n};
+    close $FH or croak "Unable to close handle to file for testing";
+
+    ok(auto::jit::_handle_asm( {
+        conf        => $conf,
+        jitbase     => $jitbase,
+        cpuarch     => $cpuarch,
+        jitarchname => $jitarchname,
+    } ), "_handle_asm() returned successfully");
+    is( $conf->data->get( 'asmfun_o' ), q{src/asmfun$(O)},
+        "Got expected value for asmfun_o: sjit case");
+    $conf->data->set( asmfun_o => undef ); # reset for next test
+
+    chdir $cwd or croak "Unable to change back to starting directory";
+}
+
+{
+    my $tdir = tempdir( CLEANUP => 1 );
+    chdir $tdir or croak "Unable to change to temporary directory";
+    my $jitbase = 'foo';
+    my $cpuarch = 'bar';
+    my $jitarchname = "${cpuarch}-baz";
+    my $asmdir = File::Spec->catdir( $jitbase, $cpuarch );
+    mkpath( $asmdir, 0, 755 ) or croak "Unable to make testing directory";
+    mkpath( q{src}, 0, 755 ) or croak "Unable to make testing directory";
+    my $asm = File::Spec->catfile( $jitbase, $cpuarch, q{asm.s} );
+    open my $FH, '>', $asm
+        or croak "Unable to open handle to file for testing";
+    print $FH qq{Hello, JIT\n};
+    close $FH or croak "Unable to close handle to file for testing";
+
+    ok(auto::jit::_handle_asm( {
+        conf        => $conf,
+        jitbase     => $jitbase,
+        cpuarch     => $cpuarch,
+        jitarchname => $jitarchname,
+    } ), "_handle_asm() returned successfully");
+    is( $conf->data->get( 'asmfun_o' ), q{src/asmfun$(O)},
+        "Got expected value for asmfun_o: asm case");
+    $conf->data->set( asmfun_o => undef ); # reset for next test
+
+    chdir $cwd or croak "Unable to change back to starting directory";
+}
+
+########### _first_probe_for_exec() ###########
+
+is(  $step->_first_probe_for_exec( 'i386', 'foobar' ), 0,
+    "Got expected value for _first_probe_for_exec");
+is(  $step->_first_probe_for_exec( 'i386', 'openbsd' ), 1,
+    "Got expected value for _first_probe_for_exec");
+is(  $step->_first_probe_for_exec( 'foobar', 'openbsd' ), 0,
+    "Got expected value for _first_probe_for_exec");
+
+########### _handle_execcapable() ###########
+
 if (! defined $conf->data->get('cpuarch') ) {
     $conf->data->set('cpuarch' => 1)
 }
@@ -55,6 +235,45 @@
     "Got expected value for execcapable");
 $conf->data->set('execcapable' => undef);
 
+########### _handle_exec_protect() ###########
+
+$conf->data->set( has_exec_protect => undef );
+auto::jit::_handle_exec_protect($conf, 0, 0);
+ok( ! defined $conf->data->get( 'has_exec_protect'),
+    "'has_exec_protect' undefined, as expected");
+
+auto::jit::_handle_exec_protect($conf, 1, 0);
+is( $conf->data->get( 'has_exec_protect'), 1,
+    "Got expected value for 'has_exec_protect'");
+$conf->data->set( has_exec_protect => undef );
+
+{
+    my ($stdout, $stderr);
+    capture(
+        sub { auto::jit::_handle_exec_protect($conf, 0, 1); },
+        \$stdout,
+        \$stderr,
+    );
+    ok( ! defined $conf->data->get( 'has_exec_protect'),
+        "'has_exec_protect' undefined, as expected");
+    like($stdout, qr/no\)/, "Got expected verbose output");
+    $conf->data->set( has_exec_protect => undef );
+}
+
+{
+    my ($stdout, $stderr);
+    capture(
+        sub { auto::jit::_handle_exec_protect($conf, 1, 1); },
+        \$stdout,
+        \$stderr,
+    );
+    is( $conf->data->get( 'has_exec_protect'), 1,
+        "Got expected value for 'has_exec_protect'");
+    like($stdout, qr/yes\)/, "Got expected verbose output");
+    $conf->data->set( has_exec_protect => undef );
+}
+
+
 pass("Completed all tests in $0");
 
 ################### DOCUMENTATION ###################
Index: t/steps/auto_jit-03.t
===================================================================
--- t/steps/auto_jit-03.t       (.../trunk)     (revision 0)
+++ t/steps/auto_jit-03.t       (.../branches/autojit)  (revision 29114)
@@ -0,0 +1,139 @@
+#! perl
+# Copyright (C) 2007, The Perl Foundation.
+# $Id$
+# auto_jit-03.t
+
+use strict;
+use warnings;
+use Test::More qw(no_plan); # tests =>  19;
+use Carp;
+use Cwd;
+use File::Path qw( mkpath );
+use File::Temp qw( tempdir );
+use File::Spec;
+use lib qw( lib t/configure/testlib );
+use_ok('config::init::defaults');
+use_ok('config::auto::jit');
+use Parrot::Configure;
+use Parrot::Configure::Options qw( process_options );
+use Parrot::Configure::Test qw( test_step_thru_runstep);
+use IO::CaptureOutput qw( capture );
+
+my $args = process_options(
+    {
+        argv => [ q{--jitcapable=0}, q{--verbose}  ],
+        mode => q{configure},
+    }
+);
+
+my $conf = Parrot::Configure->new;
+
+test_step_thru_runstep( $conf, q{init::defaults}, $args );
+
+my $pkg = q{auto::jit};
+
+$conf->add_steps($pkg);
+$conf->options->set( %{$args} );
+
+my ( $task, $step_name, $step);
+$task        = $conf->steps->[-1];
+$step_name   = $task->step;
+
+$step = $step_name->new();
+ok( defined $step, "$step_name constructor returned defined value" );
+isa_ok( $step, $step_name );
+ok( $step->description(), "$step_name has description" );
+
+# Mock some values so that we can get to the point inside runstep() where the
+# command-line option for jitcapable is relevant.
+
+my $cwd = cwd();
+{
+    my $tdir = tempdir( CLEANUP => 1 );
+    chdir $tdir or croak "Unable to change to temporary directory";
+    my $jitbase = 'foo';
+    my $cpuarch = 'i386';
+    my $osname = 'darwin';
+    my $corejitdir = File::Spec->catdir ( $jitbase, $cpuarch );
+    mkpath( $corejitdir, 0, 755 ) or croak "Unable to make testing directory";
+    my $corejit = File::Spec->catfile( $jitbase, $cpuarch, q{core.jit} );
+    open my $FH, '>', $corejit
+        or croak "Unable to open handle to file for testing";
+    print $FH qq{Hello, JIT\n};
+    close $FH or croak "Unable to close handle to file for testing";
+    my $orig = $step->{jit_is_working};
+    $step->{jit_is_working} = { $cpuarch => 1 };
+    $conf->data->set( cpuarch => $cpuarch );
+    $conf->data->set( osname => $osname );
+    {
+        my ($stdout, $stderr, $ret);
+        capture(
+            sub { $ret = $step->runstep($conf); },
+            \$stdout,
+            \$stderr,
+        );
+        ok( $ret, "$step_name runstep() returned true value" );
+        like($stdout, qr/yes|no/s, "Got expected verbose output");
+    }
+    $step->{jit_is_working} = $orig;
+    $conf->data->set( cpuarch => undef );
+    $conf->data->set( osname => undef );
+
+    is( $conf->data->get( 'jitarchname' ), 'nojit',
+        "Got expected value for jitarchname");
+    is( $conf->data->get( 'jitcapable' ), 0,
+        "Got expected value for jitcapable");
+    is( $conf->data->get( 'execcapable' ), 0,
+        "Got expected value for execcapable");
+    is( $conf->data->get( 'cc_hasjit' ), '',
+        "Got expected value for cc_hasjit");
+    is( $conf->data->get( 'TEMP_jit_o' ), '',
+        "Got expected value for TEMP_jit_o");
+    is( $conf->data->get( 'TEMP_exec_h' ), '',
+        "Got expected value for TEMP_exec_h");
+    is( $conf->data->get( 'TEMP_exec_o' ), '',
+        "Got expected value for TEMP_exec_o");
+    is( $conf->data->get( 'TEMP_exec_dep' ), '',
+        "Got expected value for TEMP_exec_dep");
+    is( $step->result(), 'no', 
+        "Got expected result for no JIT");
+
+    chdir $cwd or croak "Unable to change back to starting directory";
+}
+
+pass("Completed all tests in $0");
+
+################### DOCUMENTATION ###################
+
+=head1 NAME
+
+auto_jit-03.t - test config::auto::jit
+
+=head1 SYNOPSIS
+
+    % prove t/steps/auto_jit-03.t
+
+=head1 DESCRIPTION
+
+The files in this directory test functionality used by F<Configure.pl>.
+
+The tests in this file tests config::auto::jit with the C<--jitcapable>
+option set to C<0>.
+
+=head1 AUTHOR
+
+James E Keenan
+
+=head1 SEE ALSO
+
+config::auto::jit, F<Configure.pl>.
+
+=cut
+
+# Local Variables:
+#   mode: cperl
+#   cperl-indent-level: 4
+#   fill-column: 100
+# End:
+# vim: expandtab shiftwidth=4:
+

Property changes on: t/steps/auto_jit-03.t
___________________________________________________________________
Name: svn:eol-style
   + native
Name: svn:mime-type
   + text/plain
Name: svn:keywords
   + Author Date Id Revision

Index: config/auto/jit.pm
===================================================================
--- config/auto/jit.pm  (.../trunk)     (revision 28733)
+++ config/auto/jit.pm  (.../branches/autojit)  (revision 29114)
@@ -22,20 +22,26 @@
 use strict;
 use warnings;
 
-
 use base qw(Parrot::Configure::Step);
-
 use Parrot::Configure::Utils qw(copy_if_diff);
 
 sub _init {
     my $self = shift;
     my %data;
-    $data{description} = q{Determining architecture, OS and JIT capability};
+    $data{description} = q{Determining JIT capability};
     $data{result}      = q{};
     $data{jit_is_working} = {
         i386 => 1,
         ppc  => 1,
     };
+    $data{jitbase_default} = 'src/jit';   # base path for jit sources
+    # jitcpuarch_platforms:  Those which should be examined for possibility of
+    # exec capability.
+    $data{jitcpuarch_platforms} = { map { $_ => 1 } qw( i386 ppc arm ) };
+    # execcapable_oses:  Those which should have exec capability.
+    $data{execcapable_oses} = { map { $_ => 1 }
+        qw( openbsd freebsd netbsd linux darwin cygwin MSWin32 )
+    };
     return \%data;
 }
 
@@ -53,13 +59,101 @@
     my $cpuarch     = $conf->data->get('cpuarch');
     my $osname      = $conf->data->get('osname');
 
-    my $jitbase  = 'src/jit';   # base path for jit sources
+    my $jitbase  = $self->{jitbase_default};   # base path for jit sources
 
     my $corejit = "$jitbase/$cpuarch/core.jit";
     print( qq{-e $corejit = },
         -e $corejit ? 'yes' : 'no', "\n" )
         if $verbose;
 
+    my $jitcapable =
+        $self->_check_jitcapability($corejit, $cpuarch, $osname);
+
+    my $jitarchname = "$cpuarch-$osname";
+    _handle_asm( {
+        conf        => $conf,
+        jitbase     => $jitbase,
+        cpuarch     => $cpuarch,
+        jitarchname => $jitarchname,
+    } );
+
+    # let developers override the default JIT capability
+    $jitcapable = $conf->options->get('jitcapable')
+        if defined $conf->options->get('jitcapable');
+
+    if (! $jitcapable) {
+        $conf->data->set(
+            jitarchname    => 'nojit',
+            jitcpuarch     => $cpuarch,
+            jitcpu         => $cpuarch,
+            jitosname      => $osname,
+            jitcapable     => 0,
+            execcapable    => 0,
+            cc_hasjit      => '',
+            TEMP_jit_o     => '',
+            TEMP_exec_h    => '',
+            TEMP_exec_o    => '',
+            TEMP_exec_dep  => '',
+        );
+        $self->set_result('no');
+        return 1;
+    }
+
+    my ( $jitcpuarch, $jitosname ) = split( /-/, $jitarchname );
+    $conf->data->set(
+        jitarchname => $jitarchname,
+        jitcpuarch  => $jitcpuarch,
+        jitcpu      => uc($jitcpuarch),
+        jitosname   => uc($jitosname),
+        jitcapable  => 1,
+        cc_hasjit   => " -DHAS_JIT -D\U$jitcpuarch",
+        TEMP_jit_o =>
+'$(SRC_DIR)/jit$(O) $(SRC_DIR)/jit_cpu$(O) $(SRC_DIR)/jit_debug$(O) 
$(SRC_DIR)/jit_debug_xcoff$(O)'
+    );
+
+    my $execcapable = $self->_first_probe_for_exec(
+        $jitcpuarch, $osname);
+    $execcapable = $conf->options->get('execcapable')
+        if defined $conf->options->get('execcapable');
+    _handle_execcapable($conf, $execcapable);
+
+    # test for executable malloced memory
+    if ( -e "config/auto/jit/test_exec_$osname.in" ) {
+        print " (has_exec_protect " if $verbose;
+        $conf->cc_gen("config/auto/jit/test_exec_$osname.in");
+        eval { $conf->cc_build(); };
+        if ($@) {
+            print " $@) " if $verbose;
+        }
+        else {
+            my $exec_protect_test = (
+                $conf->cc_run(0) !~ /ok/ && $conf->cc_run(1) =~ /ok/
+            );
+            _handle_exec_protect($conf, $exec_protect_test, $verbose);
+        }
+        $conf->cc_clean();
+    }
+
+    # RT #43146 use executable memory for this test if needed
+    #
+    # test for some instructions
+    if ( $jitcpuarch eq 'i386' ) {
+        $conf->cc_gen('config/auto/jit/test_c.in');
+        eval { $conf->cc_build(); };
+        unless ( $@ || $conf->cc_run() !~ /ok/ ) {
+            $conf->data->set( jit_i386 => 'fcomip' );
+        }
+        $conf->cc_clean();
+    }
+    $self->set_result('yes');
+    return 1;
+}
+
+#################### INTERNAL SUBROUTINES ####################
+
+sub _check_jitcapability {
+    my $self = shift;
+    my ($corejit, $cpuarch, $osname) = @_;
     my $jitcapable = 0;
     if ( -e $corejit ) {
 
@@ -78,110 +172,37 @@
             $jitcapable = 0;
         }
     }
+    return $jitcapable;
+}
 
-    my $jitarchname = "$cpuarch-$osname";
-    my $sjit = "$jitbase/$cpuarch/$jitarchname.s";
-    my $asm = "$jitbase/$cpuarch/asm.s";
+sub _handle_asm {
+    my $arg = shift;
+    my $sjit = "$arg->{jitbase}/$arg->{cpuarch}/$arg->{jitarchname}.s";
+    my $asm = "$arg->{jitbase}/$arg->{cpuarch}/asm.s";
     if ( -e $sjit ) {
         copy_if_diff( $sjit, "src/asmfun.s" );
-        $conf->data->set( asmfun_o => 'src/asmfun$(O)' );
+        $arg->{conf}->data->set( asmfun_o => 'src/asmfun$(O)' );
     }
     elsif ( -e $asm ) {
         copy_if_diff( $asm, "src/asmfun.s" );
-        $conf->data->set( asmfun_o => 'src/asmfun$(O)' );
+        $arg->{conf}->data->set( asmfun_o => 'src/asmfun$(O)' );
     }
     else {
-        $conf->data->set( asmfun_o => '' );
+        $arg->{conf}->data->set( asmfun_o => '' );
     }
+}
 
-    # let developers override the default JIT capability
-    $jitcapable = $conf->options->get('jitcapable')
-        if defined $conf->options->get('jitcapable');
-
-    if ($jitcapable) {
-        my ( $jitcpuarch, $jitosname ) = split( /-/, $jitarchname );
-
-        $conf->data->set(
-            jitarchname => $jitarchname,
-            jitcpuarch  => $jitcpuarch,
-            jitcpu      => uc($jitcpuarch),
-            jitosname   => uc($jitosname),
-            jitcapable  => 1,
-            cc_hasjit   => " -DHAS_JIT -D\U$jitcpuarch",
-            TEMP_jit_o =>
-'$(SRC_DIR)/jit$(O) $(SRC_DIR)/jit_cpu$(O) $(SRC_DIR)/jit_debug$(O) 
$(SRC_DIR)/jit_debug_xcoff$(O)'
-        );
-
-        my $execcapable = 0;
-        if (   ( $jitcpuarch eq 'i386' )
-            || ( $jitcpuarch eq 'ppc' )
-            || ( $jitcpuarch eq 'arm' ) )
-        {
-            $execcapable = 1;
-            unless ( ( $osname eq 'openbsd' )
-                || (   $osname eq 'freebsd' )
-                || (   $osname eq 'netbsd' )
-                || (   $osname eq 'linux' )
-                || (   $osname eq 'darwin' )
-                || (   $osname eq 'cygwin' )
-                || (   $osname eq 'MSWin32' ) )
-            {
-                $execcapable = 0;
-            }
+sub _first_probe_for_exec {
+    my $self = shift;
+    my ($jitcpuarch, $osname) = @_;
+    my $execcapable = 0;
+    if ( $self->{jitcpuarch_platforms}->{$jitcpuarch} ) {
+        $execcapable = 1;
+        unless ( $self->{execcapable_oses}->{$osname} ) {
+            $execcapable = 0;
         }
-        $execcapable = $conf->options->get('execcapable')
-            if defined $conf->options->get('execcapable');
-        _handle_execcapable($conf, $execcapable);
-
-        # test for executable malloced memory
-        if ( -e "config/auto/jit/test_exec_$osname.in" ) {
-            print " (has_exec_protect " if $verbose;
-            $conf->cc_gen("config/auto/jit/test_exec_$osname.in");
-            eval { $conf->cc_build(); };
-            if ($@) {
-                print " $@) " if $verbose;
-            }
-            else {
-                if ( $conf->cc_run(0) !~ /ok/ && $conf->cc_run(1) =~ /ok/ ) {
-                    $conf->data->set( has_exec_protect => 1 );
-                    print "yes) " if $verbose;
-                }
-                else {
-                    print "no) " if $verbose;
-                }
-            }
-            $conf->cc_clean();
-        }
-
-        # RT #43146 use executable memory for this test if needed
-        #
-        # test for some instructions
-        if ( $jitcpuarch eq 'i386' ) {
-            $conf->cc_gen('config/auto/jit/test_c.in');
-            eval { $conf->cc_build(); };
-            unless ( $@ || $conf->cc_run() !~ /ok/ ) {
-                $conf->data->set( jit_i386 => 'fcomip' );
-            }
-            $conf->cc_clean();
-        }
     }
-    else {
-        $conf->data->set(
-            jitarchname    => 'nojit',
-            jitcpuarch     => $cpuarch,
-            jitcpu         => $cpuarch,
-            jitosname      => $osname,
-            jitcapable     => 0,
-            execcapable    => 0,
-            cc_hasjit      => '',
-            TEMP_jit_o     => '',
-            TEMP_exec_h    => '',
-            TEMP_exec_o    => '',
-            TEMP_exec_dep  => '',
-        );
-    }
-
-    return 1;
+    return $execcapable;
 }
 
 sub _handle_execcapable {
@@ -210,6 +231,17 @@
     return 1;
 }
 
+sub _handle_exec_protect {
+    my ($conf, $exec_protect_test, $verbose) = @_;
+    if ($exec_protect_test) {
+        $conf->data->set( has_exec_protect => 1 );
+        print "yes) " if $verbose;
+    }
+    else {
+        print "no) " if $verbose;
+    }
+}
+
 1;
 
 # Local Variables:

Reply via email to