Skip to content

Commit 4cba234

Browse files
rakudramacommit-bot@chromium.org
authored andcommitted
[dart2js] new-rti: Remove no-op evals.
$T.eval$1("0") --> $T Change-Id: Ifb544563f963af5ac6005d6719aaeb45d4e393ec Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/110349 Commit-Queue: Stephen Adams <[email protected]> Reviewed-by: Mayank Patke <[email protected]>
1 parent a66a42b commit 4cba234

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

pkg/compiler/lib/src/js_model/type_recipe.dart

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,17 @@ abstract class TypeRecipe {
7979
// yield the same type, e.g. `List<X> @X` and `List<Y> @Y`.
8080
return false;
8181
}
82+
83+
/// Returns `true` if [recipe] evaluates in an environment with [structure] to
84+
/// the environment.
85+
static bool isIdentity(
86+
TypeRecipe recipe, TypeEnvironmentStructure structure) {
87+
if (structure is SingletonTypeEnvironmentStructure &&
88+
recipe is TypeExpressionRecipe) {
89+
if (structure.variable == recipe.type) return true;
90+
}
91+
return false;
92+
}
8293
}
8394

8495
/// A recipe that yields a reified type.

pkg/compiler/lib/src/ssa/optimize.dart

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import '../js_backend/field_analysis.dart'
1818
import '../js_backend/backend.dart' show CodegenInputs;
1919
import '../js_backend/native_data.dart' show NativeData;
2020
import '../js_backend/runtime_types_codegen.dart';
21+
import '../js_model/type_recipe.dart' show TypeRecipe;
2122
import '../native/behavior.dart';
2223
import '../options.dart';
2324
import '../universe/selector.dart' show Selector;
@@ -1846,6 +1847,14 @@ class SsaInstructionSimplifier extends HBaseVisitor
18461847

18471848
return node;
18481849
}
1850+
1851+
@override
1852+
HInstruction visitTypeEval(HTypeEval node) {
1853+
if (TypeRecipe.isIdentity(node.typeExpression, node.envStructure)) {
1854+
return node.inputs.single;
1855+
}
1856+
return node;
1857+
}
18491858
}
18501859

18511860
class SsaCheckInserter extends HBaseVisitor implements OptimizationPhase {

0 commit comments

Comments
 (0)