8#define H (translation_helper_)
9#define I Isolate::Current()
19 intptr_t data_program_offset)
28 return current * 31 + val;
32 void BuildHash(uint32_t val);
33 void CalculateConstructorFingerprint();
34 void CalculateArgumentsFingerprint();
35 void CalculateVariableDeclarationFingerprint();
36 void CalculateStatementListFingerprint();
37 void CalculateListOfExpressionsFingerprint();
38 void CalculateListOfNamedExpressionsFingerprint();
39 void CalculateListOfDartTypesFingerprint();
40 void CalculateListOfVariableDeclarationsFingerprint();
41 void CalculateStringReferenceFingerprint();
42 void CalculateListOfStringsFingerprint();
43 void CalculateTypeParameterFingerprint();
44 void CalculateTypeParametersListFingerprint();
45 void CalculateCanonicalNameFingerprint();
46 void CalculateInterfaceMemberNameFingerprint();
47 void CalculateInitializerFingerprint();
48 void CalculateDartTypeFingerprint();
49 void CalculateOptionalDartTypeFingerprint();
50 void CalculateInterfaceTypeFingerprint(
bool simple);
51 void CalculateFunctionTypeFingerprint(
bool simple);
52 void CalculateGetterNameFingerprint();
53 void CalculateSetterNameFingerprint();
54 void CalculateMethodNameFingerprint();
55 void CalculateExpressionFingerprint();
56 void CalculateStatementFingerprint();
57 void CalculateFunctionNodeFingerprint();
64void KernelFingerprintHelper::BuildHash(uint32_t val) {
68void KernelFingerprintHelper::CalculateConstructorFingerprint() {
72 CalculateListOfExpressionsFingerprint();
73 CalculateFunctionNodeFingerprint();
75 for (intptr_t
i = 0;
i <
len; ++
i) {
76 CalculateInitializerFingerprint();
79 BuildHash(helper.flags_);
82void KernelFingerprintHelper::CalculateArgumentsFingerprint() {
85 CalculateListOfDartTypesFingerprint();
86 CalculateListOfExpressionsFingerprint();
87 CalculateListOfNamedExpressionsFingerprint();
90void KernelFingerprintHelper::CalculateVariableDeclarationFingerprint() {
94 CalculateListOfExpressionsFingerprint();
99 CalculateDartTypeFingerprint();
101 CalculateExpressionFingerprint();
104 BuildHash(helper.flags_);
107void KernelFingerprintHelper::CalculateStatementListFingerprint() {
109 for (intptr_t
i = 0;
i < list_length; ++
i) {
110 CalculateStatementFingerprint();
114void KernelFingerprintHelper::CalculateListOfExpressionsFingerprint() {
116 for (intptr_t
i = 0;
i < list_length; ++
i) {
117 CalculateExpressionFingerprint();
121void KernelFingerprintHelper::CalculateListOfNamedExpressionsFingerprint() {
123 for (intptr_t
i = 0;
i < list_length; ++
i) {
124 CalculateStringReferenceFingerprint();
125 CalculateExpressionFingerprint();
129void KernelFingerprintHelper::CalculateListOfDartTypesFingerprint() {
131 for (intptr_t
i = 0;
i < list_length; ++
i) {
132 CalculateDartTypeFingerprint();
136void KernelFingerprintHelper::CalculateStringReferenceFingerprint() {
141void KernelFingerprintHelper::CalculateListOfStringsFingerprint() {
143 for (intptr_t
i = 0;
i < list_length; ++
i) {
144 CalculateStringReferenceFingerprint();
148void KernelFingerprintHelper::CalculateListOfVariableDeclarationsFingerprint() {
150 for (intptr_t
i = 0;
i < list_length; ++
i) {
152 CalculateVariableDeclarationFingerprint();
156void KernelFingerprintHelper::CalculateTypeParameterFingerprint() {
160 CalculateListOfExpressionsFingerprint();
170 CalculateDartTypeFingerprint();
171 CalculateDartTypeFingerprint();
172 BuildHash(helper.flags_);
175void KernelFingerprintHelper::CalculateTypeParametersListFingerprint() {
177 for (intptr_t
i = 0;
i < list_length; ++
i) {
178 CalculateTypeParameterFingerprint();
182void KernelFingerprintHelper::CalculateCanonicalNameFingerprint() {
184 BuildHash(
H.DartString(
i).Hash());
187void KernelFingerprintHelper::CalculateInterfaceMemberNameFingerprint() {
188 CalculateCanonicalNameFingerprint();
192void KernelFingerprintHelper::CalculateInitializerFingerprint() {
196 case kInvalidInitializer:
198 case kFieldInitializer:
201 CalculateExpressionFingerprint();
203 case kSuperInitializer:
205 CalculateCanonicalNameFingerprint();
206 CalculateArgumentsFingerprint();
208 case kRedirectingInitializer:
210 CalculateCanonicalNameFingerprint();
211 CalculateArgumentsFingerprint();
213 case kLocalInitializer:
214 CalculateVariableDeclarationFingerprint();
216 case kAssertInitializer:
217 CalculateStatementFingerprint();
225void KernelFingerprintHelper::CalculateDartTypeFingerprint() {
239 CalculateInterfaceTypeFingerprint(
false);
241 case kSimpleInterfaceType:
242 CalculateInterfaceTypeFingerprint(
true);
245 CalculateFunctionTypeFingerprint(
false);
247 case kSimpleFunctionType:
248 CalculateFunctionTypeFingerprint(
true);
250 case kTypeParameterType: {
252 BuildHash(
static_cast<uint32_t
>(nullability));
256 case kIntersectionType:
257 CalculateDartTypeFingerprint();
258 CalculateDartTypeFingerprint();
262 CalculateListOfDartTypesFingerprint();
264 BuildHash(named_count);
265 for (intptr_t
i = 0;
i < named_count; ++
i) {
266 CalculateStringReferenceFingerprint();
267 CalculateDartTypeFingerprint();
272 case kExtensionType: {
277 CalculateDartTypeFingerprint();
282 CalculateDartTypeFingerprint();
290void KernelFingerprintHelper::CalculateOptionalDartTypeFingerprint() {
293 if (tag == kNothing) {
296 ASSERT(tag == kSomething);
297 CalculateDartTypeFingerprint();
300void KernelFingerprintHelper::CalculateInterfaceTypeFingerprint(
bool simple) {
302 BuildHash(
static_cast<uint32_t
>(nullability));
304 ASSERT(
H.IsClass(kernel_class));
305 const String&
class_name =
H.DartClassName(kernel_class);
306 NameIndex kernel_library =
H.CanonicalNameParent(kernel_class);
307 const String& library_name =
308 H.DartSymbolPlain(
H.CanonicalNameString(kernel_library));
310 BuildHash(library_name.Hash());
312 CalculateListOfDartTypesFingerprint();
316void KernelFingerprintHelper::CalculateFunctionTypeFingerprint(
bool simple) {
318 BuildHash(
static_cast<uint32_t
>(nullability));
321 CalculateTypeParametersListFingerprint();
326 CalculateListOfDartTypesFingerprint();
329 const intptr_t named_count =
331 BuildHash(named_count);
332 for (intptr_t
i = 0;
i < named_count; ++
i) {
334 CalculateStringReferenceFingerprint();
335 CalculateDartTypeFingerprint();
340 CalculateDartTypeFingerprint();
343void KernelFingerprintHelper::CalculateGetterNameFingerprint() {
346 BuildHash(
H.DartGetterName(
name).Hash());
351void KernelFingerprintHelper::CalculateSetterNameFingerprint() {
353 if (!
H.IsRoot(
name)) {
354 BuildHash(
H.DartSetterName(
name).Hash());
359void KernelFingerprintHelper::CalculateMethodNameFingerprint() {
360 const NameIndex
name =
362 if (!
H.IsRoot(
name)) {
363 BuildHash(
H.DartProcedureName(
name).Hash());
368void KernelFingerprintHelper::CalculateExpressionFingerprint() {
373 case kInvalidExpression:
375 CalculateStringReferenceFingerprint();
377 CalculateExpressionFingerprint();
384 CalculateOptionalDartTypeFingerprint();
386 case kSpecializedVariableGet:
394 CalculateExpressionFingerprint();
396 case kSpecializedVariableSet:
399 CalculateExpressionFingerprint();
404 CalculateExpressionFingerprint();
407 CalculateGetterNameFingerprint();
412 CalculateExpressionFingerprint();
415 case kInstanceTearOff:
418 CalculateExpressionFingerprint();
421 CalculateGetterNameFingerprint();
423 case kFunctionTearOff:
430 CalculateExpressionFingerprint();
432 CalculateExpressionFingerprint();
433 CalculateSetterNameFingerprint();
438 CalculateExpressionFingerprint();
440 CalculateExpressionFingerprint();
442 case kAbstractSuperPropertyGet:
447 case kAbstractSuperPropertySet:
452 case kSuperPropertyGet:
455 CalculateGetterNameFingerprint();
457 case kSuperPropertySet:
460 CalculateExpressionFingerprint();
461 CalculateSetterNameFingerprint();
465 CalculateCanonicalNameFingerprint();
469 CalculateCanonicalNameFingerprint();
470 CalculateExpressionFingerprint();
472 case kInstanceInvocation:
476 CalculateExpressionFingerprint();
478 CalculateArgumentsFingerprint();
480 CalculateMethodNameFingerprint();
482 case kDynamicInvocation:
486 CalculateExpressionFingerprint();
488 CalculateArgumentsFingerprint();
490 case kLocalFunctionInvocation:
494 CalculateArgumentsFingerprint();
497 case kFunctionInvocation:
500 CalculateExpressionFingerprint();
501 CalculateArgumentsFingerprint();
506 CalculateExpressionFingerprint();
507 CalculateExpressionFingerprint();
509 CalculateMethodNameFingerprint();
513 CalculateExpressionFingerprint();
515 case kAbstractSuperMethodInvocation:
520 case kSuperMethodInvocation:
523 CalculateArgumentsFingerprint();
524 CalculateInterfaceMemberNameFingerprint();
526 case kStaticInvocation:
528 CalculateCanonicalNameFingerprint();
529 CalculateArgumentsFingerprint();
531 case kConstructorInvocation:
533 CalculateCanonicalNameFingerprint();
534 CalculateArgumentsFingerprint();
538 CalculateExpressionFingerprint();
542 CalculateExpressionFingerprint();
544 case kLogicalExpression:
546 CalculateExpressionFingerprint();
548 CalculateExpressionFingerprint();
550 case kConditionalExpression:
552 CalculateExpressionFingerprint();
553 CalculateExpressionFingerprint();
554 CalculateExpressionFingerprint();
555 CalculateOptionalDartTypeFingerprint();
557 case kStringConcatenation:
559 CalculateListOfExpressionsFingerprint();
563 CalculateExpressionFingerprint();
564 CalculateDartTypeFingerprint();
569 CalculateExpressionFingerprint();
570 CalculateDartTypeFingerprint();
574 CalculateDartTypeFingerprint();
576 case kThisExpression:
585 CalculateExpressionFingerprint();
589 CalculateDartTypeFingerprint();
590 CalculateListOfExpressionsFingerprint();
599 CalculateDartTypeFingerprint();
600 CalculateDartTypeFingerprint();
602 for (intptr_t
i = 0;
i < list_length; ++
i) {
603 CalculateExpressionFingerprint();
604 CalculateExpressionFingerprint();
610 CalculateListOfExpressionsFingerprint();
611 CalculateListOfNamedExpressionsFingerprint();
612 CalculateDartTypeFingerprint();
614 case kRecordIndexGet:
616 CalculateExpressionFingerprint();
617 CalculateDartTypeFingerprint();
622 CalculateExpressionFingerprint();
623 CalculateDartTypeFingerprint();
624 CalculateStringReferenceFingerprint();
626 case kFunctionExpression:
628 CalculateFunctionNodeFingerprint();
632 CalculateVariableDeclarationFingerprint();
633 CalculateExpressionFingerprint();
635 case kBlockExpression:
637 CalculateStatementListFingerprint();
638 CalculateExpressionFingerprint();
642 CalculateExpressionFingerprint();
643 CalculateListOfDartTypesFingerprint();
647 CalculateStringReferenceFingerprint();
651 CalculateStringReferenceFingerprint();
653 case kSpecializedIntLiteral:
656 case kNegativeIntLiteral:
660 case kPositiveIntLiteral:
664 case kDoubleLiteral: {
667 uint64_t
data = bit_cast<uint64_t>(
value);
668 BuildHash(
static_cast<uint32_t
>(
data >> 32));
669 BuildHash(
static_cast<uint32_t
>(
data));
681 case kConstantExpression:
686 case kFileUriConstantExpression:
693 case kCheckLibraryIsLoaded:
697 case kAwaitExpression:
699 CalculateExpressionFingerprint();
701 CalculateDartTypeFingerprint();
704 case kFileUriExpression:
707 CalculateExpressionFingerprint();
709 case kConstStaticInvocation:
710 case kConstConstructorInvocation:
711 case kConstListLiteral:
712 case kConstSetLiteral:
713 case kConstMapLiteral:
715 case kListConcatenation:
716 case kSetConcatenation:
717 case kMapConcatenation:
718 case kInstanceCreation:
720 case kSwitchExpression:
721 case kPatternAssignment:
730void KernelFingerprintHelper::CalculateStatementFingerprint() {
734 case kExpressionStatement:
735 CalculateExpressionFingerprint();
740 CalculateStatementListFingerprint();
742 case kEmptyStatement:
745 CalculateStatementListFingerprint();
747 case kAssertStatement:
748 CalculateExpressionFingerprint();
752 CalculateExpressionFingerprint();
755 case kLabeledStatement:
757 CalculateStatementFingerprint();
759 case kBreakStatement:
763 case kWhileStatement:
765 CalculateExpressionFingerprint();
766 CalculateStatementFingerprint();
770 CalculateStatementFingerprint();
771 CalculateExpressionFingerprint();
773 case kForStatement: {
775 CalculateListOfVariableDeclarationsFingerprint();
777 if (tag == kSomething) {
778 CalculateExpressionFingerprint();
780 CalculateListOfExpressionsFingerprint();
781 CalculateStatementFingerprint();
784 case kSwitchStatement: {
787 CalculateExpressionFingerprint();
788 CalculateOptionalDartTypeFingerprint();
790 for (intptr_t
i = 0;
i < case_count; ++
i) {
793 for (intptr_t j = 0; j < expression_count; ++j) {
795 CalculateExpressionFingerprint();
797 BuildHash(
static_cast<uint32_t
>(
ReadBool()));
798 CalculateStatementFingerprint();
802 case kContinueSwitchStatement:
808 CalculateExpressionFingerprint();
809 CalculateStatementFingerprint();
810 CalculateStatementFingerprint();
812 case kReturnStatement: {
816 if (tag == kSomething) {
817 CalculateExpressionFingerprint();
823 CalculateStatementFingerprint();
826 for (intptr_t
i = 0;
i < catch_count; ++
i) {
828 CalculateDartTypeFingerprint();
831 if (tag == kSomething) {
832 CalculateVariableDeclarationFingerprint();
836 if (tag == kSomething) {
837 CalculateVariableDeclarationFingerprint();
839 CalculateStatementFingerprint();
845 CalculateStatementFingerprint();
846 CalculateStatementFingerprint();
848 case kYieldStatement: {
851 CalculateExpressionFingerprint();
854 case kVariableDeclaration:
855 CalculateVariableDeclarationFingerprint();
859 CalculateVariableDeclarationFingerprint();
860 CalculateFunctionNodeFingerprint();
862 case kForInStatement:
863 case kAsyncForInStatement:
864 case kIfCaseStatement:
865 case kPatternSwitchStatement:
866 case kPatternVariableDeclaration:
884 CalculateDartTypeFingerprint();
888 if (
PeekTag() == kFunctionExpression) {
890 CalculateExpressionFingerprint();
895 BuildHash(
name.Hash());
896 BuildHash(field_helper.
flags_);
901void KernelFingerprintHelper::CalculateFunctionNodeFingerprint() {
905 CalculateTypeParametersListFingerprint();
908 function_node_helper.ReadUntilExcluding(
910 CalculateListOfVariableDeclarationsFingerprint();
911 CalculateListOfVariableDeclarationsFingerprint();
912 CalculateDartTypeFingerprint();
913 CalculateOptionalDartTypeFingerprint();
926 CalculateStatementFingerprint();
928 BuildHash(function_node_helper.total_parameter_count_);
929 BuildHash(function_node_helper.required_parameter_count_);
937 }
else if (tag == kConstructor) {
938 CalculateConstructorFingerprint();
947 CalculateFunctionNodeFingerprint();
949 BuildHash(procedure_helper.
kind_);
950 BuildHash(procedure_helper.
flags_);
953 BuildHash(
name.Hash());
958 const Class& klass) {
970 if (!
type.IsNull()) {
977 for (intptr_t
i = 0;
i < fields.
Length(); ++
i) {
978 field ^= fields.
At(
i);
985 for (intptr_t
i = 0;
i < functions.
Length(); ++
i) {
986 func ^= functions.
At(
i);
992 for (intptr_t
i = 0;
i < interfaces.
Length(); ++
i) {
1002 const Field& field) {
1011 zone, &translation_helper,
1028 zone, &translation_helper,
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
static uint32_t hash(const SkShaderBase::GradientInfo &v)
ObjectPtr At(intptr_t index) const
TypePtr super_type() const
ArrayPtr interfaces() const
ArrayPtr current_functions() const
intptr_t kernel_offset() const
intptr_t KernelLibraryOffset() const
TypedDataViewPtr KernelLibrary() const
KernelProgramInfoPtr KernelProgramInfo() const
intptr_t KernelLibraryOffset() const
intptr_t kernel_offset() const
TypedDataViewPtr KernelLibrary() const
KernelProgramInfoPtr KernelProgramInfo() const
static Thread * Current()
void ReadUntilExcluding(Field field)
void SetJustRead(Field field)
intptr_t annotation_count_
static uint32_t CalculateHash(uint32_t current, uint32_t val)
virtual ~KernelFingerprintHelper()
uint32_t CalculateFunctionFingerprint()
KernelFingerprintHelper(Zone *zone, TranslationHelper *translation_helper, const TypedDataView &data, intptr_t data_program_offset)
uint32_t CalculateFieldFingerprint()
friend class ConstructorHelper
friend class TypeParameterHelper
void SetOffset(intptr_t offset)
const String & ReadNameAsGetterName()
const String & ReadNameAsMethodName()
void SkipListOfDartTypes()
friend class VariableDeclarationHelper
void SkipConstantReference()
const String & ReadNameAsSetterName()
intptr_t ReadListLength()
TokenPosition ReadPosition()
Tag ReadTag(uint8_t *payload=nullptr)
virtual void ReportUnexpectedTag(const char *variant, Tag tag)
Tag PeekTag(uint8_t *payload=nullptr)
NameIndex ReadCanonicalNameReference()
const String & ReadNameAsFieldName()
void SkipCanonicalNameReference()
void SkipBytes(intptr_t skip)
StringIndex ReadStringReference()
Nullability ReadNullability()
static uint32_t CalculateFunctionFingerprint(const Function &func)
static uint32_t CalculateFieldFingerprint(const Field &field)
static uint32_t CalculateClassFingerprint(const Class &klass)
void ReadUntilExcluding(Field field)
void SetJustRead(Field field)
intptr_t annotation_count_
void InitFromKernelProgramInfo(const KernelProgramInfo &info)
const char *const class_name
static uint32_t Hash(uint32_t key)
static int8_t data[kExtLength]