Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dart2js: swarm should not contain _LinkedCustomHashMap. #13661

Closed
rakudrama opened this issue Sep 27, 2013 · 5 comments
Closed

dart2js: swarm should not contain _LinkedCustomHashMap. #13661

rakudrama opened this issue Sep 27, 2013 · 5 comments
Labels
closed-obsolete Closed as the reported issue is no longer relevant type-enhancement A request for a change that isn't a bug web-dart2js

Comments

@rakudrama
Copy link
Member

swarm at r28020

Every call site in the generated code for LinkedHashMap_LinkedHashMap looks like

    LinkedHashMap_LinkedHashMap(null, null, null, <varies>, <varies>);

The code is not specialized, which drags in _LinkedIdentityHashMap and _LinkedCustomHashMap$ which are otherwise unreferenced (this costs only ~2k, but still is unshaken)

LinkedHashMap_LinkedHashMap: function(equals, hashCode, isValidKey, $K, $V) {
  var t1;
  if (hashCode == null) {
    if (equals == null) {
      t1 = new P._LinkedHashMap(0, null, null, null, null, null, 0);
      H.setRuntimeTypeInfo(t1, [$K, $V]);
      return t1;
    }
    hashCode = P._defaultHashCode$closure;
  } else {
    if ((P.identityHashCode$closure == null ? hashCode == null : P.identityHashCode$closure === hashCode) && (P.identical$closure == null ? equals == null : P.identical$closure === equals)) {
      t1 = new P._LinkedIdentityHashMap(0, null, null, null, null, null, 0);
      H.setRuntimeTypeInfo(t1, [$K, $V]);
      return t1;
    }
    if (equals == null)
      equals = P._defaultEquals$closure;
  }
  return P._LinkedCustomHashMap$(equals, hashCode, isValidKey, $K, $V);
},

I could not repro this on a simpler example, and the similarly structured LinkedHashSet is optimized, so type inference on the larger program must be getting confused by something.

@kasperl
Copy link

kasperl commented Sep 30, 2013

Added this to the Later milestone.
Removed Priority-Unassigned label.
Added Priority-Medium label.

@DartBot
Copy link

DartBot commented Oct 17, 2013

This comment was originally written by ngeoffray@google.com


I investigated a bit, and the reason the inferrer thinks a non-null equals and hashCode may be passed in is because of our constant maps. Whenever there is a constant map, we register the GeneralConstantMap class that does allocated a LinkedHashMap with non-null equals and hashCode.

To fix this, we need to recognize during resolution that the keys of the constant map are strings only, and therefore we don't need the GeneralConstantMap.


cc @johnniwinther.

@kasperl
Copy link

kasperl commented Jul 10, 2014

Removed this from the Later milestone.
Added Oldschool-Milestone-Later label.

@kasperl
Copy link

kasperl commented Aug 4, 2014

Removed Oldschool-Milestone-Later label.

@sigmundch
Copy link
Member

In dart2js-0.1.10-dev.0.2 it seems this is now working. The generated code from running

dart2js samples-dev/swarm/swarm.dart

generates:

  LinkedHashMap_LinkedHashMap: function(equals, hashCode, isValidKey, $K, $V) {
    return H.setRuntimeTypeInfo(new H.JsLinkedHashMap(0, null, null, null, null, null, 0), [$K, $V]);
  },
  LinkedHashMap_LinkedHashMap$identity: function($K, $V) {

@sra - let me know if I misinterpreted the results


Added AssumedStale label.

@rakudrama rakudrama added Type-Enhancement web-dart2js closed-obsolete Closed as the reported issue is no longer relevant labels Apr 14, 2015
@kevmoo kevmoo added type-enhancement A request for a change that isn't a bug and removed type-enhancement labels Mar 1, 2016
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closed-obsolete Closed as the reported issue is no longer relevant type-enhancement A request for a change that isn't a bug web-dart2js
Projects
None yet
Development

No branches or pull requests

5 participants