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

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

Issue 1564423002: Copy all fields of NullCheck (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 4 years, 11 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 | « pkg/compiler/lib/src/cps_ir/inline.dart ('k') | pkg/compiler/lib/src/tree_ir/tree_ir_builder.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/js_backend/codegen/codegen.dart
diff --git a/pkg/compiler/lib/src/js_backend/codegen/codegen.dart b/pkg/compiler/lib/src/js_backend/codegen/codegen.dart
index 8f3819f465407ec06aa6dc9a2cfcb502cb0dbc70..7fff9a15a8138f331fa44a886f30cfe42fa1f06e 100644
--- a/pkg/compiler/lib/src/js_backend/codegen/codegen.dart
+++ b/pkg/compiler/lib/src/js_backend/codegen/codegen.dart
@@ -1021,7 +1021,15 @@ class CodeGenerator extends tree_ir.StatementVisitor
@override
void visitNullCheck(tree_ir.NullCheck node) {
js.Expression value = visitExpression(node.value);
- js.Expression access = node.selector != null
+ // TODO(sra): Try to use the selector even when [useSelector] is false. The
+ // reason we use 'toString' is that it is always defined so avoids a slow
+ // lookup (in V8) of an absent property. We could use the property for the
+ // selector if we knew it was present. The property is present if the
+ // associated method was not inlined away, or if there is a noSuchMethod
+ // hook for that selector. We don't know these things here, but the decision
+ // could be deferred by creating a deferred property that was resolved after
+ // codegen.
+ js.Expression access = node.selector != null && node.useSelector
? js.js('#.#', [value, glue.invocationName(node.selector)])
: js.js('#.toString', [value]);
if (node.condition != null) {
« no previous file with comments | « pkg/compiler/lib/src/cps_ir/inline.dart ('k') | pkg/compiler/lib/src/tree_ir/tree_ir_builder.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698