dart2js: missed CSE opportinities in checked mode #10769
Labels
P2
A bug or feature request we're likely to work on
type-bug
Incorrect behavior (everything from a crash to more subtle misbehavior)
web-dart2js
The code for LinkedHashMap.operator[]= contains type checks for type parameters K, V.
Ignoring for now that the code could be heavily specialized (this.$asLinkedHashMap -> undefined aka null since there are no classes extending or implementing LinkedHashMap),
there is a lot of repeated code.
this.$asLinkedHashMap is idempotent.
$.getRuntimeTypeInfo(this) is idempotent.
$$.LinkedHashMap = {"": "Object;_length,_strings,_nums,_rest,_first,_last,modifications",
...
$indexSet: function(, key, value) {
var $arguments, arguments0, strings, table, nums, rest, hash, bucket, t1, index;
$arguments = this.$asLinkedHashMap;
arguments0 = $.getRuntimeTypeInfo(this);
if ($arguments != null && $arguments.constructor === Array)
;
else
$arguments = typeof $arguments == "function" ? $arguments.apply(null, arguments0) : arguments0;
$.assertSubtypeOfRuntimeType(key, $arguments == null ? null : $arguments[0]);
$arguments = this.$asLinkedHashMap;
arguments0 = $.getRuntimeTypeInfo(this);
if ($arguments != null && $arguments.constructor === Array)
;
else
$arguments = typeof $arguments == "function" ? $arguments.apply(null, arguments0) : arguments0;
$.assertSubtypeOfRuntimeType(value, $arguments == null ? null : $arguments[1]);
Ideally this should optimize to something like:
arguments0 = $.getRuntimeTypeInfo(this);
$arguments = arguments0;
$.assertSubtypeOfRuntimeType(key, $arguments == null ? null : $arguments[0]);
$.assertSubtypeOfRuntimeType(value, $arguments == null ? null : $arguments[1]);
The text was updated successfully, but these errors were encountered: