Skip to content

Commit 6d57515

Browse files
aartbikcommit-bot@chromium.org
authored andcommitted
[vm/compiler] Changes in Cid range computation
Rationale: An incorrect edit slipped into the JIT version, which had some performance regression. Also we now make the null optional when not excluded explicitly, since this results in no ranges for a few cases. flutter/flutter#28260 Change-Id: I799683d938287661321033d6839fcf2f471b2bc4 Reviewed-on: https://dart-review.googlesource.com/c/94349 Commit-Queue: Aart Bik <[email protected]> Reviewed-by: Martin Kustermann <[email protected]> Reviewed-by: Alexander Markov <[email protected]>
1 parent 2d58ea3 commit 6d57515

File tree

2 files changed

+19
-11
lines changed

2 files changed

+19
-11
lines changed

runtime/vm/compiler/backend/il.cc

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -131,12 +131,11 @@ const CidRangeVector& HierarchyInfo::SubtypeRangesForClass(
131131
CidRangeVector& ranges = (*cid_ranges)[klass.id()];
132132
if (ranges.length() == 0) {
133133
if (!FLAG_precompiled_mode) {
134-
BuildRangesForJIT(table, &ranges, klass,
135-
/*use_subtype_test=*/true,
136-
/*include_abstract*/ false);
134+
BuildRangesForJIT(table, &ranges, klass, /*use_subtype_test=*/true,
135+
include_abstract, exclude_null);
137136
} else {
138-
BuildRangesFor(table, &ranges, klass,
139-
/*use_subtype_test=*/true, include_abstract, exclude_null);
137+
BuildRangesFor(table, &ranges, klass, /*use_subtype_test=*/true,
138+
include_abstract, exclude_null);
140139
}
141140
}
142141
return ranges;
@@ -155,7 +154,8 @@ const CidRangeVector& HierarchyInfo::SubclassRangesForClass(
155154
if (!FLAG_precompiled_mode) {
156155
BuildRangesForJIT(table, &ranges, klass,
157156
/*use_subtype_test=*/true,
158-
/*include_abstract=*/false);
157+
/*include_abstract=*/false,
158+
/*exclude_null=*/false);
159159
} else {
160160
BuildRangesFor(table, &ranges, klass,
161161
/*use_subtype_test=*/false,
@@ -201,6 +201,7 @@ void HierarchyInfo::BuildRangesFor(ClassTable* table,
201201
if (cid == kTypeArgumentsCid) continue;
202202
if (cid == kVoidCid) continue;
203203
if (cid == kDynamicCid) continue;
204+
if (cid == kNullCid && !exclude_null) continue;
204205
cls = table->At(cid);
205206
if (!include_abstract && cls.is_abstract()) continue;
206207
if (cls.is_patch()) continue;
@@ -209,7 +210,8 @@ void HierarchyInfo::BuildRangesFor(ClassTable* table,
209210
// We are either interested in [CidRange]es of subclasses or subtypes.
210211
bool test_succeeded = false;
211212
if (cid == kNullCid) {
212-
test_succeeded = !exclude_null;
213+
ASSERT(exclude_null);
214+
test_succeeded = false;
213215
} else if (use_subtype_test) {
214216
cls_type = cls.RareType();
215217
test_succeeded = cls_type.IsSubtypeOf(dst_type, Heap::kNew);
@@ -256,12 +258,14 @@ void HierarchyInfo::BuildRangesForJIT(ClassTable* table,
256258
CidRangeVector* ranges,
257259
const Class& dst_klass,
258260
bool use_subtype_test,
259-
bool include_abstract) {
261+
bool include_abstract,
262+
bool exclude_null) {
260263
if (dst_klass.InVMHeap()) {
261264
BuildRangesFor(table, ranges, dst_klass, use_subtype_test, include_abstract,
262-
/*exclude_null=*/false);
265+
exclude_null);
263266
return;
264267
}
268+
ASSERT(!exclude_null);
265269

266270
Zone* zone = thread()->zone();
267271
GrowableArray<intptr_t> cids;

runtime/vm/compiler/backend/il.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,10 @@ class HierarchyInfo : public ThreadStackResource {
242242

243243
private:
244244
// Does not use any hierarchy information available in the system but computes
245-
// it via O(n) class table traversal.
245+
// it via O(n) class table traversal. The boolean parameters denote:
246+
// use_subtype_test : if set, IsSubtypeOf() is used to compute inclusion
247+
// include_abstract : if set, include abstract types (don't care otherwise)
248+
// exclude_null : if set, exclude null types (don't care otherwise)
246249
void BuildRangesFor(ClassTable* table,
247250
CidRangeVector* ranges,
248251
const Class& klass,
@@ -256,7 +259,8 @@ class HierarchyInfo : public ThreadStackResource {
256259
CidRangeVector* ranges,
257260
const Class& klass,
258261
bool use_subtype_test,
259-
bool include_abstract);
262+
bool include_abstract,
263+
bool exclude_null);
260264

261265
CidRangeVector* cid_subtype_ranges_nullable_;
262266
CidRangeVector* cid_subtype_ranges_abstract_nullable_;

0 commit comments

Comments
 (0)