Ignore:
Timestamp:
Jun 7, 2020, 12:35:37 AM (5 years ago)
Author:
[email protected]
Message:

[JSC] Checksum for generated files should be emitted at the end of the files
https://bugs.webkit.org/show_bug.cgi?id=212875

Reviewed by Mark Lam.

If the offlineasm file generation is interrupted in the middle of the generation, it already emitted checksum.
So next file generation can accept this broken file as a result of offlineasm and skip file generation.
We should emit checksum at the end of files. For now, this patch takes a quick way: just iterating lines, getting
a last line and use it for checksum comparison.

  • generator/GeneratedFile.rb:
  • offlineasm/asm.rb:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/offlineasm/asm.rb

    r250806 r262694  
    364364
    365365if FileTest.exist? outputFlnm
     366    lastLine = nil
    366367    File.open(outputFlnm, "r") {
    367         | inp |
    368         firstLine = inp.gets
    369         if firstLine and firstLine.chomp == inputHash
    370             $stderr.puts "offlineasm: Nothing changed."
    371             exit 0
    372         end
     368        | file |
     369        file.each_line {
     370            | line |
     371            line = line.chomp
     372            unless line.empty?
     373                lastLine = line
     374            end
     375        }
    373376    }
     377    if lastLine and lastLine == inputHash
     378        $stderr.puts "Offlineasm: Nothing changed."
     379        exit 0
     380    end
    374381end
    375382
     
    377384    | outp |
    378385    $output = outp
    379     $output.puts inputHash
    380386
    381387    $asm = Assembler.new($output)
     
    409415        }
    410416    }
     417
     418    $output.fsync
     419    $output.puts inputHash
    411420}
Note: See TracChangeset for help on using the changeset viewer.