Changeset 215166 in webkit


Ignore:
Timestamp:
Apr 9, 2017 2:48:06 PM (7 years ago)
Author:
commit-queue@webkit.org
Message:

generate-bindings-all.pl shouldn't use Perl threads
https://bugs.webkit.org/show_bug.cgi?id=170106

Patch by Fujii Hironori <Fujii Hironori> on 2017-04-09
Reviewed by Yusuke Suzuki.

The use of interpreter-based threads in Perl is officially
discouraged and not all Linux distributions and BSD compile Perl
with threads support. Use fork instead of threads to run
generate-bindings.pl in parallel.

  • bindings/scripts/generate-bindings-all.pl:

(spawnGenerateBindingsIfNeeded): Added.
(executeCommand): Removed the workaround for Cygwin Perl threads.
(spawnCommand): Added.
(worker): Deleted.

Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r215163 r215166  
     12017-04-09  Fujii Hironori  <Hironori.Fujii@sony.com>
     2
     3        generate-bindings-all.pl shouldn't use Perl threads
     4        https://bugs.webkit.org/show_bug.cgi?id=170106
     5
     6        Reviewed by Yusuke Suzuki.
     7
     8        The use of interpreter-based threads in Perl is officially
     9        discouraged and not all Linux distributions and BSD compile Perl
     10        with threads support. Use fork instead of threads to run
     11        generate-bindings.pl in parallel.
     12
     13        * bindings/scripts/generate-bindings-all.pl:
     14        (spawnGenerateBindingsIfNeeded): Added.
     15        (executeCommand): Removed the workaround for Cygwin Perl threads.
     16        (spawnCommand): Added.
     17        (worker): Deleted.
     18
    1192017-04-09  Said Abou-Hallawa  <sabouhallawa@apple.com>
    220
  • trunk/Source/WebCore/bindings/scripts/generate-bindings-all.pl

    r208220 r215166  
    3333use File::Find;
    3434use Getopt::Long;
    35 use threads;
    36 use threads::shared;
    37 use Thread::Queue;
    3835
    3936my $perl = $^X;
     
    122119    needsUpdate(\@output, \@deps);
    123120}}, @idlFiles;
    124 my $queue = Thread::Queue->new(@idlFilesToUpdate);
    125 my $abort :shared = 0;
     121
     122my $abort = 0;
    126123my $totalCount = @idlFilesToUpdate;
    127 my $currentCount :shared = 0;
    128 
    129 my @threadPool = map { threads->create(\&worker) } (1 .. $numOfJobs);
    130 $_->join for @threadPool;
     124my $currentCount = 0;
     125
     126spawnGenerateBindingsIfNeeded() for (1 .. $numOfJobs);
     127while (waitpid(-1, 0) != -1) {
     128    if ($?) {
     129        $abort = 1;
     130    }
     131    spawnGenerateBindingsIfNeeded();
     132}
    131133exit $abort;
    132134
     
    158160}
    159161
    160 sub worker {
    161     while (my $file = $queue->dequeue_nb()) {
    162         last if $abort;
    163         eval {
    164             $currentCount++;
    165             my $basename = basename($file);
    166             printProgress("[$currentCount/$totalCount] $basename");
    167             executeCommand($perl, @args, $file) == 0 or die;
    168         };
    169         if ($@) {
    170             $abort = 1;
    171             die;
    172         }
    173     }
     162sub spawnGenerateBindingsIfNeeded
     163{
     164    return if $abort;
     165    return unless @idlFilesToUpdate;
     166    my $file = shift @idlFilesToUpdate;
     167    $currentCount++;
     168    my $basename = basename($file);
     169    printProgress("[$currentCount/$totalCount] $basename");
     170    my $pid = spawnCommand($perl, @args, $file);
     171    $abort = 1 unless defined $pid;
    174172}
    175173
     
    197195sub executeCommand
    198196{
    199     if ($^O eq 'cygwin') {
    200         # 'system' of Cygwin Perl doesn't seem thread-safe
    201         my $pid = fork();
    202         defined($pid) or die;
    203         if ($pid == 0) {
    204             exec(@_) or die;
    205         }
    206         waitpid($pid, 0);
    207         return $?;
    208     }
    209197    if ($^O eq 'MSWin32') {
    210198        return system(quoteCommand(@_));
    211199    }
    212200    return system(@_);
     201}
     202
     203sub spawnCommand
     204{
     205    my $pid = fork();
     206    if ($pid == 0) {
     207        @_ = quoteCommand(@_) if ($^O eq 'MSWin32');
     208        exec(@_);
     209        die "Cannot exec";
     210    }
     211    return $pid;
    213212}
    214213
Note: See TracChangeset for help on using the changeset viewer.