mirror of
https://github.com/dart-lang/sdk
synced 2024-11-02 12:24:24 +00:00
[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:
parent
c084ebb430
commit
b40969ea57
7 changed files with 1885 additions and 23 deletions
|
@ -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
|
@ -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",
|
||||
|
|
|
@ -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},
|
||||
|
|
|
@ -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)));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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)));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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)));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue