Skip to content

Commit 0162e7c

Browse files
alexmarkovcommit-bot@chromium.org
authored andcommitted
[vm] Enable fingerprints checking of recognized methods
Fixes #36376 Change-Id: I470b95a1f854ef6e3798422508a89bc61f71cd0c Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/153740 Reviewed-by: Martin Kustermann <[email protected]> Commit-Queue: Alexander Markov <[email protected]>
1 parent 2280e77 commit 0162e7c

File tree

7 files changed

+391
-405
lines changed

7 files changed

+391
-405
lines changed

runtime/vm/compiler/frontend/kernel_fingerprints.cc

+3-1
Original file line numberDiff line numberDiff line change
@@ -227,9 +227,11 @@ void KernelFingerprintHelper::CalculateDartTypeFingerprint() {
227227
case kDynamicType:
228228
case kVoidType:
229229
case kBottomType:
230-
case kNeverType:
231230
// those contain nothing.
232231
break;
232+
case kNeverType:
233+
BuildHash(static_cast<uint32_t>(ReadNullability()));
234+
break;
233235
case kInterfaceType:
234236
CalculateInterfaceTypeFingerprint(false);
235237
break;

runtime/vm/compiler/method_recognizer.cc

+2-5
Original file line numberDiff line numberDiff line change
@@ -204,10 +204,7 @@ void MethodRecognizer::InitializeState() {
204204
func = Library::GetFunction(libs, recognized_methods[i].class_name,
205205
recognized_methods[i].function_name);
206206
if (!func.IsNull()) {
207-
CHECK_FINGERPRINT3(func, recognized_methods[i].class_name,
208-
recognized_methods[i].function_name,
209-
recognized_methods[i].enum_name,
210-
recognized_methods[i].fp);
207+
ASSERT(func.CheckSourceFingerprint(recognized_methods[i].fp));
211208
func.set_recognized_kind(kind);
212209
switch (kind) {
213210
#define RECOGNIZE_METHOD(class_name, function_name, enum_name, fp) \
@@ -228,7 +225,7 @@ void MethodRecognizer::InitializeState() {
228225
#define SET_FUNCTION_BIT(class_name, function_name, dest, fp, setter, value) \
229226
func = Library::GetFunction(libs, #class_name, #function_name); \
230227
if (!func.IsNull()) { \
231-
CHECK_FINGERPRINT3(func, class_name, function_name, dest, fp); \
228+
ASSERT(func.CheckSourceFingerprint(fp)); \
232229
func.setter(value); \
233230
} else if (!FLAG_precompiled_mode) { \
234231
OS::PrintErr("Missing %s::%s\n", #class_name, #function_name); \

runtime/vm/compiler/method_recognizer.h

-6
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,6 @@ class MethodTokenRecognizer : public AllStatic {
6565
static Token::Kind RecognizeTokenKind(const String& name);
6666
};
6767

68-
#define CHECK_FINGERPRINT2(f, p0, p1, fp) \
69-
ASSERT(f.CheckSourceFingerprint(#p0 ", " #p1, fp))
70-
71-
#define CHECK_FINGERPRINT3(f, p0, p1, p2, fp) \
72-
ASSERT(f.CheckSourceFingerprint(#p0 ", " #p1 ", " #p2, fp))
73-
7468
// Class that recognizes factories and returns corresponding result cid.
7569
class FactoryRecognizer : public AllStatic {
7670
public:

runtime/vm/compiler/recognized_methods_list.h

+381-381
Large diffs are not rendered by default.

runtime/vm/dart_api_impl.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -1160,7 +1160,7 @@ static Dart_Isolate CreateIsolate(IsolateGroup* group,
11601160
is_new_group ? nullptr : group, isolate_data));
11611161
if (error_obj.IsNull()) {
11621162
#if defined(DEBUG) && !defined(DART_PRECOMPILED_RUNTIME)
1163-
if (FLAG_check_function_fingerprints && source->kernel_buffer == NULL) {
1163+
if (FLAG_check_function_fingerprints && !FLAG_precompiled_mode) {
11641164
Library::CheckFunctionFingerprints();
11651165
}
11661166
#endif // defined(DEBUG) && !defined(DART_PRECOMPILED_RUNTIME).

runtime/vm/object.cc

+3-10
Original file line numberDiff line numberDiff line change
@@ -9153,7 +9153,7 @@ void Function::SetDeoptReasonForAll(intptr_t deopt_id,
91539153
}
91549154
}
91559155

9156-
bool Function::CheckSourceFingerprint(const char* prefix, int32_t fp) const {
9156+
bool Function::CheckSourceFingerprint(int32_t fp) const {
91579157
if (Isolate::Current()->obfuscate() || FLAG_precompiled_mode ||
91589158
(Dart::vm_snapshot_kind() != Snapshot::kNone)) {
91599159
return true; // The kernel structure has been altered, skip checking.
@@ -9165,12 +9165,6 @@ bool Function::CheckSourceFingerprint(const char* prefix, int32_t fp) const {
91659165
return true;
91669166
}
91679167

9168-
#if 1
9169-
// The non-nullable experiment changes the fingerprints, we only track
9170-
// one fingerprint set, until we unfork and settle on a single snapshot
9171-
// version this check has to be bypassed.
9172-
// TODO(36376) - Restore checking fingerprints of recognized methods.
9173-
#else
91749168
if (SourceFingerprint() != fp) {
91759169
const bool recalculatingFingerprints = false;
91769170
if (recalculatingFingerprints) {
@@ -9189,7 +9183,6 @@ bool Function::CheckSourceFingerprint(const char* prefix, int32_t fp) const {
91899183
return false;
91909184
}
91919185
}
9192-
#endif
91939186
return true;
91949187
}
91959188

@@ -13520,7 +13513,7 @@ void Library::CheckFunctionFingerprints() {
1352013513
has_errors = true; \
1352113514
OS::PrintErr("Function not found %s.%s\n", #class_name, #function_name); \
1352213515
} else { \
13523-
CHECK_FINGERPRINT3(func, class_name, function_name, dest, fp); \
13516+
ASSERT(func.CheckSourceFingerprint(fp)); \
1352413517
}
1352513518

1352613519
#define CHECK_FINGERPRINTS2(class_name, function_name, dest, fp) \
@@ -13563,7 +13556,7 @@ void Library::CheckFunctionFingerprints() {
1356313556
has_errors = true; \
1356413557
OS::PrintErr("Function not found %s.%s\n", #class_name, #factory_name); \
1356513558
} else { \
13566-
CHECK_FINGERPRINT2(func, symbol, cid, fp); \
13559+
ASSERT(func.CheckSourceFingerprint(fp)); \
1356713560
}
1356813561

1356913562
all_libs.Add(&Library::ZoneHandle(Library::CoreLibrary()));

runtime/vm/object.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -3515,7 +3515,7 @@ class Function : public Object {
35153515
int32_t SourceFingerprint() const;
35163516

35173517
// Return false and report an error if the fingerprint does not match.
3518-
bool CheckSourceFingerprint(const char* prefix, int32_t fp) const;
3518+
bool CheckSourceFingerprint(int32_t fp) const;
35193519

35203520
// Works with map [deopt-id] -> ICData.
35213521
void SaveICDataMap(

0 commit comments

Comments
 (0)