diff --git a/.gitignore b/.gitignore index 1301daa1f6b9..d395ef65f190 100644 --- a/.gitignore +++ b/.gitignore @@ -114,9 +114,6 @@ logs/results.json doc/api/ build/ -build-sdk-debug.sh -build-sdk.sh -build-fiber-test.sh *.exe *.aot *.S diff --git a/build-fiber-test.sh b/build-fiber-test.sh new file mode 100755 index 000000000000..a1c57e4d6af5 --- /dev/null +++ b/build-fiber-test.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +set -e + +dart --enable_mirrors=true compile aot-snapshot runtime/tests/vm/dart/fiber/fiber_test.dart \ No newline at end of file diff --git a/build-sdk-debug.sh b/build-sdk-debug.sh new file mode 100755 index 000000000000..4677d3e2a47c --- /dev/null +++ b/build-sdk-debug.sh @@ -0,0 +1,3 @@ +#!/bin/bash +export CPATH="" +./tools/build.py -m debug -a x64 runtime dart_precompiled_runtime ddc dartanalyzer analysis_server create_common_sdk create_platform_sdk diff --git a/build-sdk-release.sh b/build-sdk-release.sh new file mode 100755 index 000000000000..ce453d795b14 --- /dev/null +++ b/build-sdk-release.sh @@ -0,0 +1,3 @@ +#!/bin/bash +export CPATH="" +./tools/build.py -m release -a x64 runtime dart_precompiled_runtime ddc dartanalyzer analysis_server create_common_sdk create_platform_sdk diff --git a/pkg/analysis_server/lib/src/computer/computer_highlights.dart b/pkg/analysis_server/lib/src/computer/computer_highlights.dart index b4444747dc91..6fa6ba9b1f09 100644 --- a/pkg/analysis_server/lib/src/computer/computer_highlights.dart +++ b/pkg/analysis_server/lib/src/computer/computer_highlights.dart @@ -4,17 +4,12 @@ import 'dart:math' as math; -import 'package:_fe_analyzer_shared/src/parser/quote.dart' - show analyzeQuote, Quote, firstQuoteLength, lastQuoteLength; +import 'package:_fe_analyzer_shared/src/parser/quote.dart' show analyzeQuote, Quote, firstQuoteLength, lastQuoteLength; import 'package:_fe_analyzer_shared/src/scanner/characters.dart' as char; -import 'package:analysis_server/lsp_protocol/protocol.dart' - show SemanticTokenTypes, SemanticTokenModifiers; -import 'package:analysis_server/src/lsp/constants.dart' - show CustomSemanticTokenModifiers, CustomSemanticTokenTypes; -import 'package:analysis_server/src/lsp/semantic_tokens/encoder.dart' - show SemanticTokenInfo; -import 'package:analysis_server/src/lsp/semantic_tokens/mapping.dart' - show highlightRegionTokenModifiers, highlightRegionTokenTypes; +import 'package:analysis_server/lsp_protocol/protocol.dart' show SemanticTokenTypes, SemanticTokenModifiers; +import 'package:analysis_server/src/lsp/constants.dart' show CustomSemanticTokenModifiers, CustomSemanticTokenTypes; +import 'package:analysis_server/src/lsp/semantic_tokens/encoder.dart' show SemanticTokenInfo; +import 'package:analysis_server/src/lsp/semantic_tokens/mapping.dart' show highlightRegionTokenModifiers, highlightRegionTokenTypes; import 'package:analyzer/dart/ast/ast.dart'; import 'package:analyzer/dart/ast/token.dart'; import 'package:analyzer/dart/ast/visitor.dart'; @@ -112,8 +107,7 @@ class DartUnitHighlightsComputer { if (_addIdentifierRegion_constructor(parent, nameToken, element)) { return; } - if (_addIdentifierRegion_getterSetterDeclaration( - parent, nameToken, element)) { + if (_addIdentifierRegion_getterSetterDeclaration(parent, nameToken, element)) { return; } if (_addIdentifierRegion_field(parent, nameToken, element)) { @@ -146,8 +140,7 @@ class DartUnitHighlightsComputer { if (_addIdentifierRegion_typeParameter(nameToken, element)) { return; } - if (_addIdentifierRegion_unresolvedInstanceMemberReference( - parent, nameToken, element)) { + if (_addIdentifierRegion_unresolvedInstanceMemberReference(parent, nameToken, element)) { return; } _addRegion_token(nameToken, HighlightRegionType.IDENTIFIER_DEFAULT); @@ -158,8 +151,7 @@ class DartUnitHighlightsComputer { if (arguments == null) { _addRegion_node(node, HighlightRegionType.ANNOTATION); } else { - _addRegion_nodeStart_tokenEnd( - node, arguments.beginToken, HighlightRegionType.ANNOTATION); + _addRegion_nodeStart_tokenEnd(node, arguments.beginToken, HighlightRegionType.ANNOTATION); _addRegion_token(arguments.endToken, HighlightRegionType.ANNOTATION); } } @@ -177,9 +169,7 @@ class DartUnitHighlightsComputer { SemanticTokenTypes? semanticType; Set? semanticModifiers; var grandParent = parent.parent; - if (parent is NamedType && - grandParent is ConstructorName && - grandParent.parent is InstanceCreationExpression) { + if (parent is NamedType && grandParent is ConstructorName && grandParent.parent is InstanceCreationExpression) { // new Class() type = HighlightRegionType.CONSTRUCTOR; semanticType = SemanticTokenTypes.class_; @@ -191,10 +181,7 @@ class DartUnitHighlightsComputer { } else { type = HighlightRegionType.CLASS; if (parent is ConstructorDeclaration) { - semanticModifiers = { - CustomSemanticTokenModifiers.constructor, - SemanticTokenModifiers.declaration - }; + semanticModifiers = {CustomSemanticTokenModifiers.constructor, SemanticTokenModifiers.declaration}; } } @@ -228,8 +215,7 @@ class DartUnitHighlightsComputer { semanticTokenType: SemanticTokenTypes.method, semanticTokenModifiers: { CustomSemanticTokenModifiers.constructor, - if (_isAnnotationIdentifier(parent)) - CustomSemanticTokenModifiers.annotation, + if (_isAnnotationIdentifier(parent)) CustomSemanticTokenModifiers.annotation, }, ); } @@ -285,30 +271,30 @@ class DartUnitHighlightsComputer { var accessor = element; var variable = accessor.variable2; if (variable is TopLevelVariableElement) { - type = accessor.isGetter - ? HighlightRegionType.TOP_LEVEL_GETTER_REFERENCE - : HighlightRegionType.TOP_LEVEL_SETTER_REFERENCE; + if (element.isSynthetic) { + type = HighlightRegionType.INSTANCE_FIELD_REFERENCE; + } else { + type = accessor.isGetter ? HighlightRegionType.TOP_LEVEL_GETTER_REFERENCE : HighlightRegionType.TOP_LEVEL_SETTER_REFERENCE; + } } else if (variable is FieldElement && variable.isEnumConstant) { type = HighlightRegionType.ENUM_CONSTANT; + } else if (element.isSynthetic) { + if (accessor.isStatic) { + type = HighlightRegionType.STATIC_FIELD_DECLARATION; + } else { + type = HighlightRegionType.INSTANCE_FIELD_REFERENCE; + } } else if (accessor.isStatic) { - type = accessor.isGetter - ? HighlightRegionType.STATIC_GETTER_REFERENCE - : HighlightRegionType.STATIC_SETTER_REFERENCE; + type = accessor.isGetter ? HighlightRegionType.STATIC_GETTER_REFERENCE : HighlightRegionType.STATIC_SETTER_REFERENCE; } else { - type = accessor.isGetter - ? HighlightRegionType.INSTANCE_GETTER_REFERENCE - : HighlightRegionType.INSTANCE_SETTER_REFERENCE; + type = accessor.isGetter ? HighlightRegionType.INSTANCE_GETTER_REFERENCE : HighlightRegionType.INSTANCE_SETTER_REFERENCE; } } // Handle tokens that are references to record fields. - if (element == null && - parent is PropertyAccess && - nameToken == parent.propertyName.token) { + if (element == null && parent is PropertyAccess && nameToken == parent.propertyName.token) { var staticType = parent.realTarget.staticType; if (staticType is RecordType) { - type = staticType.fieldByName(nameToken.lexeme) != null - ? HighlightRegionType.INSTANCE_FIELD_REFERENCE - : HighlightRegionType.UNRESOLVED_INSTANCE_MEMBER_REFERENCE; + type = staticType.fieldByName(nameToken.lexeme) != null ? HighlightRegionType.INSTANCE_FIELD_REFERENCE : HighlightRegionType.UNRESOLVED_INSTANCE_MEMBER_REFERENCE; } } // add region @@ -316,21 +302,17 @@ class DartUnitHighlightsComputer { return _addRegion_token( nameToken, type, - semanticTokenModifiers: _isAnnotationIdentifier(parent) - ? {CustomSemanticTokenModifiers.annotation} - : null, + semanticTokenModifiers: _isAnnotationIdentifier(parent) ? {CustomSemanticTokenModifiers.annotation} : null, ); } return false; } - bool _addIdentifierRegion_function( - AstNode parent, Token nameToken, Element? element) { + bool _addIdentifierRegion_function(AstNode parent, Token nameToken, Element? element) { if (element is! FunctionElement) { return false; } - var isInvocation = - parent is MethodInvocation && parent.methodName.token == nameToken; + var isInvocation = parent is MethodInvocation && parent.methodName.token == nameToken; HighlightRegionType type; var isTopLevel = element.enclosingElement is CompilationUnitElement; type = isTopLevel @@ -414,44 +396,34 @@ class DartUnitHighlightsComputer { return _addRegion_token(nameToken, type); } - bool _addIdentifierRegion_method( - AstNode parent, Token nameToken, Element? element) { + bool _addIdentifierRegion_method(AstNode parent, Token nameToken, Element? element) { if (element is! MethodElement) { return false; } var isStatic = element.isStatic; - var isInvocation = - parent is MethodInvocation && parent.methodName.token == nameToken; + var isInvocation = parent is MethodInvocation && parent.methodName.token == nameToken; // OK HighlightRegionType type; if (isStatic) { - type = isInvocation - ? HighlightRegionType.STATIC_METHOD_REFERENCE - : HighlightRegionType.STATIC_METHOD_TEAR_OFF; + type = isInvocation ? HighlightRegionType.STATIC_METHOD_REFERENCE : HighlightRegionType.STATIC_METHOD_TEAR_OFF; } else { - type = isInvocation - ? HighlightRegionType.INSTANCE_METHOD_REFERENCE - : HighlightRegionType.INSTANCE_METHOD_TEAR_OFF; + type = isInvocation ? HighlightRegionType.INSTANCE_METHOD_REFERENCE : HighlightRegionType.INSTANCE_METHOD_TEAR_OFF; } return _addRegion_token(nameToken, type); } - bool _addIdentifierRegion_parameter( - AstNode parent, Token nameToken, Element? element) { + bool _addIdentifierRegion_parameter(AstNode parent, Token nameToken, Element? element) { if (element is! ParameterElement) { return false; } var type = HighlightRegionType.PARAMETER_REFERENCE; - var modifiers = - parent is Label ? {CustomSemanticTokenModifiers.label} : null; + var modifiers = parent is Label ? {CustomSemanticTokenModifiers.label} : null; return _addRegion_token(nameToken, type, semanticTokenModifiers: modifiers); } bool _addIdentifierRegion_typeAlias(Token nameToken, Element? element) { if (element is TypeAliasElement) { - var type = element.aliasedType is FunctionType - ? HighlightRegionType.FUNCTION_TYPE_ALIAS - : HighlightRegionType.TYPE_ALIAS; + var type = element.aliasedType is FunctionType ? HighlightRegionType.FUNCTION_TYPE_ALIAS : HighlightRegionType.TYPE_ALIAS; return _addRegion_token(nameToken, type); } return false; @@ -464,8 +436,7 @@ class DartUnitHighlightsComputer { return _addRegion_token(nameToken, HighlightRegionType.TYPE_PARAMETER); } - bool _addIdentifierRegion_unresolvedInstanceMemberReference( - AstNode parent, Token nameToken, Element? element) { + bool _addIdentifierRegion_unresolvedInstanceMemberReference(AstNode parent, Token nameToken, Element? element) { // unresolved if (element != null) { return false; @@ -474,9 +445,7 @@ class DartUnitHighlightsComputer { var decorate = false; if (parent is MethodInvocation) { var target = parent.realTarget; - if (parent.methodName.token == nameToken && - target != null && - _isDynamicExpression(target)) { + if (parent.methodName.token == nameToken && target != null && _isDynamicExpression(target)) { decorate = true; } } else { @@ -527,8 +496,7 @@ class DartUnitHighlightsComputer { semanticTokenType ??= highlightRegionTokenTypes[type]; semanticTokenModifiers ??= highlightRegionTokenModifiers[type]; if (semanticTokenType != null) { - _semanticTokens.add(SemanticTokenInfo( - offset, length, semanticTokenType, semanticTokenModifiers)); + _semanticTokens.add(SemanticTokenInfo(offset, length, semanticTokenType, semanticTokenModifiers)); } } } @@ -551,8 +519,7 @@ class DartUnitHighlightsComputer { return true; } - void _addRegion_nodeStart_tokenEnd( - AstNode a, Token b, HighlightRegionType type) { + void _addRegion_nodeStart_tokenEnd(AstNode a, Token b, HighlightRegionType type) { var offset = a.offset; var end = b.end; _addRegion(offset, end - offset, type); @@ -567,15 +534,12 @@ class DartUnitHighlightsComputer { if (token != null) { var offset = token.offset; var length = token.length; - _addRegion(offset, length, type, - semanticTokenType: semanticTokenType, - semanticTokenModifiers: semanticTokenModifiers); + _addRegion(offset, length, type, semanticTokenType: semanticTokenType, semanticTokenModifiers: semanticTokenModifiers); } return true; } - void _addRegion_tokenStart_tokenEnd( - Token a, Token b, HighlightRegionType type) { + void _addRegion_tokenStart_tokenEnd(Token a, Token b, HighlightRegionType type) { var offset = a.offset; var end = b.end; _addRegion(offset, end - offset, type); @@ -625,15 +589,13 @@ class _DartUnitHighlightsComputerVisitor extends RecursiveAstVisitor { @override void visitAssertStatement(AssertStatement node) { - computer._addRegion_token(node.assertKeyword, HighlightRegionType.KEYWORD, - semanticTokenModifiers: {CustomSemanticTokenModifiers.control}); + computer._addRegion_token(node.assertKeyword, HighlightRegionType.KEYWORD, semanticTokenModifiers: {CustomSemanticTokenModifiers.control}); super.visitAssertStatement(node); } @override void visitAssignedVariablePattern(AssignedVariablePattern node) { - computer._addRegion_token( - node.name, HighlightRegionType.LOCAL_VARIABLE_REFERENCE); + computer._addRegion_token(node.name, HighlightRegionType.LOCAL_VARIABLE_REFERENCE); super.visitAssignedVariablePattern(node); } @@ -641,29 +603,25 @@ class _DartUnitHighlightsComputerVisitor extends RecursiveAstVisitor { void visitAugmentationImportDirective(AugmentationImportDirective node) { computer._addRegion_node(node, HighlightRegionType.DIRECTIVE); computer._addRegion_token(node.importKeyword, HighlightRegionType.BUILT_IN); - computer._addRegion_token( - node.augmentKeyword, HighlightRegionType.BUILT_IN); + computer._addRegion_token(node.augmentKeyword, HighlightRegionType.BUILT_IN); super.visitAugmentationImportDirective(node); } @override void visitAugmentedExpression(AugmentedExpression node) { - computer._addRegion_token( - node.augmentedKeyword, HighlightRegionType.KEYWORD); + computer._addRegion_token(node.augmentedKeyword, HighlightRegionType.KEYWORD); super.visitAugmentedExpression(node); } @override void visitAugmentedInvocation(AugmentedInvocation node) { - computer._addRegion_token( - node.augmentedKeyword, HighlightRegionType.KEYWORD); + computer._addRegion_token(node.augmentedKeyword, HighlightRegionType.KEYWORD); super.visitAugmentedInvocation(node); } @override void visitAwaitExpression(AwaitExpression node) { - computer._addRegion_token(node.awaitKeyword, HighlightRegionType.BUILT_IN, - semanticTokenModifiers: {CustomSemanticTokenModifiers.control}); + computer._addRegion_token(node.awaitKeyword, HighlightRegionType.BUILT_IN, semanticTokenModifiers: {CustomSemanticTokenModifiers.control}); super.visitAwaitExpression(node); } @@ -682,15 +640,13 @@ class _DartUnitHighlightsComputerVisitor extends RecursiveAstVisitor { @override void visitBreakStatement(BreakStatement node) { - computer._addRegion_token(node.breakKeyword, HighlightRegionType.KEYWORD, - semanticTokenModifiers: {CustomSemanticTokenModifiers.control}); + computer._addRegion_token(node.breakKeyword, HighlightRegionType.KEYWORD, semanticTokenModifiers: {CustomSemanticTokenModifiers.control}); super.visitBreakStatement(node); } @override void visitCaseClause(CaseClause node) { - computer._addRegion_token(node.caseKeyword, HighlightRegionType.KEYWORD, - semanticTokenModifiers: {CustomSemanticTokenModifiers.control}); + computer._addRegion_token(node.caseKeyword, HighlightRegionType.KEYWORD, semanticTokenModifiers: {CustomSemanticTokenModifiers.control}); super.visitCaseClause(node); } @@ -702,20 +658,16 @@ class _DartUnitHighlightsComputerVisitor extends RecursiveAstVisitor { @override void visitCatchClause(CatchClause node) { - computer._addRegion_token(node.catchKeyword, HighlightRegionType.KEYWORD, - semanticTokenModifiers: {CustomSemanticTokenModifiers.control}); - computer._addRegion_token(node.onKeyword, HighlightRegionType.BUILT_IN, - semanticTokenModifiers: {CustomSemanticTokenModifiers.control}); + computer._addRegion_token(node.catchKeyword, HighlightRegionType.KEYWORD, semanticTokenModifiers: {CustomSemanticTokenModifiers.control}); + computer._addRegion_token(node.onKeyword, HighlightRegionType.BUILT_IN, semanticTokenModifiers: {CustomSemanticTokenModifiers.control}); var exceptionParameter = node.exceptionParameter; if (exceptionParameter != null) { - computer._addRegion_token(exceptionParameter.name, - HighlightRegionType.LOCAL_VARIABLE_DECLARATION); + computer._addRegion_token(exceptionParameter.name, HighlightRegionType.LOCAL_VARIABLE_DECLARATION); } var stackTraceParameter = node.stackTraceParameter; if (stackTraceParameter != null) { - computer._addRegion_token(stackTraceParameter.name, - HighlightRegionType.LOCAL_VARIABLE_DECLARATION); + computer._addRegion_token(stackTraceParameter.name, HighlightRegionType.LOCAL_VARIABLE_DECLARATION); } super.visitCatchClause(node); @@ -723,20 +675,16 @@ class _DartUnitHighlightsComputerVisitor extends RecursiveAstVisitor { @override void visitClassDeclaration(ClassDeclaration node) { - computer._addRegion_token( - node.augmentKeyword, HighlightRegionType.BUILT_IN); + computer._addRegion_token(node.augmentKeyword, HighlightRegionType.BUILT_IN); computer._addRegion_token(node.macroKeyword, HighlightRegionType.BUILT_IN); - computer._addRegion_token( - node.abstractKeyword, HighlightRegionType.BUILT_IN); + computer._addRegion_token(node.abstractKeyword, HighlightRegionType.BUILT_IN); computer._addRegion_token(node.sealedKeyword, HighlightRegionType.BUILT_IN); computer._addRegion_token(node.baseKeyword, HighlightRegionType.BUILT_IN); - computer._addRegion_token( - node.interfaceKeyword, HighlightRegionType.BUILT_IN); + computer._addRegion_token(node.interfaceKeyword, HighlightRegionType.BUILT_IN); computer._addRegion_token(node.finalKeyword, HighlightRegionType.BUILT_IN); computer._addRegion_token(node.mixinKeyword, HighlightRegionType.BUILT_IN); computer._addRegion_token(node.classKeyword, HighlightRegionType.KEYWORD); - computer._addRegion_token(node.name, HighlightRegionType.CLASS, - semanticTokenModifiers: {SemanticTokenModifiers.declaration}); + computer._addRegion_token(node.name, HighlightRegionType.CLASS, semanticTokenModifiers: {SemanticTokenModifiers.declaration}); super.visitClassDeclaration(node); } @@ -745,12 +693,10 @@ class _DartUnitHighlightsComputerVisitor extends RecursiveAstVisitor { // TODO(brianwilkerson): Update the interface to expose the token. // computer._addRegion_token( // node.augmentKeyword, HighlightRegionType.BUILT_IN); - computer._addRegion_token( - node.abstractKeyword, HighlightRegionType.BUILT_IN); + computer._addRegion_token(node.abstractKeyword, HighlightRegionType.BUILT_IN); computer._addRegion_token(node.sealedKeyword, HighlightRegionType.BUILT_IN); computer._addRegion_token(node.baseKeyword, HighlightRegionType.BUILT_IN); - computer._addRegion_token( - node.interfaceKeyword, HighlightRegionType.BUILT_IN); + computer._addRegion_token(node.interfaceKeyword, HighlightRegionType.BUILT_IN); computer._addRegion_token(node.finalKeyword, HighlightRegionType.BUILT_IN); computer._addRegion_token(node.mixinKeyword, HighlightRegionType.BUILT_IN); super.visitClassTypeAlias(node); @@ -764,12 +710,9 @@ class _DartUnitHighlightsComputerVisitor extends RecursiveAstVisitor { @override void visitConstructorDeclaration(ConstructorDeclaration node) { - computer._addRegion_token( - node.augmentKeyword, HighlightRegionType.BUILT_IN); - computer._addRegion_token( - node.externalKeyword, HighlightRegionType.BUILT_IN); - computer._addRegion_token( - node.factoryKeyword, HighlightRegionType.BUILT_IN); + computer._addRegion_token(node.augmentKeyword, HighlightRegionType.BUILT_IN); + computer._addRegion_token(node.externalKeyword, HighlightRegionType.BUILT_IN); + computer._addRegion_token(node.factoryKeyword, HighlightRegionType.BUILT_IN); computer._addRegion_token(node.constKeyword, HighlightRegionType.KEYWORD); computer._addRegion_token( node.name, @@ -791,8 +734,7 @@ class _DartUnitHighlightsComputerVisitor extends RecursiveAstVisitor { // We have a `ConstructorReference` only when it is resolved. // TODO(scheglov): The `ConstructorName` in a tear-off always has a name, // but this is not expressed via types. - computer._addRegion_node( - constructorName.name!, HighlightRegionType.CONSTRUCTOR_TEAR_OFF); + computer._addRegion_node(constructorName.name!, HighlightRegionType.CONSTRUCTOR_TEAR_OFF); } @override @@ -806,8 +748,7 @@ class _DartUnitHighlightsComputerVisitor extends RecursiveAstVisitor { @override void visitContinueStatement(ContinueStatement node) { - computer._addRegion_token(node.continueKeyword, HighlightRegionType.KEYWORD, - semanticTokenModifiers: {CustomSemanticTokenModifiers.control}); + computer._addRegion_token(node.continueKeyword, HighlightRegionType.KEYWORD, semanticTokenModifiers: {CustomSemanticTokenModifiers.control}); super.visitContinueStatement(node); } @@ -826,24 +767,20 @@ class _DartUnitHighlightsComputerVisitor extends RecursiveAstVisitor { @override void visitDeclaredVariablePattern(DeclaredVariablePattern node) { computer._addRegion_token(node.keyword, HighlightRegionType.KEYWORD); - computer._addRegion_token( - node.name, HighlightRegionType.LOCAL_VARIABLE_DECLARATION); + computer._addRegion_token(node.name, HighlightRegionType.LOCAL_VARIABLE_DECLARATION); super.visitDeclaredVariablePattern(node); } @override void visitDefaultFormalParameter(DefaultFormalParameter node) { - computer._addRegion_token( - node.requiredKeyword, HighlightRegionType.KEYWORD); + computer._addRegion_token(node.requiredKeyword, HighlightRegionType.KEYWORD); super.visitDefaultFormalParameter(node); } @override void visitDoStatement(DoStatement node) { - computer._addRegion_token(node.doKeyword, HighlightRegionType.KEYWORD, - semanticTokenModifiers: {CustomSemanticTokenModifiers.control}); - computer._addRegion_token(node.whileKeyword, HighlightRegionType.KEYWORD, - semanticTokenModifiers: {CustomSemanticTokenModifiers.control}); + computer._addRegion_token(node.doKeyword, HighlightRegionType.KEYWORD, semanticTokenModifiers: {CustomSemanticTokenModifiers.control}); + computer._addRegion_token(node.whileKeyword, HighlightRegionType.KEYWORD, semanticTokenModifiers: {CustomSemanticTokenModifiers.control}); super.visitDoStatement(node); } @@ -895,10 +832,8 @@ class _DartUnitHighlightsComputerVisitor extends RecursiveAstVisitor { @override void visitExtensionDeclaration(ExtensionDeclaration node) { - computer._addRegion_token( - node.augmentKeyword, HighlightRegionType.BUILT_IN); - computer._addRegion_token( - node.extensionKeyword, HighlightRegionType.KEYWORD); + computer._addRegion_token(node.augmentKeyword, HighlightRegionType.BUILT_IN); + computer._addRegion_token(node.extensionKeyword, HighlightRegionType.KEYWORD); computer._addRegion_token(node.name, HighlightRegionType.EXTENSION); super.visitExtensionDeclaration(node); } @@ -950,10 +885,8 @@ class _DartUnitHighlightsComputerVisitor extends RecursiveAstVisitor { // TODO(brianwilkerson): Update the interface to expose the token. // computer._addRegion_token( // node.augmentKeyword, HighlightRegionType.BUILT_IN); - computer._addRegion_token( - node.abstractKeyword, HighlightRegionType.BUILT_IN); - computer._addRegion_token( - node.externalKeyword, HighlightRegionType.BUILT_IN); + computer._addRegion_token(node.abstractKeyword, HighlightRegionType.BUILT_IN); + computer._addRegion_token(node.externalKeyword, HighlightRegionType.BUILT_IN); computer._addRegion_token(node.staticKeyword, HighlightRegionType.BUILT_IN); super.visitFieldDeclaration(node); @@ -987,15 +920,13 @@ class _DartUnitHighlightsComputerVisitor extends RecursiveAstVisitor { @override void visitForEachPartsWithDeclaration(ForEachPartsWithDeclaration node) { - computer._addRegion_token(node.inKeyword, HighlightRegionType.KEYWORD, - semanticTokenModifiers: {CustomSemanticTokenModifiers.control}); + computer._addRegion_token(node.inKeyword, HighlightRegionType.KEYWORD, semanticTokenModifiers: {CustomSemanticTokenModifiers.control}); super.visitForEachPartsWithDeclaration(node); } @override void visitForEachPartsWithIdentifier(ForEachPartsWithIdentifier node) { - computer._addRegion_token(node.inKeyword, HighlightRegionType.KEYWORD, - semanticTokenModifiers: {CustomSemanticTokenModifiers.control}); + computer._addRegion_token(node.inKeyword, HighlightRegionType.KEYWORD, semanticTokenModifiers: {CustomSemanticTokenModifiers.control}); super.visitForEachPartsWithIdentifier(node); } @@ -1007,30 +938,23 @@ class _DartUnitHighlightsComputerVisitor extends RecursiveAstVisitor { @override void visitForElement(ForElement node) { - computer._addRegion_token(node.awaitKeyword, HighlightRegionType.BUILT_IN, - semanticTokenModifiers: {CustomSemanticTokenModifiers.control}); - computer._addRegion_token(node.forKeyword, HighlightRegionType.KEYWORD, - semanticTokenModifiers: {CustomSemanticTokenModifiers.control}); + computer._addRegion_token(node.awaitKeyword, HighlightRegionType.BUILT_IN, semanticTokenModifiers: {CustomSemanticTokenModifiers.control}); + computer._addRegion_token(node.forKeyword, HighlightRegionType.KEYWORD, semanticTokenModifiers: {CustomSemanticTokenModifiers.control}); super.visitForElement(node); } @override void visitForStatement(ForStatement node) { - computer._addRegion_token(node.awaitKeyword, HighlightRegionType.BUILT_IN, - semanticTokenModifiers: {CustomSemanticTokenModifiers.control}); - computer._addRegion_token(node.forKeyword, HighlightRegionType.KEYWORD, - semanticTokenModifiers: {CustomSemanticTokenModifiers.control}); + computer._addRegion_token(node.awaitKeyword, HighlightRegionType.BUILT_IN, semanticTokenModifiers: {CustomSemanticTokenModifiers.control}); + computer._addRegion_token(node.forKeyword, HighlightRegionType.KEYWORD, semanticTokenModifiers: {CustomSemanticTokenModifiers.control}); super.visitForStatement(node); } @override void visitFunctionDeclaration(FunctionDeclaration node) { - computer._addRegion_token( - node.augmentKeyword, HighlightRegionType.BUILT_IN); - computer._addRegion_token( - node.externalKeyword, HighlightRegionType.BUILT_IN); - computer._addRegion_token( - node.propertyKeyword, HighlightRegionType.BUILT_IN); + computer._addRegion_token(node.augmentKeyword, HighlightRegionType.BUILT_IN); + computer._addRegion_token(node.externalKeyword, HighlightRegionType.BUILT_IN); + computer._addRegion_token(node.propertyKeyword, HighlightRegionType.BUILT_IN); HighlightRegionType nameType; if (node.isGetter) { @@ -1049,33 +973,27 @@ class _DartUnitHighlightsComputerVisitor extends RecursiveAstVisitor { @override void visitFunctionTypeAlias(FunctionTypeAlias node) { - computer._addRegion_token( - node.typedefKeyword, HighlightRegionType.BUILT_IN); - computer._addRegion_token( - node.name, HighlightRegionType.FUNCTION_TYPE_ALIAS); + computer._addRegion_token(node.typedefKeyword, HighlightRegionType.BUILT_IN); + computer._addRegion_token(node.name, HighlightRegionType.FUNCTION_TYPE_ALIAS); super.visitFunctionTypeAlias(node); } @override void visitFunctionTypedFormalParameter(FunctionTypedFormalParameter node) { - computer._addRegion_token( - node.requiredKeyword, HighlightRegionType.KEYWORD); - computer._addRegion_token( - node.name, HighlightRegionType.PARAMETER_DECLARATION); + computer._addRegion_token(node.requiredKeyword, HighlightRegionType.KEYWORD); + computer._addRegion_token(node.name, HighlightRegionType.PARAMETER_DECLARATION); super.visitFunctionTypedFormalParameter(node); } @override void visitGenericFunctionType(GenericFunctionType node) { - computer._addRegion_token( - node.functionKeyword, HighlightRegionType.BUILT_IN); + computer._addRegion_token(node.functionKeyword, HighlightRegionType.BUILT_IN); super.visitGenericFunctionType(node); } @override void visitGenericTypeAlias(GenericTypeAlias node) { - computer._addRegion_token( - node.typedefKeyword, HighlightRegionType.BUILT_IN); + computer._addRegion_token(node.typedefKeyword, HighlightRegionType.BUILT_IN); HighlightRegionType nameType; if (node.functionType != null) { @@ -1096,26 +1014,21 @@ class _DartUnitHighlightsComputerVisitor extends RecursiveAstVisitor { @override void visitIfElement(IfElement node) { - computer._addRegion_token(node.ifKeyword, HighlightRegionType.KEYWORD, - semanticTokenModifiers: {CustomSemanticTokenModifiers.control}); - computer._addRegion_token(node.elseKeyword, HighlightRegionType.KEYWORD, - semanticTokenModifiers: {CustomSemanticTokenModifiers.control}); + computer._addRegion_token(node.ifKeyword, HighlightRegionType.KEYWORD, semanticTokenModifiers: {CustomSemanticTokenModifiers.control}); + computer._addRegion_token(node.elseKeyword, HighlightRegionType.KEYWORD, semanticTokenModifiers: {CustomSemanticTokenModifiers.control}); super.visitIfElement(node); } @override void visitIfStatement(IfStatement node) { - computer._addRegion_token(node.ifKeyword, HighlightRegionType.KEYWORD, - semanticTokenModifiers: {CustomSemanticTokenModifiers.control}); - computer._addRegion_token(node.elseKeyword, HighlightRegionType.KEYWORD, - semanticTokenModifiers: {CustomSemanticTokenModifiers.control}); + computer._addRegion_token(node.ifKeyword, HighlightRegionType.KEYWORD, semanticTokenModifiers: {CustomSemanticTokenModifiers.control}); + computer._addRegion_token(node.elseKeyword, HighlightRegionType.KEYWORD, semanticTokenModifiers: {CustomSemanticTokenModifiers.control}); super.visitIfStatement(node); } @override void visitImplementsClause(ImplementsClause node) { - computer._addRegion_token( - node.implementsKeyword, HighlightRegionType.BUILT_IN); + computer._addRegion_token(node.implementsKeyword, HighlightRegionType.BUILT_IN); super.visitImplementsClause(node); } @@ -1123,8 +1036,7 @@ class _DartUnitHighlightsComputerVisitor extends RecursiveAstVisitor { void visitImportDirective(ImportDirective node) { computer._addRegion_node(node, HighlightRegionType.DIRECTIVE); computer._addRegion_token(node.importKeyword, HighlightRegionType.BUILT_IN); - computer._addRegion_token( - node.deferredKeyword, HighlightRegionType.BUILT_IN); + computer._addRegion_token(node.deferredKeyword, HighlightRegionType.BUILT_IN); computer._addRegion_token(node.asKeyword, HighlightRegionType.BUILT_IN); _addRegions_configurations(node.configurations); super.visitImportDirective(node); @@ -1192,18 +1104,15 @@ class _DartUnitHighlightsComputerVisitor extends RecursiveAstVisitor { @override void visitLibraryAugmentationDirective(LibraryAugmentationDirective node) { computer._addRegion_node(node, HighlightRegionType.DIRECTIVE); - computer._addRegion_token( - node.libraryKeyword, HighlightRegionType.BUILT_IN); - computer._addRegion_token( - node.augmentKeyword, HighlightRegionType.BUILT_IN); + computer._addRegion_token(node.libraryKeyword, HighlightRegionType.BUILT_IN); + computer._addRegion_token(node.augmentKeyword, HighlightRegionType.BUILT_IN); super.visitLibraryAugmentationDirective(node); } @override void visitLibraryDirective(LibraryDirective node) { computer._addRegion_node(node, HighlightRegionType.DIRECTIVE); - computer._addRegion_token( - node.libraryKeyword, HighlightRegionType.BUILT_IN); + computer._addRegion_token(node.libraryKeyword, HighlightRegionType.BUILT_IN); super.visitLibraryDirective(node); } @@ -1222,30 +1131,19 @@ class _DartUnitHighlightsComputerVisitor extends RecursiveAstVisitor { @override void visitMethodDeclaration(MethodDeclaration node) { - computer._addRegion_token( - node.augmentKeyword, HighlightRegionType.BUILT_IN); - computer._addRegion_token( - node.externalKeyword, HighlightRegionType.BUILT_IN); - computer._addRegion_token( - node.modifierKeyword, HighlightRegionType.BUILT_IN); - computer._addRegion_token( - node.operatorKeyword, HighlightRegionType.BUILT_IN); - computer._addRegion_token( - node.propertyKeyword, HighlightRegionType.BUILT_IN); + computer._addRegion_token(node.augmentKeyword, HighlightRegionType.BUILT_IN); + computer._addRegion_token(node.externalKeyword, HighlightRegionType.BUILT_IN); + computer._addRegion_token(node.modifierKeyword, HighlightRegionType.BUILT_IN); + computer._addRegion_token(node.operatorKeyword, HighlightRegionType.BUILT_IN); + computer._addRegion_token(node.propertyKeyword, HighlightRegionType.BUILT_IN); HighlightRegionType nameType; if (node.isGetter) { - nameType = node.isStatic - ? HighlightRegionType.STATIC_GETTER_DECLARATION - : HighlightRegionType.INSTANCE_GETTER_DECLARATION; + nameType = node.isStatic ? HighlightRegionType.STATIC_GETTER_DECLARATION : HighlightRegionType.INSTANCE_GETTER_DECLARATION; } else if (node.isSetter) { - nameType = node.isStatic - ? HighlightRegionType.STATIC_SETTER_DECLARATION - : HighlightRegionType.INSTANCE_SETTER_DECLARATION; + nameType = node.isStatic ? HighlightRegionType.STATIC_SETTER_DECLARATION : HighlightRegionType.INSTANCE_SETTER_DECLARATION; } else { - nameType = node.isStatic - ? HighlightRegionType.STATIC_METHOD_DECLARATION - : HighlightRegionType.INSTANCE_METHOD_DECLARATION; + nameType = node.isStatic ? HighlightRegionType.STATIC_METHOD_DECLARATION : HighlightRegionType.INSTANCE_METHOD_DECLARATION; } computer._addRegion_token(node.name, nameType); @@ -1254,8 +1152,7 @@ class _DartUnitHighlightsComputerVisitor extends RecursiveAstVisitor { @override void visitMixinDeclaration(MixinDeclaration node) { - computer._addRegion_token( - node.augmentKeyword, HighlightRegionType.BUILT_IN); + computer._addRegion_token(node.augmentKeyword, HighlightRegionType.BUILT_IN); computer._addRegion_token(node.baseKeyword, HighlightRegionType.BUILT_IN); computer._addRegion_token(node.mixinKeyword, HighlightRegionType.BUILT_IN); computer._addRegion_token(node.name, HighlightRegionType.MIXIN); @@ -1284,9 +1181,7 @@ class _DartUnitHighlightsComputerVisitor extends RecursiveAstVisitor { if (isDynamic || isNever) { computer._addRegion_token( node.name2, - isDynamic - ? HighlightRegionType.TYPE_NAME_DYNAMIC - : HighlightRegionType.CLASS, + isDynamic ? HighlightRegionType.TYPE_NAME_DYNAMIC : HighlightRegionType.CLASS, semanticTokenType: SemanticTokenTypes.type, ); return; @@ -1330,8 +1225,7 @@ class _DartUnitHighlightsComputerVisitor extends RecursiveAstVisitor { @override void visitPartOfDirective(PartOfDirective node) { computer._addRegion_node(node, HighlightRegionType.DIRECTIVE); - computer._addRegion_tokenStart_tokenEnd( - node.partKeyword, node.ofKeyword, HighlightRegionType.BUILT_IN); + computer._addRegion_tokenStart_tokenEnd(node.partKeyword, node.ofKeyword, HighlightRegionType.BUILT_IN); super.visitPartOfDirective(node); } @@ -1339,8 +1233,7 @@ class _DartUnitHighlightsComputerVisitor extends RecursiveAstVisitor { void visitPatternFieldName(PatternFieldName node) { var name = node.name; if (name != null) { - computer._addRegion_token( - node.name, HighlightRegionType.INSTANCE_GETTER_REFERENCE); + computer._addRegion_token(node.name, HighlightRegionType.INSTANCE_GETTER_REFERENCE); } super.visitPatternFieldName(node); } @@ -1406,15 +1299,13 @@ class _DartUnitHighlightsComputerVisitor extends RecursiveAstVisitor { @override void visitRethrowExpression(RethrowExpression node) { - computer._addRegion_token(node.rethrowKeyword, HighlightRegionType.KEYWORD, - semanticTokenModifiers: {CustomSemanticTokenModifiers.control}); + computer._addRegion_token(node.rethrowKeyword, HighlightRegionType.KEYWORD, semanticTokenModifiers: {CustomSemanticTokenModifiers.control}); super.visitRethrowExpression(node); } @override void visitReturnStatement(ReturnStatement node) { - computer._addRegion_token(node.returnKeyword, HighlightRegionType.KEYWORD, - semanticTokenModifiers: {CustomSemanticTokenModifiers.control}); + computer._addRegion_token(node.returnKeyword, HighlightRegionType.KEYWORD, semanticTokenModifiers: {CustomSemanticTokenModifiers.control}); super.visitReturnStatement(node); } @@ -1440,14 +1331,11 @@ class _DartUnitHighlightsComputerVisitor extends RecursiveAstVisitor { @override void visitSimpleFormalParameter(SimpleFormalParameter node) { - computer._addRegion_token( - node.requiredKeyword, HighlightRegionType.KEYWORD); + computer._addRegion_token(node.requiredKeyword, HighlightRegionType.KEYWORD); computer._addRegion_token( node.name, - node.declaredElement!.type is DynamicType - ? HighlightRegionType.DYNAMIC_PARAMETER_DECLARATION - : HighlightRegionType.PARAMETER_DECLARATION, + node.declaredElement!.type is DynamicType ? HighlightRegionType.DYNAMIC_PARAMETER_DECLARATION : HighlightRegionType.PARAMETER_DECLARATION, ); super.visitSimpleFormalParameter(node); @@ -1511,15 +1399,13 @@ class _DartUnitHighlightsComputerVisitor extends RecursiveAstVisitor { @override void visitSwitchCase(SwitchCase node) { - computer._addRegion_token(node.keyword, HighlightRegionType.KEYWORD, - semanticTokenModifiers: {CustomSemanticTokenModifiers.control}); + computer._addRegion_token(node.keyword, HighlightRegionType.KEYWORD, semanticTokenModifiers: {CustomSemanticTokenModifiers.control}); super.visitSwitchCase(node); } @override void visitSwitchDefault(SwitchDefault node) { - computer._addRegion_token(node.keyword, HighlightRegionType.KEYWORD, - semanticTokenModifiers: {CustomSemanticTokenModifiers.control}); + computer._addRegion_token(node.keyword, HighlightRegionType.KEYWORD, semanticTokenModifiers: {CustomSemanticTokenModifiers.control}); super.visitSwitchDefault(node); } @@ -1531,15 +1417,13 @@ class _DartUnitHighlightsComputerVisitor extends RecursiveAstVisitor { @override void visitSwitchPatternCase(SwitchPatternCase node) { - computer._addRegion_token(node.keyword, HighlightRegionType.KEYWORD, - semanticTokenModifiers: {CustomSemanticTokenModifiers.control}); + computer._addRegion_token(node.keyword, HighlightRegionType.KEYWORD, semanticTokenModifiers: {CustomSemanticTokenModifiers.control}); super.visitSwitchPatternCase(node); } @override void visitSwitchStatement(SwitchStatement node) { - computer._addRegion_token(node.switchKeyword, HighlightRegionType.KEYWORD, - semanticTokenModifiers: {CustomSemanticTokenModifiers.control}); + computer._addRegion_token(node.switchKeyword, HighlightRegionType.KEYWORD, semanticTokenModifiers: {CustomSemanticTokenModifiers.control}); super.visitSwitchStatement(node); } @@ -1551,27 +1435,22 @@ class _DartUnitHighlightsComputerVisitor extends RecursiveAstVisitor { @override void visitThrowExpression(ThrowExpression node) { - computer._addRegion_token(node.throwKeyword, HighlightRegionType.KEYWORD, - semanticTokenModifiers: {CustomSemanticTokenModifiers.control}); + computer._addRegion_token(node.throwKeyword, HighlightRegionType.KEYWORD, semanticTokenModifiers: {CustomSemanticTokenModifiers.control}); super.visitThrowExpression(node); } @override void visitTopLevelVariableDeclaration(TopLevelVariableDeclaration node) { - computer._addRegion_token( - node.augmentKeyword, HighlightRegionType.BUILT_IN); - computer._addRegion_token( - node.externalKeyword, HighlightRegionType.BUILT_IN); + computer._addRegion_token(node.augmentKeyword, HighlightRegionType.BUILT_IN); + computer._addRegion_token(node.externalKeyword, HighlightRegionType.BUILT_IN); super.visitTopLevelVariableDeclaration(node); } @override void visitTryStatement(TryStatement node) { - computer._addRegion_token(node.tryKeyword, HighlightRegionType.KEYWORD, - semanticTokenModifiers: {CustomSemanticTokenModifiers.control}); - computer._addRegion_token(node.finallyKeyword, HighlightRegionType.KEYWORD, - semanticTokenModifiers: {CustomSemanticTokenModifiers.control}); + computer._addRegion_token(node.tryKeyword, HighlightRegionType.KEYWORD, semanticTokenModifiers: {CustomSemanticTokenModifiers.control}); + computer._addRegion_token(node.finallyKeyword, HighlightRegionType.KEYWORD, semanticTokenModifiers: {CustomSemanticTokenModifiers.control}); super.visitTryStatement(node); } @@ -1587,16 +1466,12 @@ class _DartUnitHighlightsComputerVisitor extends RecursiveAstVisitor { if (element is FieldElement) { computer._addRegion_token( node.name, - element.isStatic - ? HighlightRegionType.STATIC_FIELD_DECLARATION - : HighlightRegionType.INSTANCE_FIELD_DECLARATION, + element.isStatic ? HighlightRegionType.STATIC_FIELD_DECLARATION : HighlightRegionType.INSTANCE_FIELD_DECLARATION, ); } else if (element is LocalVariableElement) { computer._addRegion_token( node.name, - element.type is DynamicType - ? HighlightRegionType.DYNAMIC_LOCAL_VARIABLE_DECLARATION - : HighlightRegionType.LOCAL_VARIABLE_DECLARATION, + element.type is DynamicType ? HighlightRegionType.DYNAMIC_LOCAL_VARIABLE_DECLARATION : HighlightRegionType.LOCAL_VARIABLE_DECLARATION, ); } else if (element is TopLevelVariableElement) { computer._addRegion_token( @@ -1617,15 +1492,13 @@ class _DartUnitHighlightsComputerVisitor extends RecursiveAstVisitor { @override void visitWhenClause(WhenClause node) { - computer._addRegion_token(node.whenKeyword, HighlightRegionType.KEYWORD, - semanticTokenModifiers: {CustomSemanticTokenModifiers.control}); + computer._addRegion_token(node.whenKeyword, HighlightRegionType.KEYWORD, semanticTokenModifiers: {CustomSemanticTokenModifiers.control}); super.visitWhenClause(node); } @override void visitWhileStatement(WhileStatement node) { - computer._addRegion_token(node.whileKeyword, HighlightRegionType.KEYWORD, - semanticTokenModifiers: {CustomSemanticTokenModifiers.control}); + computer._addRegion_token(node.whileKeyword, HighlightRegionType.KEYWORD, semanticTokenModifiers: {CustomSemanticTokenModifiers.control}); super.visitWhileStatement(node); } @@ -1647,16 +1520,13 @@ class _DartUnitHighlightsComputerVisitor extends RecursiveAstVisitor { var star = node.star; var offset = keyword.offset; var end = star != null ? star.end : keyword.end; - computer._addRegion(offset, end - offset, HighlightRegionType.BUILT_IN, - semanticTokenModifiers: {CustomSemanticTokenModifiers.control}); + computer._addRegion(offset, end - offset, HighlightRegionType.BUILT_IN, semanticTokenModifiers: {CustomSemanticTokenModifiers.control}); super.visitYieldStatement(node); } void _addRegions_configurations(List configurations) { for (var configuration in configurations) { - computer._addRegion_token( - configuration.ifKeyword, HighlightRegionType.BUILT_IN, - semanticTokenModifiers: {CustomSemanticTokenModifiers.control}); + computer._addRegion_token(configuration.ifKeyword, HighlightRegionType.BUILT_IN, semanticTokenModifiers: {CustomSemanticTokenModifiers.control}); } } @@ -1666,8 +1536,7 @@ class _DartUnitHighlightsComputerVisitor extends RecursiveAstVisitor { var star = node.star; var offset = keyword.offset; var end = star != null ? star.end : keyword.end; - computer._addRegion(offset, end - offset, HighlightRegionType.BUILT_IN, - semanticTokenModifiers: {CustomSemanticTokenModifiers.control}); + computer._addRegion(offset, end - offset, HighlightRegionType.BUILT_IN, semanticTokenModifiers: {CustomSemanticTokenModifiers.control}); } } @@ -1681,11 +1550,9 @@ class _DartUnitHighlightsComputerVisitor extends RecursiveAstVisitor { case Quote.Double: case Quote.MultiLineSingle: case Quote.MultiLineDouble: - _findEscapes(node, startIndex: startIndex, endIndex: endIndex, - listener: (offset, end) { + _findEscapes(node, startIndex: startIndex, endIndex: endIndex, listener: (offset, end) { var length = end - offset; - computer._addRegion(node.offset + offset, length, - HighlightRegionType.VALID_STRING_ESCAPE); + computer._addRegion(node.offset + offset, length, HighlightRegionType.VALID_STRING_ESCAPE); }); case Quote.RawSingle: case Quote.RawDouble: @@ -1711,10 +1578,8 @@ class _DartUnitHighlightsComputerVisitor extends RecursiveAstVisitor { bool isBackslash(int i) => i <= length && codeUnits[i] == char.$BACKSLASH; bool isHexEscape(int i) => i <= length && codeUnits[i] == char.$x; bool isUnicodeHexEscape(int i) => i <= length && codeUnits[i] == char.$u; - bool isOpenBrace(int i) => - i <= length && codeUnits[i] == char.$OPEN_CURLY_BRACKET; - bool isCloseBrace(int i) => - i <= length && codeUnits[i] == char.$CLOSE_CURLY_BRACKET; + bool isOpenBrace(int i) => i <= length && codeUnits[i] == char.$OPEN_CURLY_BRACKET; + bool isCloseBrace(int i) => i <= length && codeUnits[i] == char.$CLOSE_CURLY_BRACKET; int? numHexDigits(int i, {required int min, required int max}) { var numHexDigits = 0; for (var j = i; j < math.min(i + max, length); j++) { diff --git a/pkg/analysis_server/lib/src/lsp/semantic_tokens/mapping.dart b/pkg/analysis_server/lib/src/lsp/semantic_tokens/mapping.dart index 38f32d41be98..dd4e37e6317c 100644 --- a/pkg/analysis_server/lib/src/lsp/semantic_tokens/mapping.dart +++ b/pkg/analysis_server/lib/src/lsp/semantic_tokens/mapping.dart @@ -130,13 +130,13 @@ final highlightRegionTokenTypes = { HighlightRegionType.IMPORT_PREFIX: SemanticTokenTypes.variable, HighlightRegionType.INSTANCE_FIELD_DECLARATION: SemanticTokenTypes.property, HighlightRegionType.INSTANCE_FIELD_REFERENCE: SemanticTokenTypes.property, - HighlightRegionType.INSTANCE_GETTER_DECLARATION: SemanticTokenTypes.property, - HighlightRegionType.INSTANCE_GETTER_REFERENCE: SemanticTokenTypes.property, + HighlightRegionType.INSTANCE_GETTER_DECLARATION: SemanticTokenTypes.function, + HighlightRegionType.INSTANCE_GETTER_REFERENCE: SemanticTokenTypes.function, HighlightRegionType.INSTANCE_METHOD_DECLARATION: SemanticTokenTypes.method, HighlightRegionType.INSTANCE_METHOD_REFERENCE: SemanticTokenTypes.method, HighlightRegionType.INSTANCE_METHOD_TEAR_OFF: SemanticTokenTypes.method, - HighlightRegionType.INSTANCE_SETTER_DECLARATION: SemanticTokenTypes.property, - HighlightRegionType.INSTANCE_SETTER_REFERENCE: SemanticTokenTypes.property, + HighlightRegionType.INSTANCE_SETTER_DECLARATION: SemanticTokenTypes.function, + HighlightRegionType.INSTANCE_SETTER_REFERENCE: SemanticTokenTypes.function, HighlightRegionType.KEYWORD: SemanticTokenTypes.keyword, HighlightRegionType.LIBRARY_NAME: SemanticTokenTypes.namespace, HighlightRegionType.LITERAL_BOOLEAN: CustomSemanticTokenTypes.boolean, @@ -152,21 +152,21 @@ final highlightRegionTokenTypes = { HighlightRegionType.PARAMETER_DECLARATION: SemanticTokenTypes.parameter, HighlightRegionType.PARAMETER_REFERENCE: SemanticTokenTypes.parameter, HighlightRegionType.STATIC_FIELD_DECLARATION: SemanticTokenTypes.property, - HighlightRegionType.STATIC_GETTER_DECLARATION: SemanticTokenTypes.property, - HighlightRegionType.STATIC_GETTER_REFERENCE: SemanticTokenTypes.property, + HighlightRegionType.STATIC_GETTER_DECLARATION: SemanticTokenTypes.function, + HighlightRegionType.STATIC_GETTER_REFERENCE: SemanticTokenTypes.function, HighlightRegionType.STATIC_METHOD_DECLARATION: SemanticTokenTypes.method, HighlightRegionType.STATIC_METHOD_REFERENCE: SemanticTokenTypes.method, HighlightRegionType.STATIC_METHOD_TEAR_OFF: SemanticTokenTypes.method, - HighlightRegionType.STATIC_SETTER_DECLARATION: SemanticTokenTypes.property, - HighlightRegionType.STATIC_SETTER_REFERENCE: SemanticTokenTypes.property, + HighlightRegionType.STATIC_SETTER_DECLARATION: SemanticTokenTypes.function, + HighlightRegionType.STATIC_SETTER_REFERENCE: SemanticTokenTypes.function, HighlightRegionType.TOP_LEVEL_FUNCTION_DECLARATION: SemanticTokenTypes.function, HighlightRegionType.TOP_LEVEL_FUNCTION_REFERENCE: SemanticTokenTypes.function, HighlightRegionType.TOP_LEVEL_FUNCTION_TEAR_OFF: SemanticTokenTypes.function, - HighlightRegionType.TOP_LEVEL_GETTER_DECLARATION: SemanticTokenTypes.property, - HighlightRegionType.TOP_LEVEL_GETTER_REFERENCE: SemanticTokenTypes.property, - HighlightRegionType.TOP_LEVEL_SETTER_DECLARATION: SemanticTokenTypes.property, - HighlightRegionType.TOP_LEVEL_SETTER_REFERENCE: SemanticTokenTypes.property, + HighlightRegionType.TOP_LEVEL_GETTER_DECLARATION: SemanticTokenTypes.function, + HighlightRegionType.TOP_LEVEL_GETTER_REFERENCE: SemanticTokenTypes.function, + HighlightRegionType.TOP_LEVEL_SETTER_DECLARATION: SemanticTokenTypes.function, + HighlightRegionType.TOP_LEVEL_SETTER_REFERENCE: SemanticTokenTypes.function, HighlightRegionType.TOP_LEVEL_VARIABLE: SemanticTokenTypes.property, HighlightRegionType.TOP_LEVEL_VARIABLE_DECLARATION: SemanticTokenTypes.property, diff --git a/runtime/lib/coroutine.cc b/runtime/lib/coroutine.cc index 860f8fb95325..82a8c56a0904 100644 --- a/runtime/lib/coroutine.cc +++ b/runtime/lib/coroutine.cc @@ -14,3 +14,4 @@ DEFINE_NATIVE_ENTRY(Coroutine_factory, 0, 3) { return Coroutine::New(size.Value(), trampoline.function()); } } // namespace dart + \ No newline at end of file diff --git a/runtime/platform/globals.h b/runtime/platform/globals.h index efca7278b20c..138313f82c59 100644 --- a/runtime/platform/globals.h +++ b/runtime/platform/globals.h @@ -88,6 +88,7 @@ #include #include #include +#include #include #include // For assert() in constant expressions. diff --git a/runtime/tests/vm/dart/fiber/fiber_benchmark.dart b/runtime/tests/vm/dart/fiber/fiber_benchmark.dart index cedda848a73a..3846e92d1263 100644 --- a/runtime/tests/vm/dart/fiber/fiber_benchmark.dart +++ b/runtime/tests/vm/dart/fiber/fiber_benchmark.dart @@ -6,13 +6,13 @@ var fibers = 100; var latency = 0.0; void main() { - Fiber.launch(benchmark, terminate: true); + Fiber.launch(benchmark); } void benchmark() { final jobs = []; for (var i = 0; i < fibers; i++) { - Fiber.schedule(Fiber.current()); + Fiber.schedule(Fiber.current); jobs.add(Fiber.spawn(scheduling)); } for (var i = 0; i < fibers; i++) { diff --git a/runtime/tests/vm/dart/fiber/fiber_captures_suite.dart b/runtime/tests/vm/dart/fiber/fiber_captures_suite.dart new file mode 100644 index 000000000000..a2c40ddfc705 --- /dev/null +++ b/runtime/tests/vm/dart/fiber/fiber_captures_suite.dart @@ -0,0 +1,86 @@ +import 'dart:fiber'; +import 'dart:async'; +import 'package:expect/expect.dart'; + +final tests = [ + testGlobalState, + testClosureState, +]; + +var globalStateValue = ""; +void testGlobalState() { + void child() { + globalStateValue += "child -> "; + Fiber.reschedule(); + globalStateValue += "child"; + } + + void main() { + globalStateValue = ""; + globalStateValue += "main -> "; + Fiber.schedule(Fiber.current); + Fiber.spawn(child); + globalStateValue += "main -> "; + Fiber.reschedule(); + Expect.equals("main -> child -> main -> child", globalStateValue); + } + + Fiber.launch(main); +} + +void testClosureState() { + var localState = "localState"; + Fiber.launch( + () { + Expect.equals("localState", localState); + localState = "after fiber"; + }, + ); + Expect.equals("after fiber", localState); + + localState = "localState"; + Fiber.launch( + () { + Expect.equals("localState", localState); + localState = "after main fiber"; + Fiber.schedule(Fiber.current); + Fiber.spawn( + () { + Expect.equals("after main fiber", localState); + localState = "after child fiber"; + Fiber.reschedule(); + Expect.equals("after child fiber after main fiber", localState); + localState = "finish"; + }, + name: "child", + ); + Expect.equals("after child fiber", localState); + localState = "after child fiber after main fiber"; + Fiber.suspend(); + }, + ); + Expect.equals("finish", localState); + + localState = "level 1"; + Fiber.launch( + () { + Expect.equals("level 1", localState); + localState = "level 2"; + Fiber.spawn( + () { + Expect.equals("level 2", localState); + localState = "level 3"; + Fiber.spawn( + () { + Expect.equals("level 3", localState); + localState = "level 4"; + }, + name: "child", + ); + }, + name: "child", + ); + }, + ); + Expect.equals("level 4", localState); +} diff --git a/runtime/tests/vm/dart/fiber/fiber_exceptions_suite.dart b/runtime/tests/vm/dart/fiber/fiber_exceptions_suite.dart index b1f8cc181e43..8c4f5c823bf7 100644 --- a/runtime/tests/vm/dart/fiber/fiber_exceptions_suite.dart +++ b/runtime/tests/vm/dart/fiber/fiber_exceptions_suite.dart @@ -2,83 +2,97 @@ import 'dart:fiber'; import 'dart:async'; import 'package:expect/expect.dart'; -void main() { - _run(mainException: true); - _run(childException: true); - _run(childException: true, mainCatchChild: true); - _run(childYield: true); - _run(childYield: true, mainCatchChild: true); -} +final tests = [ + testIdleException, + testMainException, + testChildException, + testChildSuspend, + testMainSuspend, +]; -class FiberException implements Exception { +class _FiberException implements Exception { final String message; - const FiberException(this.message); + const _FiberException(this.message); } -void _run({mainException = false, childException = false, mainCatchChild = false, childYield = false, mainYield = false}) { - print("_run: mainException = $mainException, childException = $childException, mainCatchChild = $mainCatchChild, childYield = $childYield, mainYield = $mainYield"); - if (mainYield) { - final child = Fiber.child(() { - Fiber.suspend(); - throw FiberException("child"); - }, name: "child"); - if (mainCatchChild) { - final main = Fiber.main( - () => Expect.equals( - Expect.throws( - () { - Fiber.fork(child); - Fiber.suspend(); - }, - ).message, - "child", - ), - ); - main.start(); - return; - } - final main = Fiber.main(() { - Fiber.fork(child); - Fiber.suspend(); - }); - Expect.equals(Expect.throws(main.start).message, "child"); - return; - } - if (childYield) { - final child = Fiber.child(() => Fiber.suspend(), name: "child"); - if (mainCatchChild) { - final main = Fiber.main( - () => Expect.equals( - Expect.throws(() { - Fiber.fork(child); - throw FiberException("main"); - }).message, - "main", - ), +void testIdleException() { + Expect.throws( + () => Fiber.launch(() => Fiber.spawn(() => Fiber.reschedule()), idle: () => throw StateError("Empty idle")), + (error) => error.message == "Empty idle", + ); +} + +void testMainException() { + Expect.throws<_FiberException>( + () => Fiber.launch(() => throw _FiberException("main")), + (e) => e.message == "main", + ); +} + +void testChildException() { + Expect.throws<_FiberException>( + () => Fiber.launch(() => Fiber.spawn(() => throw _FiberException("child"))), + (e) => e.message == "child", + ); + + Fiber.launch( + () => Expect.throws<_FiberException>( + () => Fiber.spawn(() => throw _FiberException("child")), + (e) => e.message == "child", + ), + ); +} + +void testChildSuspend() { + Expect.throws<_FiberException>( + () => Fiber.launch( + () { + Fiber.spawn(Fiber.reschedule); + throw _FiberException("main"); + Fiber.reschedule(); + }, + ), + (e) => e.message == "main", + ); + + Fiber.launch( + () => Expect.throws<_FiberException>( + () { + Fiber.spawn(Fiber.reschedule); + throw _FiberException("main"); + Fiber.reschedule(); + }, + (e) => e.message == "main", + ), + ); +} + +void testMainSuspend() { + Expect.throws<_FiberException>( + () { + Fiber.launch(() { + Fiber.spawn(() { + Fiber.reschedule(); + throw _FiberException("child"); + }); + Fiber.reschedule(); + }); + }, + (e) => e.message == "child", + ); + + Fiber.launch( + () { + Expect.throws<_FiberException>( + () { + Fiber.spawn(() { + Fiber.reschedule(); + throw _FiberException("child"); + }); + Fiber.reschedule(); + }, + (e) => e.message == "child", ); - main.start(); - return; - } - final main = Fiber.main(() { - Fiber.fork(child); - throw FiberException("main"); - }); - Expect.equals(Expect.throws(main.start).message, "main"); - return; - } - if (childException) { - final child = Fiber.child(() => throw FiberException("child"), name: "child"); - if (mainCatchChild) { - final main = Fiber.main(() => Expect.equals(Expect.throws(() => Fiber.fork(child)).message, "child")); - main.start(); - return; - } - final main = Fiber.main(() => Fiber.fork(child)); - Expect.equals(Expect.throws(main.start).message, "child"); - return; - } - if (mainException) { - final main = Fiber.main(() => throw FiberException("main")); - Expect.equals(Expect.throws(main.start).message, "main"); - } + }, + ); } diff --git a/runtime/tests/vm/dart/fiber/fiber_flow_suite.dart b/runtime/tests/vm/dart/fiber/fiber_flow_suite.dart new file mode 100644 index 000000000000..9de4fa57da73 --- /dev/null +++ b/runtime/tests/vm/dart/fiber/fiber_flow_suite.dart @@ -0,0 +1,72 @@ +import 'dart:fiber'; +import 'dart:async'; +import 'package:expect/expect.dart'; + +final tests = [ + testReturnParent, + testReturnParentSuspend, + testReturnParentDead, +]; + +void testReturnParent() { + Fiber.launch( + () { + Fiber.child(() { + var state = "child1"; + Fiber.spawn(() { + Expect.equals(state, "child1"); + state = "child2"; + }); + Expect.equals(state, "child2"); + }); + }, + ); +} + +void testReturnParentSuspend() { + Fiber.launch( + () { + Fiber.child(() { + var state = "child1"; + Fiber.spawn(() { + Expect.equals(state, "child1"); + state = "child2"; + Fiber.reschedule(); + state = "child2.suspended"; + }); + Expect.equals(state, "child2"); + Fiber.suspend(); + Expect.equals(state, "child2.suspended"); + }); + }, + ); +} + +void testReturnParentDead() { + Fiber.launch( + () { + var state = "main"; + + final child1 = Fiber.child(() { + Expect.equals("child2", state); + state = "child1"; + Fiber.reschedule(); + Expect.equals("child2.dead", state); + state = "child1.dead"; + }); + + final child2 = Fiber.child(() { + state = "child2"; + Fiber.fork(child1); + Expect.equals("child1", state); + state = "child2.dead"; + }); + + Fiber.fork(child2); + + Fiber.reschedule(); + + Expect.equals("child1.dead", state); + }, + ); +} diff --git a/runtime/tests/vm/dart/fiber/fiber_launch_suite.dart b/runtime/tests/vm/dart/fiber/fiber_launch_suite.dart index 1e65b385bcf5..8069badba3c1 100644 --- a/runtime/tests/vm/dart/fiber/fiber_launch_suite.dart +++ b/runtime/tests/vm/dart/fiber/fiber_launch_suite.dart @@ -4,7 +4,6 @@ import 'package:expect/expect.dart'; final tests = [ testEmpty, - testIdle, testTerminated, testFunction, testClosure, @@ -13,72 +12,73 @@ final tests = [ ]; void testEmpty() { - Fiber.launch(() {}); -} - -void testIdle() { - Expect.throws( - () => Fiber.launch(() => Fiber.spawn(() => Fiber.reschedule())), - (error) => error is StateError && error.message == "There are no scheduled fibers and FiberProcessor idle function is not defined", - ); + final fiber = Fiber.launch(() { + Expect.equals(Fiber.current.state.kind, FiberStateKind.running); + }); + Expect.equals(fiber.state.kind, FiberStateKind.disposed); } void testTerminated() { - Fiber.launch(() => Fiber.spawn(() => Fiber.reschedule()), terminate: true); + final fiber = Fiber.launch(() { + final child = Fiber.spawn(() => Fiber.reschedule()); + Expect.equals(child.state.kind, FiberStateKind.suspended); + Fiber.reschedule(); + Expect.equals(child.state.kind, FiberStateKind.disposed); + }); + Expect.equals(fiber.state.kind, FiberStateKind.disposed); } void testFunction() { void entry() { - Expect.equals("argument", Fiber.current().argument.positioned(0)); + Expect.equals("argument", Fiber.current.argument.positioned(0)); } - Fiber.launch(entry, argument: ["argument"], terminate: true); + Fiber.launch(entry, argument: ["argument"]); } void testClosure() { Fiber.launch( - () => Expect.equals("argument", Fiber.current().argument.positioned(0)), + () => Expect.equals("argument", Fiber.current.argument.positioned(0)), argument: ["argument"], - terminate: true, ); } void testFork() { void child() { - Expect.equals("child", Fiber.current().name); - Expect.equals("child", Fiber.current().argument.positioned(0)); + Expect.equals("child", Fiber.current.name); + Expect.equals("child", Fiber.current.argument.positioned(0)); } void main() { - Expect.equals("main", Fiber.current().argument.positioned(0)); + Expect.equals("main", Fiber.current.argument.positioned(0)); Fiber.spawn(child, name: "child", argument: ["child"]); } - Fiber.launch(main, argument: ["main"], terminate: true); + Fiber.launch(main, argument: ["main"]); } void testForks() { void child3() { - Expect.equals("child3", Fiber.current().name); - Expect.equals("child3", Fiber.current().argument.positioned(0)); + Expect.equals("child3", Fiber.current.name); + Expect.equals("child3", Fiber.current.argument.positioned(0)); } void child2() { - Expect.equals("child2", Fiber.current().name); - Expect.equals("child2", Fiber.current().argument.positioned(0)); + Expect.equals("child2", Fiber.current.name); + Expect.equals("child2", Fiber.current.argument.positioned(0)); Fiber.spawn(child3, name: "child3", argument: ["child3"]); } void child1() { - Expect.equals("child1", Fiber.current().name); - Expect.equals("child1", Fiber.current().argument.positioned(0)); + Expect.equals("child1", Fiber.current.name); + Expect.equals("child1", Fiber.current.argument.positioned(0)); Fiber.spawn(child2, name: "child2", argument: ["child2"]); } void main() { - Expect.equals("main", Fiber.current().argument.positioned(0)); + Expect.equals("main", Fiber.current.argument.positioned(0)); Fiber.spawn(child1, name: "child1", argument: ["child1"]); } - Fiber.launch(main, argument: ["main"], terminate: true); + Fiber.launch(main, argument: ["main"]); } diff --git a/runtime/tests/vm/dart/fiber/fiber_lifecycle_suite.dart b/runtime/tests/vm/dart/fiber/fiber_lifecycle_suite.dart index 55d3d4ea5a14..8ccddf304753 100644 --- a/runtime/tests/vm/dart/fiber/fiber_lifecycle_suite.dart +++ b/runtime/tests/vm/dart/fiber/fiber_lifecycle_suite.dart @@ -4,21 +4,46 @@ import 'package:expect/expect.dart'; final tests = [ testRecycle, + testDisposed, ]; void testRecycle() { Fiber.launch( () { var localState = "main"; - final child = Fiber.child( - () => localState = "$localState -> child", - persistent: true, - ); + final child = Fiber.child(() => localState = "$localState -> child", persistent: true); Fiber.fork(child); Expect.isTrue(child.state.finished); Fiber.fork(child); + Expect.isTrue(child.state.finished); Expect.equals("main -> child -> child", localState); }, - terminate: true, + ); + + Fiber.launch( + () { + var localState = "main"; + var child = Fiber.child(() => localState = "$localState -> child", persistent: true); + Expect.equals(child.size, 524288); + Fiber.fork(child); + Expect.isTrue(child.state.finished); + + child = Fiber.child(() => localState = "$localState -> child", persistent: true, size: 128); + Fiber.fork(child); + Expect.isTrue(child.state.finished); + Expect.equals(child.size, 4096); + + Expect.equals("main -> child -> child", localState); + }, + ); +} + +void testDisposed() { + Fiber.launch( + () { + final child = Fiber.child(() => {}, persistent: false); + Fiber.fork(child); + Expect.isTrue(child.state.disposed); + }, ); } diff --git a/runtime/tests/vm/dart/fiber/fiber_state_suite.dart b/runtime/tests/vm/dart/fiber/fiber_state_suite.dart index c62ce13a7d57..b51ab044892c 100644 --- a/runtime/tests/vm/dart/fiber/fiber_state_suite.dart +++ b/runtime/tests/vm/dart/fiber/fiber_state_suite.dart @@ -1,89 +1,19 @@ import 'dart:fiber'; -import 'dart:async'; import 'package:expect/expect.dart'; final tests = [ - testGlobalState, - testClosureState, + testRegistry, + testStateLink, + testProcessor, + testInvariant, ]; -var globalStateValue = ""; -void testGlobalState() { - void child() { - globalStateValue += "child -> "; - Fiber.reschedule(); - globalStateValue += "child"; - } - - void main() { - globalStateValue = ""; - globalStateValue += "main -> "; - Fiber.schedule(Fiber.current()); - Fiber.spawn(child); - globalStateValue += "main -> "; - Fiber.reschedule(); - Expect.equals("main -> child -> main -> child", globalStateValue); - } - - Fiber.launch(main, terminate: true); +void testRegistry() { + Fiber.launch(() => Expect.equals(2, Fiber.registry.length)); } -void testClosureState() { - var localState = "localState"; - Fiber.launch( - () { - Expect.equals("localState", localState); - localState = "after fiber"; - }, - terminate: true, - ); - Expect.equals("after fiber", localState); +void testStateLink() {} - localState = "localState"; - Fiber.launch( - () { - Expect.equals("localState", localState); - localState = "after main fiber"; - Fiber.schedule(Fiber.current()); - Fiber.spawn( - () { - Expect.equals("after main fiber", localState); - localState = "after child fiber"; - Fiber.reschedule(); - Expect.equals("after child fiber after main fiber", localState); - localState = "finish"; - }, - name: "child", - ); - Expect.equals("after child fiber", localState); - localState = "after child fiber after main fiber"; - Fiber.suspend(); - }, - terminate: true, - ); - Expect.equals("finish", localState); +void testProcessor() {} - localState = "level 1"; - Fiber.launch( - () { - Expect.equals("level 1", localState); - localState = "level 2"; - Fiber.spawn( - () { - Expect.equals("level 2", localState); - localState = "level 3"; - Fiber.spawn( - () { - Expect.equals("level 3", localState); - localState = "level 4"; - }, - name: "child", - ); - }, - name: "child", - ); - }, - terminate: true, - ); - Expect.equals("level 4", localState); -} +void testInvariant() {} diff --git a/runtime/tests/vm/dart/fiber/fiber_test.dart b/runtime/tests/vm/dart/fiber/fiber_test.dart index 7428b5504b4e..e450d9089b27 100644 --- a/runtime/tests/vm/dart/fiber/fiber_test.dart +++ b/runtime/tests/vm/dart/fiber/fiber_test.dart @@ -3,12 +3,18 @@ import 'dart:async'; import 'package:expect/expect.dart'; import 'fiber_lifecycle_suite.dart' as lifecycle; import 'fiber_launch_suite.dart' as launch; +import 'fiber_captures_suite.dart' as captures; +import 'fiber_flow_suite.dart' as flow; +import 'fiber_exceptions_suite.dart' as exceptions; import 'fiber_state_suite.dart' as state; final suites = { "launch": launch.tests, "state": state.tests, + "captures": captures.tests, "lifecycle": lifecycle.tests, + "flow": flow.tests, + "exceptions": exceptions.tests, }; void main(List arguments) { @@ -30,7 +36,7 @@ void main(List arguments) { print("Processing suite: ${arguments[0]}"); for (var test in suite!) { final function = RegExp(r"Function 'test(.+)'").firstMatch(test.toString())!.group(1); - if (arguments.length == 1 || function == arguments[1].toLowerCase()) { + if (arguments.length == 2 || function == arguments[1].toLowerCase()) { print("Processing test: test${function}"); test(); print("Test: test${function} finished"); diff --git a/runtime/vm/compiler/backend/il.cc b/runtime/vm/compiler/backend/il.cc index 23492853bc79..1697a788062e 100644 --- a/runtime/vm/compiler/backend/il.cc +++ b/runtime/vm/compiler/backend/il.cc @@ -8607,6 +8607,16 @@ void CoroutineTransferInstr::EmitNativeCode(FlowGraphCompiler* compiler) { #if defined(TARGET_ARCH_ARM) || defined(TARGET_ARCH_ARM64) SPILLS_LR_TO_FRAME({}); #endif + __ LoadFieldFromOffset(TMP, kFromCoroutine, Coroutine::attributes_offset()); + __ AndImmediate(TMP, ~Coroutine::CoroutineAttributes::running); + __ OrImmediate(TMP, Coroutine::CoroutineAttributes::suspended); + __ StoreFieldToOffset(TMP, kFromCoroutine, Coroutine::attributes_offset()); + + __ LoadFieldFromOffset(TMP, kToCoroutine, Coroutine::attributes_offset()); + __ AndImmediate(TMP, ~Coroutine::CoroutineAttributes::suspended); + __ OrImmediate(TMP, Coroutine::CoroutineAttributes::running); + __ StoreFieldToOffset(TMP, kToCoroutine, Coroutine::attributes_offset()); + __ PushRegister(FPREG); __ StoreFieldToOffset(SPREG, kFromCoroutine, Coroutine::stack_base_offset()); diff --git a/runtime/vm/compiler/backend/slot.h b/runtime/vm/compiler/backend/slot.h index 7975658ce8a3..3ed91b8a4cbc 100644 --- a/runtime/vm/compiler/backend/slot.h +++ b/runtime/vm/compiler/backend/slot.h @@ -188,6 +188,7 @@ class ParsedFunction; V(FunctionType, UntaggedFunctionType, packed_type_parameter_counts, Uint16, \ FINAL) \ V(SubtypeTestCache, UntaggedSubtypeTestCache, num_inputs, Uint32, FINAL) \ + V(Coroutine, UntaggedCoroutine, stack_size, IntPtr, VAR) \ V(Coroutine, UntaggedCoroutine, index, IntPtr, VAR) \ V(Coroutine, UntaggedCoroutine, attributes, IntPtr, VAR) @@ -240,12 +241,12 @@ class ParsedFunction; // // Note: Currently LoadFieldInstr::IsImmutableLengthLoad() assumes that no // slots of non-Dart values represent length loads. -#define NULLABLE_TAGGED_NATIVE_NONDART_SLOTS_LIST(V) \ - V(Isolate, _, finalizers, GrowableObjectArray, VAR) \ - V(LocalHandle, _, ptr, Dynamic, VAR) \ - V(ObjectStore, _, record_field_names, Array, VAR) \ - V(IsolateObjectStore, _, coroutines_registry, Array, VAR) \ - V(Thread, _, coroutine, Coroutine, VAR) \ +#define NULLABLE_TAGGED_NATIVE_NONDART_SLOTS_LIST(V) \ + V(Isolate, _, finalizers, GrowableObjectArray, VAR) \ + V(Isolate, _, coroutines_registry, GrowableObjectArray, VAR) \ + V(LocalHandle, _, ptr, Dynamic, VAR) \ + V(ObjectStore, _, record_field_names, Array, VAR) \ + V(Thread, _, coroutine, Coroutine, VAR) \ V(PersistentHandle, _, ptr, Dynamic, VAR) // List of slots that correspond to fields of non-Dart objects containing @@ -291,12 +292,11 @@ class ParsedFunction; // fields, they should never change during a given execution of the code // generated for a function and the compiler only does intra-procedural // load optimizations. -#define UNTAGGED_NATIVE_NONDART_SLOTS_LIST(V) \ - V(IsolateGroup, _, object_store, false, FINAL) \ - V(Isolate, _, isolate_object_store, false, FINAL) \ - V(Thread, _, api_top_scope, false, VAR) \ - V(Thread, _, isolate, false, FINAL) \ - V(Thread, _, isolate_group, false, FINAL) \ +#define UNTAGGED_NATIVE_NONDART_SLOTS_LIST(V) \ + V(IsolateGroup, _, object_store, false, FINAL) \ + V(Thread, _, api_top_scope, false, VAR) \ + V(Thread, _, isolate, false, FINAL) \ + V(Thread, _, isolate_group, false, FINAL) \ V(Thread, _, service_extension_stream, false, FINAL) // No untagged slot on a non-Dart object should contain a GC-movable address. diff --git a/runtime/vm/compiler/frontend/kernel_to_il.cc b/runtime/vm/compiler/frontend/kernel_to_il.cc index d71daa035435..d4c2cddad97d 100644 --- a/runtime/vm/compiler/frontend/kernel_to_il.cc +++ b/runtime/vm/compiler/frontend/kernel_to_il.cc @@ -1161,10 +1161,11 @@ bool FlowGraphBuilder::IsRecognizedMethodForFlowGraph( case MethodRecognizer::kCoroutineInitialize: case MethodRecognizer::kCoroutineTransfer: case MethodRecognizer::kCoroutine_getCurrent: - case MethodRecognizer::kCoroutine_atIndex: + case MethodRecognizer::kCoroutine_getRegistry: case MethodRecognizer::kCoroutine_getAttributes: case MethodRecognizer::kCoroutine_setAttributes: case MethodRecognizer::kCoroutine_getIndex: + case MethodRecognizer::kCoroutine_getSize: return true; default: return false; @@ -1962,11 +1963,9 @@ FlowGraph* FlowGraphBuilder::BuildGraphOfRecognizedMethod( body += LoadNativeField(Slot::Thread_coroutine()); break; } - case MethodRecognizer::kCoroutine_atIndex: { - body += LoadIsolateObjectStore(); - body += LoadNativeField(Slot::IsolateObjectStore_coroutines_registry()); - body += LoadLocal(parsed_function_->RawParameterVariable(0)); - body += LoadIndexed(kArrayCid); + case MethodRecognizer::kCoroutine_getRegistry: { + body += LoadIsolate(); + body += LoadNativeField(Slot::Isolate_coroutines_registry()); break; } case MethodRecognizer::kCoroutine_getIndex: { @@ -1981,6 +1980,12 @@ FlowGraph* FlowGraphBuilder::BuildGraphOfRecognizedMethod( body += Box(kUnboxedInt64); break; } + case MethodRecognizer::kCoroutine_getSize: { + body += LoadLocal(parsed_function_->RawParameterVariable(0)); + body += LoadNativeField(Slot::Coroutine_stack_size()); + body += Box(kUnboxedInt64); + break; + } case MethodRecognizer::kCoroutine_setAttributes: { body += LoadLocal(parsed_function_->RawParameterVariable(0)); body += LoadLocal(parsed_function_->RawParameterVariable(1)); @@ -4709,13 +4714,6 @@ Fragment FlowGraphBuilder::LoadObjectStore() { return body; } -Fragment FlowGraphBuilder::LoadIsolateObjectStore() { - Fragment body; - body += LoadIsolate(); - body += LoadNativeField(Slot::Isolate_isolate_object_store()); - return body; -} - Fragment FlowGraphBuilder::LoadServiceExtensionStream() { Fragment body; body += LoadThread(); diff --git a/runtime/vm/compiler/frontend/kernel_to_il.h b/runtime/vm/compiler/frontend/kernel_to_il.h index f9136d4a3bb4..403c1139547a 100644 --- a/runtime/vm/compiler/frontend/kernel_to_il.h +++ b/runtime/vm/compiler/frontend/kernel_to_il.h @@ -319,9 +319,6 @@ class FlowGraphBuilder : public BaseFlowGraphBuilder { // Loads the (untagged) current ObjectStore address. Fragment LoadObjectStore(); - // Loads the (untagged) current IsolateObjectStore address. - Fragment LoadIsolateObjectStore(); - // Loads the (untagged) service extension stream address. Fragment LoadServiceExtensionStream(); diff --git a/runtime/vm/compiler/recognized_methods_list.h b/runtime/vm/compiler/recognized_methods_list.h index e9ad79b2b9ea..673b7f091b64 100644 --- a/runtime/vm/compiler/recognized_methods_list.h +++ b/runtime/vm/compiler/recognized_methods_list.h @@ -389,6 +389,7 @@ namespace dart { V(_Coroutine, get:_entry, Coroutine_getEntry, 0xc825e938) \ V(_Coroutine, get:_trampoline, Coroutine_getTrampoline, 0xc5b7b65a) \ V(_Coroutine, get:_argument, Coroutine_getArgument, 0xd8767529) \ + V(_Coroutine, get:_size, Coroutine_getSize, 0x75030c2a) \ V(_Coroutine, get:_attributes, Coroutine_getAttributes, 0x4bba9d49) \ V(_Coroutine, get:_caller, Coroutine_getCaller, 0x786ccafc) \ V(_Coroutine, get:_scheduler, Coroutine_getScheduler, 0x6ad5213d) \ @@ -408,7 +409,7 @@ namespace dart { V(_Coroutine, set:_toProcessorPrevious, Coroutine_setToProcessorPrevious, \ 0x9b4aa9a6) \ V(_Coroutine, get:_current, Coroutine_getCurrent, 0xc8452bde) \ - V(_Coroutine, _at, Coroutine_atIndex, 0x28bab05c) \ + V(_Coroutine, get:_registry, Coroutine_getRegistry, 0xa2d4414e) \ // List of intrinsics: diff --git a/runtime/vm/compiler/runtime_api.h b/runtime/vm/compiler/runtime_api.h index f726c54b00d4..01d6d030ac88 100644 --- a/runtime/vm/compiler/runtime_api.h +++ b/runtime/vm/compiler/runtime_api.h @@ -1360,18 +1360,13 @@ class Isolate : public AllStatic { static word current_tag_offset(); static word user_tag_offset(); static word finalizers_offset(); - static word isolate_object_store_offset(); + static word coroutines_registry_offset(); #if !defined(PRODUCT) static word single_step_offset(); static word has_resumption_breakpoints_offset(); #endif // !defined(PRODUCT) }; -class IsolateObjectStore : public AllStatic { - public: - static word coroutines_registry_offset(); -}; - class IsolateGroup : public AllStatic { public: static word object_store_offset(); diff --git a/runtime/vm/compiler/runtime_offsets_extracted.h b/runtime/vm/compiler/runtime_offsets_extracted.h index 247004fbd64e..3593a60cbac4 100644 --- a/runtime/vm/compiler/runtime_offsets_extracted.h +++ b/runtime/vm/compiler/runtime_offsets_extracted.h @@ -139,14 +139,13 @@ static constexpr dart::compiler::target::word Int32x4_value_offset = 0x8; static constexpr dart::compiler::target::word Isolate_current_tag_offset = 0x14; static constexpr dart::compiler::target::word Isolate_default_tag_offset = 0x18; static constexpr dart::compiler::target::word Isolate_finalizers_offset = 0x20; -static constexpr dart::compiler::target::word Isolate_isolate_object_store_offset = 0x28; +static constexpr dart::compiler::target::word Isolate_coroutines_registry_offset = 0x2c; static constexpr dart::compiler::target::word Isolate_has_resumption_breakpoints_offset = 0x25; static constexpr dart::compiler::target::word IsolateGroup_object_store_offset = 0x10; static constexpr dart::compiler::target::word IsolateGroup_class_table_offset = 0x8; static constexpr dart::compiler::target::word IsolateGroup_cached_class_table_table_offset = 0xc; static constexpr dart::compiler::target::word Isolate_single_step_offset = 0x24; static constexpr dart::compiler::target::word Isolate_user_tag_offset = 0x10; -static constexpr dart::compiler::target::word IsolateObjectStore_coroutines_registry_offset = 0xc; static constexpr dart::compiler::target::word LinkedHashBase_data_offset = 0xc; static constexpr dart::compiler::target::word ImmutableLinkedHashBase_data_offset = 0xc; static constexpr dart::compiler::target::word LinkedHashBase_deleted_keys_offset = 0x14; @@ -597,14 +596,13 @@ static constexpr dart::compiler::target::word Int32x4_value_offset = 0x8; static constexpr dart::compiler::target::word Isolate_current_tag_offset = 0x28; static constexpr dart::compiler::target::word Isolate_default_tag_offset = 0x30; static constexpr dart::compiler::target::word Isolate_finalizers_offset = 0x40; -static constexpr dart::compiler::target::word Isolate_isolate_object_store_offset = 0x50; +static constexpr dart::compiler::target::word Isolate_coroutines_registry_offset = 0x58; static constexpr dart::compiler::target::word Isolate_has_resumption_breakpoints_offset = 0x49; static constexpr dart::compiler::target::word IsolateGroup_object_store_offset = 0x20; static constexpr dart::compiler::target::word IsolateGroup_class_table_offset = 0x10; static constexpr dart::compiler::target::word IsolateGroup_cached_class_table_table_offset = 0x18; static constexpr dart::compiler::target::word Isolate_single_step_offset = 0x48; static constexpr dart::compiler::target::word Isolate_user_tag_offset = 0x20; -static constexpr dart::compiler::target::word IsolateObjectStore_coroutines_registry_offset = 0x18; static constexpr dart::compiler::target::word LinkedHashBase_data_offset = 0x18; static constexpr dart::compiler::target::word ImmutableLinkedHashBase_data_offset = 0x18; static constexpr dart::compiler::target::word LinkedHashBase_deleted_keys_offset = 0x28; @@ -1055,14 +1053,13 @@ static constexpr dart::compiler::target::word Int32x4_value_offset = 0x8; static constexpr dart::compiler::target::word Isolate_current_tag_offset = 0x14; static constexpr dart::compiler::target::word Isolate_default_tag_offset = 0x18; static constexpr dart::compiler::target::word Isolate_finalizers_offset = 0x20; -static constexpr dart::compiler::target::word Isolate_isolate_object_store_offset = 0x28; +static constexpr dart::compiler::target::word Isolate_coroutines_registry_offset = 0x2c; static constexpr dart::compiler::target::word Isolate_has_resumption_breakpoints_offset = 0x25; static constexpr dart::compiler::target::word IsolateGroup_object_store_offset = 0x10; static constexpr dart::compiler::target::word IsolateGroup_class_table_offset = 0x8; static constexpr dart::compiler::target::word IsolateGroup_cached_class_table_table_offset = 0xc; static constexpr dart::compiler::target::word Isolate_single_step_offset = 0x24; static constexpr dart::compiler::target::word Isolate_user_tag_offset = 0x10; -static constexpr dart::compiler::target::word IsolateObjectStore_coroutines_registry_offset = 0xc; static constexpr dart::compiler::target::word LinkedHashBase_data_offset = 0xc; static constexpr dart::compiler::target::word ImmutableLinkedHashBase_data_offset = 0xc; static constexpr dart::compiler::target::word LinkedHashBase_deleted_keys_offset = 0x14; @@ -1513,14 +1510,13 @@ static constexpr dart::compiler::target::word Int32x4_value_offset = 0x8; static constexpr dart::compiler::target::word Isolate_current_tag_offset = 0x28; static constexpr dart::compiler::target::word Isolate_default_tag_offset = 0x30; static constexpr dart::compiler::target::word Isolate_finalizers_offset = 0x40; -static constexpr dart::compiler::target::word Isolate_isolate_object_store_offset = 0x50; +static constexpr dart::compiler::target::word Isolate_coroutines_registry_offset = 0x58; static constexpr dart::compiler::target::word Isolate_has_resumption_breakpoints_offset = 0x49; static constexpr dart::compiler::target::word IsolateGroup_object_store_offset = 0x20; static constexpr dart::compiler::target::word IsolateGroup_class_table_offset = 0x10; static constexpr dart::compiler::target::word IsolateGroup_cached_class_table_table_offset = 0x18; static constexpr dart::compiler::target::word Isolate_single_step_offset = 0x48; static constexpr dart::compiler::target::word Isolate_user_tag_offset = 0x20; -static constexpr dart::compiler::target::word IsolateObjectStore_coroutines_registry_offset = 0x18; static constexpr dart::compiler::target::word LinkedHashBase_data_offset = 0x18; static constexpr dart::compiler::target::word ImmutableLinkedHashBase_data_offset = 0x18; static constexpr dart::compiler::target::word LinkedHashBase_deleted_keys_offset = 0x28; @@ -1971,14 +1967,13 @@ static constexpr dart::compiler::target::word Int32x4_value_offset = 0x8; static constexpr dart::compiler::target::word Isolate_current_tag_offset = 0x28; static constexpr dart::compiler::target::word Isolate_default_tag_offset = 0x30; static constexpr dart::compiler::target::word Isolate_finalizers_offset = 0x40; -static constexpr dart::compiler::target::word Isolate_isolate_object_store_offset = 0x50; +static constexpr dart::compiler::target::word Isolate_coroutines_registry_offset = 0x58; static constexpr dart::compiler::target::word Isolate_has_resumption_breakpoints_offset = 0x49; static constexpr dart::compiler::target::word IsolateGroup_object_store_offset = 0x20; static constexpr dart::compiler::target::word IsolateGroup_class_table_offset = 0x10; static constexpr dart::compiler::target::word IsolateGroup_cached_class_table_table_offset = 0x18; static constexpr dart::compiler::target::word Isolate_single_step_offset = 0x48; static constexpr dart::compiler::target::word Isolate_user_tag_offset = 0x20; -static constexpr dart::compiler::target::word IsolateObjectStore_coroutines_registry_offset = 0x18; static constexpr dart::compiler::target::word LinkedHashBase_data_offset = 0x10; static constexpr dart::compiler::target::word ImmutableLinkedHashBase_data_offset = 0x10; static constexpr dart::compiler::target::word LinkedHashBase_deleted_keys_offset = 0x18; @@ -2430,14 +2425,13 @@ static constexpr dart::compiler::target::word Int32x4_value_offset = 0x8; static constexpr dart::compiler::target::word Isolate_current_tag_offset = 0x28; static constexpr dart::compiler::target::word Isolate_default_tag_offset = 0x30; static constexpr dart::compiler::target::word Isolate_finalizers_offset = 0x40; -static constexpr dart::compiler::target::word Isolate_isolate_object_store_offset = 0x50; +static constexpr dart::compiler::target::word Isolate_coroutines_registry_offset = 0x58; static constexpr dart::compiler::target::word Isolate_has_resumption_breakpoints_offset = 0x49; static constexpr dart::compiler::target::word IsolateGroup_object_store_offset = 0x20; static constexpr dart::compiler::target::word IsolateGroup_class_table_offset = 0x10; static constexpr dart::compiler::target::word IsolateGroup_cached_class_table_table_offset = 0x18; static constexpr dart::compiler::target::word Isolate_single_step_offset = 0x48; static constexpr dart::compiler::target::word Isolate_user_tag_offset = 0x20; -static constexpr dart::compiler::target::word IsolateObjectStore_coroutines_registry_offset = 0x18; static constexpr dart::compiler::target::word LinkedHashBase_data_offset = 0x10; static constexpr dart::compiler::target::word ImmutableLinkedHashBase_data_offset = 0x10; static constexpr dart::compiler::target::word LinkedHashBase_deleted_keys_offset = 0x18; @@ -2889,14 +2883,13 @@ static constexpr dart::compiler::target::word Int32x4_value_offset = 0x8; static constexpr dart::compiler::target::word Isolate_current_tag_offset = 0x14; static constexpr dart::compiler::target::word Isolate_default_tag_offset = 0x18; static constexpr dart::compiler::target::word Isolate_finalizers_offset = 0x20; -static constexpr dart::compiler::target::word Isolate_isolate_object_store_offset = 0x28; +static constexpr dart::compiler::target::word Isolate_coroutines_registry_offset = 0x2c; static constexpr dart::compiler::target::word Isolate_has_resumption_breakpoints_offset = 0x25; static constexpr dart::compiler::target::word IsolateGroup_object_store_offset = 0x10; static constexpr dart::compiler::target::word IsolateGroup_class_table_offset = 0x8; static constexpr dart::compiler::target::word IsolateGroup_cached_class_table_table_offset = 0xc; static constexpr dart::compiler::target::word Isolate_single_step_offset = 0x24; static constexpr dart::compiler::target::word Isolate_user_tag_offset = 0x10; -static constexpr dart::compiler::target::word IsolateObjectStore_coroutines_registry_offset = 0xc; static constexpr dart::compiler::target::word LinkedHashBase_data_offset = 0xc; static constexpr dart::compiler::target::word ImmutableLinkedHashBase_data_offset = 0xc; static constexpr dart::compiler::target::word LinkedHashBase_deleted_keys_offset = 0x14; @@ -3347,14 +3340,13 @@ static constexpr dart::compiler::target::word Int32x4_value_offset = 0x8; static constexpr dart::compiler::target::word Isolate_current_tag_offset = 0x28; static constexpr dart::compiler::target::word Isolate_default_tag_offset = 0x30; static constexpr dart::compiler::target::word Isolate_finalizers_offset = 0x40; -static constexpr dart::compiler::target::word Isolate_isolate_object_store_offset = 0x50; +static constexpr dart::compiler::target::word Isolate_coroutines_registry_offset = 0x58; static constexpr dart::compiler::target::word Isolate_has_resumption_breakpoints_offset = 0x49; static constexpr dart::compiler::target::word IsolateGroup_object_store_offset = 0x20; static constexpr dart::compiler::target::word IsolateGroup_class_table_offset = 0x10; static constexpr dart::compiler::target::word IsolateGroup_cached_class_table_table_offset = 0x18; static constexpr dart::compiler::target::word Isolate_single_step_offset = 0x48; static constexpr dart::compiler::target::word Isolate_user_tag_offset = 0x20; -static constexpr dart::compiler::target::word IsolateObjectStore_coroutines_registry_offset = 0x18; static constexpr dart::compiler::target::word LinkedHashBase_data_offset = 0x18; static constexpr dart::compiler::target::word ImmutableLinkedHashBase_data_offset = 0x18; static constexpr dart::compiler::target::word LinkedHashBase_deleted_keys_offset = 0x28; @@ -3802,12 +3794,11 @@ static constexpr dart::compiler::target::word Int32x4_value_offset = 0x8; static constexpr dart::compiler::target::word Isolate_current_tag_offset = 0x14; static constexpr dart::compiler::target::word Isolate_default_tag_offset = 0x18; static constexpr dart::compiler::target::word Isolate_finalizers_offset = 0x20; -static constexpr dart::compiler::target::word Isolate_isolate_object_store_offset = 0x28; +static constexpr dart::compiler::target::word Isolate_coroutines_registry_offset = 0x2c; static constexpr dart::compiler::target::word IsolateGroup_object_store_offset = 0x10; static constexpr dart::compiler::target::word IsolateGroup_class_table_offset = 0x8; static constexpr dart::compiler::target::word IsolateGroup_cached_class_table_table_offset = 0xc; static constexpr dart::compiler::target::word Isolate_user_tag_offset = 0x10; -static constexpr dart::compiler::target::word IsolateObjectStore_coroutines_registry_offset = 0xc; static constexpr dart::compiler::target::word LinkedHashBase_data_offset = 0xc; static constexpr dart::compiler::target::word ImmutableLinkedHashBase_data_offset = 0xc; static constexpr dart::compiler::target::word LinkedHashBase_deleted_keys_offset = 0x14; @@ -4255,12 +4246,11 @@ static constexpr dart::compiler::target::word Int32x4_value_offset = 0x8; static constexpr dart::compiler::target::word Isolate_current_tag_offset = 0x28; static constexpr dart::compiler::target::word Isolate_default_tag_offset = 0x30; static constexpr dart::compiler::target::word Isolate_finalizers_offset = 0x40; -static constexpr dart::compiler::target::word Isolate_isolate_object_store_offset = 0x50; +static constexpr dart::compiler::target::word Isolate_coroutines_registry_offset = 0x58; static constexpr dart::compiler::target::word IsolateGroup_object_store_offset = 0x20; static constexpr dart::compiler::target::word IsolateGroup_class_table_offset = 0x10; static constexpr dart::compiler::target::word IsolateGroup_cached_class_table_table_offset = 0x18; static constexpr dart::compiler::target::word Isolate_user_tag_offset = 0x20; -static constexpr dart::compiler::target::word IsolateObjectStore_coroutines_registry_offset = 0x18; static constexpr dart::compiler::target::word LinkedHashBase_data_offset = 0x18; static constexpr dart::compiler::target::word ImmutableLinkedHashBase_data_offset = 0x18; static constexpr dart::compiler::target::word LinkedHashBase_deleted_keys_offset = 0x28; @@ -4708,12 +4698,11 @@ static constexpr dart::compiler::target::word Int32x4_value_offset = 0x8; static constexpr dart::compiler::target::word Isolate_current_tag_offset = 0x14; static constexpr dart::compiler::target::word Isolate_default_tag_offset = 0x18; static constexpr dart::compiler::target::word Isolate_finalizers_offset = 0x20; -static constexpr dart::compiler::target::word Isolate_isolate_object_store_offset = 0x28; +static constexpr dart::compiler::target::word Isolate_coroutines_registry_offset = 0x2c; static constexpr dart::compiler::target::word IsolateGroup_object_store_offset = 0x10; static constexpr dart::compiler::target::word IsolateGroup_class_table_offset = 0x8; static constexpr dart::compiler::target::word IsolateGroup_cached_class_table_table_offset = 0xc; static constexpr dart::compiler::target::word Isolate_user_tag_offset = 0x10; -static constexpr dart::compiler::target::word IsolateObjectStore_coroutines_registry_offset = 0xc; static constexpr dart::compiler::target::word LinkedHashBase_data_offset = 0xc; static constexpr dart::compiler::target::word ImmutableLinkedHashBase_data_offset = 0xc; static constexpr dart::compiler::target::word LinkedHashBase_deleted_keys_offset = 0x14; @@ -5161,12 +5150,11 @@ static constexpr dart::compiler::target::word Int32x4_value_offset = 0x8; static constexpr dart::compiler::target::word Isolate_current_tag_offset = 0x28; static constexpr dart::compiler::target::word Isolate_default_tag_offset = 0x30; static constexpr dart::compiler::target::word Isolate_finalizers_offset = 0x40; -static constexpr dart::compiler::target::word Isolate_isolate_object_store_offset = 0x50; +static constexpr dart::compiler::target::word Isolate_coroutines_registry_offset = 0x58; static constexpr dart::compiler::target::word IsolateGroup_object_store_offset = 0x20; static constexpr dart::compiler::target::word IsolateGroup_class_table_offset = 0x10; static constexpr dart::compiler::target::word IsolateGroup_cached_class_table_table_offset = 0x18; static constexpr dart::compiler::target::word Isolate_user_tag_offset = 0x20; -static constexpr dart::compiler::target::word IsolateObjectStore_coroutines_registry_offset = 0x18; static constexpr dart::compiler::target::word LinkedHashBase_data_offset = 0x18; static constexpr dart::compiler::target::word ImmutableLinkedHashBase_data_offset = 0x18; static constexpr dart::compiler::target::word LinkedHashBase_deleted_keys_offset = 0x28; @@ -5614,12 +5602,11 @@ static constexpr dart::compiler::target::word Int32x4_value_offset = 0x8; static constexpr dart::compiler::target::word Isolate_current_tag_offset = 0x28; static constexpr dart::compiler::target::word Isolate_default_tag_offset = 0x30; static constexpr dart::compiler::target::word Isolate_finalizers_offset = 0x40; -static constexpr dart::compiler::target::word Isolate_isolate_object_store_offset = 0x50; +static constexpr dart::compiler::target::word Isolate_coroutines_registry_offset = 0x58; static constexpr dart::compiler::target::word IsolateGroup_object_store_offset = 0x20; static constexpr dart::compiler::target::word IsolateGroup_class_table_offset = 0x10; static constexpr dart::compiler::target::word IsolateGroup_cached_class_table_table_offset = 0x18; static constexpr dart::compiler::target::word Isolate_user_tag_offset = 0x20; -static constexpr dart::compiler::target::word IsolateObjectStore_coroutines_registry_offset = 0x18; static constexpr dart::compiler::target::word LinkedHashBase_data_offset = 0x10; static constexpr dart::compiler::target::word ImmutableLinkedHashBase_data_offset = 0x10; static constexpr dart::compiler::target::word LinkedHashBase_deleted_keys_offset = 0x18; @@ -6068,12 +6055,11 @@ static constexpr dart::compiler::target::word Int32x4_value_offset = 0x8; static constexpr dart::compiler::target::word Isolate_current_tag_offset = 0x28; static constexpr dart::compiler::target::word Isolate_default_tag_offset = 0x30; static constexpr dart::compiler::target::word Isolate_finalizers_offset = 0x40; -static constexpr dart::compiler::target::word Isolate_isolate_object_store_offset = 0x50; +static constexpr dart::compiler::target::word Isolate_coroutines_registry_offset = 0x58; static constexpr dart::compiler::target::word IsolateGroup_object_store_offset = 0x20; static constexpr dart::compiler::target::word IsolateGroup_class_table_offset = 0x10; static constexpr dart::compiler::target::word IsolateGroup_cached_class_table_table_offset = 0x18; static constexpr dart::compiler::target::word Isolate_user_tag_offset = 0x20; -static constexpr dart::compiler::target::word IsolateObjectStore_coroutines_registry_offset = 0x18; static constexpr dart::compiler::target::word LinkedHashBase_data_offset = 0x10; static constexpr dart::compiler::target::word ImmutableLinkedHashBase_data_offset = 0x10; static constexpr dart::compiler::target::word LinkedHashBase_deleted_keys_offset = 0x18; @@ -6522,12 +6508,11 @@ static constexpr dart::compiler::target::word Int32x4_value_offset = 0x8; static constexpr dart::compiler::target::word Isolate_current_tag_offset = 0x14; static constexpr dart::compiler::target::word Isolate_default_tag_offset = 0x18; static constexpr dart::compiler::target::word Isolate_finalizers_offset = 0x20; -static constexpr dart::compiler::target::word Isolate_isolate_object_store_offset = 0x28; +static constexpr dart::compiler::target::word Isolate_coroutines_registry_offset = 0x2c; static constexpr dart::compiler::target::word IsolateGroup_object_store_offset = 0x10; static constexpr dart::compiler::target::word IsolateGroup_class_table_offset = 0x8; static constexpr dart::compiler::target::word IsolateGroup_cached_class_table_table_offset = 0xc; static constexpr dart::compiler::target::word Isolate_user_tag_offset = 0x10; -static constexpr dart::compiler::target::word IsolateObjectStore_coroutines_registry_offset = 0xc; static constexpr dart::compiler::target::word LinkedHashBase_data_offset = 0xc; static constexpr dart::compiler::target::word ImmutableLinkedHashBase_data_offset = 0xc; static constexpr dart::compiler::target::word LinkedHashBase_deleted_keys_offset = 0x14; @@ -6975,12 +6960,11 @@ static constexpr dart::compiler::target::word Int32x4_value_offset = 0x8; static constexpr dart::compiler::target::word Isolate_current_tag_offset = 0x28; static constexpr dart::compiler::target::word Isolate_default_tag_offset = 0x30; static constexpr dart::compiler::target::word Isolate_finalizers_offset = 0x40; -static constexpr dart::compiler::target::word Isolate_isolate_object_store_offset = 0x50; +static constexpr dart::compiler::target::word Isolate_coroutines_registry_offset = 0x58; static constexpr dart::compiler::target::word IsolateGroup_object_store_offset = 0x20; static constexpr dart::compiler::target::word IsolateGroup_class_table_offset = 0x10; static constexpr dart::compiler::target::word IsolateGroup_cached_class_table_table_offset = 0x18; static constexpr dart::compiler::target::word Isolate_user_tag_offset = 0x20; -static constexpr dart::compiler::target::word IsolateObjectStore_coroutines_registry_offset = 0x18; static constexpr dart::compiler::target::word LinkedHashBase_data_offset = 0x18; static constexpr dart::compiler::target::word ImmutableLinkedHashBase_data_offset = 0x18; static constexpr dart::compiler::target::word LinkedHashBase_deleted_keys_offset = 0x28; @@ -7428,14 +7412,13 @@ static constexpr dart::compiler::target::word AOT_Int32x4_value_offset = 0x8; static constexpr dart::compiler::target::word AOT_Isolate_current_tag_offset = 0x14; static constexpr dart::compiler::target::word AOT_Isolate_default_tag_offset = 0x18; static constexpr dart::compiler::target::word AOT_Isolate_finalizers_offset = 0x20; -static constexpr dart::compiler::target::word AOT_Isolate_isolate_object_store_offset = 0x28; +static constexpr dart::compiler::target::word AOT_Isolate_coroutines_registry_offset = 0x2c; static constexpr dart::compiler::target::word AOT_Isolate_has_resumption_breakpoints_offset = 0x25; static constexpr dart::compiler::target::word AOT_IsolateGroup_object_store_offset = 0x10; static constexpr dart::compiler::target::word AOT_IsolateGroup_class_table_offset = 0x8; static constexpr dart::compiler::target::word AOT_IsolateGroup_cached_class_table_table_offset = 0xc; static constexpr dart::compiler::target::word AOT_Isolate_single_step_offset = 0x24; static constexpr dart::compiler::target::word AOT_Isolate_user_tag_offset = 0x10; -static constexpr dart::compiler::target::word AOT_IsolateObjectStore_coroutines_registry_offset = 0xc; static constexpr dart::compiler::target::word AOT_LinkedHashBase_data_offset = 0xc; static constexpr dart::compiler::target::word AOT_ImmutableLinkedHashBase_data_offset = 0xc; static constexpr dart::compiler::target::word AOT_LinkedHashBase_deleted_keys_offset = 0x14; @@ -7883,14 +7866,13 @@ static constexpr dart::compiler::target::word AOT_Int32x4_value_offset = 0x8; static constexpr dart::compiler::target::word AOT_Isolate_current_tag_offset = 0x28; static constexpr dart::compiler::target::word AOT_Isolate_default_tag_offset = 0x30; static constexpr dart::compiler::target::word AOT_Isolate_finalizers_offset = 0x40; -static constexpr dart::compiler::target::word AOT_Isolate_isolate_object_store_offset = 0x50; +static constexpr dart::compiler::target::word AOT_Isolate_coroutines_registry_offset = 0x58; static constexpr dart::compiler::target::word AOT_Isolate_has_resumption_breakpoints_offset = 0x49; static constexpr dart::compiler::target::word AOT_IsolateGroup_object_store_offset = 0x20; static constexpr dart::compiler::target::word AOT_IsolateGroup_class_table_offset = 0x10; static constexpr dart::compiler::target::word AOT_IsolateGroup_cached_class_table_table_offset = 0x18; static constexpr dart::compiler::target::word AOT_Isolate_single_step_offset = 0x48; static constexpr dart::compiler::target::word AOT_Isolate_user_tag_offset = 0x20; -static constexpr dart::compiler::target::word AOT_IsolateObjectStore_coroutines_registry_offset = 0x18; static constexpr dart::compiler::target::word AOT_LinkedHashBase_data_offset = 0x18; static constexpr dart::compiler::target::word AOT_ImmutableLinkedHashBase_data_offset = 0x18; static constexpr dart::compiler::target::word AOT_LinkedHashBase_deleted_keys_offset = 0x28; @@ -8343,14 +8325,13 @@ static constexpr dart::compiler::target::word AOT_Int32x4_value_offset = 0x8; static constexpr dart::compiler::target::word AOT_Isolate_current_tag_offset = 0x28; static constexpr dart::compiler::target::word AOT_Isolate_default_tag_offset = 0x30; static constexpr dart::compiler::target::word AOT_Isolate_finalizers_offset = 0x40; -static constexpr dart::compiler::target::word AOT_Isolate_isolate_object_store_offset = 0x50; +static constexpr dart::compiler::target::word AOT_Isolate_coroutines_registry_offset = 0x58; static constexpr dart::compiler::target::word AOT_Isolate_has_resumption_breakpoints_offset = 0x49; static constexpr dart::compiler::target::word AOT_IsolateGroup_object_store_offset = 0x20; static constexpr dart::compiler::target::word AOT_IsolateGroup_class_table_offset = 0x10; static constexpr dart::compiler::target::word AOT_IsolateGroup_cached_class_table_table_offset = 0x18; static constexpr dart::compiler::target::word AOT_Isolate_single_step_offset = 0x48; static constexpr dart::compiler::target::word AOT_Isolate_user_tag_offset = 0x20; -static constexpr dart::compiler::target::word AOT_IsolateObjectStore_coroutines_registry_offset = 0x18; static constexpr dart::compiler::target::word AOT_LinkedHashBase_data_offset = 0x18; static constexpr dart::compiler::target::word AOT_ImmutableLinkedHashBase_data_offset = 0x18; static constexpr dart::compiler::target::word AOT_LinkedHashBase_deleted_keys_offset = 0x28; @@ -8798,14 +8779,13 @@ static constexpr dart::compiler::target::word AOT_Int32x4_value_offset = 0x8; static constexpr dart::compiler::target::word AOT_Isolate_current_tag_offset = 0x28; static constexpr dart::compiler::target::word AOT_Isolate_default_tag_offset = 0x30; static constexpr dart::compiler::target::word AOT_Isolate_finalizers_offset = 0x40; -static constexpr dart::compiler::target::word AOT_Isolate_isolate_object_store_offset = 0x50; +static constexpr dart::compiler::target::word AOT_Isolate_coroutines_registry_offset = 0x58; static constexpr dart::compiler::target::word AOT_Isolate_has_resumption_breakpoints_offset = 0x49; static constexpr dart::compiler::target::word AOT_IsolateGroup_object_store_offset = 0x20; static constexpr dart::compiler::target::word AOT_IsolateGroup_class_table_offset = 0x10; static constexpr dart::compiler::target::word AOT_IsolateGroup_cached_class_table_table_offset = 0x18; static constexpr dart::compiler::target::word AOT_Isolate_single_step_offset = 0x48; static constexpr dart::compiler::target::word AOT_Isolate_user_tag_offset = 0x20; -static constexpr dart::compiler::target::word AOT_IsolateObjectStore_coroutines_registry_offset = 0x18; static constexpr dart::compiler::target::word AOT_LinkedHashBase_data_offset = 0x10; static constexpr dart::compiler::target::word AOT_ImmutableLinkedHashBase_data_offset = 0x10; static constexpr dart::compiler::target::word AOT_LinkedHashBase_deleted_keys_offset = 0x18; @@ -9254,14 +9234,13 @@ static constexpr dart::compiler::target::word AOT_Int32x4_value_offset = 0x8; static constexpr dart::compiler::target::word AOT_Isolate_current_tag_offset = 0x28; static constexpr dart::compiler::target::word AOT_Isolate_default_tag_offset = 0x30; static constexpr dart::compiler::target::word AOT_Isolate_finalizers_offset = 0x40; -static constexpr dart::compiler::target::word AOT_Isolate_isolate_object_store_offset = 0x50; +static constexpr dart::compiler::target::word AOT_Isolate_coroutines_registry_offset = 0x58; static constexpr dart::compiler::target::word AOT_Isolate_has_resumption_breakpoints_offset = 0x49; static constexpr dart::compiler::target::word AOT_IsolateGroup_object_store_offset = 0x20; static constexpr dart::compiler::target::word AOT_IsolateGroup_class_table_offset = 0x10; static constexpr dart::compiler::target::word AOT_IsolateGroup_cached_class_table_table_offset = 0x18; static constexpr dart::compiler::target::word AOT_Isolate_single_step_offset = 0x48; static constexpr dart::compiler::target::word AOT_Isolate_user_tag_offset = 0x20; -static constexpr dart::compiler::target::word AOT_IsolateObjectStore_coroutines_registry_offset = 0x18; static constexpr dart::compiler::target::word AOT_LinkedHashBase_data_offset = 0x10; static constexpr dart::compiler::target::word AOT_ImmutableLinkedHashBase_data_offset = 0x10; static constexpr dart::compiler::target::word AOT_LinkedHashBase_deleted_keys_offset = 0x18; @@ -9710,14 +9689,13 @@ static constexpr dart::compiler::target::word AOT_Int32x4_value_offset = 0x8; static constexpr dart::compiler::target::word AOT_Isolate_current_tag_offset = 0x14; static constexpr dart::compiler::target::word AOT_Isolate_default_tag_offset = 0x18; static constexpr dart::compiler::target::word AOT_Isolate_finalizers_offset = 0x20; -static constexpr dart::compiler::target::word AOT_Isolate_isolate_object_store_offset = 0x28; +static constexpr dart::compiler::target::word AOT_Isolate_coroutines_registry_offset = 0x2c; static constexpr dart::compiler::target::word AOT_Isolate_has_resumption_breakpoints_offset = 0x25; static constexpr dart::compiler::target::word AOT_IsolateGroup_object_store_offset = 0x10; static constexpr dart::compiler::target::word AOT_IsolateGroup_class_table_offset = 0x8; static constexpr dart::compiler::target::word AOT_IsolateGroup_cached_class_table_table_offset = 0xc; static constexpr dart::compiler::target::word AOT_Isolate_single_step_offset = 0x24; static constexpr dart::compiler::target::word AOT_Isolate_user_tag_offset = 0x10; -static constexpr dart::compiler::target::word AOT_IsolateObjectStore_coroutines_registry_offset = 0xc; static constexpr dart::compiler::target::word AOT_LinkedHashBase_data_offset = 0xc; static constexpr dart::compiler::target::word AOT_ImmutableLinkedHashBase_data_offset = 0xc; static constexpr dart::compiler::target::word AOT_LinkedHashBase_deleted_keys_offset = 0x14; @@ -10165,14 +10143,13 @@ static constexpr dart::compiler::target::word AOT_Int32x4_value_offset = 0x8; static constexpr dart::compiler::target::word AOT_Isolate_current_tag_offset = 0x28; static constexpr dart::compiler::target::word AOT_Isolate_default_tag_offset = 0x30; static constexpr dart::compiler::target::word AOT_Isolate_finalizers_offset = 0x40; -static constexpr dart::compiler::target::word AOT_Isolate_isolate_object_store_offset = 0x50; +static constexpr dart::compiler::target::word AOT_Isolate_coroutines_registry_offset = 0x58; static constexpr dart::compiler::target::word AOT_Isolate_has_resumption_breakpoints_offset = 0x49; static constexpr dart::compiler::target::word AOT_IsolateGroup_object_store_offset = 0x20; static constexpr dart::compiler::target::word AOT_IsolateGroup_class_table_offset = 0x10; static constexpr dart::compiler::target::word AOT_IsolateGroup_cached_class_table_table_offset = 0x18; static constexpr dart::compiler::target::word AOT_Isolate_single_step_offset = 0x48; static constexpr dart::compiler::target::word AOT_Isolate_user_tag_offset = 0x20; -static constexpr dart::compiler::target::word AOT_IsolateObjectStore_coroutines_registry_offset = 0x18; static constexpr dart::compiler::target::word AOT_LinkedHashBase_data_offset = 0x18; static constexpr dart::compiler::target::word AOT_ImmutableLinkedHashBase_data_offset = 0x18; static constexpr dart::compiler::target::word AOT_LinkedHashBase_deleted_keys_offset = 0x28; @@ -10617,12 +10594,11 @@ static constexpr dart::compiler::target::word AOT_Int32x4_value_offset = 0x8; static constexpr dart::compiler::target::word AOT_Isolate_current_tag_offset = 0x14; static constexpr dart::compiler::target::word AOT_Isolate_default_tag_offset = 0x18; static constexpr dart::compiler::target::word AOT_Isolate_finalizers_offset = 0x20; -static constexpr dart::compiler::target::word AOT_Isolate_isolate_object_store_offset = 0x28; +static constexpr dart::compiler::target::word AOT_Isolate_coroutines_registry_offset = 0x2c; static constexpr dart::compiler::target::word AOT_IsolateGroup_object_store_offset = 0x10; static constexpr dart::compiler::target::word AOT_IsolateGroup_class_table_offset = 0x8; static constexpr dart::compiler::target::word AOT_IsolateGroup_cached_class_table_table_offset = 0xc; static constexpr dart::compiler::target::word AOT_Isolate_user_tag_offset = 0x10; -static constexpr dart::compiler::target::word AOT_IsolateObjectStore_coroutines_registry_offset = 0xc; static constexpr dart::compiler::target::word AOT_LinkedHashBase_data_offset = 0xc; static constexpr dart::compiler::target::word AOT_ImmutableLinkedHashBase_data_offset = 0xc; static constexpr dart::compiler::target::word AOT_LinkedHashBase_deleted_keys_offset = 0x14; @@ -11067,12 +11043,11 @@ static constexpr dart::compiler::target::word AOT_Int32x4_value_offset = 0x8; static constexpr dart::compiler::target::word AOT_Isolate_current_tag_offset = 0x28; static constexpr dart::compiler::target::word AOT_Isolate_default_tag_offset = 0x30; static constexpr dart::compiler::target::word AOT_Isolate_finalizers_offset = 0x40; -static constexpr dart::compiler::target::word AOT_Isolate_isolate_object_store_offset = 0x50; +static constexpr dart::compiler::target::word AOT_Isolate_coroutines_registry_offset = 0x58; static constexpr dart::compiler::target::word AOT_IsolateGroup_object_store_offset = 0x20; static constexpr dart::compiler::target::word AOT_IsolateGroup_class_table_offset = 0x10; static constexpr dart::compiler::target::word AOT_IsolateGroup_cached_class_table_table_offset = 0x18; static constexpr dart::compiler::target::word AOT_Isolate_user_tag_offset = 0x20; -static constexpr dart::compiler::target::word AOT_IsolateObjectStore_coroutines_registry_offset = 0x18; static constexpr dart::compiler::target::word AOT_LinkedHashBase_data_offset = 0x18; static constexpr dart::compiler::target::word AOT_ImmutableLinkedHashBase_data_offset = 0x18; static constexpr dart::compiler::target::word AOT_LinkedHashBase_deleted_keys_offset = 0x28; @@ -11522,12 +11497,11 @@ static constexpr dart::compiler::target::word AOT_Int32x4_value_offset = 0x8; static constexpr dart::compiler::target::word AOT_Isolate_current_tag_offset = 0x28; static constexpr dart::compiler::target::word AOT_Isolate_default_tag_offset = 0x30; static constexpr dart::compiler::target::word AOT_Isolate_finalizers_offset = 0x40; -static constexpr dart::compiler::target::word AOT_Isolate_isolate_object_store_offset = 0x50; +static constexpr dart::compiler::target::word AOT_Isolate_coroutines_registry_offset = 0x58; static constexpr dart::compiler::target::word AOT_IsolateGroup_object_store_offset = 0x20; static constexpr dart::compiler::target::word AOT_IsolateGroup_class_table_offset = 0x10; static constexpr dart::compiler::target::word AOT_IsolateGroup_cached_class_table_table_offset = 0x18; static constexpr dart::compiler::target::word AOT_Isolate_user_tag_offset = 0x20; -static constexpr dart::compiler::target::word AOT_IsolateObjectStore_coroutines_registry_offset = 0x18; static constexpr dart::compiler::target::word AOT_LinkedHashBase_data_offset = 0x18; static constexpr dart::compiler::target::word AOT_ImmutableLinkedHashBase_data_offset = 0x18; static constexpr dart::compiler::target::word AOT_LinkedHashBase_deleted_keys_offset = 0x28; @@ -11972,12 +11946,11 @@ static constexpr dart::compiler::target::word AOT_Int32x4_value_offset = 0x8; static constexpr dart::compiler::target::word AOT_Isolate_current_tag_offset = 0x28; static constexpr dart::compiler::target::word AOT_Isolate_default_tag_offset = 0x30; static constexpr dart::compiler::target::word AOT_Isolate_finalizers_offset = 0x40; -static constexpr dart::compiler::target::word AOT_Isolate_isolate_object_store_offset = 0x50; +static constexpr dart::compiler::target::word AOT_Isolate_coroutines_registry_offset = 0x58; static constexpr dart::compiler::target::word AOT_IsolateGroup_object_store_offset = 0x20; static constexpr dart::compiler::target::word AOT_IsolateGroup_class_table_offset = 0x10; static constexpr dart::compiler::target::word AOT_IsolateGroup_cached_class_table_table_offset = 0x18; static constexpr dart::compiler::target::word AOT_Isolate_user_tag_offset = 0x20; -static constexpr dart::compiler::target::word AOT_IsolateObjectStore_coroutines_registry_offset = 0x18; static constexpr dart::compiler::target::word AOT_LinkedHashBase_data_offset = 0x10; static constexpr dart::compiler::target::word AOT_ImmutableLinkedHashBase_data_offset = 0x10; static constexpr dart::compiler::target::word AOT_LinkedHashBase_deleted_keys_offset = 0x18; @@ -12423,12 +12396,11 @@ static constexpr dart::compiler::target::word AOT_Int32x4_value_offset = 0x8; static constexpr dart::compiler::target::word AOT_Isolate_current_tag_offset = 0x28; static constexpr dart::compiler::target::word AOT_Isolate_default_tag_offset = 0x30; static constexpr dart::compiler::target::word AOT_Isolate_finalizers_offset = 0x40; -static constexpr dart::compiler::target::word AOT_Isolate_isolate_object_store_offset = 0x50; +static constexpr dart::compiler::target::word AOT_Isolate_coroutines_registry_offset = 0x58; static constexpr dart::compiler::target::word AOT_IsolateGroup_object_store_offset = 0x20; static constexpr dart::compiler::target::word AOT_IsolateGroup_class_table_offset = 0x10; static constexpr dart::compiler::target::word AOT_IsolateGroup_cached_class_table_table_offset = 0x18; static constexpr dart::compiler::target::word AOT_Isolate_user_tag_offset = 0x20; -static constexpr dart::compiler::target::word AOT_IsolateObjectStore_coroutines_registry_offset = 0x18; static constexpr dart::compiler::target::word AOT_LinkedHashBase_data_offset = 0x10; static constexpr dart::compiler::target::word AOT_ImmutableLinkedHashBase_data_offset = 0x10; static constexpr dart::compiler::target::word AOT_LinkedHashBase_deleted_keys_offset = 0x18; @@ -12874,12 +12846,11 @@ static constexpr dart::compiler::target::word AOT_Int32x4_value_offset = 0x8; static constexpr dart::compiler::target::word AOT_Isolate_current_tag_offset = 0x14; static constexpr dart::compiler::target::word AOT_Isolate_default_tag_offset = 0x18; static constexpr dart::compiler::target::word AOT_Isolate_finalizers_offset = 0x20; -static constexpr dart::compiler::target::word AOT_Isolate_isolate_object_store_offset = 0x28; +static constexpr dart::compiler::target::word AOT_Isolate_coroutines_registry_offset = 0x2c; static constexpr dart::compiler::target::word AOT_IsolateGroup_object_store_offset = 0x10; static constexpr dart::compiler::target::word AOT_IsolateGroup_class_table_offset = 0x8; static constexpr dart::compiler::target::word AOT_IsolateGroup_cached_class_table_table_offset = 0xc; static constexpr dart::compiler::target::word AOT_Isolate_user_tag_offset = 0x10; -static constexpr dart::compiler::target::word AOT_IsolateObjectStore_coroutines_registry_offset = 0xc; static constexpr dart::compiler::target::word AOT_LinkedHashBase_data_offset = 0xc; static constexpr dart::compiler::target::word AOT_ImmutableLinkedHashBase_data_offset = 0xc; static constexpr dart::compiler::target::word AOT_LinkedHashBase_deleted_keys_offset = 0x14; @@ -13324,12 +13295,11 @@ static constexpr dart::compiler::target::word AOT_Int32x4_value_offset = 0x8; static constexpr dart::compiler::target::word AOT_Isolate_current_tag_offset = 0x28; static constexpr dart::compiler::target::word AOT_Isolate_default_tag_offset = 0x30; static constexpr dart::compiler::target::word AOT_Isolate_finalizers_offset = 0x40; -static constexpr dart::compiler::target::word AOT_Isolate_isolate_object_store_offset = 0x50; +static constexpr dart::compiler::target::word AOT_Isolate_coroutines_registry_offset = 0x58; static constexpr dart::compiler::target::word AOT_IsolateGroup_object_store_offset = 0x20; static constexpr dart::compiler::target::word AOT_IsolateGroup_class_table_offset = 0x10; static constexpr dart::compiler::target::word AOT_IsolateGroup_cached_class_table_table_offset = 0x18; static constexpr dart::compiler::target::word AOT_Isolate_user_tag_offset = 0x20; -static constexpr dart::compiler::target::word AOT_IsolateObjectStore_coroutines_registry_offset = 0x18; static constexpr dart::compiler::target::word AOT_LinkedHashBase_data_offset = 0x18; static constexpr dart::compiler::target::word AOT_ImmutableLinkedHashBase_data_offset = 0x18; static constexpr dart::compiler::target::word AOT_LinkedHashBase_deleted_keys_offset = 0x28; diff --git a/runtime/vm/compiler/runtime_offsets_list.h b/runtime/vm/compiler/runtime_offsets_list.h index f13704315779..5f1b3bf99f28 100644 --- a/runtime/vm/compiler/runtime_offsets_list.h +++ b/runtime/vm/compiler/runtime_offsets_list.h @@ -170,14 +170,13 @@ FIELD(Isolate, current_tag_offset) \ FIELD(Isolate, default_tag_offset) \ FIELD(Isolate, finalizers_offset) \ - FIELD(Isolate, isolate_object_store_offset) \ + FIELD(Isolate, coroutines_registry_offset) \ NOT_IN_PRODUCT(FIELD(Isolate, has_resumption_breakpoints_offset)) \ FIELD(IsolateGroup, object_store_offset) \ FIELD(IsolateGroup, class_table_offset) \ FIELD(IsolateGroup, cached_class_table_table_offset) \ NOT_IN_PRODUCT(FIELD(Isolate, single_step_offset)) \ FIELD(Isolate, user_tag_offset) \ - FIELD(IsolateObjectStore, coroutines_registry_offset) \ FIELD(LinkedHashBase, data_offset) \ FIELD(ImmutableLinkedHashBase, data_offset) \ FIELD(LinkedHashBase, deleted_keys_offset) \ diff --git a/runtime/vm/compiler/stub_code_compiler_x64.cc b/runtime/vm/compiler/stub_code_compiler_x64.cc index d0d38f338997..1b16822ed086 100644 --- a/runtime/vm/compiler/stub_code_compiler_x64.cc +++ b/runtime/vm/compiler/stub_code_compiler_x64.cc @@ -3106,6 +3106,10 @@ void StubCodeCompiler::GenerateJumpToFrameStub() { /*ignore_unwind_in_progress=*/true); __ Bind(&exit_through_non_ffi); + + // Set the tag. + __ movq(Assembler::VMTagAddress(), Immediate(VMTag::kDartTagId)); + Label no_coroutine; __ Load(TMP, compiler::Address(THR, compiler::target::Thread::coroutine_offset())); @@ -3121,8 +3125,6 @@ void StubCodeCompiler::GenerateJumpToFrameStub() { __ PopRegister(CallingConventions::kArg1Reg); __ Bind(&no_coroutine); - // Set the tag. - __ movq(Assembler::VMTagAddress(), Immediate(VMTag::kDartTagId)); // Clear top exit frame. __ movq(Address(THR, target::Thread::top_exit_frame_info_offset()), Immediate(0)); diff --git a/runtime/vm/coroutine_test.cc b/runtime/vm/coroutine_test.cc new file mode 100644 index 000000000000..04c8dffa0a9c --- /dev/null +++ b/runtime/vm/coroutine_test.cc @@ -0,0 +1,12 @@ +// Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +#include "platform/assert.h" +#include "vm/isolate.h" +#include "vm/unit_test.h" + +namespace dart { +TEST_CASE(Coroutine_test) { +} +} // namespace dart diff --git a/runtime/vm/dart.cc b/runtime/vm/dart.cc index 3c4502ba3535..cba234fe427a 100644 --- a/runtime/vm/dart.cc +++ b/runtime/vm/dart.cc @@ -973,6 +973,7 @@ ErrorPtr Dart::InitializeIsolate(Thread* T, return error.ptr(); } + I->set_coroutines_registry(GrowableObjectArray::New(FLAG_coroutines_registry_initial_capacity)); I->set_init_callback_data(isolate_data); #if !defined(PRODUCT) diff --git a/runtime/vm/flag_list.h b/runtime/vm/flag_list.h index f1707556f279..534da93b0df6 100644 --- a/runtime/vm/flag_list.h +++ b/runtime/vm/flag_list.h @@ -26,19 +26,19 @@ constexpr intptr_t kDefaultOptimizationCounterThreshold = 30000; // to conditionally make these into product flags to make the disassembler // usable in product mode. #if defined(FORCE_INCLUDE_DISASSEMBLER) -#define DISASSEMBLE_FLAGS(P, R, C, D) \ - P(disassemble, bool, false, "Disassemble dart code.") \ - P(disassemble_optimized, bool, false, "Disassemble optimized code.") \ - P(disassemble_relative, bool, false, "Use offsets instead of absolute PCs") \ - P(disassemble_stubs, bool, false, "Disassemble generated stubs.") \ +#define DISASSEMBLE_FLAGS(P, R, C, D) \ + P(disassemble, bool, false, "Disassemble dart code.") \ + P(disassemble_optimized, bool, false, "Disassemble optimized code.") \ + P(disassemble_relative, bool, false, "Use offsets instead of absolute PCs") \ + P(disassemble_stubs, bool, false, "Disassemble generated stubs.") \ P(support_disassembler, bool, true, "Support the disassembler.") #else -#define DISASSEMBLE_FLAGS(P, R, C, D) \ - R(disassemble, false, bool, false, "Disassemble dart code.") \ - R(disassemble_optimized, false, bool, false, "Disassemble optimized code.") \ - R(disassemble_relative, false, bool, false, \ - "Use offsets instead of absolute PCs") \ - R(disassemble_stubs, false, bool, false, "Disassemble generated stubs.") \ +#define DISASSEMBLE_FLAGS(P, R, C, D) \ + R(disassemble, false, bool, false, "Disassemble dart code.") \ + R(disassemble_optimized, false, bool, false, "Disassemble optimized code.") \ + R(disassemble_relative, false, bool, false, \ + "Use offsets instead of absolute PCs") \ + R(disassemble_stubs, false, bool, false, "Disassemble generated stubs.") \ R(support_disassembler, false, bool, true, "Support the disassembler.") #endif @@ -242,10 +242,10 @@ constexpr bool FLAG_support_il_printer = false; R(eliminate_type_checks, true, bool, true, \ "Eliminate type checks when allowed by static type analysis.") \ D(support_rr, bool, false, "Support running within RR.") \ - P(coroutines_registry_initial_size, int, 64, \ + P(coroutines_registry_initial_capacity, int, 64, \ "All coroutines array initial size.") \ - P(coroutines_registry_shrink_marker, int, 1024 * 1024, \ - "Shrink coroutines registry when reached marker size.") \ + P(coroutines_registry_shrink_capacity, int, 1024 * 1024, \ + "Shrink coroutines registry when reached this capacity.") \ P(verify_entry_points, bool, false, \ "Throw API error on invalid member access through native API. See " \ "entry_point_pragma.md") \ diff --git a/runtime/vm/isolate.cc b/runtime/vm/isolate.cc index 893c186a59a7..a92d68ec2972 100644 --- a/runtime/vm/isolate.cc +++ b/runtime/vm/isolate.cc @@ -15,6 +15,7 @@ #include "vm/class_finalizer.h" #include "vm/code_observers.h" #include "vm/compiler/jit/compiler.h" +#include "vm/compiler/runtime_api.h" #include "vm/dart_api_message.h" #include "vm/dart_api_state.h" #include "vm/dart_entry.h" @@ -108,7 +109,8 @@ DEFINE_FLAG(bool, // and assigned to an isolate. class VerifyOriginId : public IsolateVisitor { public: - explicit VerifyOriginId(Dart_Port id) : id_(id) {} + explicit VerifyOriginId(Dart_Port id) + : id_(id) {} void VisitIsolate(Isolate* isolate) { ASSERT(isolate->origin_id() != id_); } @@ -489,7 +491,7 @@ void IsolateGroup::CreateHeap(bool is_vm_isolate, : FLAG_old_gen_heap_size) * MBInWords); -#define ISOLATE_GROUP_METRIC_CONSTRUCTORS(type, variable, name, unit) \ +#define ISOLATE_GROUP_METRIC_CONSTRUCTORS(type, variable, name, unit) \ metric_##variable##_.InitInstance(this, name, nullptr, Metric::unit); ISOLATE_GROUP_METRIC_LIST(ISOLATE_GROUP_METRIC_CONSTRUCTORS) #undef ISOLATE_GROUP_METRIC_CONSTRUCTORS @@ -1599,7 +1601,7 @@ MessageHandler::MessageStatus IsolateMessageHandler::ProcessUnhandledException( void IsolateGroup::FlagsInitialize(Dart_IsolateFlags* api_flags) { api_flags->version = DART_FLAGS_CURRENT_VERSION; -#define INIT_FROM_FLAG(when, name, bitname, isolate_flag, flag) \ +#define INIT_FROM_FLAG(when, name, bitname, isolate_flag, flag) \ api_flags->isolate_flag = flag; BOOL_ISOLATE_GROUP_FLAG_LIST(INIT_FROM_FLAG) #undef INIT_FROM_FLAG @@ -1610,7 +1612,7 @@ void IsolateGroup::FlagsInitialize(Dart_IsolateFlags* api_flags) { void IsolateGroup::FlagsCopyTo(Dart_IsolateFlags* api_flags) { api_flags->version = DART_FLAGS_CURRENT_VERSION; -#define INIT_FROM_FIELD(when, name, bitname, isolate_flag, flag) \ +#define INIT_FROM_FIELD(when, name, bitname, isolate_flag, flag) \ api_flags->isolate_flag = name(); BOOL_ISOLATE_GROUP_FLAG_LIST(INIT_FROM_FIELD) #undef INIT_FROM_FIELD @@ -1634,8 +1636,8 @@ void IsolateGroup::FlagsCopyFrom(const Dart_IsolateFlags& api_flags) { #define FLAG_FOR_PRODUCT(action) action -#define SET_FROM_FLAG(when, name, bitname, isolate_flag, flag) \ - FLAG_FOR_##when(isolate_group_flags_ = bitname##Bit::update( \ +#define SET_FROM_FLAG(when, name, bitname, isolate_flag, flag) \ + FLAG_FOR_##when(isolate_group_flags_ = bitname##Bit::update( \ api_flags.isolate_flag, isolate_group_flags_)); BOOL_ISOLATE_GROUP_FLAG_LIST(SET_FROM_FLAG) @@ -1649,7 +1651,7 @@ void Isolate::FlagsInitialize(Dart_IsolateFlags* api_flags) { IsolateGroup::FlagsInitialize(api_flags); api_flags->version = DART_FLAGS_CURRENT_VERSION; -#define INIT_FROM_FLAG(when, name, bitname, isolate_flag, flag) \ +#define INIT_FROM_FLAG(when, name, bitname, isolate_flag, flag) \ api_flags->isolate_flag = flag; BOOL_ISOLATE_FLAG_LIST(INIT_FROM_FLAG) #undef INIT_FROM_FLAG @@ -1662,7 +1664,7 @@ void Isolate::FlagsCopyTo(Dart_IsolateFlags* api_flags) const { group()->FlagsCopyTo(api_flags); api_flags->version = DART_FLAGS_CURRENT_VERSION; -#define INIT_FROM_FIELD(when, name, bitname, isolate_flag, flag) \ +#define INIT_FROM_FIELD(when, name, bitname, isolate_flag, flag) \ api_flags->isolate_flag = name(); BOOL_ISOLATE_FLAG_LIST(INIT_FROM_FIELD) #undef INIT_FROM_FIELD @@ -1686,8 +1688,8 @@ void Isolate::FlagsCopyFrom(const Dart_IsolateFlags& api_flags) { #define FLAG_FOR_PRODUCT(action) action -#define SET_FROM_FLAG(when, name, bitname, isolate_flag, flag) \ - FLAG_FOR_##when(isolate_flags_ = bitname##Bit::update( \ +#define SET_FROM_FLAG(when, name, bitname, isolate_flag, flag) \ + FLAG_FOR_##when(isolate_flags_ = bitname##Bit::update( \ api_flags.isolate_flag, isolate_flags_)); BOOL_ISOLATE_FLAG_LIST(SET_FROM_FLAG) @@ -1705,7 +1707,7 @@ void BaseIsolate::AssertCurrent(BaseIsolate* isolate) { #endif // defined(DEBUG) #if defined(DEBUG) -#define REUSABLE_HANDLE_SCOPE_INIT(object) \ +#define REUSABLE_HANDLE_SCOPE_INIT(object) \ reusable_##object##_handle_scope_active_(false), #else #define REUSABLE_HANDLE_SCOPE_INIT(object) @@ -1741,14 +1743,16 @@ Isolate::Isolate(IsolateGroup* isolate_group, field_table_(new FieldTable(/*isolate=*/this)), finalizers_(GrowableObjectArray::null()), isolate_object_store_(new IsolateObjectStore()), + coroutines_registry_(GrowableObjectArray::null()), isolate_group_(isolate_group), + saved_coroutine_(Coroutine::null()), isolate_flags_(0), #if !defined(PRODUCT) last_resume_timestamp_(OS::GetCurrentTimeMillis()), vm_tag_counters_(), pending_service_extension_calls_(GrowableObjectArray::null()), registered_service_extension_handlers_(GrowableObjectArray::null()), -#define ISOLATE_METRIC_CONSTRUCTORS(type, variable, name, unit) \ +#define ISOLATE_METRIC_CONSTRUCTORS(type, variable, name, unit) \ metric_##variable##_(), ISOLATE_METRIC_LIST(ISOLATE_METRIC_CONSTRUCTORS) #undef ISOLATE_METRIC_CONSTRUCTORS @@ -1759,7 +1763,6 @@ Isolate::Isolate(IsolateGroup* isolate_group, on_cleanup_callback_(Isolate::CleanupCallback()), random_(), mutex_(NOT_IN_PRODUCT("Isolate::mutex_")), - saved_coroutine_(Coroutine::null()), tag_table_(GrowableObjectArray::null()), sticky_error_(Error::null()), spawn_count_monitor_(), @@ -1849,8 +1852,8 @@ Isolate* Isolate::InitIsolate(const char* name_prefix, #if !defined(PRODUCT) // Initialize metrics. -#define ISOLATE_METRIC_INIT(type, variable, name, unit) \ - result->metric_##variable##_.InitInstance(result, name, nullptr, \ +#define ISOLATE_METRIC_INIT(type, variable, name, unit) \ + result->metric_##variable##_.InitInstance(result, name, nullptr, \ Metric::unit); ISOLATE_METRIC_LIST(ISOLATE_METRIC_INIT); #undef ISOLATE_METRIC_INIT @@ -2518,11 +2521,11 @@ void Isolate::LowLevelShutdown() { if (FLAG_print_metrics) { LogBlock lb; OS::PrintErr("Printing metrics for %s\n", name()); -#define ISOLATE_GROUP_METRIC_PRINT(type, variable, name, unit) \ +#define ISOLATE_GROUP_METRIC_PRINT(type, variable, name, unit) \ OS::PrintErr("%s\n", isolate_group_->Get##variable##Metric()->ToString()); ISOLATE_GROUP_METRIC_LIST(ISOLATE_GROUP_METRIC_PRINT) #undef ISOLATE_GROUP_METRIC_PRINT -#define ISOLATE_METRIC_PRINT(type, variable, name, unit) \ +#define ISOLATE_METRIC_PRINT(type, variable, name, unit) \ OS::PrintErr("%s\n", metric_##variable##_.ToString()); ISOLATE_METRIC_LIST(ISOLATE_METRIC_PRINT) #undef ISOLATE_METRIC_PRINT @@ -2740,6 +2743,7 @@ void Isolate::VisitObjectPointers(ObjectPointerVisitor* visitor, visitor->VisitPointer(reinterpret_cast(&sticky_error_)); visitor->VisitPointer(reinterpret_cast(&finalizers_)); visitor->VisitPointer(reinterpret_cast(&saved_coroutine_)); + visitor->VisitPointer(reinterpret_cast(&coroutines_registry_)); #if !defined(PRODUCT) visitor->VisitPointer( reinterpret_cast(&pending_service_extension_calls_)); @@ -3131,11 +3135,11 @@ void Isolate::PrintJSON(JSONStream* stream, bool ref) { #define TO_STRING(s) STR(s) #define STR(s) #s -#define ADD_ISOLATE_FLAGS(when, name, bitname, isolate_flag_name, flag_name) \ - { \ - JSONObject jsflag(&jsflags); \ - jsflag.AddProperty("name", TO_STRING(name)); \ - jsflag.AddProperty("valueAsString", name() ? "true" : "false"); \ +#define ADD_ISOLATE_FLAGS(when, name, bitname, isolate_flag_name, flag_name) \ + { \ + JSONObject jsflag(&jsflags); \ + jsflag.AddProperty("name", TO_STRING(name)); \ + jsflag.AddProperty("valueAsString", name() ? "true" : "false"); \ } JSONArray jsflags(&jsobj, "isolateFlags"); BOOL_ISOLATE_FLAG_LIST(ADD_ISOLATE_FLAGS) diff --git a/runtime/vm/isolate.h b/runtime/vm/isolate.h index 1f41c3cc795a..0c6e5c5203fd 100644 --- a/runtime/vm/isolate.h +++ b/runtime/vm/isolate.h @@ -5,6 +5,8 @@ #ifndef RUNTIME_VM_ISOLATE_H_ #define RUNTIME_VM_ISOLATE_H_ +#include "vm/compiler/runtime_api.h" +#include "vm/tagged_pointer.h" #if defined(SHOULD_NOT_INCLUDE_RUNTIME) #error "Should not include runtime" #endif @@ -1012,6 +1014,12 @@ class Isolate : public BaseIsolate, public IntrusiveDListEntry { CoroutineLink* finished_coroutines() { return &finished_coroutines_; } CoroutineLink* active_coroutines() { return &active_coroutines_; } + + GrowableObjectArrayPtr coroutines_registry() { return coroutines_registry_; } + void set_coroutines_registry(GrowableObjectArrayPtr coroutines) { coroutines_registry_ = coroutines; } + static intptr_t coroutines_registry_offset() { + return OFFSET_OF(Isolate, coroutines_registry_); + } IsolateObjectStore* isolate_object_store() const { return isolate_object_store_.get(); @@ -1081,10 +1089,6 @@ class Isolate : public BaseIsolate, public IntrusiveDListEntry { return OFFSET_OF(Isolate, finalizers_); } - static intptr_t isolate_object_store_offset() { - return OFFSET_OF(Isolate, isolate_object_store_); - } - Dart_EnvironmentCallback environment_callback() const { return environment_callback_; } @@ -1574,10 +1578,14 @@ class Isolate : public BaseIsolate, public IntrusiveDListEntry { bool has_resumption_breakpoints_ = false; bool is_system_isolate_ = false; std::unique_ptr isolate_object_store_; + GrowableObjectArrayPtr coroutines_registry_; // End accessed from generated code. IsolateGroup* const isolate_group_; IdleTimeHandler idle_time_handler_; + CoroutinePtr saved_coroutine_; + CoroutineLink active_coroutines_; + CoroutineLink finished_coroutines_; #define ISOLATE_FLAG_BITS(V) \ V(ErrorsFatal) \ @@ -1687,9 +1695,7 @@ class Isolate : public BaseIsolate, public IntrusiveDListEntry { DeoptContext* deopt_context_ = nullptr; FfiCallbackMetadata::Metadata* ffi_callback_list_head_ = nullptr; intptr_t ffi_callback_keep_alive_counter_ = 0; - CoroutinePtr saved_coroutine_; - CoroutineLink active_coroutines_; - CoroutineLink finished_coroutines_; + GrowableObjectArrayPtr tag_table_; diff --git a/runtime/vm/object.cc b/runtime/vm/object.cc index 99cedc326e5d..199943de5214 100644 --- a/runtime/vm/object.cc +++ b/runtime/vm/object.cc @@ -6,6 +6,7 @@ #include #include "platform/globals.h" +#include "vm/flags.h" #if !defined(DART_TARGET_OS_WINDOWS) #include @@ -9204,9 +9205,10 @@ bool Function::RecognizedKindForceOptimize() const { case MethodRecognizer::kTypedData_memMove8: case MethodRecognizer::kTypedData_memMove16: case MethodRecognizer::kCoroutine_getCurrent: - case MethodRecognizer::kCoroutine_atIndex: + case MethodRecognizer::kCoroutine_getRegistry: case MethodRecognizer::kCoroutine_getAttributes: case MethodRecognizer::kCoroutine_getIndex: + case MethodRecognizer::kCoroutine_getSize: case MethodRecognizer::kCoroutine_setAttributes: case MethodRecognizer::kMemCopy: // Prevent the GC from running so that the operation is atomic from @@ -25056,6 +25058,22 @@ ObjectPtr GrowableObjectArray::RemoveLast() const { return obj.ptr(); } +ObjectPtr GrowableObjectArray::RemoveAt(intptr_t index) const { + ASSERT(!IsNull()); + ASSERT(Length() > 0); + intptr_t last = Length() - 1; + if (index < last) { + Swap(index, last); + } + return RemoveLast(); +} + +void GrowableObjectArray::Swap(intptr_t i, intptr_t j) const { + auto temp = At(i); + data()->untag()->set_element(i, At(j)); + data()->untag()->set_element(j, temp); +} + GrowableObjectArrayPtr GrowableObjectArray::New(intptr_t capacity, Heap::Space space) { ArrayPtr raw_data = (capacity == 0) ? Object::empty_array().ptr() @@ -26643,20 +26661,19 @@ CodePtr SuspendState::GetCodeObject() const { CoroutinePtr Coroutine::New(uintptr_t size, FunctionPtr trampoline) { auto isolate = Isolate::Current(); - auto object_store = Isolate::Current()->isolate_object_store(); auto finished = isolate->finished_coroutines(); auto active = isolate->active_coroutines(); - auto& registry = Array::Handle(object_store->coroutines_registry()); + auto& registry = GrowableObjectArray::Handle(isolate->coroutines_registry()); auto page_size = VirtualMemory::PageSize(); - auto stack_size = (size_t)size * kWordSize + page_size - 1; + auto stack_size = (size + page_size - 1) & ~(page_size - 1); if (finished->IsNotEmpty()) { auto& coroutine = Coroutine::Handle(finished->First()->Value()); coroutine.change_state(CoroutineAttributes::finished, CoroutineAttributes::created); CoroutineLink::StealHead(active, coroutine.to_state()); coroutine.untag()->set_trampoline(trampoline); - if (stack_size != coroutine.stack_size()) { + if (UNLIKELY(stack_size != coroutine.stack_size())) { #if defined(DART_TARGET_OS_WINDOWS) VirtualFree((void*)stack_limit(), 0, MEM_RELEASE); #else @@ -26682,7 +26699,7 @@ CoroutinePtr Coroutine::New(uintptr_t size, FunctionPtr trampoline) { return coroutine.ptr(); } - const auto& coroutine = Coroutine::Handle(Object::Allocate(Heap::kOld)); + const auto& coroutine = Coroutine::Handle(Object::Allocate(Heap::kNew)); #if defined(DART_TARGET_OS_WINDOWS) void* stack_base = (void*)((uintptr_t)VirtualAlloc( nullptr, stack_size, MEM_RESERVE | MEM_COMMIT, @@ -26703,29 +26720,12 @@ CoroutinePtr Coroutine::New(uintptr_t size, FunctionPtr trampoline) { coroutine.untag()->stack_base_ = stack_base; coroutine.untag()->stack_limit_ = stack_limit; coroutine.untag()->overflow_stack_limit_ = stack_limit + CalculateHeadroom(stack_base - stack_limit); - coroutine.untag()->set_index(-1); coroutine.untag()->set_trampoline(trampoline); - CoroutineLink::AddHead(active, coroutine.to_state()); - - intptr_t free_index = -1; - for (auto index = 0; index < registry.Length(); index++) { - if (registry.At(index) == Object::null()) { - free_index = index; - break; - } - } - - if (free_index == -1) { - free_index = registry.Length(); - auto current_capacity = registry.Length(); - auto new_capacity = current_capacity = (current_capacity > 1) ? (current_capacity + (current_capacity / 2)) : (current_capacity + 1); - registry = Array::Grow(registry, new_capacity, Heap::kOld); - object_store->set_coroutines_registry(registry); - } + coroutine.untag()->set_index(registry.Length()); + registry.Add(coroutine); - coroutine.untag()->set_index(free_index); - registry.SetAt(free_index, coroutine); + CoroutineLink::AddHead(active, coroutine.to_state()); return coroutine.ptr(); } @@ -26767,39 +26767,23 @@ void Coroutine::dispose(Thread* thread, Zone* zone, bool remove_from_registry) c return; } - auto object_store = thread->isolate()->isolate_object_store(); - auto& coroutines = Array::Handle(zone, object_store->coroutines_registry()); - coroutines.SetAt(index(), Object::null_object()); + auto& coroutines = GrowableObjectArray::Handle(zone, thread->isolate()->coroutines_registry()); + coroutines.RemoveAt(index()); untag()->set_index(-1); - if (coroutines.Length() < FLAG_coroutines_registry_shrink_marker) { + if (coroutines.Capacity() < FLAG_coroutines_registry_shrink_capacity) { return; } - intptr_t new_length = 0; + auto& new_coroutines = GrowableObjectArray::Handle(GrowableObjectArray::New(std::max(coroutines.Length(), (intptr_t)FLAG_coroutines_registry_initial_capacity))); + auto& new_coroutine = Coroutine::Handle(); for (intptr_t index = 0; index < coroutines.Length(); index++) { - if (coroutines.At(index) != Object::null()) new_length++; - } - - if (new_length != 0) { - auto& coroutine = Coroutine::Handle(zone); - auto& new_coroutines = Array::Handle(Array::NewUninitialized(std::max(new_length, (intptr_t)FLAG_coroutines_registry_initial_size))); - for (intptr_t index = 0, new_index = 0; index < coroutines.Length(); index++) { - if (coroutines.At(index) != Object::null()) { - coroutine ^= coroutines.At(index); - new_coroutines.SetAt(new_index, coroutine); - coroutine.set_index(new_index); - new_index++; - } - } - coroutines.Truncate(0); - object_store->set_coroutines_registry(new_coroutines); - return; + new_coroutine ^= coroutines.At(index); + new_coroutine.set_index(new_coroutines.Length()); + new_coroutines.Add(new_coroutine); } - - coroutines.Truncate(0); - coroutines ^= Array::New(FLAG_coroutines_registry_initial_size); - object_store->set_coroutines_registry(coroutines); + Array::Handle(coroutines.data()).Truncate(0); + thread->isolate()->set_coroutines_registry(new_coroutines.ptr()); } const char* Coroutine::ToCString() const { @@ -26812,16 +26796,13 @@ const char* Coroutine::ToCString() const { void Coroutine::HandleJumpToFrame(Thread* thread, uword stack_pointer) { auto zone = thread->zone(); - auto object_store = thread->isolate()->isolate_object_store(); - auto& coroutines = Array::Handle(zone, object_store->coroutines_registry()); + auto& coroutines = GrowableObjectArray::Handle(zone, thread->isolate()->coroutines_registry()); auto& found = Coroutine::Handle(zone); for (auto index = 0; index < coroutines.Length(); index++) { - if (coroutines.At(index) != Object::null()) { - auto candidate = Coroutine::RawCast(coroutines.At(index)); - if (stack_pointer > candidate.untag()->stack_limit() && stack_pointer <= candidate.untag()->stack_root()) { - found ^= candidate; - break; - } + auto candidate = Coroutine::RawCast(coroutines.At(index)); + if (stack_pointer > candidate.untag()->stack_limit() && stack_pointer <= candidate.untag()->stack_root()) { + found ^= candidate; + break; } } if (found.IsNull()) { @@ -26846,43 +26827,38 @@ void Coroutine::HandleRootEnter(Thread* thread, Zone* zone) { } void Coroutine::HandleRootExit(Thread* thread, Zone* zone) { - auto object_store = thread->isolate()->isolate_object_store(); - auto& coroutines = Array::Handle(zone, object_store->coroutines_registry()); + auto& coroutines = GrowableObjectArray::Handle(zone, thread->isolate()->coroutines_registry()); auto& coroutine = Coroutine::Handle(zone); intptr_t recycled_count = 0; for (auto index = 0; index < coroutines.Length(); index++) { - if (coroutines.At(index) != Object::null()) { - coroutine ^= coroutines.At(index); - if (coroutine.is_persistent() && !coroutine.is_finished()) { - coroutine.recycle(zone); - recycled_count++; - continue; - } - if (coroutine.is_ephemeral() && !coroutine.is_disposed()) { - coroutine.dispose(thread, zone, false); - } + coroutine ^= coroutines.At(index); + if (coroutine.is_persistent() && !coroutine.is_finished()) { + coroutine.recycle(zone); + recycled_count++; + continue; + } + if (coroutine.is_ephemeral() && !coroutine.is_disposed()) { + coroutine.dispose(thread, zone, false); } } if (recycled_count != 0) { - auto& recycled = Array::Handle(Array::NewUninitialized(std::max(recycled_count, (intptr_t)FLAG_coroutines_registry_initial_size))); - for (auto index = 0, recycled_index = 0; index < coroutines.Length(); index++) { - if (coroutines.At(index) != Object::null()) { - coroutine ^= coroutines.At(index); - if (coroutine.is_finished()) { - recycled.SetAt(recycled_index, coroutine); - coroutine.set_index(recycled_index); - recycled_index++; - } + auto& recycled = GrowableObjectArray::Handle(GrowableObjectArray::New(std::max(recycled_count, (intptr_t)FLAG_coroutines_registry_initial_capacity))); + for (auto index = 0; index < coroutines.Length(); index++) { + coroutine ^= coroutines.At(index); + if (coroutine.is_finished()) { + coroutine.set_index(recycled.Length()); + recycled.Add(coroutine); } } - object_store->set_coroutines_registry(recycled); + thread->isolate()->set_coroutines_registry(recycled.ptr()); + thread->ExitCoroutine(); + return; } - coroutines.Truncate(0); - object_store->set_coroutines_registry(Array::Handle(Array::New(FLAG_coroutines_registry_initial_size))); - + Array::Handle(coroutines.data()).Truncate(0); + thread->isolate()->set_coroutines_registry(GrowableObjectArray::New(FLAG_coroutines_registry_initial_capacity)); thread->ExitCoroutine(); } diff --git a/runtime/vm/object.h b/runtime/vm/object.h index 6add16712290..803756ca4b41 100644 --- a/runtime/vm/object.h +++ b/runtime/vm/object.h @@ -11102,6 +11102,8 @@ class GrowableObjectArray : public Instance { void Grow(intptr_t new_capacity, Heap::Space space = Heap::kNew) const; ObjectPtr RemoveLast() const; + void Swap(intptr_t i, intptr_t j) const; + ObjectPtr RemoveAt(intptr_t index) const; virtual TypeArgumentsPtr GetTypeArguments() const { return untag()->type_arguments(); diff --git a/runtime/vm/object_store.cc b/runtime/vm/object_store.cc index 90bdc097fc8f..f9862b8d3bf4 100644 --- a/runtime/vm/object_store.cc +++ b/runtime/vm/object_store.cc @@ -78,7 +78,6 @@ ErrorPtr IsolateObjectStore::PreallocateObjects(const Object& out_of_memory) { resume_capabilities_ = GrowableObjectArray::New(); exit_listeners_ = GrowableObjectArray::New(); error_listeners_ = GrowableObjectArray::New(); - coroutines_registry_ = Array::New(FLAG_coroutines_registry_initial_size); dart_args_1_ = Array::New(1); dart_args_2_ = Array::New(2); diff --git a/runtime/vm/object_store.h b/runtime/vm/object_store.h index 84e3756747d9..786d9ea616cd 100644 --- a/runtime/vm/object_store.h +++ b/runtime/vm/object_store.h @@ -394,7 +394,6 @@ class ObjectPointerVisitor; RW(UnhandledException, preallocated_unhandled_exception) \ RW(StackTrace, preallocated_stack_trace) \ RW(UnwindError, preallocated_unwind_error) \ - RW(Array, coroutines_registry) \ R_(Array, dart_args_1) \ R_(Array, dart_args_2) \ R_(GrowableObjectArray, resume_capabilities) \ diff --git a/runtime/vm/raw_object.h b/runtime/vm/raw_object.h index 24629b8be5ca..f3b17a13be50 100644 --- a/runtime/vm/raw_object.h +++ b/runtime/vm/raw_object.h @@ -3809,11 +3809,11 @@ class UntaggedCoroutine : public UntaggedInstance { uword overflow_stack_limit() const { return overflow_stack_limit_; } uword attributes() const { return attributes_; } - uword index() const { return index_; } - - void set_index(uword index) { index_ = index; } void set_attributes(uword attributes) { attributes_ = attributes; } + uword index() const { return index_; } + void set_index(uword index) { index_ = index; } + bool HasStackHeadroom() { return OSThread::GetCurrentStackPointer() > overflow_stack_limit_; } diff --git a/runtime/vm/stack_frame.cc b/runtime/vm/stack_frame.cc index bc74bd2d3dda..cc073bfcb9e4 100644 --- a/runtime/vm/stack_frame.cc +++ b/runtime/vm/stack_frame.cc @@ -654,8 +654,8 @@ void StackFrameIterator::FrameSetIterator::Unpoison() { StackFrame* StackFrameIterator::FrameSetIterator::NextFrame(bool validate) { StackFrame* frame; ASSERT(HasNext()); - if (stack_owner_ == kStackOwnerCoroutine && StubCode::InCoroutineStub(pc_)) { - frame = &stack_frame_; + frame = &stack_frame_; + if (stack_owner_ == kStackOwnerCoroutine && StubCode::InCoroutineStub(frame->pc())) { frame->sp_ = sp_; frame->fp_ = fp_; frame->pc_ = pc_; @@ -665,7 +665,6 @@ StackFrame* StackFrameIterator::FrameSetIterator::NextFrame(bool validate) { Unpoison(); return NextFrame(validate); } - frame = &stack_frame_; frame->sp_ = sp_; frame->fp_ = fp_; frame->pc_ = pc_; diff --git a/runtime/vm/vm_sources.gni b/runtime/vm/vm_sources.gni index 758e2f2178e0..b4eaa8e2ff0b 100644 --- a/runtime/vm/vm_sources.gni +++ b/runtime/vm/vm_sources.gni @@ -401,6 +401,7 @@ vm_sources_tests = [ "code_patcher_ia32_test.cc", "code_patcher_riscv_test.cc", "code_patcher_x64_test.cc", + "coroutine_test.cc", "compiler_test.cc", "cpu_test.cc", "cpuinfo_test.cc", diff --git a/sdk.code-workspace b/sdk.code-workspace index d901d2cefe1d..8f834a667c2d 100644 --- a/sdk.code-workspace +++ b/sdk.code-workspace @@ -47,7 +47,7 @@ "settings": { "C_Cpp.intelliSenseEngine": "disabled", "clangd.arguments": [ - "--compile-commands-dir=out/DebugX64" + "--compile-commands-dir=out/DebugX64", ], "files.exclude": { "**/*.S": true, diff --git a/sdk/lib/_internal/js_dev_runtime/patch/fiber_patch.dart b/sdk/lib/_internal/js_dev_runtime/patch/fiber_patch.dart index 8f1f2c59ba2e..349a1d0e2a82 100644 --- a/sdk/lib/_internal/js_dev_runtime/patch/fiber_patch.dart +++ b/sdk/lib/_internal/js_dev_runtime/patch/fiber_patch.dart @@ -12,6 +12,8 @@ class _Coroutine { @patch int get _index => throw UnsupportedError("_Coroutine._current"); @patch + int get _size => throw UnsupportedError("_Coroutine._current"); + @patch void Function() get _entry => throw UnsupportedError("_Coroutine._current"); @patch set _entry(void Function() value) => throw UnsupportedError("_Coroutine._current"); @@ -50,7 +52,7 @@ class _Coroutine { @patch static _Coroutine? get _current => throw UnsupportedError("_Coroutine._current"); @patch - static _Coroutine _at(int index) => throw UnsupportedError("_Coroutine._initialize"); + static List<_Coroutine> get _registry => throw UnsupportedError("_Coroutine._current"); @patch static void _initialize(_Coroutine root) => throw UnsupportedError("_Coroutine._initialize"); @patch diff --git a/sdk/lib/_internal/js_runtime/lib/fiber_patch.dart b/sdk/lib/_internal/js_runtime/lib/fiber_patch.dart index 8f1f2c59ba2e..349a1d0e2a82 100644 --- a/sdk/lib/_internal/js_runtime/lib/fiber_patch.dart +++ b/sdk/lib/_internal/js_runtime/lib/fiber_patch.dart @@ -12,6 +12,8 @@ class _Coroutine { @patch int get _index => throw UnsupportedError("_Coroutine._current"); @patch + int get _size => throw UnsupportedError("_Coroutine._current"); + @patch void Function() get _entry => throw UnsupportedError("_Coroutine._current"); @patch set _entry(void Function() value) => throw UnsupportedError("_Coroutine._current"); @@ -50,7 +52,7 @@ class _Coroutine { @patch static _Coroutine? get _current => throw UnsupportedError("_Coroutine._current"); @patch - static _Coroutine _at(int index) => throw UnsupportedError("_Coroutine._initialize"); + static List<_Coroutine> get _registry => throw UnsupportedError("_Coroutine._current"); @patch static void _initialize(_Coroutine root) => throw UnsupportedError("_Coroutine._initialize"); @patch diff --git a/sdk/lib/_internal/vm/lib/fiber_patch.dart b/sdk/lib/_internal/vm/lib/fiber_patch.dart index 5639c0f9d802..6dd6a4acdfc8 100644 --- a/sdk/lib/_internal/vm/lib/fiber_patch.dart +++ b/sdk/lib/_internal/vm/lib/fiber_patch.dart @@ -22,6 +22,11 @@ class _Coroutine { @pragma("vm:prefer-inline") external int get _index; + @patch + @pragma("vm:recognized", "other") + @pragma("vm:prefer-inline") + external int get _size; + @patch @pragma("vm:recognized", "other") @pragma("vm:prefer-inline") @@ -105,13 +110,6 @@ class _Coroutine { @pragma("vm:prefer-inline") external set _toProcessorPrevious(_Coroutine value); - @patch - @pragma("vm:recognized", "other") - @pragma("vm:prefer-inline") - @pragma("vm:unsafe:no-interrupts") - @pragma("vm:unsafe:no-bounds-checks") - external static _Coroutine _at(int index); - @patch @pragma("vm:recognized", "other") @pragma("vm:never-inline") @@ -140,4 +138,12 @@ class _Coroutine { @pragma("vm:unsafe:no-interrupts") @pragma("vm:unsafe:no-bounds-checks") external static _Coroutine? get _current; + + @patch + @pragma("vm:recognized", "other") + @pragma("vm:prefer-inline") + @pragma("vm:idempotent") + @pragma("vm:unsafe:no-interrupts") + @pragma("vm:unsafe:no-bounds-checks") + external static List<_Coroutine> get _registry; } diff --git a/sdk/lib/_internal/wasm/lib/fiber_patch.dart b/sdk/lib/_internal/wasm/lib/fiber_patch.dart index 8f1f2c59ba2e..349a1d0e2a82 100644 --- a/sdk/lib/_internal/wasm/lib/fiber_patch.dart +++ b/sdk/lib/_internal/wasm/lib/fiber_patch.dart @@ -12,6 +12,8 @@ class _Coroutine { @patch int get _index => throw UnsupportedError("_Coroutine._current"); @patch + int get _size => throw UnsupportedError("_Coroutine._current"); + @patch void Function() get _entry => throw UnsupportedError("_Coroutine._current"); @patch set _entry(void Function() value) => throw UnsupportedError("_Coroutine._current"); @@ -50,7 +52,7 @@ class _Coroutine { @patch static _Coroutine? get _current => throw UnsupportedError("_Coroutine._current"); @patch - static _Coroutine _at(int index) => throw UnsupportedError("_Coroutine._initialize"); + static List<_Coroutine> get _registry => throw UnsupportedError("_Coroutine._current"); @patch static void _initialize(_Coroutine root) => throw UnsupportedError("_Coroutine._initialize"); @patch diff --git a/sdk/lib/fiber/fiber.dart b/sdk/lib/fiber/fiber.dart index 16f1d2d22068..921775d24687 100644 --- a/sdk/lib/fiber/fiber.dart +++ b/sdk/lib/fiber/fiber.dart @@ -3,8 +3,8 @@ library dart.fiber; part 'fiber_processor.dart'; part 'fiber_factory.dart'; -const _kDefaultStackSize = 128 * (1 << 10); -const _kSchedulerStackSize = 128 * (1 << 10); +const _kDefaultStackSize = 512 * (1 << 10); +const _kSchedulerStackSize = 256 * (1 << 10); const _kMainFiber = "main"; const _kSchedulerFiber = "scheduler"; @@ -16,6 +16,8 @@ const _kFiberFinished = 1 << 3; const _kFiberDisposed = 1 << 4; const _kFiberPersistent = 1 << 5; +enum FiberStateKind { created, running, suspended, finished, disposed, unknown } + extension type FiberState(int _state) { @pragma("vm:prefer-inline") bool get created => _state & _kFiberCreated != 0; @@ -35,13 +37,14 @@ extension type FiberState(int _state) { @pragma("vm:prefer-inline") int get value => _state; - String string() { - if (created) return "created"; - if (running) return "running"; - if (suspended) return "suspended"; - if (finished) return "finished"; - if (disposed) return "disposed"; - return "unknown"; + @pragma("vm:prefer-inline") + FiberStateKind get kind { + if (created) return FiberStateKind.created; + if (running) return FiberStateKind.running; + if (suspended) return FiberStateKind.suspended; + if (finished) return FiberStateKind.finished; + if (disposed) return FiberStateKind.disposed; + return FiberStateKind.unknown; } } @@ -80,79 +83,39 @@ extension type FiberArgument(Object? _argument) { Map? get asMap => _argument == null ? {} : _argument as Map; } -class _Coroutine { - external factory _Coroutine._(int size, Function trampoline); - - external String get _name; - external set _name(String value); - - external int get _index; - - external void Function() get _entry; - external set _entry(void Function() value); - - external void Function() get _trampoline; - external set _trampoline(void Function() value); - - external Object? get _argument; - external set _argument(Object? value); - - external int get _attributes; - external set _attributes(int value); - - external _Coroutine get _caller; - external set _caller(_Coroutine value); - - external _Coroutine get _scheduler; - external set _scheduler(_Coroutine value); - - external _FiberProcessor get _processor; - external set _processor(_FiberProcessor value); - - external _Coroutine get _toProcessorNext; - external set _toProcessorNext(_Coroutine value); - - external _Coroutine get _toProcessorPrevious; - external set _toProcessorPrevious(_Coroutine value); - - external static _Coroutine? get _current; - - external static _Coroutine _at(int index); - external static void _initialize(_Coroutine root); - external static void _transfer(_Coroutine from, _Coroutine to); - external static void _fork(_Coroutine from, _Coroutine to); +extension type FiberRegistry(List<_Coroutine> _registry) { + @pragma("vm:prefer-inline") + int get length => _registry.length; } extension type Fiber(_Coroutine _coroutine) implements _Coroutine { @pragma("vm:prefer-inline") - static void launch( + factory Fiber.child( void Function() entry, { - bool terminate = false, + bool persistent = false, int size = _kDefaultStackSize, - void Function()? idle, + String? name, Object? argument, }) => - _FiberProcessor(idle: idle)._process( + _FiberFactory._child( entry, argument: argument, - terminate: terminate, size: size, + name: name, + persistent: persistent, ); @pragma("vm:prefer-inline") - factory Fiber.child( + static Fiber launch( void Function() entry, { - bool persistent = false, int size = _kDefaultStackSize, - String? name, + void Function()? idle, Object? argument, }) => - _FiberFactory._child( + _FiberProcessor(idle)._process( entry, argument: argument, size: size, - name: name, - persistent: persistent, ); @pragma("vm:prefer-inline") @@ -176,7 +139,7 @@ extension type Fiber(_Coroutine _coroutine) implements _Coroutine { @pragma("vm:prefer-inline") static void fork(Fiber callee) { - final caller = Fiber.current(); + final caller = Fiber.current; assert(callee.state.created || callee.state.finished); callee._caller = caller; caller._attributes = (caller._attributes & ~_kFiberRunning) | _kFiberSuspended; @@ -186,45 +149,46 @@ extension type Fiber(_Coroutine _coroutine) implements _Coroutine { @pragma("vm:prefer-inline") static void suspend() { - final caller = Fiber.current(); + final caller = Fiber.current; final callee = Fiber(caller._caller); assert(callee.state.suspended || identical(callee, caller!._scheduler)); caller._caller = caller._scheduler; - caller._attributes = (caller._attributes & ~_kFiberRunning) | _kFiberSuspended; - callee._attributes = (callee._attributes & ~_kFiberSuspended) | _kFiberRunning; _Coroutine._transfer(caller, callee); } @pragma("vm:prefer-inline") - static Fiber current() { + static Fiber get current { final current = _Coroutine._current; assert(current != null); return Fiber(current!); } + @pragma("vm:prefer-inline") + static FiberRegistry get registry => FiberRegistry(_Coroutine._registry); + @pragma("vm:prefer-inline") static void schedule(Fiber fiber) { assert(fiber.state.suspended || fiber.state.running); - Fiber.current()._processor._schedule(fiber); + Fiber.current._processor._schedule(fiber); } @pragma("vm:prefer-inline") static void reschedule() { - Fiber.schedule(Fiber.current()); + Fiber.schedule(Fiber.current); Fiber.suspend(); } @pragma("vm:prefer-inline") static void terminate() { - Fiber.current()._processor._stop(); + Fiber.current._processor._stop(); Fiber.suspend(); } @pragma("vm:prefer-inline") - static Fiber at(int index) => Fiber(_Coroutine._at(index)); + int get index => _coroutine._index; @pragma("vm:prefer-inline") - int get index => _coroutine._index; + int get size => _coroutine._size; @pragma("vm:prefer-inline") String get name => _coroutine._name; @@ -241,3 +205,51 @@ extension type Fiber(_Coroutine _coroutine) implements _Coroutine { @pragma("vm:never-inline") static void _run() => _Coroutine._current!._entry(); } + +class _Coroutine { + external factory _Coroutine._(int size, Function trampoline); + + external String get _name; + external set _name(String value); + + external int get _index; + + external int get _size; + + external void Function() get _entry; + external set _entry(void Function() value); + + external void Function() get _trampoline; + external set _trampoline(void Function() value); + + external Object? get _argument; + external set _argument(Object? value); + + external int get _attributes; + external set _attributes(int value); + + external _Coroutine get _caller; + external set _caller(_Coroutine value); + + external _Coroutine get _scheduler; + external set _scheduler(_Coroutine value); + + external _FiberProcessor get _processor; + external set _processor(_FiberProcessor value); + + external _Coroutine get _toProcessorNext; + external set _toProcessorNext(_Coroutine value); + + external _Coroutine get _toProcessorPrevious; + external set _toProcessorPrevious(_Coroutine value); + + external static _Coroutine? get _current; + + external static List<_Coroutine> get _registry; + + external static void _initialize(_Coroutine root); + + external static void _transfer(_Coroutine from, _Coroutine to); + + external static void _fork(_Coroutine from, _Coroutine to); +} diff --git a/sdk/lib/fiber/fiber_factory.dart b/sdk/lib/fiber/fiber_factory.dart index 4bd30afab0c6..94db1e827e99 100644 --- a/sdk/lib/fiber/fiber_factory.dart +++ b/sdk/lib/fiber/fiber_factory.dart @@ -5,7 +5,7 @@ class _FiberFactory { static Fiber _scheduler(_FiberProcessor processor) { final coroutine = _Coroutine._(_kSchedulerStackSize, Fiber._run); coroutine._name = _kSchedulerFiber; - coroutine._entry = _FiberProcessor._loop; + coroutine._entry = processor._idle == null ? _FiberProcessor._loopFinite : _FiberProcessor._loopInfinite; coroutine._processor = processor; coroutine._attributes = _kFiberCreated; return Fiber(coroutine); @@ -37,7 +37,7 @@ class _FiberFactory { bool persistent = false, String? name, }) { - final current = Fiber.current(); + final current = Fiber.current; final coroutine = _Coroutine._(size, Fiber._run); coroutine._name = name ?? entry.toString(); coroutine._entry = entry; diff --git a/sdk/lib/fiber/fiber_processor.dart b/sdk/lib/fiber/fiber_processor.dart index 108cd47b9b35..a554b5a271c2 100644 --- a/sdk/lib/fiber/fiber_processor.dart +++ b/sdk/lib/fiber/fiber_processor.dart @@ -43,53 +43,68 @@ extension type _FiberProcessorLink(_Coroutine _coroutine) { } class _FiberProcessor { - late final void Function() _idle; + final void Function()? _idle; late final _FiberProcessorLink _scheduled; late final Fiber _scheduler; late void Function() _entry; - late bool _terminate; var _running = false; bool get running => _running; - static void _defaultIdle() => throw StateError("There are no scheduled fibers and FiberProcessor idle function is not defined"); + _FiberProcessor(void Function()? idle) : _idle = idle; - _FiberProcessor({void Function()? idle}) { - _idle = idle ?? _defaultIdle; - _scheduler = _FiberFactory._scheduler(this); - _scheduled = _FiberProcessorLink(_scheduler); - _FiberProcessorLink._create(_scheduler); - } - - void _process( + Fiber _process( void Function() entry, { int size = _kDefaultStackSize, - bool terminate = false, Object? argument, }) { if (_running) throw StateError("FiberProcessor is running"); - _terminate = terminate; _entry = entry; - _schedule(_FiberFactory._main(this, _main, argument: argument, size: size)); + _scheduler = _FiberFactory._scheduler(this); + _scheduled = _FiberProcessorLink(_scheduler); + _FiberProcessorLink._create(_scheduler); + final fiber = _FiberFactory._main(this, _main, argument: argument, size: size); + _schedule(fiber); _running = true; _Coroutine._initialize(_scheduler); _running = false; + return fiber; } @pragma("vm:never-inline") static void _main() { - final processor = Fiber.current()._processor; + final processor = Fiber.current._processor; processor._entry(); - if (processor._terminate && processor._running) Fiber.terminate(); + if (processor._idle == null && processor._running) Fiber.terminate(); + } + + @pragma("vm:never-inline") + static void _loopFinite() { + final scheduler = Fiber.current; + final processor = scheduler._processor; + final scheduled = processor._scheduled; + Fiber.fork(Fiber(scheduled._removeHead()._coroutine)); + if (scheduled._isEmpty || !processor._running) return; + for (;;) { + var last = Fiber(scheduled._removeHead()._coroutine); + var first = last; + while (!scheduled._isEmpty) { + last._caller = Fiber(scheduled._removeHead()._coroutine); + last = Fiber(last._caller); + } + last._caller = scheduler; + _Coroutine._transfer(scheduler, first); + if (!processor._running || scheduled._isEmpty) return; + } } @pragma("vm:never-inline") - static void _loop() { - final scheduler = Fiber.current(); + static void _loopInfinite() { + final scheduler = Fiber.current; final processor = scheduler._processor; final scheduled = processor._scheduled; - final idle = processor._idle; + final idle = processor._idle!; Fiber.fork(Fiber(scheduled._removeHead()._coroutine)); if (scheduled._isEmpty || !processor._running) return; for (;;) { @@ -100,15 +115,11 @@ class _FiberProcessor { last = Fiber(last._caller); } last._caller = scheduler; - scheduler._attributes = (scheduler._attributes & ~_kFiberRunning) | _kFiberSuspended; - first._attributes = (first._attributes & ~_kFiberSuspended) | _kFiberRunning; _Coroutine._transfer(scheduler, first); if (!processor._running) return; if (scheduled._isEmpty) { idle(); - if (!processor._running) { - return; - } + if (!processor._running) return; if (scheduled._isEmpty) throw StateError("There are no scheduled fibers after idle"); } } diff --git a/test-sdk-deug.sh b/test-sdk-deug.sh new file mode 100755 index 000000000000..07cda536fd5b --- /dev/null +++ b/test-sdk-deug.sh @@ -0,0 +1,4 @@ +#!/bin/bash +export CPATH="" +./tools/build.py -m debug -a x64 runtime dart_precompiled_runtime ddc dartanalyzer analysis_server create_common_sdk create_platform_sdk +out/DebugX64/run_vm_tests Coroutine_test \ No newline at end of file