mirror of
https://github.com/dart-lang/sdk
synced 2024-09-18 20:11:19 +00:00
dart2js: fix nondeterministic output of type metadata.
Use consistent hashcode for deferred index into metadata. Slightly nicer names for type constants in non-minified mode. C.Type_k8F --> C.Type_String_k8F BUG= http://dartbug.com/24391 R=het@google.com Review URL: https://codereview.chromium.org//1358363002 .
This commit is contained in:
parent
72ee80467a
commit
4cb72d2baf
|
@ -215,7 +215,7 @@ class FunctionInlineCache {
|
|||
enum SyntheticConstantKind {
|
||||
DUMMY_INTERCEPTOR,
|
||||
EMPTY_VALUE,
|
||||
TYPEVARIABLE_REFERENCE,
|
||||
TYPEVARIABLE_REFERENCE, // Reference to a type in reflection data.
|
||||
NAME
|
||||
}
|
||||
|
||||
|
|
|
@ -1710,11 +1710,13 @@ class ConstantNamingVisitor implements ConstantValueVisitor {
|
|||
|
||||
@override
|
||||
void visitType(TypeConstantValue constant, [_]) {
|
||||
// Generates something like 'Type_String_k8F', using the simple name of the
|
||||
// type and a hash to disambiguate the same name in different libraries.
|
||||
addRoot('Type');
|
||||
DartType type = constant.representedType;
|
||||
JavaScriptBackend backend = compiler.backend;
|
||||
String name = backend.rti.getTypeRepresentationForTypeConstant(type);
|
||||
addIdentifier(name);
|
||||
String simpleName = type.element.name;
|
||||
addIdentifier(simpleName);
|
||||
add(getHashTag(constant, 3));
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -1730,7 +1732,7 @@ class ConstantNamingVisitor implements ConstantValueVisitor {
|
|||
add('dummy_receiver');
|
||||
break;
|
||||
case SyntheticConstantKind.TYPEVARIABLE_REFERENCE:
|
||||
add('type_variable_reference');
|
||||
// Omit. These are opaque deferred indexes with nothing helpful to add.
|
||||
break;
|
||||
case SyntheticConstantKind.NAME:
|
||||
add('name');
|
||||
|
@ -1829,6 +1831,7 @@ class ConstantCanonicalHasher implements ConstantValueVisitor<int, Null> {
|
|||
int visitType(TypeConstantValue constant, [_]) {
|
||||
DartType type = constant.representedType;
|
||||
JavaScriptBackend backend = compiler.backend;
|
||||
// This name includes the library name and type parameters.
|
||||
String name = backend.rti.getTypeRepresentationForTypeConstant(type);
|
||||
return _hashString(4, name);
|
||||
}
|
||||
|
@ -1840,15 +1843,18 @@ class ConstantCanonicalHasher implements ConstantValueVisitor<int, Null> {
|
|||
}
|
||||
|
||||
@override
|
||||
visitSynthetic(SyntheticConstantValue constant, [_]) {
|
||||
int visitSynthetic(SyntheticConstantValue constant, [_]) {
|
||||
switch (constant.kind) {
|
||||
case SyntheticConstantKind.TYPEVARIABLE_REFERENCE:
|
||||
return constant.payload.hashCode;
|
||||
// These contain a deferred opaque index into metadata. There is nothing
|
||||
// we can access that is stable between compiles. Luckily, since they
|
||||
// resolve to integer indexes, they're always part of a larger constant.
|
||||
return 0;
|
||||
default:
|
||||
compiler.internalError(NO_LOCATION_SPANNABLE,
|
||||
'SyntheticConstantValue should never be named and '
|
||||
'never be subconstant');
|
||||
return null;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue