Skip to content

Commit 16ff4ae

Browse files
alexmarkovcommit-bot@chromium.org
authored and
commit-bot@chromium.org
committed
Revert "[vm] Hide internal implementation List types and expose them as List"
This reverts commit 824bec5. Reason for revert: b/196606044 Original change's description: > [vm] Hide internal implementation List types and expose them as List > > When taking a type of an instance with x.runtimeType we can map > internal classes _List, _ImmutableList and _GrowableList to a > user-visible List class. This is similar to what we do for > implementation classes of int, String and Type. > After that, result of x.runtimeType for built-in lists would be > compatible with List<T> type literals. > > Also, both intrinsic and native implementations of _haveSameRuntimeType > are updated to agree with new semantic of runtimeType. > > TEST=co19/LanguageFeatures/Constructor-tear-offs/type_literal_A01_t01 > TEST=runtime/tests/vm/dart/have_same_runtime_type_test > > Fixes #46893 > Issue #46231 > > Change-Id: Ie24a9f527f66a06118427b7a09e49c03dff93d8e > Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/210066 > Commit-Queue: Alexander Markov <alexmarkov@google.com> > Reviewed-by: Tess Strickland <sstrickl@google.com> TBR=rmacnak@google.com,alexmarkov@google.com,sstrickl@google.com Change-Id: I4c3dddbc358d6ad3b14081706f7aec110a2e0562 No-Presubmit: true No-Tree-Checks: true No-Try: true Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/210200 Reviewed-by: Alexander Markov <alexmarkov@google.com> Commit-Queue: Alexander Markov <alexmarkov@google.com>
1 parent 6465ee4 commit 16ff4ae

12 files changed

+40
-206
lines changed

