[dart2js] Adding function kind info to closure call methods

Change-Id: Ibb78a41c8e414c909999591c8d667a7697af32ef
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/250147
Commit-Queue: Mark Zhou <markzipan@google.com>
Reviewed-by: Joshua Litt <joshualitt@google.com>
This commit is contained in:
Mark Zhou 2022-07-01 00:30:46 +00:00 committed by Commit Bot
parent c084ebb430
commit b40969ea57
7 changed files with 1885 additions and 23 deletions

View file

@ -546,8 +546,8 @@ class KernelInfoCollector {
FunctionInfo visitFunction(ir.FunctionNode function,
{FunctionEntity functionEntity, LocalFunctionInfo localFunctionInfo}) {
final parent = function.parent;
String name =
parent is ir.LocalFunction ? 'call' : parent.toStringInternal();
bool isClosureCallMethod = parent is ir.LocalFunction;
String name = isClosureCallMethod ? 'call' : parent.toStringInternal();
bool isConstructor = parent is ir.Constructor;
bool isFactory = parent is ir.Procedure && parent.isFactory;
// Kernel `isStatic` refers to static members, constructors, and top-level
@ -562,7 +562,8 @@ class KernelInfoCollector {
!isFactory;
bool isConst = parent is ir.Member && parent.isConst;
bool isExternal = parent is ir.Member && parent.isExternal;
bool isMethod = parent is ir.Member && parent.enclosingClass != null;
bool isMethod = isClosureCallMethod ||
(parent is ir.Member && parent.enclosingClass != null);
bool isGetter = parent is ir.Procedure && parent.isGetter;
bool isSetter = parent is ir.Procedure && parent.isSetter;
int kind;

File diff suppressed because it is too large Load diff

View file

@ -121,7 +121,80 @@
import 'lib.dart' deferred as lib;
/*member: main:
/*spec.member: main:
closure=[{
"id": "closure/memory:sdk/tests/web/native/main.dart::main.main_closure",
"kind": "closure",
"name": "main_closure",
"size": 201,
"outputUnit": "outputUnit/main",
"parent": "function/memory:sdk/tests/web/native/main.dart::main",
"function": "function/memory:sdk/tests/web/native/main.dart::main.main_closure.call"
}],
function=[
{
"id": "function/memory:sdk/tests/web/native/main.dart::main",
"kind": "function",
"name": "main",
"size": 301,
"outputUnit": "outputUnit/main",
"parent": "library/memory:sdk/tests/web/native/main.dart::",
"children": [
"closure/memory:sdk/tests/web/native/main.dart::main.main_closure"
],
"modifiers": {
"static": false,
"const": false,
"factory": false,
"external": false
},
"returnType": "dynamic",
"inferredReturnType": "[exact=_Future]",
"parameters": [],
"sideEffects": "SideEffects(reads anything; writes anything)",
"inlinedCount": 0,
"code": "main() {\n return A.loadDeferredLibrary(\"lib\").then$1$1(new A.main_closure(), type$.Null);\n }",
"type": "dynamic Function()",
"functionKind": 0
},
{
"id": "function/memory:sdk/tests/web/native/main.dart::main.main_closure.call",
"kind": "function",
"name": "call",
"size": 84,
"outputUnit": "outputUnit/main",
"parent": "closure/memory:sdk/tests/web/native/main.dart::main.main_closure",
"children": [],
"modifiers": {
"static": false,
"const": false,
"factory": false,
"external": false
},
"returnType": "Null",
"inferredReturnType": "[null]",
"parameters": [
{
"name": "_",
"type": "[null|subclass=Object]",
"declaredType": "dynamic"
}
],
"sideEffects": "SideEffects(reads anything; writes anything)",
"inlinedCount": 0,
"code": "call$1(_) {\n A.checkDeferredIsLoaded(\"lib\");\n C.C_Deferred.call$0();\n }",
"type": "Null Function(dynamic)",
"functionKind": 2
}],
holding=[
{"id":"function/dart:_js_helper::loadDeferredLibrary","mask":null},
{"id":"function/dart:_rti::_setArrayType","mask":null},
{"id":"function/dart:_rti::findType","mask":null},
{"id":"function/dart:async::_Future.then","mask":"[exact=_Future]"},
{"id":"function/memory:sdk/tests/web/native/main.dart::main.main_closure.call","mask":null},
{"id":"function/memory:sdk/tests/web/native/main.dart::main.main_closure.call","mask":null}]
*/
/*canary.member: main:
closure=[{
"id": "closure/memory:sdk/tests/web/native/main.dart::main.main_closure",
"kind": "closure",

View file

@ -356,7 +356,8 @@ class Subclass extends Clazz {
"parent": "function/memory:sdk/tests/web/native/main.dart::main",
"function": "function/memory:sdk/tests/web/native/main.dart::main.main_closure.call"
}],
function=[{
function=[
{
"id": "function/memory:sdk/tests/web/native/main.dart::main",
"kind": "function",
"name": "main",
@ -380,6 +381,29 @@ class Subclass extends Clazz {
"code": "main() {\n var s = new A.Subclass();\n A.Clazz.prototype.get$method.call(s).call$1(0);\n A.Expect_throws(new A.main_closure(s), type$.legacy_Object);\n }",
"type": "dynamic Function()*",
"functionKind": 0
},
{
"id": "function/memory:sdk/tests/web/native/main.dart::main.main_closure.call",
"kind": "function",
"name": "call",
"size": 71,
"outputUnit": "outputUnit/main",
"parent": "closure/memory:sdk/tests/web/native/main.dart::main.main_closure",
"children": [],
"modifiers": {
"static": false,
"const": false,
"factory": false,
"external": false
},
"returnType": "void",
"inferredReturnType": "[null]",
"parameters": [],
"sideEffects": "SideEffects(reads nothing; writes nothing)",
"inlinedCount": 0,
"code": "call$0() {\n return this.s.super$Mixin$method(A._asIntS(\"\"));\n }",
"type": "void Function()",
"functionKind": 2
}],
holding=[
{"id":"function/dart:_js_helper::closureFromTearOff","mask":null},

View file

@ -60,7 +60,7 @@ Map transformJsonObjectForComparison(Map object) {
}
// Remove disambiguation portions of names. E.g., name%N -> name.
if (key == 'id' || key == 'name' || key == 'function') {
if (key == 'id' || key == 'name' || key == 'function' || key == 'parent') {
newValue = value.replaceAll(RegExp(r'%\d+'), '');
} else if (key == 'children') {
List values = object[key];
@ -214,6 +214,8 @@ class DumpInfoDataComputer extends DataComputer<Features> {
for (final closure in functionInfo.closures) {
features.addElement(
Tags.closure, jsonEncode(closure.accept(converter)));
features.addElement(
Tags.function, jsonEncode(closure.function.accept(converter)));
}
}
@ -227,6 +229,8 @@ class DumpInfoDataComputer extends DataComputer<Features> {
for (final closure in functionInfo.closures) {
features.addElement(
Tags.closure, jsonEncode(closure.accept(converter)));
features.addElement(
Tags.function, jsonEncode(closure.function.accept(converter)));
}
}

View file

@ -165,6 +165,8 @@ class DumpInfoDataComputer extends DataComputer<Features> {
for (final closure in functionInfo.closures) {
features.addElement(
Tags.closure, jsonEncode(closure.accept(converter)));
features.addElement(
Tags.function, jsonEncode(closure.function.accept(converter)));
}
}
@ -178,6 +180,8 @@ class DumpInfoDataComputer extends DataComputer<Features> {
for (final closure in functionInfo.closures) {
features.addElement(
Tags.closure, jsonEncode(closure.accept(converter)));
features.addElement(
Tags.function, jsonEncode(closure.function.accept(converter)));
}
}

View file

@ -163,6 +163,8 @@ class DumpInfoDataComputer extends DataComputer<Features> {
for (final closure in functionInfo.closures) {
features.addElement(
Tags.closure, jsonEncode(closure.accept(converter)));
features.addElement(
Tags.function, jsonEncode(closure.function.accept(converter)));
}
}
@ -176,6 +178,8 @@ class DumpInfoDataComputer extends DataComputer<Features> {
for (final closure in functionInfo.closures) {
features.addElement(
Tags.closure, jsonEncode(closure.accept(converter)));
features.addElement(
Tags.function, jsonEncode(closure.function.accept(converter)));
}
}