Title: [262694] trunk/Source/_javascript_Core
Revision
262694
Author
ysuz...@apple.com
Date
2020-06-07 00:35:37 -0700 (Sun, 07 Jun 2020)

Log 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:

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (262693 => 262694)


--- trunk/Source/_javascript_Core/ChangeLog	2020-06-07 02:54:52 UTC (rev 262693)
+++ trunk/Source/_javascript_Core/ChangeLog	2020-06-07 07:35:37 UTC (rev 262694)
@@ -1,3 +1,18 @@
+2020-06-07  Yusuke Suzuki  <ysuz...@apple.com>
+
+        [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:
+
 2020-06-06  Mark Lam  <mark....@apple.com>
 
         Make CodeBlockHash robust against unreasonably long source code.

Modified: trunk/Source/_javascript_Core/generator/GeneratedFile.rb (262693 => 262694)


--- trunk/Source/_javascript_Core/generator/GeneratedFile.rb	2020-06-07 02:54:52 UTC (rev 262693)
+++ trunk/Source/_javascript_Core/generator/GeneratedFile.rb	2020-06-07 07:35:37 UTC (rev 262694)
@@ -61,7 +61,6 @@
         yield template
 
         file = File.open(filename, "w")
-        self.sha1(file, template, dependencies)
         self.license(file, template, dependencies)
 
         unless template.prefix.nil?
@@ -73,10 +72,13 @@
         unless template.suffix.nil?
             write(file, template.suffix.to_s, "\n")
         end
+
+        file.fsync
+        self.sha1(file, template, dependencies)
     end
 
     def self.sha1(file, template, dependencies)
-      write(file, template.line_comment, " SHA1Hash: ", Digest::SHA1.hexdigest(dependencies.join), "\n")
+        write(file, template.line_comment, " SHA1Hash: ", Digest::SHA1.hexdigest(dependencies.join), "\n")
     end
 
     def self.license(file, template, dependencies)

Modified: trunk/Source/_javascript_Core/offlineasm/asm.rb (262693 => 262694)


--- trunk/Source/_javascript_Core/offlineasm/asm.rb	2020-06-07 02:54:52 UTC (rev 262693)
+++ trunk/Source/_javascript_Core/offlineasm/asm.rb	2020-06-07 07:35:37 UTC (rev 262694)
@@ -363,20 +363,26 @@
     " " + Digest::SHA1.hexdigest($options.has_key?(:assembler) ? $options[:assembler] : "")
 
 if FileTest.exist? outputFlnm
+    lastLine = nil
     File.open(outputFlnm, "r") {
-        | inp |
-        firstLine = inp.gets
-        if firstLine and firstLine.chomp == inputHash
-            $stderr.puts "offlineasm: Nothing changed."
-            exit 0
-        end
+        | file |
+        file.each_line {
+            | line |
+            line = line.chomp
+            unless line.empty?
+                lastLine = line
+            end
+        }
     }
+    if lastLine and lastLine == inputHash
+        $stderr.puts "Offlineasm: Nothing changed."
+        exit 0
+    end
 end
 
 File.open(outputFlnm, "w") {
     | outp |
     $output = outp
-    $output.puts inputHash
 
     $asm = Assembler.new($output)
     
@@ -408,4 +414,7 @@
             }
         }
     }
+
+    $output.fsync
+    $output.puts inputHash
 }
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to