Changeset 263569 in webkit


Ignore:
Timestamp:
Jun 26, 2020, 10:18:41 AM (5 years ago)
Author:
Jonathan Bedard
Message:

run-javascriptcore-tests: Support Apple Silicon running x86 processes
https://bugs.webkit.org/show_bug.cgi?id=213487
<rdar://problem/64606667>

Reviewed by Saam Barati.

  • Scripts/run-javascriptcore-tests:

(configurationForUpload): Add --architecture flag.
(runTest): Run test suite with specific architecture.
(runJSCStressTests): Pass architecture to run-jsc-stress-tests.

  • Scripts/run-jsc-stress-tests: Add --force-architecture flag.
  • Scripts/webkitdirs.pm:

(determineNativeArchitecture): Add function to determine machine's native architecture.
(determineArchitecture): Leverage the nativeArchitecture instead of hard-coding simulator
architectures.
(architecturesForProducts): Determine the architectures supported by a given build.
(nativeArchitecture): Return nativeArchitecture.

Location:
trunk/Tools
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Tools/ChangeLog

    r263563 r263569  
     12020-06-26  Jonathan Bedard  <jbedard@apple.com>
     2
     3        run-javascriptcore-tests: Support Apple Silicon running x86 processes
     4        https://bugs.webkit.org/show_bug.cgi?id=213487
     5        <rdar://problem/64606667>
     6
     7        Reviewed by Saam Barati.
     8
     9        * Scripts/run-javascriptcore-tests:
     10        (configurationForUpload): Add --architecture flag.
     11        (runTest): Run test suite with specific architecture.
     12        (runJSCStressTests): Pass architecture to run-jsc-stress-tests.
     13        * Scripts/run-jsc-stress-tests: Add --force-architecture flag.
     14        * Scripts/webkitdirs.pm:
     15        (determineNativeArchitecture): Add function to determine machine's native architecture.
     16        (determineArchitecture): Leverage the nativeArchitecture instead of hard-coding simulator
     17        architectures.
     18        (architecturesForProducts): Determine the architectures supported by a given build.
     19        (nativeArchitecture): Return nativeArchitecture.
     20
    1212020-06-26  Sihui Liu  <sihui_liu@apple.com>
    222
  • trunk/Tools/Scripts/run-javascriptcore-tests

    r263431 r263569  
    105105my $remoteHost = 0;
    106106my $model = 0;
     107my $archs = undef;
    107108my $version;
    108109my $versionName;
     
    232233Usage: $programName [options] [options to pass to build system]
    233234  --help                        Show this help message
     235  --architecture                Attempt to override the native architecture of a machine.
    234236  --root=                       Path to pre-built root containing jsc
    235237  --[no-]ftl-jit                Turn the FTL JIT on or off
     
    328330    'remote=s' => \$remoteHost,
    329331    'model=s' => \$model,
     332    'architecture=s' => \$archs,
    330333    'version=s' => \$version,
    331334    'version-name=s' => \$versionName,
     
    351354);
    352355
    353 
    354356my $specificTestsSpecified = 0;
    355357if ($runTestMasm == DO_RUN
     
    450452    my $result = {
    451453        platform => $platform,
    452         architecture => architecture(),
     454        architecture => $archs,
    453455        is_simulator => $simulator,
    454456        style => lc(configuration()),
     
    484486
    485487setConfigurationProductDir(Cwd::abs_path($root)) if (defined($root));
     488my $archsInBuild = architecturesForProducts();
     489if (defined $archs) {
     490    die "$archs not supported by the provided binary, which supports '$archsInBuild'" if index($archsInBuild, $archs) == -1;
     491} else {
     492    # Fallback is x86_64, which we replace with the native architecture if the native architecture is in the provided build
     493    $archs = "x86_64";
     494    $archs = nativeArchitecture() if index($archsInBuild, nativeArchitecture()) != -1;
     495}
     496
     497# For running tests, arm64e should map to arm64
     498$archs = "arm64" if $archs eq "arm64e";
     499if ($archs ne nativeArchitecture() && (nativeArchitecture() ne "arm64" || !isAppleMacWebKit())) {
     500    die "Cannot run tests with $archs on this machine";
     501}
     502
    486503configurationForUpload() if (defined($report));
    487504
     
    552569    my @command = (testPath($productDir, $testName));
    553570    unshift @command, ("xcrun", "-sdk", xcodeSDK(), "sim") if willUseIOSSimulatorSDK();
     571    unshift @command, ("/usr/bin/arch", "-$archs") if $archs ne nativeArchitecture();
    554572    unshift @command, wrapperPrefixIfNeeded() if isGtk() or isWPE();
    555573
     
    713731    my @jscStressDriverCmd = (
    714732        "/usr/bin/env", "ruby", "Tools/Scripts/run-jsc-stress-tests",
    715         "-j", jscPath($productDir), "-o", $jscStressResultsDir);
     733        "-j", jscPath($productDir), "-o", $jscStressResultsDir, "--arch", $archs);
     734
     735    if (nativeArchitecture() != $archs) {
     736        push(@jscStressDriverCmd, "--force-architecture");
     737        push(@jscStressDriverCmd, $archs);
     738    }
    716739
    717740    push(@jscStressDriverCmd, @testList);
  • trunk/Tools/Scripts/run-jsc-stress-tests

    r263290 r263569  
    115115$remoteHosts = []
    116116$architecture = nil
     117$forceArchitecture = nil
    117118$hostOS = nil
    118119$model = nil
     
    140141    puts "--tarball [fileName]        Creates a tarball of the final bundle.  Use name if supplied for tar file."
    141142    puts "--arch                      Specify architecture instead of determining from JavaScriptCore build."
     143    puts "--force-architecture        Override the architecture to run tests with."
    142144    puts "                            e.g. x86, x86_64, arm."
    143145    puts "--os                        Specify os instead of determining from JavaScriptCore build."
     
    181183               ['--force-vm-copy', GetoptLong::NO_ARGUMENT],
    182184               ['--arch', GetoptLong::REQUIRED_ARGUMENT],
     185               ['--force-architecture', GetoptLong::REQUIRED_ARGUMENT],
    183186               ['--os', GetoptLong::REQUIRED_ARGUMENT],
    184187               ['--shell-runner', GetoptLong::NO_ARGUMENT],
     
    248251    when '--arch'
    249252        $architecture = arg
     253    when '--force-architecture'
     254        $architecture = arg unless $architecture
     255        $forceArchitecture = arg
    250256    when '--os'
    251257        $hostOS = arg
     
    558564end
    559565
     566def vmCommand
     567    if ($forceArchitecture)
     568        ["/usr/bin/arch", "-" + $forceArchitecture,  pathToVM.to_s]
     569    else
     570        [pathToVM.to_s]
     571    end
     572end
     573
    560574def pathToHelpers
    561575    pathToBundleResourceFromBenchmarkDirectory(".helpers")
     
    644658
    645659def runWithOutputHandler(kind, outputHandler, *options)
    646     addRunCommand(kind, [pathToVM.to_s] + BASE_OPTIONS + $testSpecificRequiredOptions + options + [$benchmark.to_s], outputHandler, simpleErrorHandler)
     660    addRunCommand(kind, vmCommand + BASE_OPTIONS + $testSpecificRequiredOptions + options + [$benchmark.to_s], outputHandler, simpleErrorHandler)
    647661end
    648662
    649663def runWithOutputHandlerWithoutBaseOption(kind, outputHandler, *options)
    650     addRunCommand(kind, [pathToVM.to_s] + $testSpecificRequiredOptions + options + [$benchmark.to_s], outputHandler, simpleErrorHandler)
     664    addRunCommand(kind, vmCommand + $testSpecificRequiredOptions + options + [$benchmark.to_s], outputHandler, simpleErrorHandler)
    651665end
    652666
     
    974988
    975989def runExceptionFuzz
    976     subCommand = escapeAll([pathToVM.to_s, "--useDollarVM=true", "--useExceptionFuzz=true", $benchmark.to_s])
     990    subCommand = escapeAll(vmCommand + ["--useDollarVM=true", "--useExceptionFuzz=true", $benchmark.to_s])
    977991    addRunCommand("exception-fuzz", ["perl", (pathToHelpers + "js-exception-fuzz").to_s, subCommand], silentOutputHandler, simpleErrorHandler)
    978992end
    979993
    980994def runExecutableAllocationFuzz(name, *options)
    981     subCommand = escapeAll([pathToVM.to_s, "--useDollarVM=true", $benchmark.to_s] + options)
     995    subCommand = escapeAll(vmCommand + ["--useDollarVM=true", $benchmark.to_s] + options)
    982996    addRunCommand("executable-allocation-fuzz-" + name, ["perl", (pathToHelpers + "js-executable-allocation-fuzz").to_s, subCommand], silentOutputHandler, simpleErrorHandler)
    983997end
     
    10281042    prepareExtraRelativeFiles(includeFiles.map { |f| "../" + f }, $collection)
    10291043
    1030     args = [pathToVM.to_s] + BASE_OPTIONS + $testSpecificRequiredOptions
     1044    args = vmCommand + BASE_OPTIONS + $testSpecificRequiredOptions
    10311045    args << "--exception=" + exception if failsWithException
    10321046    args << "--test262-async" if isAsync
     
    10701084
    10711085def runES6(mode)
    1072     args = [pathToVM.to_s] + BASE_OPTIONS + $testSpecificRequiredOptions + [$benchmark.to_s]
     1086    args = vmCommand + BASE_OPTIONS + $testSpecificRequiredOptions + [$benchmark.to_s]
    10731087    case mode
    10741088    when :normal
     
    12681282    prepareExtraRelativeFiles(extraFiles.map { |f| "../" + f }, $collection)
    12691283
    1270     args = [pathToVM.to_s] + BASE_OPTIONS + $testSpecificRequiredOptions
     1284    args = vmCommand + BASE_OPTIONS + $testSpecificRequiredOptions
    12711285    args += FTL_OPTIONS if $isFTLPlatform
    12721286    args += EAGER_OPTIONS
     
    13091323    prepareExtraAbsoluteFiles(LAYOUTTESTS_PATH, ["resources/standalone-pre.js", "resources/standalone-post.js"])
    13101324
    1311     args = [pathToVM.to_s] + BASE_OPTIONS + $testSpecificRequiredOptions + options +
     1325    args = vmCommand + BASE_OPTIONS + $testSpecificRequiredOptions + options +
    13121326        [(Pathname.new("resources") + "standalone-pre.js").to_s,
    13131327         $benchmark.to_s,
     
    14491463    prepareExtraRelativeFiles(before.map{|v| (Pathname("..") + v).to_s}, $collection)
    14501464    prepareExtraRelativeFiles(after.map{|v| (Pathname("..") + v).to_s}, $collection)
    1451     args = [pathToVM.to_s] + BASE_OPTIONS + $testSpecificRequiredOptions + options + before.map{|v| v.to_s} + [$benchmark.to_s] + after.map{|v| v.to_s}
     1465    args = vmCommand + BASE_OPTIONS + $testSpecificRequiredOptions + options + before.map{|v| v.to_s} + [$benchmark.to_s] + after.map{|v| v.to_s}
    14521466    addRunCommand("complex", args, noisyOutputHandler, simpleErrorHandler, *additionalEnv)
    14531467end
     
    14601474    end
    14611475    prepareExtraRelativeFiles(extraFiles.map{|v| (Pathname("..") + v).to_s}, $collection)
    1462     args = [pathToVM.to_s] + BASE_OPTIONS + $testSpecificRequiredOptions + options + extraFiles.map{|v| v.to_s} + [$benchmark.to_s]
     1476    args = vmCommand + BASE_OPTIONS + $testSpecificRequiredOptions + options + extraFiles.map{|v| v.to_s} + [$benchmark.to_s]
    14631477    case mode
    14641478    when :normal
     
    15301544
    15311545def runNoisyTestImpl(kind, options, additionalEnv)
    1532     addRunCommand(kind, [pathToVM.to_s] + BASE_OPTIONS + $testSpecificRequiredOptions + options + [$benchmark.to_s], noisyOutputHandler, noisyErrorHandler, *additionalEnv)
     1546    addRunCommand(kind, vmCommand + BASE_OPTIONS + $testSpecificRequiredOptions + options + [$benchmark.to_s], noisyOutputHandler, noisyErrorHandler, *additionalEnv)
    15331547end
    15341548
  • trunk/Tools/Scripts/webkitdirs.pm

    r263310 r263569  
    129129
    130130my $architecture;
     131my $nativeArchitecture;
    131132my $asanIsEnabled;
    132133my $forceOptimizationLevel;
     
    351352}
    352353
     354sub determineNativeArchitecture
     355{
     356    return if defined $nativeArchitecture;
     357    $nativeArchitecture = `uname -m`;
     358    chomp $nativeArchitecture;
     359    $nativeArchitecture = "x86_64" if (not defined $nativeArchitecture);
     360
     361    # FIXME: Remove this when <rdar://problem/64208532> is resolved
     362    if (isAppleCocoaWebKit() && $nativeArchitecture ne "x86_64") {
     363        $nativeArchitecture = "arm64";
     364    }
     365    die "'arm64e' is an invalid native architecture" if $nativeArchitecture eq "arm64e";
     366}
     367
    353368sub determineArchitecture
    354369{
    355370    return if defined $architecture;
    356     # make sure $architecture is defined in all cases
    357     $architecture = "";
    358371
    359372    determineBaseProductDir();
    360373    determineXcodeSDK();
     374    determineNativeArchitecture();
     375    $architecture = $nativeArchitecture;
    361376
    362377    if (isAppleCocoaWebKit()) {
     
    368383            chomp $architecture;
    369384        } else {
    370             if (not defined $xcodeSDK or $xcodeSDK =~ /^(\/$|macosx)/) {
    371                 my $supports64Bit = `sysctl -n hw.optional.x86_64`;
    372                 chomp $supports64Bit;
    373                 $architecture = 'x86_64' if $supports64Bit;
    374             } elsif ($xcodeSDK =~ /^iphonesimulator/) {
    375                 $architecture = 'x86_64';
    376             } elsif ($xcodeSDK =~ /^iphoneos/) {
     385            if ($xcodeSDK =~ /^iphoneos/) {
    377386                $architecture = 'arm64';
    378387            } elsif ($xcodeSDK =~ /^watchsimulator/) {
     
    380389            } elsif ($xcodeSDK =~ /^watchos/) {
    381390                $architecture = 'arm64_32 arm64e armv7k';
    382             } elsif ($xcodeSDK =~ /^appletvsimulator/) {
    383                 $architecture = 'x86_64';
    384391            } elsif ($xcodeSDK =~ /^appletvos/) {
    385392                $architecture = 'arm64';
     
    401408            }
    402409            close $cmake_sysinfo;
    403         }
    404     }
    405 
    406     if (!isAnyWindows()) {
    407         if (!$architecture) {
    408             # Fall back to output of `uname -m', if it is present.
    409             $architecture = `uname -m`;
    410             chomp $architecture;
    411410        }
    412411    }
     
    841840}
    842841
     842sub architecturesForProducts
     843{
     844    # Most ports don't have emulation, assume that the user gave us an accurate architecture
     845    if (!isAppleCocoaWebKit()) {
     846        return determineArchitecture();
     847    }
     848    my $webkitBinary = File::Spec->catdir(executableProductDir(), "JavaScriptCore.framework", "JavaScriptCore");
     849    my $architectures = `/usr/bin/lipo -archs $webkitBinary`;
     850    chomp($architectures);
     851    return $architectures;
     852}
     853
    843854sub configuration()
    844855{
     
    10391050    determinePassedArchitecture();
    10401051    return $passedArchitecture;
     1052}
     1053
     1054sub nativeArchitecture()
     1055{
     1056    determineNativeArchitecture();
     1057    return $nativeArchitecture;
    10411058}
    10421059
Note: See TracChangeset for help on using the changeset viewer.