Skip to content

Commit b654350

Browse files
natebiggsCommit Queue
authored andcommitted
[dart2wasm] Fix compare not set in some cases.
See https://logs.chromium.org/logs/flutter/buildbucket/cr-buildbucket/8708335777872213505/+/u/run_test.dart_for_web_skwasm_tests_shard_and_subshard_5/stdout Change-Id: I2ed89f308cf394f65e76f5eacaa293a8c5ff62fb Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/442300 Reviewed-by: Siva Annamalai <[email protected]> Commit-Queue: Nate Biggs <[email protected]>
1 parent 8bc4ef7 commit b654350

File tree

1 file changed

+20
-15
lines changed

1 file changed

+20
-15
lines changed

pkg/dart2wasm/lib/code_generator.dart

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4415,17 +4415,6 @@ class SwitchInfo {
44154415
translator.typeEnvironment.isSubtypeOf(codeGen.dartTypeOf(e),
44164416
translator.coreTypes.typeNonNullableRawType));
44174417

4418-
void useCompareIdentity() {
4419-
// Object identity switch
4420-
nonNullableType = translator.topTypeNonNullable;
4421-
nullableType = translator.topType;
4422-
compare = (switchExprLocal, pushCaseExpr) {
4423-
codeGen.b.local_get(switchExprLocal);
4424-
pushCaseExpr();
4425-
codeGen.call(translator.coreTypes.identicalProcedure.reference);
4426-
};
4427-
}
4428-
44294418
if (node.cases.every((c) =>
44304419
c.expressions.isEmpty && c.isDefault ||
44314420
c.expressions.every((e) =>
@@ -4616,17 +4605,33 @@ class SwitchInfo {
46164605
// Now that we've normalized to 0 it should be safe to switch to i32.
46174606
codeGen.b.i32_wrap_i64();
46184607
});
4608+
}
46194609

4610+
if (brTable == null) {
4611+
// Object identity switch
4612+
nonNullableType = translator.topTypeNonNullable;
4613+
nullableType = translator.topType;
4614+
} else {
46204615
nonNullableType =
46214616
translator.classInfo[switchExprClass]!.nonNullableType;
46224617
nullableType = translator.classInfo[switchExprClass]!.nullableType;
46234618
}
46244619

4625-
if (brTable == null) {
4626-
useCompareIdentity();
4627-
}
4620+
// Set compare anyway for state machine handling
4621+
compare = (switchExprLocal, pushCaseExpr) {
4622+
codeGen.b.local_get(switchExprLocal);
4623+
pushCaseExpr();
4624+
codeGen.call(translator.coreTypes.identicalProcedure.reference);
4625+
};
46284626
} else {
4629-
useCompareIdentity();
4627+
// Object identity switch
4628+
nonNullableType = translator.topTypeNonNullable;
4629+
nullableType = translator.topType;
4630+
compare = (switchExprLocal, pushCaseExpr) {
4631+
codeGen.b.local_get(switchExprLocal);
4632+
pushCaseExpr();
4633+
codeGen.call(translator.coreTypes.identicalProcedure.reference);
4634+
};
46304635
}
46314636

46324637
_initializeSpecialCases(node);

0 commit comments

Comments
 (0)