runtime/lib/object.cc

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -101,18 +101,14 @@ static bool HaveSameRuntimeTypeHelper(Zone* zone,
101101
if (left_cid != right_cid) {
102102
if (IsIntegerClassId(left_cid)) {
103103
return IsIntegerClassId(right_cid);
104-
} else if (IsStringClassId(left_cid)) {
104+
}
105+
if (IsStringClassId(left_cid)) {
105106
return IsStringClassId(right_cid);
106-
} else if (IsTypeClassId(left_cid)) {
107+
}
108+
if (IsTypeClassId(left_cid)) {
107109
return IsTypeClassId(right_cid);
108-
} else if (IsArrayClassId(left_cid)) {
109-
if (!IsArrayClassId(right_cid)) {
110-
return false;
111-
}
112-
// Still need to check type arguments.
113-
} else {
114-
return false;
115110
}
111+
return false;
116112
}
117113

118114
if (left_cid == kClosureCid) {

runtime/tests/vm/dart/have_same_runtime_type_test.dart

Lines changed: 0 additions & 32 deletions
This file was deleted.

runtime/tests/vm/dart_2/have_same_runtime_type_test.dart

Lines changed: 0 additions & 34 deletions
This file was deleted.

runtime/vm/class_id.h

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ typedef uint16_t ClassIdTagType;
7878
V(Mint) \
7979
V(Double) \
8080
V(Bool) \
81+
V(GrowableObjectArray) \
8182
V(Float32x4) \
8283
V(Int32x4) \
8384
V(Float64x2) \
@@ -107,14 +108,10 @@ typedef uint16_t ClassIdTagType;
107108
// TODO(http://dartbug.com/45908): Add ImmutableLinkedHashSet.
108109
#define CLASS_LIST_SETS(V) V(LinkedHashSet)
109110

110-
#define CLASS_LIST_FIXED_LENGTH_ARRAYS(V) \
111+
#define CLASS_LIST_ARRAYS(V) \
111112
V(Array) \
112113
V(ImmutableArray)
113114

114-
#define CLASS_LIST_ARRAYS(V) \
115-
CLASS_LIST_FIXED_LENGTH_ARRAYS(V) \
116-
V(GrowableObjectArray)
117-
118115
#define CLASS_LIST_STRINGS(V) \
119116
V(String) \
120117
V(OneByteString) \
@@ -185,7 +182,6 @@ typedef uint16_t ClassIdTagType;
185182
V(LinkedHashMap) \
186183
V(LinkedHashSet) \
187184
V(Array) \
188-
V(GrowableObjectArray) \
189185
V(String)
190186

191187
#define CLASS_LIST_NO_OBJECT(V) \
@@ -331,15 +327,11 @@ inline bool IsExternalStringClassId(intptr_t index) {
331327
index == kExternalTwoByteStringCid);
332328
}
333329

334-
inline bool IsArrayClassId(intptr_t index) {
335-
COMPILE_ASSERT(kImmutableArrayCid == kArrayCid + 1);
336-
COMPILE_ASSERT(kGrowableObjectArrayCid == kArrayCid + 2);
337-
return (index >= kArrayCid && index <= kGrowableObjectArrayCid);
338-
}
339-
340330
inline bool IsBuiltinListClassId(intptr_t index) {
341331
// Make sure this function is updated when new builtin List types are added.
342-
return (IsArrayClassId(index) || IsTypedDataBaseClassId(index) ||
332+
COMPILE_ASSERT(kImmutableArrayCid == kArrayCid + 1);
333+
return ((index >= kArrayCid && index <= kImmutableArrayCid) ||
334+
(index == kGrowableObjectArrayCid) || IsTypedDataBaseClassId(index) ||
343335
(index == kByteBufferCid));
344336
}
345337

runtime/vm/compiler/asm_intrinsifier_arm.cc

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1198,14 +1198,6 @@ static void JumpIfNotString(Assembler* assembler,
11981198
kIfNotInRange, target);
11991199
}
12001200

1201-
static void JumpIfNotList(Assembler* assembler,
1202-
Register cid,
1203-
Register tmp,
1204-
Label* target) {
1205-
RangeCheck(assembler, cid, tmp, kArrayCid, kGrowableObjectArrayCid,
1206-
kIfNotInRange, target);
1207-
}
1208-
12091201
static void JumpIfType(Assembler* assembler,
12101202
Register cid,
12111203
Register tmp,
@@ -1292,7 +1284,7 @@ static void EquivalentClassIds(Assembler* assembler,
12921284
Register scratch,
12931285
bool testing_instance_cids) {
12941286
Label different_cids, equal_cids_but_generic, not_integer,
1295-
not_integer_or_string, not_integer_or_string_or_list;
1287+
not_integer_or_string;
12961288

12971289
// Check if left hand side is a closure. Closures are handled in the runtime.
12981290
__ CompareImmediate(cid1, kClosureCid);
@@ -1318,8 +1310,7 @@ static void EquivalentClassIds(Assembler* assembler,
13181310
__ b(equal);
13191311

13201312
// Class ids are different. Check if we are comparing two string types (with
1321-
// different representations), two integer types, two list types or two type
1322-
// types.
1313+
// different representations) or two integer types or two type types.
13231314
__ Bind(&different_cids);
13241315
__ CompareImmediate(cid1, kNumPredefinedCids);
13251316
__ b(not_equal, HI);
@@ -1344,20 +1335,9 @@ static void EquivalentClassIds(Assembler* assembler,
13441335

13451336
if (testing_instance_cids) {
13461337
__ Bind(&not_integer_or_string);
1347-
// Check if both are List types.
1348-
JumpIfNotList(assembler, cid1, scratch, &not_integer_or_string_or_list);
1349-
1350-
// First type is a List. Check if the second is a List too.
1351-
JumpIfNotList(assembler, cid2, scratch, not_equal);
1352-
ASSERT(compiler::target::Array::type_arguments_offset() ==
1353-
compiler::target::GrowableObjectArray::type_arguments_offset());
1354-
__ LoadImmediate(scratch, compiler::target::Array::type_arguments_offset());
1355-
__ b(&equal_cids_but_generic);
1356-
1357-
__ Bind(&not_integer_or_string_or_list);
13581338
// Check if the first type is a Type. If it is not then types are not
13591339
// equivalent because they have different class ids and they are not String
1360-
// or integer or List or Type.
1340+
// or integer or Type.
13611341
JumpIfNotType(assembler, cid1, scratch, not_equal);
13621342

13631343
// First type is a Type. Check if the second is a Type too.

runtime/vm/compiler/asm_intrinsifier_arm64.cc

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1342,14 +1342,6 @@ static void JumpIfNotString(Assembler* assembler,
13421342
kIfNotInRange, target);
13431343
}
13441344

1345-
static void JumpIfNotList(Assembler* assembler,
1346-
Register cid,
1347-
Register tmp,
1348-
Label* target) {
1349-
RangeCheck(assembler, cid, tmp, kArrayCid, kGrowableObjectArrayCid,
1350-
kIfNotInRange, target);
1351-
}
1352-
13531345
static void JumpIfType(Assembler* assembler,
13541346
Register cid,
13551347
Register tmp,
@@ -1440,7 +1432,7 @@ static void EquivalentClassIds(Assembler* assembler,
14401432
Register scratch,
14411433
bool testing_instance_cids) {
14421434
Label different_cids, equal_cids_but_generic, not_integer,
1443-
not_integer_or_string, not_integer_or_string_or_list;
1435+
not_integer_or_string;
14441436

14451437
// Check if left hand side is a closure. Closures are handled in the runtime.
14461438
__ CompareImmediate(cid1, kClosureCid);
@@ -1466,8 +1458,7 @@ static void EquivalentClassIds(Assembler* assembler,
14661458
__ b(equal);
14671459

14681460
// Class ids are different. Check if we are comparing two string types (with
1469-
// different representations), two integer types, two list types or two type
1470-
// types.
1461+
// different representations) or two integer types or two type types.
14711462
__ Bind(&different_cids);
14721463
__ CompareImmediate(cid1, kNumPredefinedCids);
14731464
__ b(not_equal, HI);
@@ -1492,20 +1483,9 @@ static void EquivalentClassIds(Assembler* assembler,
14921483

14931484
if (testing_instance_cids) {
14941485
__ Bind(&not_integer_or_string);
1495-
// Check if both are List types.
1496-
JumpIfNotList(assembler, cid1, scratch, &not_integer_or_string_or_list);
1497-
1498-
// First type is a List. Check if the second is a List too.
1499-
JumpIfNotList(assembler, cid2, scratch, not_equal);
1500-
ASSERT(compiler::target::Array::type_arguments_offset() ==
1501-
compiler::target::GrowableObjectArray::type_arguments_offset());
1502-
__ LoadImmediate(scratch, compiler::target::Array::type_arguments_offset());
1503-
__ b(&equal_cids_but_generic);
1504-
1505-
__ Bind(&not_integer_or_string_or_list);
15061486
// Check if the first type is a Type. If it is not then types are not
15071487
// equivalent because they have different class ids and they are not String
1508-
// or integer or List or Type.
1488+
// or integer or Type.
15091489
JumpIfNotType(assembler, cid1, scratch, not_equal);
15101490

15111491
// First type is a Type. Check if the second is a Type too.

runtime/vm/compiler/asm_intrinsifier_ia32.cc

Lines changed: 7 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1281,11 +1281,6 @@ static void JumpIfNotString(Assembler* assembler, Register cid, Label* target) {
12811281
kIfNotInRange, target);
12821282
}
12831283

1284-
static void JumpIfNotList(Assembler* assembler, Register cid, Label* target) {
1285-
RangeCheck(assembler, cid, kArrayCid, kGrowableObjectArrayCid, kIfNotInRange,
1286-
target);
1287-
}
1288-
12891284
static void JumpIfType(Assembler* assembler, Register cid, Label* target) {
12901285
RangeCheck(assembler, cid, kTypeCid, kFunctionTypeCid, kIfInRange, target);
12911286
}
@@ -1375,7 +1370,7 @@ static void EquivalentClassIds(Assembler* assembler,
13751370
Register scratch,
13761371
bool testing_instance_cids) {
13771372
Label different_cids, equal_cids_but_generic, not_integer,
1378-
not_integer_or_string, not_integer_or_string_or_list;
1373+
not_integer_or_string;
13791374

13801375
// Check if left hand side is a closure. Closures are handled in the runtime.
13811376
__ cmpl(cid1, Immediate(kClosureCid));
@@ -1397,12 +1392,11 @@ static void EquivalentClassIds(Assembler* assembler,
13971392
scratch,
13981393
target::Class::host_type_arguments_field_offset_in_words_offset()));
13991394
__ cmpl(scratch, Immediate(target::Class::kNoTypeArguments));
1400-
__ j(NOT_EQUAL, &equal_cids_but_generic);
1395+
__ j(NOT_EQUAL, &equal_cids_but_generic, Assembler::kNearJump);
14011396
__ jmp(equal);
14021397

14031398
// Class ids are different. Check if we are comparing two string types (with
1404-
// different representations), two integer types, two list types or two type
1405-
// types.
1399+
// different representations) or two integer types or two type types.
14061400
__ Bind(&different_cids);
14071401
__ cmpl(cid1, Immediate(kNumPredefinedCids));
14081402
__ j(ABOVE_EQUAL, not_equal);
@@ -1412,42 +1406,25 @@ static void EquivalentClassIds(Assembler* assembler,
14121406
JumpIfNotInteger(assembler, scratch, &not_integer);
14131407

14141408
// First type is an integer. Check if the second is an integer too.
1415-
__ movl(scratch, cid2);
1416-
JumpIfInteger(assembler, scratch, equal);
1409+
JumpIfInteger(assembler, cid2, equal);
14171410
// Integer types are only equivalent to other integer types.
14181411
__ jmp(not_equal);
14191412

14201413
__ Bind(&not_integer);
14211414
// Check if both are String types.
1422-
__ movl(scratch, cid1);
1423-
JumpIfNotString(assembler, scratch,
1415+
JumpIfNotString(assembler, cid1,
14241416
testing_instance_cids ? &not_integer_or_string : not_equal);
14251417

14261418
// First type is a String. Check if the second is a String too.
1427-
__ movl(scratch, cid2);
1428-
JumpIfString(assembler, scratch, equal);
1419+
JumpIfString(assembler, cid2, equal);
14291420
// String types are only equivalent to other String types.
14301421
__ jmp(not_equal);
14311422

14321423
if (testing_instance_cids) {
14331424
__ Bind(&not_integer_or_string);
1434-
// Check if both are List types.
1435-
__ movl(scratch, cid1);
1436-
JumpIfNotList(assembler, scratch, &not_integer_or_string_or_list);
1437-
1438-
// First type is a List. Check if the second is a List too.
1439-
__ movl(scratch, cid2);
1440-
JumpIfNotList(assembler, scratch, not_equal);
1441-
ASSERT(compiler::target::Array::type_arguments_offset() ==
1442-
compiler::target::GrowableObjectArray::type_arguments_offset());
1443-
__ movl(scratch,
1444-
Immediate(compiler::target::Array::type_arguments_offset()));
1445-
__ jmp(&equal_cids_but_generic, Assembler::kNearJump);
1446-
1447-
__ Bind(&not_integer_or_string_or_list);
14481425
// Check if the first type is a Type. If it is not then types are not
14491426
// equivalent because they have different class ids and they are not String
1450-
// or integer or List or Type.
1427+
// or integer or Type.
14511428
JumpIfNotType(assembler, cid1, not_equal);
14521429

14531430
// First type is a Type. Check if the second is a Type too.

0 commit comments

Comments
 (0)