Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(180)

Unified Diff: pkg/compiler/lib/src/ssa/codegen.dart

Issue 2674813004: dart2js: Keep refined type for type checks (Closed)
Patch Set: Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | pkg/compiler/lib/src/ssa/codegen_helpers.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/ssa/codegen.dart
diff --git a/pkg/compiler/lib/src/ssa/codegen.dart b/pkg/compiler/lib/src/ssa/codegen.dart
index 56740243115ac3700f782ec851a3090814d57a4c..27e2c4f506351c6bf1c440ad1e8a6c7b1569d3aa 100644
--- a/pkg/compiler/lib/src/ssa/codegen.dart
+++ b/pkg/compiler/lib/src/ssa/codegen.dart
@@ -2807,15 +2807,17 @@ class SsaCodeGenerator implements HVisitor, HBlockInformationVisitor {
negative: negative);
}
- js.Expression generateReceiverOrArgumentTypeTest(
- HInstruction input, TypeMask checkedType) {
- TypeMask inputType = input.instructionType;
+ js.Expression generateReceiverOrArgumentTypeTest(HTypeConversion node) {
+ HInstruction input = node.checkedInput;
+ TypeMask inputType = node.inputType ?? input.instructionType;
+ TypeMask checkedType = node.checkedType;
// Figure out if it is beneficial to turn this into a null check.
// V8 generally prefers 'typeof' checks, but for integers and
// indexable primitives we cannot compile this test into a single
// typeof check so the null check is cheaper.
bool isIntCheck = checkedType.containsOnlyInt(closedWorld);
- bool turnIntoNumCheck = isIntCheck && input.isIntegerOrNull(closedWorld);
+ bool turnIntoNumCheck =
+ isIntCheck && inputType.nonNullable().containsOnlyInt(closedWorld);
Siggi Cherem (dart-lang) 2017/02/03 21:48:16 I think it's fine to keep it nullable here (the an
bool turnIntoNullCheck = !turnIntoNumCheck &&
(checkedType.nullable() == inputType) &&
(isIntCheck ||
@@ -2848,8 +2850,7 @@ class SsaCodeGenerator implements HVisitor, HBlockInformationVisitor {
void visitTypeConversion(HTypeConversion node) {
if (node.isArgumentTypeCheck || node.isReceiverTypeCheck) {
- js.Expression test = generateReceiverOrArgumentTypeTest(
- node.checkedInput, node.checkedType);
+ js.Expression test = generateReceiverOrArgumentTypeTest(node);
js.Block oldContainer = currentContainer;
js.Statement body = new js.Block.empty();
currentContainer = body;
« no previous file with comments | « no previous file | pkg/compiler/lib/src/ssa/codegen_helpers.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698