-
Notifications
You must be signed in to change notification settings - Fork 383
Clean up file hash usage #10102
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Clean up file hash usage #10102
Changes from all commits
ff6da36
7a237de
597a6d5
878e612
8879c81
0d4ee44
5d7fdaf
f7f2256
d1c4000
28b6dbb
334f14f
ec9b458
ce8db41
30abfda
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,7 +15,7 @@ | |
*/ | ||
package com.google.gwt.dev.javac; | ||
|
||
import com.google.gwt.dev.util.Util; | ||
import com.google.gwt.thirdparty.guava.common.hash.Hashing; | ||
|
||
import org.objectweb.asm.AnnotationVisitor; | ||
import org.objectweb.asm.Attribute; | ||
|
@@ -24,6 +24,7 @@ | |
import org.objectweb.asm.FieldVisitor; | ||
import org.objectweb.asm.Opcodes; | ||
|
||
import java.nio.charset.StandardCharsets; | ||
import java.util.Arrays; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
@@ -60,7 +61,7 @@ public CompileDependencyVisitor() { | |
} | ||
|
||
public String getSignature() { | ||
return Util.computeStrongName(Util.getBytes(getRawString())); | ||
return Hashing.murmur3_128().hashString(getRawString(), StandardCharsets.UTF_8).toString(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Collisions in this result in the compiler failing to generated code correctly in a variety of ways - this should be revisited to find a safer way to handle collisions. |
||
} | ||
|
||
@Override | ||
|
@@ -203,7 +204,7 @@ private String getRawString() { | |
* methods in a class. | ||
* | ||
* @param byteCode byte code for class to analyze. | ||
* @return a hex string representing an MD5 digest. | ||
* @return a hex string representing a murmur3 hash. | ||
*/ | ||
public static String getCompileDependencySignature(byte[] byteCode) { | ||
CompileDependencyVisitor v = visitCompileDependenciesInBytecode(byteCode); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,6 +45,7 @@ | |
import com.google.gwt.dev.util.log.speedtracer.CompilerEventType; | ||
import com.google.gwt.dev.util.log.speedtracer.SpeedTracerLogger; | ||
import com.google.gwt.dev.util.log.speedtracer.SpeedTracerLogger.Event; | ||
import com.google.gwt.thirdparty.guava.common.hash.Hashing; | ||
import com.google.gwt.thirdparty.guava.common.io.Files; | ||
|
||
import java.io.ByteArrayOutputStream; | ||
|
@@ -54,10 +55,12 @@ | |
import java.io.OutputStream; | ||
import java.io.PrintWriter; | ||
import java.io.StringWriter; | ||
import java.nio.charset.StandardCharsets; | ||
import java.util.ArrayList; | ||
import java.util.Collection; | ||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Locale; | ||
import java.util.Map; | ||
import java.util.Map.Entry; | ||
import java.util.Set; | ||
|
@@ -149,8 +152,9 @@ public void abort() { | |
@Override | ||
public void commit(TreeLogger logger) { | ||
String source = sw.toString(); | ||
strongHash = Util.computeStrongName(Util.getBytes(source)); | ||
sourceToken = diskCache.writeString(source); | ||
byte[] sourceBytes = source.getBytes(StandardCharsets.UTF_8); | ||
strongHash = Hashing.murmur3_128().hashBytes(sourceBytes).toString().toUpperCase(Locale.ROOT); | ||
sourceToken = diskCache.writeByteArray(sourceBytes); | ||
Comment on lines
+155
to
+157
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Collisions from this are especially bad for the correct output, and should be revisited (so that collisions don't result in broken code). |
||
sw = null; | ||
creationTime = System.currentTimeMillis(); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Collisions from this are especially bad for the compiler, and should be revisited (so that collisions don't result in broken code).