)]}'
{
  "commit": "302885c467144f064481df43bd9154477f100c5e",
  "tree": "aaec51495e14823be57ad1437f4463ca36cceda5",
  "parents": [
    "727c0e5ee20246ab676d4722b79982c78de75ffa"
  ],
  "author": {
    "name": "Martin Kustermann",
    "email": "kustermann@google.com",
    "time": "Thu Apr 10 06:01:48 2025 -0700"
  },
  "committer": {
    "name": "Commit Queue",
    "email": "dart-scoped@luci-project-accounts.iam.gserviceaccount.com",
    "time": "Thu Apr 10 06:01:48 2025 -0700"
  },
  "message": "[dart2wasm] Smaller `as T` type checks due to less inlining\n\nCurrently we are quite agressive when inlining `as T` type checks. This\nis due to a number of `@pragma(\u0027wasm:prefer-inline\u0027)` annotations\ncombined with `@pragma(\u0027wasm:static-dispatch\u0027)` annotations causing us\nto generate polymorphic dispatcher functions for calls to\n`_Type._checkInstance`, combined with the polymorphic call target force\ninlining targets with \u003c\u003d 2 specializations.\n\nThese combination of factors lead to a `x as T` to become something like\n\n    \u003c... code for checking x \u0026 T\u0027s nullability ...\u003e\n    classId \u003d x.classId;\n    if classId \u003d ClassId.getClassId(_InterfaceClass)\n      ...\n    else\n      ...\n\nThis lead to binaryen sometimes infer the `x.classId` value to be a\nconstant which prunes the branches which then calls the faster path for\ninterface type checks.\n\nThough this is quite a lot of code size. So instead of inlining all\nthese things, but still taking advantage of the binaryen global\noptimizations that may infer `x.classId` we load the class id (which\nbinaryen may sometimes turn into a constant) and then pass it to the\npolymorphic dispatcher (which we no longer inline to safe code size).\n\nThis way if the class id is a constant, either binaryen or V8 will see\nthat it can inline the polymorphic dispatcher as most of its body\ndisappears if the class id is known.\n\nSince we no longer inline the polyhmorphic dispatcher, we can now also\nmark other common types via `@pragma(\u0027wasm:static-dispatch\u0027)` - such as\n`_RecordType._checkInstance`. This in return will speed up any code that\nuses records in collections (e.g. in maps / sets / lists) as the\ncovariance checks now involve loading class id and branching on it to a\ndevirtualized `_RecordType._checkInstance` instead of an indirect call\nthat also involves a function type check).\n\nWe also remove the `@pragma(\u0027wasm:prefer-inline\u0027)` on the\n`_checkSubclassRelationshipViaTable` function: The idea was that if\nbinaryen infers the load of class id most of the code that follows can\nbe optimized away at compile time. Unfortunately the tables can get\nlarge, which made us not use `ImmutableWasmArray` but instead normal\n`WasmArray`. That in return makes binaryen unable to optimize loads from\nit (at constant index) away, as the contents of the array may change\n(they never do, but binaryen doesn\u0027t know that). So there\u0027s little\nbenefit in inlining it.\n\nChange-Id: I416fbdd35c6425a626378f2e9ea2009e50bf600b\nReviewed-on: https://dart-review.googlesource.com/c/sdk/+/420320\nReviewed-by: Ömer Ağacan \u003comersa@google.com\u003e\nCommit-Queue: Martin Kustermann \u003ckustermann@google.com\u003e\n",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "0b369cf0a84345f1d97b9329320cd26a9b6fd912",
      "old_mode": 33188,
      "old_path": "pkg/dart2wasm/lib/code_generator.dart",
      "new_id": "1abb2ab4c2dfb20f0c55cbd27a1ccf07391f3f02",
      "new_mode": 33188,
      "new_path": "pkg/dart2wasm/lib/code_generator.dart"
    },
    {
      "type": "modify",
      "old_id": "8b5fb71399b4399137d5dc50f1c90a9f0f2bdf33",
      "old_mode": 33188,
      "old_path": "pkg/dart2wasm/lib/translator.dart",
      "new_id": "d292eb150c210caaade9a30cc0bc8e26a68c1103",
      "new_mode": 33188,
      "new_path": "pkg/dart2wasm/lib/translator.dart"
    },
    {
      "type": "modify",
      "old_id": "495311a0b237306c28169a547b8f4d1e60bb9b63",
      "old_mode": 33188,
      "old_path": "sdk/lib/_internal/wasm/lib/type.dart",
      "new_id": "79e41c2655d03efebdf7f8d3bd37fbc76c676f09",
      "new_mode": 33188,
      "new_path": "sdk/lib/_internal/wasm/lib/type.dart"
    }
  ]
}
