Version 2.17.0-202.0.dev

Merge commit 'a48d05c8f98513b3ba4d3ee178fcda4d871b8844' into 'dev'
diff --git a/pkg/analyzer/lib/src/fasta/ast_builder.dart b/pkg/analyzer/lib/src/fasta/ast_builder.dart
index 18f6f4c..66b1e0f 100644
--- a/pkg/analyzer/lib/src/fasta/ast_builder.dart
+++ b/pkg/analyzer/lib/src/fasta/ast_builder.dart
@@ -2146,8 +2146,8 @@
     }
     var withClause = pop(NullValue.WithClause) as WithClause;
     var superclass = pop() as NamedType;
-    var macroKeyword = pop(NullValue.Token) as Token?;
     var augmentKeyword = pop(NullValue.Token) as Token?;
+    var macroKeyword = pop(NullValue.Token) as Token?;
     var modifiers = pop() as _Modifiers?;
     var typeParameters = pop() as TypeParameterList?;
     var name = pop() as SimpleIdentifier;
@@ -2750,8 +2750,8 @@
     var implementsClause = pop(NullValue.IdentifierList) as ImplementsClause?;
     var withClause = pop(NullValue.WithClause) as WithClause?;
     var extendsClause = pop(NullValue.ExtendsClause) as ExtendsClause?;
-    var macroKeyword = pop(NullValue.Token) as Token?;
     var augmentKeyword = pop(NullValue.Token) as Token?;
+    var macroKeyword = pop(NullValue.Token) as Token?;
     var modifiers = pop() as _Modifiers?;
     var typeParameters = pop() as TypeParameterList?;
     var name = pop() as SimpleIdentifier;
diff --git a/pkg/analyzer/test/src/dart/ast/to_source_visitor_test.dart b/pkg/analyzer/test/src/dart/ast/to_source_visitor_test.dart
index 17ba251..bb1b5fb 100644
--- a/pkg/analyzer/test/src/dart/ast/to_source_visitor_test.dart
+++ b/pkg/analyzer/test/src/dart/ast/to_source_visitor_test.dart
@@ -225,11 +225,15 @@
     _assertSource("abstract macro class C {}", declaration);
   }
 
+  @FailingTest(issue: 'https://github.com/dart-lang/sdk/issues/48541')
   void test_visitClassDeclaration_augment() {
-    ClassDeclaration declaration = AstTestFactory.classDeclaration(
-        null, "C", null, null, null, null,
-        isAugmentation: true);
-    _assertSource("augment class C {}", declaration);
+    var findNode = _parseStringToFindNode(r'''
+augment class A {}
+''');
+    _assertSource(
+      'augment class A {}',
+      findNode.classDeclaration('class A'),
+    );
   }
 
   void test_visitClassDeclaration_empty() {
@@ -293,10 +297,13 @@
   }
 
   void test_visitClassDeclaration_macro() {
-    ClassDeclaration declaration = AstTestFactory.classDeclaration(
-        null, "C", null, null, null, null,
-        isMacro: true);
-    _assertSource("macro class C {}", declaration);
+    var findNode = _parseStringToFindNode(r'''
+macro class A {}
+''');
+    _assertSource(
+      'macro class A {}',
+      findNode.classDeclaration('class A'),
+    );
   }
 
   void test_visitClassDeclaration_multipleMember() {
@@ -446,17 +453,15 @@
             isMacro: true));
   }
 
+  @FailingTest(issue: 'https://github.com/dart-lang/sdk/issues/48541')
   void test_visitClassTypeAlias_augment() {
+    var findNode = _parseStringToFindNode(r'''
+augment class A = S with M;
+''');
     _assertSource(
-        "augment class C = S with M1;",
-        AstTestFactory.classTypeAlias(
-            "C",
-            null,
-            null,
-            AstTestFactory.namedType4("S"),
-            AstTestFactory.withClause([AstTestFactory.namedType4("M1")]),
-            null,
-            isAugmentation: true));
+      'augment class A = S with M;',
+      findNode.classTypeAlias('class A'),
+    );
   }
 
   void test_visitClassTypeAlias_generic() {
@@ -486,16 +491,13 @@
   }
 
   void test_visitClassTypeAlias_macro() {
+    var findNode = _parseStringToFindNode(r'''
+macro class A = S with M;
+''');
     _assertSource(
-        "macro class C = S with M1;",
-        AstTestFactory.classTypeAlias(
-            "C",
-            null,
-            null,
-            AstTestFactory.namedType4("S"),
-            AstTestFactory.withClause([AstTestFactory.namedType4("M1")]),
-            null,
-            isMacro: true));
+      'macro class A = S with M;',
+      findNode.classTypeAlias('class A'),
+    );
   }
 
   void test_visitClassTypeAlias_minimal() {
diff --git a/pkg/analyzer/test/src/fasta/ast_builder_test.dart b/pkg/analyzer/test/src/fasta/ast_builder_test.dart
index 82198f5..8c4659e 100644
--- a/pkg/analyzer/test/src/fasta/ast_builder_test.dart
+++ b/pkg/analyzer/test/src/fasta/ast_builder_test.dart
@@ -15,6 +15,71 @@
 
 @reflectiveTest
 class AstBuilderTest extends ParserDiagnosticsTest {
+  @FailingTest(issue: 'https://github.com/dart-lang/sdk/issues/48541')
+  void test_class_augment() {
+    var parseResult = parseStringWithErrors(r'''
+augment class A {}
+''');
+    parseResult.assertNoErrors();
+
+    var node = parseResult.findNode.classDeclaration('class A {}');
+    assertParsedNodeText(node, r'''
+ClassDeclaration
+  augmentKeyword: augment
+  classKeyword: class
+  name: SimpleIdentifier
+    token: A
+  leftBracket: {
+  rightBracket: }
+''');
+  }
+
+  void test_class_macro() {
+    var parseResult = parseStringWithErrors(r'''
+macro class A {}
+''');
+    parseResult.assertNoErrors();
+
+    var node = parseResult.findNode.classDeclaration('class A {}');
+    assertParsedNodeText(node, r'''
+ClassDeclaration
+  macroKeyword: macro
+  classKeyword: class
+  name: SimpleIdentifier
+    token: A
+  leftBracket: {
+  rightBracket: }
+''');
+  }
+
+  void test_classAlias_macro() {
+    var parseResult = parseStringWithErrors(r'''
+mixin M {}
+macro class A = Object with M;
+''');
+    parseResult.assertNoErrors();
+
+    var node = parseResult.findNode.classTypeAlias('class A');
+    assertParsedNodeText(node, r'''
+ClassTypeAlias
+  typedefKeyword: class
+  name: SimpleIdentifier
+    token: A
+  equals: =
+  macroKeyword: macro
+  superclass: NamedType
+    name: SimpleIdentifier
+      token: Object
+  withClause: WithClause
+    withKeyword: with
+    mixinTypes
+      NamedType
+        name: SimpleIdentifier
+          token: M
+  semicolon: ;
+''');
+  }
+
   void test_constructor_factory_misnamed() {
     var parseResult = parseStringWithErrors(r'''
 class A {
diff --git a/pkg/analyzer/test/src/summary/resolved_ast_printer.dart b/pkg/analyzer/test/src/summary/resolved_ast_printer.dart
index f8a4382c..5f96163 100644
--- a/pkg/analyzer/test/src/summary/resolved_ast_printer.dart
+++ b/pkg/analyzer/test/src/summary/resolved_ast_printer.dart
@@ -199,6 +199,17 @@
   }
 
   @override
+  void visitClassTypeAlias(ClassTypeAlias node) {
+    _writeln('ClassTypeAlias');
+    _withIndent(() {
+      _writeNamedChildEntities(node);
+      if (_withResolution) {
+        _writeElement('declaredElement', node.declaredElement);
+      }
+    });
+  }
+
+  @override
   void visitComment(Comment node) {
     _writeln('Comment');
     _withIndent(() {
diff --git a/pkg/analyzer/test/src/summary/resynthesize_common.dart b/pkg/analyzer/test/src/summary/resynthesize_common.dart
index d4e691d..edd5540 100644
--- a/pkg/analyzer/test/src/summary/resynthesize_common.dart
+++ b/pkg/analyzer/test/src/summary/resynthesize_common.dart
@@ -31,7 +31,6 @@
   late final SourceFactory sourceFactory;
   late final FolderBasedDartSdk sdk;
 
-  late String testFile;
   late Source testSource;
   Set<Source> otherLibrarySources = <Source>{};
 
@@ -54,10 +53,14 @@
         ResourceUriResolver(resourceProvider),
       ],
     );
-
-    testFile = convertPath('/test.dart');
   }
 
+  String get testFilePath => '$testPackageLibPath/test.dart';
+
+  String get testPackageLibPath => '$testPackageRootPath/lib';
+
+  String get testPackageRootPath => '/home/test';
+
   void addLibrary(String uri) {
     var source = sourceFactory.forUri(uri)!;
     otherLibrarySources.add(source);
@@ -76,7 +79,7 @@
   }
 
   Source addTestSource(String code, [Uri? uri]) {
-    testSource = addSource(testFile, code);
+    testSource = addSource(testFilePath, code);
     return testSource;
   }
 
@@ -2013,7 +2016,7 @@
   }
 
   test_class_constructor_redirected_factory_named_imported() async {
-    addLibrarySource('/foo.dart', '''
+    addLibrarySource('$testPackageLibPath/foo.dart', '''
 import 'test.dart';
 class D extends C {
   D.named() : super._();
@@ -2029,13 +2032,13 @@
     checkElementText(library, r'''
 library
   imports
-    foo.dart
+    package:test/foo.dart
   definingUnit
     classes
       class C @25
         constructors
           factory @39
-            redirectedConstructor: foo.dart::@class::D::@constructor::named
+            redirectedConstructor: package:test/foo.dart::@class::D::@constructor::named
           _ @58
             periodOffset: 57
             nameEnd: 59
@@ -2043,7 +2046,7 @@
   }
 
   test_class_constructor_redirected_factory_named_imported_generic() async {
-    addLibrarySource('/foo.dart', '''
+    addLibrarySource('$testPackageLibPath/foo.dart', '''
 import 'test.dart';
 class D<T, U> extends C<U, T> {
   D.named() : super._();
@@ -2059,7 +2062,7 @@
     checkElementText(library, r'''
 library
   imports
-    foo.dart
+    package:test/foo.dart
   definingUnit
     classes
       class C @25
@@ -2071,7 +2074,7 @@
         constructors
           factory @45
             redirectedConstructor: ConstructorMember
-              base: foo.dart::@class::D::@constructor::named
+              base: package:test/foo.dart::@class::D::@constructor::named
               substitution: {T: U, U: T}
           _ @70
             periodOffset: 69
@@ -2080,7 +2083,7 @@
   }
 
   test_class_constructor_redirected_factory_named_prefixed() async {
-    addLibrarySource('/foo.dart', '''
+    addLibrarySource('$testPackageLibPath/foo.dart', '''
 import 'test.dart';
 class D extends C {
   D.named() : super._();
@@ -2096,13 +2099,13 @@
     checkElementText(library, r'''
 library
   imports
-    foo.dart as foo @21
+    package:test/foo.dart as foo @21
   definingUnit
     classes
       class C @32
         constructors
           factory @46
-            redirectedConstructor: foo.dart::@class::D::@constructor::named
+            redirectedConstructor: package:test/foo.dart::@class::D::@constructor::named
           _ @69
             periodOffset: 68
             nameEnd: 70
@@ -2110,7 +2113,7 @@
   }
 
   test_class_constructor_redirected_factory_named_prefixed_generic() async {
-    addLibrarySource('/foo.dart', '''
+    addLibrarySource('$testPackageLibPath/foo.dart', '''
 import 'test.dart';
 class D<T, U> extends C<U, T> {
   D.named() : super._();
@@ -2126,7 +2129,7 @@
     checkElementText(library, r'''
 library
   imports
-    foo.dart as foo @21
+    package:test/foo.dart as foo @21
   definingUnit
     classes
       class C @32
@@ -2138,7 +2141,7 @@
         constructors
           factory @52
             redirectedConstructor: ConstructorMember
-              base: foo.dart::@class::D::@constructor::named
+              base: package:test/foo.dart::@class::D::@constructor::named
               substitution: {T: U, U: T}
           _ @81
             periodOffset: 80
@@ -2310,7 +2313,7 @@
   }
 
   test_class_constructor_redirected_factory_unnamed_imported() async {
-    addLibrarySource('/foo.dart', '''
+    addLibrarySource('$testPackageLibPath/foo.dart', '''
 import 'test.dart';
 class D extends C {
   D() : super._();
@@ -2326,13 +2329,13 @@
     checkElementText(library, r'''
 library
   imports
-    foo.dart
+    package:test/foo.dart
   definingUnit
     classes
       class C @25
         constructors
           factory @39
-            redirectedConstructor: foo.dart::@class::D::@constructor::•
+            redirectedConstructor: package:test/foo.dart::@class::D::@constructor::•
           _ @52
             periodOffset: 51
             nameEnd: 53
@@ -2340,7 +2343,7 @@
   }
 
   test_class_constructor_redirected_factory_unnamed_imported_generic() async {
-    addLibrarySource('/foo.dart', '''
+    addLibrarySource('$testPackageLibPath/foo.dart', '''
 import 'test.dart';
 class D<T, U> extends C<U, T> {
   D() : super._();
@@ -2356,7 +2359,7 @@
     checkElementText(library, r'''
 library
   imports
-    foo.dart
+    package:test/foo.dart
   definingUnit
     classes
       class C @25
@@ -2368,7 +2371,7 @@
         constructors
           factory @45
             redirectedConstructor: ConstructorMember
-              base: foo.dart::@class::D::@constructor::•
+              base: package:test/foo.dart::@class::D::@constructor::•
               substitution: {T: U, U: T}
           _ @64
             periodOffset: 63
@@ -2377,7 +2380,7 @@
   }
 
   test_class_constructor_redirected_factory_unnamed_imported_viaTypeAlias() async {
-    addLibrarySource('/foo.dart', '''
+    addLibrarySource('$testPackageLibPath/foo.dart', '''
 import 'test.dart';
 typedef A = B;
 class B extends C {
@@ -2394,13 +2397,13 @@
     checkElementText(library, r'''
 library
   imports
-    foo.dart
+    package:test/foo.dart
   definingUnit
     classes
       class C @25
         constructors
           factory @39
-            redirectedConstructor: foo.dart::@class::B::@constructor::•
+            redirectedConstructor: package:test/foo.dart::@class::B::@constructor::•
           _ @52
             periodOffset: 51
             nameEnd: 53
@@ -2408,7 +2411,7 @@
   }
 
   test_class_constructor_redirected_factory_unnamed_prefixed() async {
-    addLibrarySource('/foo.dart', '''
+    addLibrarySource('$testPackageLibPath/foo.dart', '''
 import 'test.dart';
 class D extends C {
   D() : super._();
@@ -2424,13 +2427,13 @@
     checkElementText(library, r'''
 library
   imports
-    foo.dart as foo @21
+    package:test/foo.dart as foo @21
   definingUnit
     classes
       class C @32
         constructors
           factory @46
-            redirectedConstructor: foo.dart::@class::D::@constructor::•
+            redirectedConstructor: package:test/foo.dart::@class::D::@constructor::•
           _ @63
             periodOffset: 62
             nameEnd: 64
@@ -2438,7 +2441,7 @@
   }
 
   test_class_constructor_redirected_factory_unnamed_prefixed_generic() async {
-    addLibrarySource('/foo.dart', '''
+    addLibrarySource('$testPackageLibPath/foo.dart', '''
 import 'test.dart';
 class D<T, U> extends C<U, T> {
   D() : super._();
@@ -2454,7 +2457,7 @@
     checkElementText(library, r'''
 library
   imports
-    foo.dart as foo @21
+    package:test/foo.dart as foo @21
   definingUnit
     classes
       class C @32
@@ -2466,7 +2469,7 @@
         constructors
           factory @52
             redirectedConstructor: ConstructorMember
-              base: foo.dart::@class::D::@constructor::•
+              base: package:test/foo.dart::@class::D::@constructor::•
               substitution: {T: U, U: T}
           _ @75
             periodOffset: 74
@@ -2475,7 +2478,7 @@
   }
 
   test_class_constructor_redirected_factory_unnamed_prefixed_viaTypeAlias() async {
-    addLibrarySource('/foo.dart', '''
+    addLibrarySource('$testPackageLibPath/foo.dart', '''
 import 'test.dart';
 typedef A = B;
 class B extends C {
@@ -2492,13 +2495,13 @@
     checkElementText(library, r'''
 library
   imports
-    foo.dart as foo @21
+    package:test/foo.dart as foo @21
   definingUnit
     classes
       class C @32
         constructors
           factory @46
-            redirectedConstructor: foo.dart::@class::B::@constructor::•
+            redirectedConstructor: package:test/foo.dart::@class::B::@constructor::•
           _ @63
             periodOffset: 62
             nameEnd: 64
@@ -3967,7 +3970,7 @@
   }
 
   test_class_field_propagatedType_final_dep_inLib() async {
-    addLibrarySource('/a.dart', 'final a = 1;');
+    addLibrarySource('$testPackageLibPath/a.dart', 'final a = 1;');
     var library = await checkLibrary('''
 import "a.dart";
 class C {
@@ -3976,7 +3979,7 @@
     checkElementText(library, r'''
 library
   imports
-    a.dart
+    package:test/a.dart
   definingUnit
     classes
       class C @23
@@ -3992,7 +3995,7 @@
   }
 
   test_class_field_propagatedType_final_dep_inPart() async {
-    addSource('/a.dart', 'part of lib; final a = 1;');
+    addSource('$testPackageLibPath/a.dart', 'part of lib; final a = 1;');
     var library = await checkLibrary('''
 library lib;
 part "a.dart";
@@ -4183,7 +4186,7 @@
   }
 
   test_class_field_type_inferred_nonNullify() async {
-    addSource('/a.dart', '''
+    addSource('$testPackageLibPath/a.dart', '''
 // @dart = 2.7
 var a = 0;
 ''');
@@ -4198,7 +4201,7 @@
     checkElementText(library, r'''
 library
   imports
-    a.dart
+    package:test/a.dart
   definingUnit
     classes
       class C @23
@@ -7199,8 +7202,7 @@
   }
 
   test_classAlias_with_const_constructors() async {
-    testFile = convertPath('/home/test/lib/test.dart');
-    addLibrarySource('/home/test/lib/a.dart', r'''
+    addLibrarySource('$testPackageLibPath/a.dart', r'''
 class Base {
   const Base._priv();
   const Base();
@@ -7253,8 +7255,7 @@
   }
 
   test_classAlias_with_forwarding_constructors() async {
-    testFile = convertPath('/home/test/lib/test.dart');
-    addLibrarySource('/home/test/lib/a.dart', r'''
+    addLibrarySource('$testPackageLibPath/a.dart', r'''
 class Base {
   bool x = true;
   Base._priv();
@@ -7685,7 +7686,8 @@
   }
 
   test_closure_in_variable_declaration_in_part() async {
-    addSource('/a.dart', 'part of lib; final f = (int i) => i.toDouble();');
+    addSource('$testPackageLibPath/a.dart',
+        'part of lib; final f = (int i) => i.toDouble();');
     var library = await checkLibrary('''
 library lib;
 part "a.dart";
@@ -10625,7 +10627,7 @@
   }
 
   test_const_invokeConstructor_generic_named_imported() async {
-    addLibrarySource('/a.dart', r'''
+    addLibrarySource('$testPackageLibPath/a.dart', r'''
 class C<K, V> {
   const C.named(K k, V v);
 }
@@ -10637,7 +10639,7 @@
     checkElementText(library, r'''
 library
   imports
-    a.dart
+    package:test/a.dart
   definingUnit
     topLevelVariables
       static const V @23
@@ -10649,7 +10651,7 @@
               type: NamedType
                 name: SimpleIdentifier
                   token: C @33
-                  staticElement: a.dart::@class::C
+                  staticElement: package:test/a.dart::@class::C
                   staticType: null
                 typeArguments: TypeArgumentList
                   leftBracket: < @34
@@ -10672,11 +10674,11 @@
               name: SimpleIdentifier
                 token: named @48
                 staticElement: ConstructorMember
-                  base: a.dart::@class::C::@constructor::named
+                  base: package:test/a.dart::@class::C::@constructor::named
                   substitution: {K: int, V: String}
                 staticType: null
               staticElement: ConstructorMember
-                base: a.dart::@class::C::@constructor::named
+                base: package:test/a.dart::@class::C::@constructor::named
                 substitution: {K: int, V: String}
             argumentList: ArgumentList
               leftParenthesis: ( @53
@@ -10695,7 +10697,7 @@
   }
 
   test_const_invokeConstructor_generic_named_imported_withPrefix() async {
-    addLibrarySource('/a.dart', r'''
+    addLibrarySource('$testPackageLibPath/a.dart', r'''
 class C<K, V> {
   const C.named(K k, V v);
 }
@@ -10707,7 +10709,7 @@
     checkElementText(library, r'''
 library
   imports
-    a.dart as p @19
+    package:test/a.dart as p @19
   definingUnit
     topLevelVariables
       static const V @28
@@ -10725,9 +10727,9 @@
                   period: . @39
                   identifier: SimpleIdentifier
                     token: C @40
-                    staticElement: a.dart::@class::C
+                    staticElement: package:test/a.dart::@class::C
                     staticType: null
-                  staticElement: a.dart::@class::C
+                  staticElement: package:test/a.dart::@class::C
                   staticType: null
                 typeArguments: TypeArgumentList
                   leftBracket: < @41
@@ -10750,11 +10752,11 @@
               name: SimpleIdentifier
                 token: named @55
                 staticElement: ConstructorMember
-                  base: a.dart::@class::C::@constructor::named
+                  base: package:test/a.dart::@class::C::@constructor::named
                   substitution: {K: int, V: String}
                 staticType: null
               staticElement: ConstructorMember
-                base: a.dart::@class::C::@constructor::named
+                base: package:test/a.dart::@class::C::@constructor::named
                 substitution: {K: int, V: String}
             argumentList: ArgumentList
               leftParenthesis: ( @60
@@ -10879,7 +10881,7 @@
   }
 
   test_const_invokeConstructor_generic_unnamed_imported() async {
-    addLibrarySource('/a.dart', r'''
+    addLibrarySource('$testPackageLibPath/a.dart', r'''
 class C<K, V> {
   const C();
 }
@@ -10891,7 +10893,7 @@
     checkElementText(library, r'''
 library
   imports
-    a.dart
+    package:test/a.dart
   definingUnit
     topLevelVariables
       static const V @23
@@ -10903,7 +10905,7 @@
               type: NamedType
                 name: SimpleIdentifier
                   token: C @33
-                  staticElement: a.dart::@class::C
+                  staticElement: package:test/a.dart::@class::C
                   staticType: null
                 typeArguments: TypeArgumentList
                   leftBracket: < @34
@@ -10923,7 +10925,7 @@
                   rightBracket: > @46
                 type: C<int, String>
               staticElement: ConstructorMember
-                base: a.dart::@class::C::@constructor::•
+                base: package:test/a.dart::@class::C::@constructor::•
                 substitution: {K: int, V: String}
             argumentList: ArgumentList
               leftParenthesis: ( @47
@@ -10936,7 +10938,7 @@
   }
 
   test_const_invokeConstructor_generic_unnamed_imported_withPrefix() async {
-    addLibrarySource('/a.dart', r'''
+    addLibrarySource('$testPackageLibPath/a.dart', r'''
 class C<K, V> {
   const C();
 }
@@ -10948,7 +10950,7 @@
     checkElementText(library, r'''
 library
   imports
-    a.dart as p @19
+    package:test/a.dart as p @19
   definingUnit
     topLevelVariables
       static const V @28
@@ -10966,9 +10968,9 @@
                   period: . @39
                   identifier: SimpleIdentifier
                     token: C @40
-                    staticElement: a.dart::@class::C
+                    staticElement: package:test/a.dart::@class::C
                     staticType: null
-                  staticElement: a.dart::@class::C
+                  staticElement: package:test/a.dart::@class::C
                   staticType: null
                 typeArguments: TypeArgumentList
                   leftBracket: < @41
@@ -10988,7 +10990,7 @@
                   rightBracket: > @53
                 type: C<int, String>
               staticElement: ConstructorMember
-                base: a.dart::@class::C::@constructor::•
+                base: package:test/a.dart::@class::C::@constructor::•
                 substitution: {K: int, V: String}
             argumentList: ArgumentList
               leftParenthesis: ( @54
@@ -11086,7 +11088,7 @@
   }
 
   test_const_invokeConstructor_named_imported() async {
-    addLibrarySource('/a.dart', r'''
+    addLibrarySource('$testPackageLibPath/a.dart', r'''
 class C {
   const C.named();
 }
@@ -11098,7 +11100,7 @@
     checkElementText(library, r'''
 library
   imports
-    a.dart
+    package:test/a.dart
   definingUnit
     topLevelVariables
       static const V @23
@@ -11110,15 +11112,15 @@
               type: NamedType
                 name: SimpleIdentifier
                   token: C @33
-                  staticElement: a.dart::@class::C
+                  staticElement: package:test/a.dart::@class::C
                   staticType: null
                 type: C
               period: . @34
               name: SimpleIdentifier
                 token: named @35
-                staticElement: a.dart::@class::C::@constructor::named
+                staticElement: package:test/a.dart::@class::C::@constructor::named
                 staticType: null
-              staticElement: a.dart::@class::C::@constructor::named
+              staticElement: package:test/a.dart::@class::C::@constructor::named
             argumentList: ArgumentList
               leftParenthesis: ( @40
               rightParenthesis: ) @41
@@ -11130,7 +11132,7 @@
   }
 
   test_const_invokeConstructor_named_imported_withPrefix() async {
-    addLibrarySource('/a.dart', r'''
+    addLibrarySource('$testPackageLibPath/a.dart', r'''
 class C {
   const C.named();
 }
@@ -11142,7 +11144,7 @@
     checkElementText(library, r'''
 library
   imports
-    a.dart as p @19
+    package:test/a.dart as p @19
   definingUnit
     topLevelVariables
       static const V @28
@@ -11160,17 +11162,17 @@
                   period: . @39
                   identifier: SimpleIdentifier
                     token: C @40
-                    staticElement: a.dart::@class::C
+                    staticElement: package:test/a.dart::@class::C
                     staticType: null
-                  staticElement: a.dart::@class::C
+                  staticElement: package:test/a.dart::@class::C
                   staticType: null
                 type: C
               period: . @41
               name: SimpleIdentifier
                 token: named @42
-                staticElement: a.dart::@class::C::@constructor::named
+                staticElement: package:test/a.dart::@class::C::@constructor::named
                 staticType: null
-              staticElement: a.dart::@class::C::@constructor::named
+              staticElement: package:test/a.dart::@class::C::@constructor::named
             argumentList: ArgumentList
               leftParenthesis: ( @47
               rightParenthesis: ) @48
@@ -11262,7 +11264,7 @@
   }
 
   test_const_invokeConstructor_named_unresolved3() async {
-    addLibrarySource('/a.dart', r'''
+    addLibrarySource('$testPackageLibPath/a.dart', r'''
 class C {
 }
 ''');
@@ -11273,7 +11275,7 @@
     checkElementText(library, r'''
 library
   imports
-    a.dart as p @19
+    package:test/a.dart as p @19
   definingUnit
     topLevelVariables
       static const V @28
@@ -11291,9 +11293,9 @@
                   period: . @39
                   identifier: SimpleIdentifier
                     token: C @40
-                    staticElement: a.dart::@class::C
+                    staticElement: package:test/a.dart::@class::C
                     staticType: null
-                  staticElement: a.dart::@class::C
+                  staticElement: package:test/a.dart::@class::C
                   staticType: null
                 type: C
               period: . @41
@@ -11313,7 +11315,7 @@
   }
 
   test_const_invokeConstructor_named_unresolved4() async {
-    addLibrarySource('/a.dart', '');
+    addLibrarySource('$testPackageLibPath/a.dart', '');
     var library = await checkLibrary(r'''
 import 'a.dart' as p;
 const V = const p.C.named();
@@ -11321,7 +11323,7 @@
     checkElementText(library, r'''
 library
   imports
-    a.dart as p @19
+    package:test/a.dart as p @19
   definingUnit
     topLevelVariables
       static const V @28
@@ -11487,7 +11489,7 @@
   }
 
   test_const_invokeConstructor_unnamed_imported() async {
-    addLibrarySource('/a.dart', r'''
+    addLibrarySource('$testPackageLibPath/a.dart', r'''
 class C {
   const C();
 }
@@ -11499,7 +11501,7 @@
     checkElementText(library, r'''
 library
   imports
-    a.dart
+    package:test/a.dart
   definingUnit
     topLevelVariables
       static const V @23
@@ -11511,10 +11513,10 @@
               type: NamedType
                 name: SimpleIdentifier
                   token: C @33
-                  staticElement: a.dart::@class::C
+                  staticElement: package:test/a.dart::@class::C
                   staticType: null
                 type: C
-              staticElement: a.dart::@class::C::@constructor::•
+              staticElement: package:test/a.dart::@class::C::@constructor::•
             argumentList: ArgumentList
               leftParenthesis: ( @34
               rightParenthesis: ) @35
@@ -11526,7 +11528,7 @@
   }
 
   test_const_invokeConstructor_unnamed_imported_withPrefix() async {
-    addLibrarySource('/a.dart', r'''
+    addLibrarySource('$testPackageLibPath/a.dart', r'''
 class C {
   const C();
 }
@@ -11538,7 +11540,7 @@
     checkElementText(library, r'''
 library
   imports
-    a.dart as p @19
+    package:test/a.dart as p @19
   definingUnit
     topLevelVariables
       static const V @28
@@ -11556,12 +11558,12 @@
                   period: . @39
                   identifier: SimpleIdentifier
                     token: C @40
-                    staticElement: a.dart::@class::C
+                    staticElement: package:test/a.dart::@class::C
                     staticType: null
-                  staticElement: a.dart::@class::C
+                  staticElement: package:test/a.dart::@class::C
                   staticType: null
                 type: C
-              staticElement: a.dart::@class::C::@constructor::•
+              staticElement: package:test/a.dart::@class::C::@constructor::•
             argumentList: ArgumentList
               leftParenthesis: ( @41
               rightParenthesis: ) @42
@@ -11604,7 +11606,7 @@
   }
 
   test_const_invokeConstructor_unnamed_unresolved2() async {
-    addLibrarySource('/a.dart', '');
+    addLibrarySource('$testPackageLibPath/a.dart', '');
     var library = await checkLibrary(r'''
 import 'a.dart' as p;
 const V = const p.C();
@@ -11612,7 +11614,7 @@
     checkElementText(library, r'''
 library
   imports
-    a.dart as p @19
+    package:test/a.dart as p @19
   definingUnit
     topLevelVariables
       static const V @28
@@ -11777,7 +11779,7 @@
   }
 
   test_const_length_ofClassConstField_imported() async {
-    addLibrarySource('/a.dart', r'''
+    addLibrarySource('$testPackageLibPath/a.dart', r'''
 class C {
   static const String F = '';
 }
@@ -11789,7 +11791,7 @@
     checkElementText(library, r'''
 library
   imports
-    a.dart
+    package:test/a.dart
   definingUnit
     topLevelVariables
       static const v @27
@@ -11799,14 +11801,14 @@
             target: PrefixedIdentifier
               prefix: SimpleIdentifier
                 token: C @31
-                staticElement: a.dart::@class::C
+                staticElement: package:test/a.dart::@class::C
                 staticType: null
               period: . @32
               identifier: SimpleIdentifier
                 token: F @33
-                staticElement: a.dart::@class::C::@getter::F
+                staticElement: package:test/a.dart::@class::C::@getter::F
                 staticType: String
-              staticElement: a.dart::@class::C::@getter::F
+              staticElement: package:test/a.dart::@class::C::@getter::F
               staticType: String
             operator: . @34
             propertyName: SimpleIdentifier
@@ -11821,7 +11823,7 @@
   }
 
   test_const_length_ofClassConstField_imported_withPrefix() async {
-    addLibrarySource('/a.dart', r'''
+    addLibrarySource('$testPackageLibPath/a.dart', r'''
 class C {
   static const String F = '';
 }
@@ -11833,7 +11835,7 @@
     checkElementText(library, r'''
 library
   imports
-    a.dart as p @19
+    package:test/a.dart as p @19
   definingUnit
     topLevelVariables
       static const v @32
@@ -11849,14 +11851,14 @@
                 period: . @37
                 identifier: SimpleIdentifier
                   token: C @38
-                  staticElement: a.dart::@class::C
+                  staticElement: package:test/a.dart::@class::C
                   staticType: null
-                staticElement: a.dart::@class::C
+                staticElement: package:test/a.dart::@class::C
                 staticType: null
               operator: . @39
               propertyName: SimpleIdentifier
                 token: F @40
-                staticElement: a.dart::@class::C::@getter::F
+                staticElement: package:test/a.dart::@class::C::@getter::F
                 staticType: String
               staticType: String
             operator: . @41
@@ -11935,7 +11937,7 @@
   }
 
   test_const_length_ofTopLevelVariable_imported() async {
-    addLibrarySource('/a.dart', r'''
+    addLibrarySource('$testPackageLibPath/a.dart', r'''
 const String S = 'abc';
 ''');
     var library = await checkLibrary(r'''
@@ -11945,7 +11947,7 @@
     checkElementText(library, r'''
 library
   imports
-    a.dart
+    package:test/a.dart
   definingUnit
     topLevelVariables
       static const v @23
@@ -11954,7 +11956,7 @@
           PrefixedIdentifier
             prefix: SimpleIdentifier
               token: S @27
-              staticElement: a.dart::@getter::S
+              staticElement: package:test/a.dart::@getter::S
               staticType: String
             period: . @28
             identifier: SimpleIdentifier
@@ -11970,7 +11972,7 @@
   }
 
   test_const_length_ofTopLevelVariable_imported_withPrefix() async {
-    addLibrarySource('/a.dart', r'''
+    addLibrarySource('$testPackageLibPath/a.dart', r'''
 const String S = 'abc';
 ''');
     var library = await checkLibrary(r'''
@@ -11980,7 +11982,7 @@
     checkElementText(library, r'''
 library
   imports
-    a.dart as p @19
+    package:test/a.dart as p @19
   definingUnit
     topLevelVariables
       static const v @28
@@ -11995,9 +11997,9 @@
               period: . @33
               identifier: SimpleIdentifier
                 token: S @34
-                staticElement: a.dart::@getter::S
+                staticElement: package:test/a.dart::@getter::S
                 staticType: String
-              staticElement: a.dart::@getter::S
+              staticElement: package:test/a.dart::@getter::S
               staticType: String
             operator: . @35
             propertyName: SimpleIdentifier
@@ -12883,8 +12885,7 @@
   }
 
   test_const_prefixExpression_extension_unaryMinus() async {
-    testFile = convertPath('/home/test/lib/test.dart');
-    addLibrarySource('/home/test/lib/a.dart', r'''
+    addLibrarySource('$testPackageLibPath/a.dart', r'''
 extension E on Object {
   int operator -() => 0;
 }
@@ -13002,7 +13003,7 @@
   }
 
   test_const_reference_staticField_imported() async {
-    addLibrarySource('/a.dart', r'''
+    addLibrarySource('$testPackageLibPath/a.dart', r'''
 class C {
   static const int F = 42;
 }
@@ -13014,7 +13015,7 @@
     checkElementText(library, r'''
 library
   imports
-    a.dart
+    package:test/a.dart
   definingUnit
     topLevelVariables
       static const V @23
@@ -13023,14 +13024,14 @@
           PrefixedIdentifier
             prefix: SimpleIdentifier
               token: C @27
-              staticElement: a.dart::@class::C
+              staticElement: package:test/a.dart::@class::C
               staticType: null
             period: . @28
             identifier: SimpleIdentifier
               token: F @29
-              staticElement: a.dart::@class::C::@getter::F
+              staticElement: package:test/a.dart::@class::C::@getter::F
               staticType: int
-            staticElement: a.dart::@class::C::@getter::F
+            staticElement: package:test/a.dart::@class::C::@getter::F
             staticType: int
     accessors
       synthetic static get V @-1
@@ -13039,7 +13040,7 @@
   }
 
   test_const_reference_staticField_imported_withPrefix() async {
-    addLibrarySource('/a.dart', r'''
+    addLibrarySource('$testPackageLibPath/a.dart', r'''
 class C {
   static const int F = 42;
 }
@@ -13051,7 +13052,7 @@
     checkElementText(library, r'''
 library
   imports
-    a.dart as p @19
+    package:test/a.dart as p @19
   definingUnit
     topLevelVariables
       static const V @28
@@ -13066,14 +13067,14 @@
               period: . @33
               identifier: SimpleIdentifier
                 token: C @34
-                staticElement: a.dart::@class::C
+                staticElement: package:test/a.dart::@class::C
                 staticType: null
-              staticElement: a.dart::@class::C
+              staticElement: package:test/a.dart::@class::C
               staticType: null
             operator: . @35
             propertyName: SimpleIdentifier
               token: F @36
-              staticElement: a.dart::@class::C::@getter::F
+              staticElement: package:test/a.dart::@class::C::@getter::F
               staticType: int
             staticType: int
     accessors
@@ -13127,7 +13128,7 @@
   }
 
   test_const_reference_staticMethod_imported() async {
-    addLibrarySource('/a.dart', r'''
+    addLibrarySource('$testPackageLibPath/a.dart', r'''
 class C {
   static int m(int a, String b) => 42;
 }
@@ -13139,7 +13140,7 @@
     checkElementText(library, r'''
 library
   imports
-    a.dart
+    package:test/a.dart
   definingUnit
     topLevelVariables
       static const V @23
@@ -13148,14 +13149,14 @@
           PrefixedIdentifier
             prefix: SimpleIdentifier
               token: C @27
-              staticElement: a.dart::@class::C
+              staticElement: package:test/a.dart::@class::C
               staticType: null
             period: . @28
             identifier: SimpleIdentifier
               token: m @29
-              staticElement: a.dart::@class::C::@method::m
+              staticElement: package:test/a.dart::@class::C::@method::m
               staticType: int Function(int, String)
-            staticElement: a.dart::@class::C::@method::m
+            staticElement: package:test/a.dart::@class::C::@method::m
             staticType: int Function(int, String)
     accessors
       synthetic static get V @-1
@@ -13164,7 +13165,7 @@
   }
 
   test_const_reference_staticMethod_imported_withPrefix() async {
-    addLibrarySource('/a.dart', r'''
+    addLibrarySource('$testPackageLibPath/a.dart', r'''
 class C {
   static int m(int a, String b) => 42;
 }
@@ -13176,7 +13177,7 @@
     checkElementText(library, r'''
 library
   imports
-    a.dart as p @19
+    package:test/a.dart as p @19
   definingUnit
     topLevelVariables
       static const V @28
@@ -13191,14 +13192,14 @@
               period: . @33
               identifier: SimpleIdentifier
                 token: C @34
-                staticElement: a.dart::@class::C
+                staticElement: package:test/a.dart::@class::C
                 staticType: null
-              staticElement: a.dart::@class::C
+              staticElement: package:test/a.dart::@class::C
               staticType: null
             operator: . @35
             propertyName: SimpleIdentifier
               token: m @36
-              staticElement: a.dart::@class::C::@method::m
+              staticElement: package:test/a.dart::@class::C::@method::m
               staticType: int Function(int, String)
             staticType: int Function(int, String)
     accessors
@@ -13307,7 +13308,7 @@
   }
 
   test_const_reference_topLevelFunction_imported() async {
-    addLibrarySource('/a.dart', r'''
+    addLibrarySource('$testPackageLibPath/a.dart', r'''
 foo() {}
 ''');
     var library = await checkLibrary(r'''
@@ -13317,7 +13318,7 @@
     checkElementText(library, r'''
 library
   imports
-    a.dart
+    package:test/a.dart
   definingUnit
     topLevelVariables
       static const V @23
@@ -13325,7 +13326,7 @@
         constantInitializer
           SimpleIdentifier
             token: foo @27
-            staticElement: a.dart::@function::foo
+            staticElement: package:test/a.dart::@function::foo
             staticType: dynamic Function()
     accessors
       synthetic static get V @-1
@@ -13334,7 +13335,7 @@
   }
 
   test_const_reference_topLevelFunction_imported_withPrefix() async {
-    addLibrarySource('/a.dart', r'''
+    addLibrarySource('$testPackageLibPath/a.dart', r'''
 foo() {}
 ''');
     var library = await checkLibrary(r'''
@@ -13344,7 +13345,7 @@
     checkElementText(library, r'''
 library
   imports
-    a.dart as p @19
+    package:test/a.dart as p @19
   definingUnit
     topLevelVariables
       static const V @28
@@ -13358,9 +13359,9 @@
             period: . @33
             identifier: SimpleIdentifier
               token: foo @34
-              staticElement: a.dart::@function::foo
+              staticElement: package:test/a.dart::@function::foo
               staticType: dynamic Function()
-            staticElement: a.dart::@function::foo
+            staticElement: package:test/a.dart::@function::foo
             staticType: dynamic Function()
     accessors
       synthetic static get V @-1
@@ -13407,7 +13408,7 @@
   }
 
   test_const_reference_topLevelVariable_imported() async {
-    addLibrarySource('/a.dart', r'''
+    addLibrarySource('$testPackageLibPath/a.dart', r'''
 const A = 1;
 ''');
     var library = await checkLibrary(r'''
@@ -13417,7 +13418,7 @@
     checkElementText(library, r'''
 library
   imports
-    a.dart
+    package:test/a.dart
   definingUnit
     topLevelVariables
       static const B @23
@@ -13426,7 +13427,7 @@
           BinaryExpression
             leftOperand: SimpleIdentifier
               token: A @27
-              staticElement: a.dart::@getter::A
+              staticElement: package:test/a.dart::@getter::A
               staticType: int
             operator: + @29
             rightOperand: IntegerLiteral
@@ -13442,7 +13443,7 @@
   }
 
   test_const_reference_topLevelVariable_imported_withPrefix() async {
-    addLibrarySource('/a.dart', r'''
+    addLibrarySource('$testPackageLibPath/a.dart', r'''
 const A = 1;
 ''');
     var library = await checkLibrary(r'''
@@ -13452,7 +13453,7 @@
     checkElementText(library, r'''
 library
   imports
-    a.dart as p @19
+    package:test/a.dart as p @19
   definingUnit
     topLevelVariables
       static const B @28
@@ -13467,9 +13468,9 @@
               period: . @33
               identifier: SimpleIdentifier
                 token: A @34
-                staticElement: a.dart::@getter::A
+                staticElement: package:test/a.dart::@getter::A
                 staticType: int
-              staticElement: a.dart::@getter::A
+              staticElement: package:test/a.dart::@getter::A
               staticType: int
             operator: + @36
             rightOperand: IntegerLiteral
@@ -13701,7 +13702,7 @@
   }
 
   test_const_reference_type_imported() async {
-    addLibrarySource('/a.dart', r'''
+    addLibrarySource('$testPackageLibPath/a.dart', r'''
 class C {}
 enum E {a, b, c}
 typedef F(int a, String b);
@@ -13715,7 +13716,7 @@
     checkElementText(library, r'''
 library
   imports
-    a.dart
+    package:test/a.dart
   definingUnit
     topLevelVariables
       static const vClass @23
@@ -13723,21 +13724,21 @@
         constantInitializer
           SimpleIdentifier
             token: C @32
-            staticElement: a.dart::@class::C
+            staticElement: package:test/a.dart::@class::C
             staticType: Type
       static const vEnum @41
         type: Type
         constantInitializer
           SimpleIdentifier
             token: E @49
-            staticElement: a.dart::@enum::E
+            staticElement: package:test/a.dart::@enum::E
             staticType: Type
       static const vFunctionTypeAlias @58
         type: Type
         constantInitializer
           SimpleIdentifier
             token: F @79
-            staticElement: a.dart::@typeAlias::F
+            staticElement: package:test/a.dart::@typeAlias::F
             staticType: Type
     accessors
       synthetic static get vClass @-1
@@ -13750,7 +13751,7 @@
   }
 
   test_const_reference_type_imported_withPrefix() async {
-    addLibrarySource('/a.dart', r'''
+    addLibrarySource('$testPackageLibPath/a.dart', r'''
 class C {}
 enum E {a, b, c}
 typedef F(int a, String b);
@@ -13764,7 +13765,7 @@
     checkElementText(library, r'''
 library
   imports
-    a.dart as p @19
+    package:test/a.dart as p @19
   definingUnit
     topLevelVariables
       static const vClass @28
@@ -13778,9 +13779,9 @@
             period: . @38
             identifier: SimpleIdentifier
               token: C @39
-              staticElement: a.dart::@class::C
+              staticElement: package:test/a.dart::@class::C
               staticType: Type
-            staticElement: a.dart::@class::C
+            staticElement: package:test/a.dart::@class::C
             staticType: Type
       static const vEnum @48
         type: Type
@@ -13793,9 +13794,9 @@
             period: . @57
             identifier: SimpleIdentifier
               token: E @58
-              staticElement: a.dart::@enum::E
+              staticElement: package:test/a.dart::@enum::E
               staticType: Type
-            staticElement: a.dart::@enum::E
+            staticElement: package:test/a.dart::@enum::E
             staticType: Type
       static const vFunctionTypeAlias @67
         type: Type
@@ -13808,9 +13809,9 @@
             period: . @89
             identifier: SimpleIdentifier
               token: F @90
-              staticElement: a.dart::@typeAlias::F
+              staticElement: package:test/a.dart::@typeAlias::F
               staticType: Type
-            staticElement: a.dart::@typeAlias::F
+            staticElement: package:test/a.dart::@typeAlias::F
             staticType: Type
     accessors
       synthetic static get vClass @-1
@@ -13903,7 +13904,7 @@
   }
 
   test_const_reference_unresolved_prefix2() async {
-    addLibrarySource('/foo.dart', '''
+    addLibrarySource('$testPackageLibPath/foo.dart', '''
 class C {}
 ''');
     var library = await checkLibrary(r'''
@@ -13913,7 +13914,7 @@
     checkElementText(library, r'''
 library
   imports
-    foo.dart as p @21
+    package:test/foo.dart as p @21
   definingUnit
     topLevelVariables
       static const V @30
@@ -13928,9 +13929,9 @@
               period: . @35
               identifier: SimpleIdentifier
                 token: C @36
-                staticElement: foo.dart::@class::C
+                staticElement: package:test/foo.dart::@class::C
                 staticType: null
-              staticElement: foo.dart::@class::C
+              staticElement: package:test/foo.dart::@class::C
               staticType: null
             operator: . @37
             propertyName: SimpleIdentifier
@@ -15286,7 +15287,7 @@
   }
 
   test_const_topLevel_typedList_imported() async {
-    addLibrarySource('/a.dart', 'class C {}');
+    addLibrarySource('$testPackageLibPath/a.dart', 'class C {}');
     var library = await checkLibrary(r'''
 import 'a.dart';
 const v = const <C>[];
@@ -15294,7 +15295,7 @@
     checkElementText(library, r'''
 library
   imports
-    a.dart
+    package:test/a.dart
   definingUnit
     topLevelVariables
       static const v @23
@@ -15308,7 +15309,7 @@
                 NamedType
                   name: SimpleIdentifier
                     token: C @34
-                    staticElement: a.dart::@class::C
+                    staticElement: package:test/a.dart::@class::C
                     staticType: null
                   type: C
               rightBracket: > @35
@@ -15322,7 +15323,7 @@
   }
 
   test_const_topLevel_typedList_importedWithPrefix() async {
-    addLibrarySource('/a.dart', 'class C {}');
+    addLibrarySource('$testPackageLibPath/a.dart', 'class C {}');
     var library = await checkLibrary(r'''
 import 'a.dart' as p;
 const v = const <p.C>[];
@@ -15330,7 +15331,7 @@
     checkElementText(library, r'''
 library
   imports
-    a.dart as p @19
+    package:test/a.dart as p @19
   definingUnit
     topLevelVariables
       static const v @28
@@ -15350,9 +15351,9 @@
                     period: . @40
                     identifier: SimpleIdentifier
                       token: C @41
-                      staticElement: a.dart::@class::C
+                      staticElement: package:test/a.dart::@class::C
                       staticType: null
-                    staticElement: a.dart::@class::C
+                    staticElement: package:test/a.dart::@class::C
                     staticType: null
                   type: C
               rightBracket: > @42
@@ -19722,23 +19723,23 @@
   }
 
   test_export_class() async {
-    addLibrarySource('/a.dart', 'class C {}');
+    addLibrarySource('$testPackageLibPath/a.dart', 'class C {}');
     var library = await checkLibrary('export "a.dart";');
     checkElementText(
         library,
         r'''
 library
   exports
-    a.dart
+    package:test/a.dart
   definingUnit
   exportScope
-    C: a.dart;C
+    C: package:test/a.dart;C
 ''',
         withExportScope: true);
   }
 
   test_export_class_type_alias() async {
-    addLibrarySource('/a.dart', r'''
+    addLibrarySource('$testPackageLibPath/a.dart', r'''
 class C = _D with _E;
 class _D {}
 class _E {}
@@ -19749,10 +19750,10 @@
         r'''
 library
   exports
-    a.dart
+    package:test/a.dart
   definingUnit
   exportScope
-    C: a.dart;C
+    C: package:test/a.dart;C
 ''',
         withExportScope: true);
   }
@@ -19761,9 +19762,9 @@
     declaredVariables = DeclaredVariables.fromMap({
       'dart.library.io': 'false',
     });
-    addLibrarySource('/foo.dart', 'class A {}');
-    addLibrarySource('/foo_io.dart', 'class A {}');
-    addLibrarySource('/foo_html.dart', 'class A {}');
+    addLibrarySource('$testPackageLibPath/foo.dart', 'class A {}');
+    addLibrarySource('$testPackageLibPath/foo_io.dart', 'class A {}');
+    addLibrarySource('$testPackageLibPath/foo_html.dart', 'class A {}');
     var library = await checkLibrary(r'''
 export 'foo.dart'
   if (dart.library.io) 'foo_io.dart'
@@ -19774,10 +19775,10 @@
         r'''
 library
   exports
-    foo.dart
+    package:test/foo.dart
   definingUnit
   exportScope
-    A: foo.dart;A
+    A: package:test/foo.dart;A
 ''',
         withExportScope: true);
     expect(library.exports[0].exportedLibrary!.source.shortName, 'foo.dart');
@@ -19788,9 +19789,9 @@
       'dart.library.io': 'true',
       'dart.library.html': 'true',
     });
-    addLibrarySource('/foo.dart', 'class A {}');
-    addLibrarySource('/foo_io.dart', 'class A {}');
-    addLibrarySource('/foo_html.dart', 'class A {}');
+    addLibrarySource('$testPackageLibPath/foo.dart', 'class A {}');
+    addLibrarySource('$testPackageLibPath/foo_io.dart', 'class A {}');
+    addLibrarySource('$testPackageLibPath/foo_html.dart', 'class A {}');
     var library = await checkLibrary(r'''
 export 'foo.dart'
   if (dart.library.io) 'foo_io.dart'
@@ -19801,10 +19802,10 @@
         r'''
 library
   exports
-    foo_io.dart
+    package:test/foo_io.dart
   definingUnit
   exportScope
-    A: foo_io.dart;A
+    A: package:test/foo_io.dart;A
 ''',
         withExportScope: true);
     expect(library.exports[0].exportedLibrary!.source.shortName, 'foo_io.dart');
@@ -19815,9 +19816,9 @@
       'dart.library.io': 'false',
       'dart.library.html': 'true',
     });
-    addLibrarySource('/foo.dart', 'class A {}');
-    addLibrarySource('/foo_io.dart', 'class A {}');
-    addLibrarySource('/foo_html.dart', 'class A {}');
+    addLibrarySource('$testPackageLibPath/foo.dart', 'class A {}');
+    addLibrarySource('$testPackageLibPath/foo_io.dart', 'class A {}');
+    addLibrarySource('$testPackageLibPath/foo_html.dart', 'class A {}');
     var library = await checkLibrary(r'''
 export 'foo.dart'
   if (dart.library.io) 'foo_io.dart'
@@ -19828,10 +19829,10 @@
         r'''
 library
   exports
-    foo_html.dart
+    package:test/foo_html.dart
   definingUnit
   exportScope
-    A: foo_html.dart;A
+    A: package:test/foo_html.dart;A
 ''',
         withExportScope: true);
     ExportElement export = library.exports[0];
@@ -19839,35 +19840,34 @@
   }
 
   test_export_function() async {
-    addLibrarySource('/a.dart', 'f() {}');
+    addLibrarySource('$testPackageLibPath/a.dart', 'f() {}');
     var library = await checkLibrary('export "a.dart";');
     checkElementText(
         library,
         r'''
 library
   exports
-    a.dart
+    package:test/a.dart
   definingUnit
   exportScope
-    f: a.dart;f
+    f: package:test/a.dart;f
 ''',
         withExportScope: true);
   }
 
   test_export_getter() async {
-    addLibrarySource('/a.dart', 'get f() => null;');
+    addLibrarySource('$testPackageLibPath/a.dart', 'get f() => null;');
     var library = await checkLibrary('export "a.dart";');
     checkElementText(library, r'''
 library
   exports
-    a.dart
+    package:test/a.dart
   definingUnit
 ''');
   }
 
   test_export_hide() async {
-    testFile = convertPath('/home/test/lib/test.dart');
-    addLibrarySource('/home/test/lib/a.dart', r'''
+    addLibrarySource('$testPackageLibPath/a.dart', r'''
 class A {}
 class B {}
 class C {}
@@ -19893,8 +19893,7 @@
   }
 
   test_export_multiple_combinators() async {
-    testFile = convertPath('/home/test/lib/test.dart');
-    addLibrarySource('/home/test/lib/a.dart', r'''
+    addLibrarySource('$testPackageLibPath/a.dart', r'''
 class A {}
 class B {}
 class C {}
@@ -19920,24 +19919,23 @@
   }
 
   test_export_setter() async {
-    addLibrarySource('/a.dart', 'void set f(value) {}');
+    addLibrarySource('$testPackageLibPath/a.dart', 'void set f(value) {}');
     var library = await checkLibrary('export "a.dart";');
     checkElementText(
         library,
         r'''
 library
   exports
-    a.dart
+    package:test/a.dart
   definingUnit
   exportScope
-    f=: a.dart;f=
+    f=: package:test/a.dart;f=
 ''',
         withExportScope: true);
   }
 
   test_export_show() async {
-    testFile = convertPath('/home/test/lib/test.dart');
-    addLibrarySource('/home/test/lib/a.dart', r'''
+    addLibrarySource('$testPackageLibPath/a.dart', r'''
 class A {}
 class B {}
 class C {}
@@ -19963,7 +19961,7 @@
   }
 
   test_export_show_getter_setter() async {
-    addLibrarySource('/a.dart', '''
+    addLibrarySource('$testPackageLibPath/a.dart', '''
 get f => null;
 void set f(value) {}
 ''');
@@ -19973,29 +19971,29 @@
         r'''
 library
   exports
-    a.dart
+    package:test/a.dart
       combinators
         show: f
   definingUnit
   exportScope
-    f: a.dart;f?
-    f=: a.dart;f=
+    f: package:test/a.dart;f?
+    f=: package:test/a.dart;f=
 ''',
         withExportScope: true);
   }
 
   test_export_typedef() async {
-    addLibrarySource('/a.dart', 'typedef F();');
+    addLibrarySource('$testPackageLibPath/a.dart', 'typedef F();');
     var library = await checkLibrary('export "a.dart";');
     checkElementText(
         library,
         r'''
 library
   exports
-    a.dart
+    package:test/a.dart
   definingUnit
   exportScope
-    F: a.dart;F
+    F: package:test/a.dart;F
 ''',
         withExportScope: true);
   }
@@ -20008,50 +20006,50 @@
   }
 
   test_export_variable() async {
-    addLibrarySource('/a.dart', 'var x;');
+    addLibrarySource('$testPackageLibPath/a.dart', 'var x;');
     var library = await checkLibrary('export "a.dart";');
     checkElementText(
         library,
         r'''
 library
   exports
-    a.dart
+    package:test/a.dart
   definingUnit
   exportScope
-    x: a.dart;x?
-    x=: a.dart;x=
+    x: package:test/a.dart;x?
+    x=: package:test/a.dart;x=
 ''',
         withExportScope: true);
   }
 
   test_export_variable_const() async {
-    addLibrarySource('/a.dart', 'const x = 0;');
+    addLibrarySource('$testPackageLibPath/a.dart', 'const x = 0;');
     var library = await checkLibrary('export "a.dart";');
     checkElementText(
         library,
         r'''
 library
   exports
-    a.dart
+    package:test/a.dart
   definingUnit
   exportScope
-    x: a.dart;x?
+    x: package:test/a.dart;x?
 ''',
         withExportScope: true);
   }
 
   test_export_variable_final() async {
-    addLibrarySource('/a.dart', 'final x = 0;');
+    addLibrarySource('$testPackageLibPath/a.dart', 'final x = 0;');
     var library = await checkLibrary('export "a.dart";');
     checkElementText(
         library,
         r'''
 library
   exports
-    a.dart
+    package:test/a.dart
   definingUnit
   exportScope
-    x: a.dart;x?
+    x: package:test/a.dart;x?
 ''',
         withExportScope: true);
   }
@@ -20060,10 +20058,10 @@
     declaredVariables = DeclaredVariables.fromMap({
       'dart.library.io': 'false',
     });
-    addLibrarySource('/foo.dart', 'class A {}');
-    addLibrarySource('/foo_io.dart', 'class A {}');
-    addLibrarySource('/foo_html.dart', 'class A {}');
-    addLibrarySource('/bar.dart', r'''
+    addLibrarySource('$testPackageLibPath/foo.dart', 'class A {}');
+    addLibrarySource('$testPackageLibPath/foo_io.dart', 'class A {}');
+    addLibrarySource('$testPackageLibPath/foo_html.dart', 'class A {}');
+    addLibrarySource('$testPackageLibPath/bar.dart', r'''
 export 'foo.dart'
   if (dart.library.io) 'foo_io.dart'
   if (dart.library.html) 'foo_html.dart';
@@ -20075,14 +20073,14 @@
     checkElementText(library, r'''
 library
   imports
-    bar.dart
+    package:test/bar.dart
   definingUnit
     classes
       class B @25
         supertype: A
         constructors
           synthetic @-1
-            superConstructor: foo.dart::@class::A::@constructor::•
+            superConstructor: package:test/foo.dart::@class::A::@constructor::•
 ''');
     var typeA = library.definingCompilationUnit.getType('B')!.supertype!;
     expect(typeA.element.source.shortName, 'foo.dart');
@@ -20093,10 +20091,10 @@
       'dart.library.io': 'true',
       'dart.library.html': 'false',
     });
-    addLibrarySource('/foo.dart', 'class A {}');
-    addLibrarySource('/foo_io.dart', 'class A {}');
-    addLibrarySource('/foo_html.dart', 'class A {}');
-    addLibrarySource('/bar.dart', r'''
+    addLibrarySource('$testPackageLibPath/foo.dart', 'class A {}');
+    addLibrarySource('$testPackageLibPath/foo_io.dart', 'class A {}');
+    addLibrarySource('$testPackageLibPath/foo_html.dart', 'class A {}');
+    addLibrarySource('$testPackageLibPath/bar.dart', r'''
 export 'foo.dart'
   if (dart.library.io) 'foo_io.dart'
   if (dart.library.html) 'foo_html.dart';
@@ -20108,14 +20106,14 @@
     checkElementText(library, r'''
 library
   imports
-    bar.dart
+    package:test/bar.dart
   definingUnit
     classes
       class B @25
         supertype: A
         constructors
           synthetic @-1
-            superConstructor: foo_io.dart::@class::A::@constructor::•
+            superConstructor: package:test/foo_io.dart::@class::A::@constructor::•
 ''');
     var typeA = library.definingCompilationUnit.getType('B')!.supertype!;
     expect(typeA.element.source.shortName, 'foo_io.dart');
@@ -20126,10 +20124,10 @@
       'dart.library.io': 'false',
       'dart.library.html': 'true',
     });
-    addLibrarySource('/foo.dart', 'class A {}');
-    addLibrarySource('/foo_io.dart', 'class A {}');
-    addLibrarySource('/foo_html.dart', 'class A {}');
-    addLibrarySource('/bar.dart', r'''
+    addLibrarySource('$testPackageLibPath/foo.dart', 'class A {}');
+    addLibrarySource('$testPackageLibPath/foo_io.dart', 'class A {}');
+    addLibrarySource('$testPackageLibPath/foo_html.dart', 'class A {}');
+    addLibrarySource('$testPackageLibPath/bar.dart', r'''
 export 'foo.dart'
   if (dart.library.io) 'foo_io.dart'
   if (dart.library.html) 'foo_html.dart';
@@ -20141,30 +20139,30 @@
     checkElementText(library, r'''
 library
   imports
-    bar.dart
+    package:test/bar.dart
   definingUnit
     classes
       class B @25
         supertype: A
         constructors
           synthetic @-1
-            superConstructor: foo_html.dart::@class::A::@constructor::•
+            superConstructor: package:test/foo_html.dart::@class::A::@constructor::•
 ''');
     var typeA = library.definingCompilationUnit.getType('B')!.supertype!;
     expect(typeA.element.source.shortName, 'foo_html.dart');
   }
 
   test_exports() async {
-    addLibrarySource('/a.dart', 'library a;');
-    addLibrarySource('/b.dart', 'library b;');
+    addLibrarySource('$testPackageLibPath/a.dart', 'library a;');
+    addLibrarySource('$testPackageLibPath/b.dart', 'library b;');
     var library = await checkLibrary('export "a.dart"; export "b.dart";');
     checkElementText(
         library,
         r'''
 library
   exports
-    a.dart
-    b.dart
+    package:test/a.dart
+    package:test/b.dart
   definingUnit
   exportScope
 ''',
@@ -20297,23 +20295,23 @@
   }
 
   test_function_entry_point_in_export() async {
-    addLibrarySource('/a.dart', 'library a; main() {}');
+    addLibrarySource('$testPackageLibPath/a.dart', 'library a; main() {}');
     var library = await checkLibrary('export "a.dart";');
     checkElementText(library, r'''
 library
   exports
-    a.dart
+    package:test/a.dart
   definingUnit
 ''');
   }
 
   test_function_entry_point_in_export_hidden() async {
-    addLibrarySource('/a.dart', 'library a; main() {}');
+    addLibrarySource('$testPackageLibPath/a.dart', 'library a; main() {}');
     var library = await checkLibrary('export "a.dart" hide main;');
     checkElementText(library, r'''
 library
   exports
-    a.dart
+    package:test/a.dart
       combinators
         hide: main
   definingUnit
@@ -20321,7 +20319,7 @@
   }
 
   test_function_entry_point_in_part() async {
-    addSource('/a.dart', 'part of my.lib; main() {}');
+    addSource('$testPackageLibPath/a.dart', 'part of my.lib; main() {}');
     var library = await checkLibrary('library my.lib; part "a.dart";');
     checkElementText(library, r'''
 library
@@ -22178,9 +22176,9 @@
     declaredVariables = DeclaredVariables.fromMap({
       'dart.library.io': 'false',
     });
-    addLibrarySource('/foo.dart', 'class A {}');
-    addLibrarySource('/foo_io.dart', 'class A {}');
-    addLibrarySource('/foo_html.dart', 'class A {}');
+    addLibrarySource('$testPackageLibPath/foo.dart', 'class A {}');
+    addLibrarySource('$testPackageLibPath/foo_io.dart', 'class A {}');
+    addLibrarySource('$testPackageLibPath/foo_html.dart', 'class A {}');
     var library = await checkLibrary(r'''
 import 'foo.dart'
   if (dart.library.io) 'foo_io.dart'
@@ -22191,14 +22189,14 @@
     checkElementText(library, r'''
 library
   imports
-    foo.dart
+    package:test/foo.dart
   definingUnit
     classes
       class B @104
         supertype: A
         constructors
           synthetic @-1
-            superConstructor: foo.dart::@class::A::@constructor::•
+            superConstructor: package:test/foo.dart::@class::A::@constructor::•
 ''');
     var typeA = library.definingCompilationUnit.getType('B')!.supertype!;
     expect(typeA.element.source.shortName, 'foo.dart');
@@ -22209,9 +22207,9 @@
       'dart.library.io': 'true',
       'dart.library.html': 'true',
     });
-    addLibrarySource('/foo.dart', 'class A {}');
-    addLibrarySource('/foo_io.dart', 'class A {}');
-    addLibrarySource('/foo_html.dart', 'class A {}');
+    addLibrarySource('$testPackageLibPath/foo.dart', 'class A {}');
+    addLibrarySource('$testPackageLibPath/foo_io.dart', 'class A {}');
+    addLibrarySource('$testPackageLibPath/foo_html.dart', 'class A {}');
     var library = await checkLibrary(r'''
 import 'foo.dart'
   if (dart.library.io) 'foo_io.dart'
@@ -22222,14 +22220,14 @@
     checkElementText(library, r'''
 library
   imports
-    foo_io.dart
+    package:test/foo_io.dart
   definingUnit
     classes
       class B @104
         supertype: A
         constructors
           synthetic @-1
-            superConstructor: foo_io.dart::@class::A::@constructor::•
+            superConstructor: package:test/foo_io.dart::@class::A::@constructor::•
 ''');
     var typeA = library.definingCompilationUnit.getType('B')!.supertype!;
     expect(typeA.element.source.shortName, 'foo_io.dart');
@@ -22240,9 +22238,9 @@
       'dart.library.io': 'true',
       'dart.library.html': 'true',
     });
-    addLibrarySource('/foo.dart', 'class A {}');
-    addLibrarySource('/foo_io.dart', 'class A {}');
-    addLibrarySource('/foo_html.dart', 'class A {}');
+    addLibrarySource('$testPackageLibPath/foo.dart', 'class A {}');
+    addLibrarySource('$testPackageLibPath/foo_io.dart', 'class A {}');
+    addLibrarySource('$testPackageLibPath/foo_html.dart', 'class A {}');
     var library = await checkLibrary(r'''
 import 'foo.dart'
   if (dart.library.io == 'true') 'foo_io.dart'
@@ -22253,14 +22251,14 @@
     checkElementText(library, r'''
 library
   imports
-    foo_io.dart
+    package:test/foo_io.dart
   definingUnit
     classes
       class B @124
         supertype: A
         constructors
           synthetic @-1
-            superConstructor: foo_io.dart::@class::A::@constructor::•
+            superConstructor: package:test/foo_io.dart::@class::A::@constructor::•
 ''');
     var typeA = library.definingCompilationUnit.getType('B')!.supertype!;
     expect(typeA.element.source.shortName, 'foo_io.dart');
@@ -22271,9 +22269,9 @@
       'dart.library.io': 'false',
       'dart.library.html': 'true',
     });
-    addLibrarySource('/foo.dart', 'class A {}');
-    addLibrarySource('/foo_io.dart', 'class A {}');
-    addLibrarySource('/foo_html.dart', 'class A {}');
+    addLibrarySource('$testPackageLibPath/foo.dart', 'class A {}');
+    addLibrarySource('$testPackageLibPath/foo_io.dart', 'class A {}');
+    addLibrarySource('$testPackageLibPath/foo_html.dart', 'class A {}');
     var library = await checkLibrary(r'''
 import 'foo.dart'
   if (dart.library.io) 'foo_io.dart'
@@ -22284,14 +22282,14 @@
     checkElementText(library, r'''
 library
   imports
-    foo_html.dart
+    package:test/foo_html.dart
   definingUnit
     classes
       class B @104
         supertype: A
         constructors
           synthetic @-1
-            superConstructor: foo_html.dart::@class::A::@constructor::•
+            superConstructor: package:test/foo_html.dart::@class::A::@constructor::•
 ''');
     var typeA = library.definingCompilationUnit.getType('B')!.supertype!;
     expect(typeA.element.source.shortName, 'foo_html.dart');
@@ -22302,9 +22300,9 @@
       'dart.library.io': 'false',
       'dart.library.html': 'true',
     });
-    addLibrarySource('/foo.dart', 'class A {}');
-    addLibrarySource('/foo_io.dart', 'class A {}');
-    addLibrarySource('/foo_html.dart', 'class A {}');
+    addLibrarySource('$testPackageLibPath/foo.dart', 'class A {}');
+    addLibrarySource('$testPackageLibPath/foo_io.dart', 'class A {}');
+    addLibrarySource('$testPackageLibPath/foo_html.dart', 'class A {}');
     var library = await checkLibrary(r'''
 import 'foo.dart'
   if (dart.library.io == 'true') 'foo_io.dart'
@@ -22315,14 +22313,14 @@
     checkElementText(library, r'''
 library
   imports
-    foo_html.dart
+    package:test/foo_html.dart
   definingUnit
     classes
       class B @124
         supertype: A
         constructors
           synthetic @-1
-            superConstructor: foo_html.dart::@class::A::@constructor::•
+            superConstructor: package:test/foo_html.dart::@class::A::@constructor::•
 ''');
     var typeA = library.definingCompilationUnit.getType('B')!.supertype!;
     expect(typeA.element.source.shortName, 'foo_html.dart');
@@ -22355,8 +22353,7 @@
   }
 
   test_import_deferred() async {
-    testFile = convertPath('/home/test/lib/test.dart');
-    addLibrarySource('/home/test/lib/a.dart', 'f() {}');
+    addLibrarySource('$testPackageLibPath/a.dart', 'f() {}');
     var library = await checkLibrary('''
 import 'a.dart' deferred as p;
 ''');
@@ -22476,7 +22473,7 @@
   }
 
   test_import_prefixed() async {
-    addLibrarySource('/a.dart', 'library a; class C {}');
+    addLibrarySource('$testPackageLibPath/a.dart', 'library a; class C {}');
     var library = await checkLibrary('import "a.dart" as a; a.C c;');
 
     expect(library.imports[0].prefix!.nameOffset, 19);
@@ -22485,7 +22482,7 @@
     checkElementText(library, r'''
 library
   imports
-    a.dart as a @19
+    package:test/a.dart as a @19
   definingUnit
     topLevelVariables
       static c @26
@@ -22513,7 +22510,7 @@
     checkElementText(library, r'''
 library
   imports
-    test.dart as p @22
+    package:test/test.dart as p @22
   definingUnit
     classes
       class C @31
@@ -22527,31 +22524,6 @@
 ''');
   }
 
-  test_import_short_absolute() async {
-    testFile = '/my/project/bin/test.dart';
-    // Note: "/a.dart" resolves differently on Windows vs. Posix.
-    var destinationPath = convertPath('/a.dart');
-    addLibrarySource(destinationPath, 'class C {}');
-    var library = await checkLibrary('import "/a.dart"; C c;');
-    checkElementText(library, r'''
-library
-  imports
-    a.dart
-  definingUnit
-    topLevelVariables
-      static c @20
-        type: C
-    accessors
-      synthetic static get c @-1
-        returnType: C
-      synthetic static set c @-1
-        parameters
-          requiredPositional _c @-1
-            type: C
-        returnType: void
-''');
-  }
-
   test_import_show() async {
     addLibrary('dart:async');
     var library = await checkLibrary('''
@@ -22607,15 +22579,15 @@
   }
 
   test_imports() async {
-    addLibrarySource('/a.dart', 'library a; class C {}');
-    addLibrarySource('/b.dart', 'library b; class D {}');
+    addLibrarySource('$testPackageLibPath/a.dart', 'library a; class C {}');
+    addLibrarySource('$testPackageLibPath/b.dart', 'library b; class D {}');
     var library =
         await checkLibrary('import "a.dart"; import "b.dart"; C c; D d;');
     checkElementText(library, r'''
 library
   imports
-    a.dart
-    b.dart
+    package:test/a.dart
+    package:test/b.dart
   definingUnit
     topLevelVariables
       static c @36
@@ -23321,7 +23293,7 @@
   }
 
   test_inferred_type_nullability_class_ref_none() async {
-    addSource('/a.dart', 'int f() => 0;');
+    addSource('$testPackageLibPath/a.dart', 'int f() => 0;');
     var library = await checkLibrary('''
 import 'a.dart';
 var x = f();
@@ -23329,7 +23301,7 @@
     checkElementText(library, r'''
 library
   imports
-    a.dart
+    package:test/a.dart
   definingUnit
     topLevelVariables
       static x @21
@@ -23346,7 +23318,7 @@
   }
 
   test_inferred_type_nullability_class_ref_question() async {
-    addSource('/a.dart', 'int? f() => 0;');
+    addSource('$testPackageLibPath/a.dart', 'int? f() => 0;');
     var library = await checkLibrary('''
 import 'a.dart';
 var x = f();
@@ -23354,7 +23326,7 @@
     checkElementText(library, r'''
 library
   imports
-    a.dart
+    package:test/a.dart
   definingUnit
     topLevelVariables
       static x @21
@@ -23371,7 +23343,7 @@
   }
 
   test_inferred_type_nullability_function_type_none() async {
-    addSource('/a.dart', 'void Function() f() => () {};');
+    addSource('$testPackageLibPath/a.dart', 'void Function() f() => () {};');
     var library = await checkLibrary('''
 import 'a.dart';
 var x = f();
@@ -23379,7 +23351,7 @@
     checkElementText(library, r'''
 library
   imports
-    a.dart
+    package:test/a.dart
   definingUnit
     topLevelVariables
       static x @21
@@ -23396,7 +23368,7 @@
   }
 
   test_inferred_type_nullability_function_type_question() async {
-    addSource('/a.dart', 'void Function()? f() => () {};');
+    addSource('$testPackageLibPath/a.dart', 'void Function()? f() => () {};');
     var library = await checkLibrary('''
 import 'a.dart';
 var x = f();
@@ -23404,7 +23376,7 @@
     checkElementText(library, r'''
 library
   imports
-    a.dart
+    package:test/a.dart
   definingUnit
     topLevelVariables
       static x @21
@@ -23567,11 +23539,11 @@
   }
 
   test_inferred_type_refers_to_function_typed_parameter_type_other_lib() async {
-    addLibrarySource('/a.dart', '''
+    addLibrarySource('$testPackageLibPath/a.dart', '''
 import 'b.dart';
 abstract class D extends E {}
 ''');
-    addLibrarySource('/b.dart', '''
+    addLibrarySource('$testPackageLibPath/b.dart', '''
 abstract class E {
   void f(int x, int g(String s));
 }
@@ -23585,14 +23557,14 @@
     checkElementText(library, r'''
 library
   imports
-    a.dart
+    package:test/a.dart
   definingUnit
     classes
       class C @23
         supertype: D
         constructors
           synthetic @-1
-            superConstructor: a.dart::@class::D::@constructor::•
+            superConstructor: package:test/a.dart::@class::D::@constructor::•
         methods
           f @44
             parameters
@@ -23747,7 +23719,7 @@
   }
 
   test_inferredType_definedInSdkLibraryPart() async {
-    addSource('/a.dart', r'''
+    addSource('$testPackageLibPath/a.dart', r'''
 import 'dart:async';
 class A {
   m(Stream p) {}
@@ -23762,14 +23734,14 @@
     checkElementText(library, r'''
 library
   imports
-    a.dart
+    package:test/a.dart
   definingUnit
     classes
       class B @23
         supertype: A
         constructors
           synthetic @-1
-            superConstructor: a.dart::@class::A::@constructor::•
+            superConstructor: package:test/a.dart::@class::A::@constructor::•
         methods
           m @39
             parameters
@@ -23831,7 +23803,7 @@
   }
 
   test_inferredType_implicitCreation_prefixed() async {
-    addLibrarySource('/foo.dart', '''
+    addLibrarySource('$testPackageLibPath/foo.dart', '''
 class A {
   A();
   A.named();
@@ -23845,7 +23817,7 @@
     checkElementText(library, r'''
 library
   imports
-    foo.dart as foo @21
+    package:test/foo.dart as foo @21
   definingUnit
     topLevelVariables
       static a1 @30
@@ -24125,7 +24097,7 @@
 
   test_instanceInference_operator_equal_legacy_from_legacy() async {
     featureSet = FeatureSets.language_2_9;
-    addLibrarySource('/legacy.dart', r'''
+    addLibrarySource('$testPackageLibPath/legacy.dart', r'''
 // @dart = 2.7
 class LegacyDefault {
   bool operator==(other) => false;
@@ -24152,14 +24124,14 @@
     checkElementText(library, r'''
 library
   imports
-    legacy.dart
+    package:test/legacy.dart
   definingUnit
     classes
       class X1 @28
         supertype: LegacyDefault*
         constructors
           synthetic @-1
-            superConstructor: legacy.dart::@class::LegacyDefault::@constructor::•
+            superConstructor: package:test/legacy.dart::@class::LegacyDefault::@constructor::•
         methods
           == @71
             parameters
@@ -24170,7 +24142,7 @@
         supertype: LegacyObject*
         constructors
           synthetic @-1
-            superConstructor: legacy.dart::@class::LegacyObject::@constructor::•
+            superConstructor: package:test/legacy.dart::@class::LegacyObject::@constructor::•
         methods
           == @140
             parameters
@@ -24181,7 +24153,7 @@
         supertype: LegacyInt*
         constructors
           synthetic @-1
-            superConstructor: legacy.dart::@class::LegacyInt::@constructor::•
+            superConstructor: package:test/legacy.dart::@class::LegacyInt::@constructor::•
         methods
           == @206
             parameters
@@ -24192,7 +24164,7 @@
   }
 
   test_instanceInference_operator_equal_legacy_from_legacy_nullSafe() async {
-    addLibrarySource('/legacy.dart', r'''
+    addLibrarySource('$testPackageLibPath/legacy.dart', r'''
 // @dart = 2.7
 class LegacyDefault {
   bool operator==(other) => false;
@@ -24204,7 +24176,7 @@
   bool operator==(int other) => false;
 }
 ''');
-    addLibrarySource('/nullSafe.dart', r'''
+    addLibrarySource('$testPackageLibPath/nullSafe.dart', r'''
 class NullSafeDefault {
   bool operator==(other) => false;
 }
@@ -24232,8 +24204,8 @@
     checkElementText(library, r'''
 library
   imports
-    legacy.dart
-    nullSafe.dart
+    package:test/legacy.dart
+    package:test/nullSafe.dart
   definingUnit
     classes
       class X1 @67
@@ -24242,7 +24214,7 @@
           NullSafeDefault*
         constructors
           synthetic @-1
-            superConstructor: legacy.dart::@class::LegacyDefault::@constructor::•
+            superConstructor: package:test/legacy.dart::@class::LegacyDefault::@constructor::•
         methods
           == @136
             parameters
@@ -24255,7 +24227,7 @@
           NullSafeObject*
         constructors
           synthetic @-1
-            superConstructor: legacy.dart::@class::LegacyObject::@constructor::•
+            superConstructor: package:test/legacy.dart::@class::LegacyObject::@constructor::•
         methods
           == @231
             parameters
@@ -24268,7 +24240,7 @@
           NullSafeInt*
         constructors
           synthetic @-1
-            superConstructor: legacy.dart::@class::LegacyInt::@constructor::•
+            superConstructor: package:test/legacy.dart::@class::LegacyInt::@constructor::•
         methods
           == @320
             parameters
@@ -24279,7 +24251,7 @@
   }
 
   test_instanceInference_operator_equal_nullSafe_from_nullSafe() async {
-    addLibrarySource('/nullSafe.dart', r'''
+    addLibrarySource('$testPackageLibPath/nullSafe.dart', r'''
 class NullSafeDefault {
   bool operator==(other) => false;
 }
@@ -24305,14 +24277,14 @@
     checkElementText(library, r'''
 library
   imports
-    nullSafe.dart
+    package:test/nullSafe.dart
   definingUnit
     classes
       class X1 @30
         supertype: NullSafeDefault
         constructors
           synthetic @-1
-            superConstructor: nullSafe.dart::@class::NullSafeDefault::@constructor::•
+            superConstructor: package:test/nullSafe.dart::@class::NullSafeDefault::@constructor::•
         methods
           == @74
             parameters
@@ -24323,7 +24295,7 @@
         supertype: NullSafeObject
         constructors
           synthetic @-1
-            superConstructor: nullSafe.dart::@class::NullSafeObject::@constructor::•
+            superConstructor: package:test/nullSafe.dart::@class::NullSafeObject::@constructor::•
         methods
           == @145
             parameters
@@ -24334,7 +24306,7 @@
         supertype: NullSafeInt
         constructors
           synthetic @-1
-            superConstructor: nullSafe.dart::@class::NullSafeInt::@constructor::•
+            superConstructor: package:test/nullSafe.dart::@class::NullSafeInt::@constructor::•
         methods
           == @213
             parameters
@@ -24526,11 +24498,11 @@
   }
 
   test_instantiateToBounds_functionTypeAlias_reexported() async {
-    addLibrarySource('/a.dart', r'''
+    addLibrarySource('$testPackageLibPath/a.dart', r'''
 class O {}
 typedef T F<T extends O>(T p);
 ''');
-    addLibrarySource('/b.dart', r'''
+    addLibrarySource('$testPackageLibPath/b.dart', r'''
 export 'a.dart' show F;
 ''');
     var library = await checkLibrary('''
@@ -24542,7 +24514,7 @@
     checkElementText(library, r'''
 library
   imports
-    b.dart
+    package:test/b.dart
   definingUnit
     classes
       class C @23
@@ -24551,7 +24523,7 @@
         methods
           f @31
             returnType: O Function(O)
-              alias: a.dart::@typeAlias::F
+              alias: package:test/a.dart::@typeAlias::F
                 typeArguments
                   O
 ''');
@@ -24750,8 +24722,7 @@
   }
 
   test_invalid_annotation_prefixed_constructor() async {
-    testFile = convertPath('/home/test/lib/test.dart');
-    addLibrarySource('/home/test/lib/a.dart', r'''
+    addLibrarySource('$testPackageLibPath/a.dart', r'''
 class A {
   const A.named();
 }
@@ -24795,8 +24766,7 @@
   }
 
   test_invalid_annotation_unprefixed_constructor() async {
-    testFile = convertPath('/home/test/lib/test.dart');
-    addLibrarySource('/home/test/lib/a.dart', r'''
+    addLibrarySource('$testPackageLibPath/a.dart', r'''
 class A {
   const A.named();
 }
@@ -24865,8 +24835,8 @@
   }
 
   test_invalid_nameConflict_imported() async {
-    addLibrarySource('/a.dart', 'V() {}');
-    addLibrarySource('/b.dart', 'V() {}');
+    addLibrarySource('$testPackageLibPath/a.dart', 'V() {}');
+    addLibrarySource('$testPackageLibPath/b.dart', 'V() {}');
     var library = await checkLibrary('''
 import 'a.dart';
 import 'b.dart';
@@ -24875,8 +24845,8 @@
     checkElementText(library, r'''
 library
   imports
-    a.dart
-    b.dart
+    package:test/a.dart
+    package:test/b.dart
   definingUnit
     functions
       foo @34
@@ -24893,9 +24863,9 @@
   }
 
   test_invalid_nameConflict_imported_exported() async {
-    addLibrarySource('/a.dart', 'V() {}');
-    addLibrarySource('/b.dart', 'V() {}');
-    addLibrarySource('/c.dart', r'''
+    addLibrarySource('$testPackageLibPath/a.dart', 'V() {}');
+    addLibrarySource('$testPackageLibPath/b.dart', 'V() {}');
+    addLibrarySource('$testPackageLibPath/c.dart', r'''
 export 'a.dart';
 export 'b.dart';
 ''');
@@ -24906,7 +24876,7 @@
     checkElementText(library, r'''
 library
   imports
-    c.dart
+    package:test/c.dart
   definingUnit
     functions
       foo @17
@@ -24916,7 +24886,7 @@
             constantInitializer
               SimpleIdentifier
                 token: V @26
-                staticElement: a.dart::@function::V
+                staticElement: package:test/a.dart::@function::V
                 staticType: dynamic Function()
         returnType: dynamic
 ''');
@@ -25043,13 +25013,13 @@
   imports
     <unresolved>
     <unresolved>
-    a1.dart
+    package:test/a1.dart
     <unresolved>
     <unresolved>
   exports
     <unresolved>
     <unresolved>
-    a2.dart
+    package:test/a2.dart
     <unresolved>
     <unresolved>
   definingUnit
@@ -25301,23 +25271,24 @@
   }
 
   test_main_class_alias_via_export() async {
-    addLibrarySource('/a.dart', 'class main = C with D; class C {} class D {}');
+    addLibrarySource('$testPackageLibPath/a.dart',
+        'class main = C with D; class C {} class D {}');
     var library = await checkLibrary('export "a.dart";');
     checkElementText(library, r'''
 library
   exports
-    a.dart
+    package:test/a.dart
   definingUnit
 ''');
   }
 
   test_main_class_via_export() async {
-    addLibrarySource('/a.dart', 'class main {}');
+    addLibrarySource('$testPackageLibPath/a.dart', 'class main {}');
     var library = await checkLibrary('export "a.dart";');
     checkElementText(library, r'''
 library
   exports
-    a.dart
+    package:test/a.dart
   definingUnit
 ''');
   }
@@ -25337,12 +25308,12 @@
   }
 
   test_main_getter_via_export() async {
-    addLibrarySource('/a.dart', 'get main => null;');
+    addLibrarySource('$testPackageLibPath/a.dart', 'get main => null;');
     var library = await checkLibrary('export "a.dart";');
     checkElementText(library, r'''
 library
   exports
-    a.dart
+    package:test/a.dart
   definingUnit
 ''');
   }
@@ -25361,12 +25332,12 @@
   }
 
   test_main_typedef_via_export() async {
-    addLibrarySource('/a.dart', 'typedef main();');
+    addLibrarySource('$testPackageLibPath/a.dart', 'typedef main();');
     var library = await checkLibrary('export "a.dart";');
     checkElementText(library, r'''
 library
   exports
-    a.dart
+    package:test/a.dart
   definingUnit
 ''');
   }
@@ -25391,12 +25362,12 @@
   }
 
   test_main_variable_via_export() async {
-    addLibrarySource('/a.dart', 'var main;');
+    addLibrarySource('$testPackageLibPath/a.dart', 'var main;');
     var library = await checkLibrary('export "a.dart";');
     checkElementText(library, r'''
 library
   exports
-    a.dart
+    package:test/a.dart
   definingUnit
 ''');
   }
@@ -25623,7 +25594,6 @@
   }
 
   test_metadata_constructor_call_named() async {
-    testFile = convertPath('/home/test/lib/test.dart');
     var library = await checkLibrary('''
 class A {
   const A.named(int _);
@@ -25846,8 +25816,7 @@
   }
 
   test_metadata_constructor_call_named_prefixed() async {
-    testFile = convertPath('/home/test/lib/test.dart');
-    addLibrarySource('/home/test/lib/foo.dart', '''
+    addLibrarySource('$testPackageLibPath/foo.dart', '''
 class A {
   const A.named(int _);
 }
@@ -25898,12 +25867,11 @@
   }
 
   test_metadata_constructor_call_named_prefixed_generic_inference() async {
-    addLibrarySource('/home/test/lib/foo.dart', '''
+    addLibrarySource('$testPackageLibPath/foo.dart', '''
 class A<T> {
   const A.named(T _);
 }
 ''');
-    testFile = convertPath('/home/test/lib/test.dart');
     var library = await checkLibrary('''
 import "foo.dart" as foo;
 @foo.A.named(0)
@@ -25954,12 +25922,11 @@
   }
 
   test_metadata_constructor_call_named_prefixed_generic_typeArguments() async {
-    addLibrarySource('/home/test/lib/foo.dart', '''
+    addLibrarySource('$testPackageLibPath/foo.dart', '''
 class A<T> {
   const A.named();
 }
 ''');
-    testFile = convertPath('/home/test/lib/test.dart');
     var library = await checkLibrary('''
 import "foo.dart" as foo;
 @foo.A<int>.named()
@@ -26097,7 +26064,6 @@
   }
 
   test_metadata_constructor_call_unnamed() async {
-    testFile = convertPath('/home/test/lib/test.dart');
     var library = await checkLibrary('''
 class A {
   const A(int _);
@@ -26230,8 +26196,7 @@
   }
 
   test_metadata_constructor_call_unnamed_prefixed() async {
-    testFile = convertPath('/home/test/lib/test.dart');
-    addLibrarySource('/home/test/lib/foo.dart', 'class A { const A(_); }');
+    addLibrarySource('$testPackageLibPath/foo.dart', 'class A { const A(_); }');
     var library =
         await checkLibrary('import "foo.dart" as foo; @foo.A(0) class C {}');
     checkElementText(library, r'''
@@ -26270,12 +26235,11 @@
   }
 
   test_metadata_constructor_call_unnamed_prefixed_generic_inference() async {
-    addLibrarySource('/home/test/lib/foo.dart', '''
+    addLibrarySource('$testPackageLibPath/foo.dart', '''
 class A<T> {
   const A(T _);
 }
 ''');
-    testFile = convertPath('/home/test/lib/test.dart');
     var library = await checkLibrary('''
 import "foo.dart" as foo;
 @foo.A(0)
@@ -26319,12 +26283,11 @@
   }
 
   test_metadata_constructor_call_unnamed_prefixed_generic_typeArguments() async {
-    addLibrarySource('/home/test/lib/foo.dart', '''
+    addLibrarySource('$testPackageLibPath/foo.dart', '''
 class A<T> {
   const A();
 }
 ''');
-    testFile = convertPath('/home/test/lib/test.dart');
     var library = await checkLibrary('''
 import "foo.dart" as foo;
 @foo.A<int>()
@@ -27198,7 +27161,7 @@
   }
 
   test_metadata_exportDirective() async {
-    addLibrarySource('/foo.dart', '');
+    addLibrarySource('$testPackageLibPath/foo.dart', '');
     var library = await checkLibrary('@a export "foo.dart"; const a = null;');
     checkElementText(library, r'''
 library
@@ -27211,7 +27174,7 @@
         staticType: null
       element: self::@getter::a
   exports
-    foo.dart
+    package:test/foo.dart
       metadata
         Annotation
           atSign: @ @0
@@ -29116,11 +29079,11 @@
   }
 
   test_metadata_offsets_onUnit() async {
-    addSource('/a.dart', '''
+    addSource('$testPackageLibPath/a.dart', '''
 part of my.lib;
 ''');
 
-    addSource('/b.dart', '''
+    addSource('$testPackageLibPath/b.dart', '''
 part of my.lib;
 ''');
 
@@ -29372,7 +29335,7 @@
   }
 
   test_metadata_partDirective() async {
-    addSource('/foo.dart', 'part of L;');
+    addSource('$testPackageLibPath/foo.dart', 'part of L;');
     var library = await checkLibrary('''
 library L;
 @a
@@ -29407,10 +29370,10 @@
   }
 
   test_metadata_partDirective2() async {
-    addSource('/a.dart', r'''
+    addSource('$testPackageLibPath/a.dart', r'''
 part of 'test.dart';
 ''');
-    addSource('/b.dart', r'''
+    addSource('$testPackageLibPath/b.dart', r'''
 part of 'test.dart';
 ''');
     var library = await checkLibrary('''
@@ -29424,12 +29387,12 @@
   }
 
   test_metadata_prefixed_variable() async {
-    addLibrarySource('/a.dart', 'const b = null;');
+    addLibrarySource('$testPackageLibPath/a.dart', 'const b = null;');
     var library = await checkLibrary('import "a.dart" as a; @a.b class C {}');
     checkElementText(library, r'''
 library
   imports
-    a.dart as a @19
+    package:test/a.dart as a @19
   definingUnit
     classes
       class C @33
@@ -29444,11 +29407,11 @@
               period: . @24
               identifier: SimpleIdentifier
                 token: b @25
-                staticElement: a.dart::@getter::b
+                staticElement: package:test/a.dart::@getter::b
                 staticType: null
-              staticElement: a.dart::@getter::b
+              staticElement: package:test/a.dart::@getter::b
               staticType: null
-            element: a.dart::@getter::b
+            element: package:test/a.dart::@getter::b
         constructors
           synthetic @-1
 ''');
@@ -29885,7 +29848,6 @@
   }
 
   test_metadata_value_class_staticField() async {
-    testFile = convertPath('/home/test/lib/test.dart');
     var library = await checkLibrary('''
 class A {
   static const x = 0;
@@ -29933,7 +29895,6 @@
   }
 
   test_metadata_value_enum_constant() async {
-    testFile = convertPath('/home/test/lib/test.dart');
     var library = await checkLibrary('''
 enum E {a, b, c}
 @E.b
@@ -30049,7 +30010,6 @@
   }
 
   test_metadata_value_extension_staticField() async {
-    testFile = convertPath('/home/test/lib/test.dart');
     var library = await checkLibrary('''
 extension E on int {
   static const x = 0;
@@ -30097,8 +30057,7 @@
   }
 
   test_metadata_value_prefix_extension_staticField() async {
-    testFile = convertPath('/home/test/lib/test.dart');
-    addLibrarySource('/home/test/lib/foo.dart', '''
+    addLibrarySource('$testPackageLibPath/foo.dart', '''
 extension E on int {
   static const x = 0;
 }
@@ -30393,7 +30352,7 @@
   }
 
   test_mixin_inference_nullSafety2() async {
-    addLibrarySource('/a.dart', r'''
+    addLibrarySource('$testPackageLibPath/a.dart', r'''
 class A<T> {}
 
 mixin B<T> on A<T> {}
@@ -30408,7 +30367,7 @@
     checkElementText(library, r'''
 library
   imports
-    a.dart
+    package:test/a.dart
   definingUnit
     classes
       class D @37
@@ -30419,13 +30378,13 @@
         constructors
           synthetic @-1
             superConstructor: ConstructorMember
-              base: a.dart::@class::A::@constructor::•
+              base: package:test/a.dart::@class::A::@constructor::•
               substitution: {T: int*}
 ''');
   }
 
   test_mixin_inference_nullSafety_mixed_inOrder() async {
-    addLibrarySource('/a.dart', r'''
+    addLibrarySource('$testPackageLibPath/a.dart', r'''
 class A<T> {}
 mixin M<U> on A<U> {}
 ''');
@@ -30437,7 +30396,7 @@
     checkElementText(library, r'''
 library
   imports
-    a.dart
+    package:test/a.dart
   definingUnit
     classes
       class B @38
@@ -30447,14 +30406,14 @@
         constructors
           synthetic @-1
             superConstructor: ConstructorMember
-              base: a.dart::@class::A::@constructor::•
+              base: package:test/a.dart::@class::A::@constructor::•
               substitution: {T: int*}
 ''');
   }
 
   @FailingTest(reason: 'Out-of-order inference is not specified yet')
   test_mixin_inference_nullSafety_mixed_outOfOrder() async {
-    addLibrarySource('/a.dart', r'''
+    addLibrarySource('$testPackageLibPath/a.dart', r'''
 // @dart = 2.8
 class A<T> {}
 mixin M<U> on A<U> {}
@@ -30571,8 +30530,8 @@
   }
 
   test_nameConflict_exportedAndLocal() async {
-    addLibrarySource('/a.dart', 'class C {}');
-    addLibrarySource('/c.dart', '''
+    addLibrarySource('$testPackageLibPath/a.dart', 'class C {}');
+    addLibrarySource('$testPackageLibPath/c.dart', '''
 export 'a.dart';
 class C {}
 ''');
@@ -30583,7 +30542,7 @@
     checkElementText(library, r'''
 library
   imports
-    c.dart
+    package:test/c.dart
   definingUnit
     topLevelVariables
       static v @19
@@ -30600,12 +30559,12 @@
   }
 
   test_nameConflict_exportedAndLocal_exported() async {
-    addLibrarySource('/a.dart', 'class C {}');
-    addLibrarySource('/c.dart', '''
+    addLibrarySource('$testPackageLibPath/a.dart', 'class C {}');
+    addLibrarySource('$testPackageLibPath/c.dart', '''
 export 'a.dart';
 class C {}
 ''');
-    addLibrarySource('/d.dart', 'export "c.dart";');
+    addLibrarySource('$testPackageLibPath/d.dart', 'export "c.dart";');
     var library = await checkLibrary('''
 import 'd.dart';
 C v = null;
@@ -30613,7 +30572,7 @@
     checkElementText(library, r'''
 library
   imports
-    d.dart
+    package:test/d.dart
   definingUnit
     topLevelVariables
       static v @19
@@ -30630,12 +30589,12 @@
   }
 
   test_nameConflict_exportedAndParted() async {
-    addLibrarySource('/a.dart', 'class C {}');
-    addLibrarySource('/b.dart', '''
+    addLibrarySource('$testPackageLibPath/a.dart', 'class C {}');
+    addLibrarySource('$testPackageLibPath/b.dart', '''
 part of lib;
 class C {}
 ''');
-    addLibrarySource('/c.dart', '''
+    addLibrarySource('$testPackageLibPath/c.dart', '''
 library lib;
 export 'a.dart';
 part 'b.dart';
@@ -30647,7 +30606,7 @@
     checkElementText(library, r'''
 library
   imports
-    c.dart
+    package:test/c.dart
   definingUnit
     topLevelVariables
       static v @19
@@ -30668,8 +30627,8 @@
       return;
     }
 
-    addLibrarySource('/a.dart', 'class A {}');
-    addLibrarySource('/b.dart', 'export "/a.dart";');
+    addLibrarySource('$testPackageLibPath/a.dart', 'class A {}');
+    addLibrarySource('$testPackageLibPath/b.dart', 'export "/a.dart";');
     var library = await checkLibrary('''
 import 'a.dart';
 import 'b.dart';
@@ -30678,8 +30637,8 @@
     checkElementText(library, r'''
 library
   imports
-    a.dart
-    b.dart
+    package:test/a.dart
+    package:test/b.dart
   definingUnit
     topLevelVariables
       static v @36
@@ -32118,8 +32077,8 @@
   }
 
   test_parts() async {
-    addSource('/a.dart', 'part of my.lib;');
-    addSource('/b.dart', 'part of my.lib;');
+    addSource('$testPackageLibPath/a.dart', 'part of my.lib;');
+    addSource('$testPackageLibPath/b.dart', 'part of my.lib;');
     var library =
         await checkLibrary('library my.lib; part "a.dart"; part "b.dart";');
     checkElementText(library, r'''
@@ -32134,7 +32093,7 @@
   }
 
   test_parts_invalidUri() async {
-    addSource('/foo/bar.dart', 'part of my.lib;');
+    addSource('$testPackageLibPath/foo/bar.dart', 'part of my.lib;');
     var library = await checkLibrary('library my.lib; part "foo/";');
     checkElementText(library, r'''
 library
@@ -32147,7 +32106,7 @@
   }
 
   test_parts_invalidUri_nullStringValue() async {
-    addSource('/foo/bar.dart', 'part of my.lib;');
+    addSource('$testPackageLibPath/foo/bar.dart', 'part of my.lib;');
     var library = await checkLibrary(r'''
 library my.lib;
 part "${foo}/bar.dart";
@@ -32566,7 +32525,7 @@
   }
 
   test_type_inference_based_on_loadLibrary() async {
-    addLibrarySource('/a.dart', '');
+    addLibrarySource('$testPackageLibPath/a.dart', '');
     var library = await checkLibrary('''
 import 'a.dart' deferred as a;
 var x = a.loadLibrary;
@@ -32574,7 +32533,7 @@
     checkElementText(library, r'''
 library
   imports
-    a.dart deferred as a @28
+    package:test/a.dart deferred as a @28
   definingUnit
     topLevelVariables
       static x @35
@@ -32591,8 +32550,7 @@
   }
 
   test_type_inference_classField_fromNullSafe_toLegacy() async {
-    testFile = convertPath('/home/test/lib/test.dart');
-    addLibrarySource('/home/test/lib/a.dart', '''
+    addLibrarySource('$testPackageLibPath/a.dart', '''
 class E {
   static final a = 0;
 }
@@ -32659,8 +32617,8 @@
   }
 
   test_type_inference_depends_on_exported_variable() async {
-    addLibrarySource('/a.dart', 'export "b.dart";');
-    addLibrarySource('/b.dart', 'var x = 0;');
+    addLibrarySource('$testPackageLibPath/a.dart', 'export "b.dart";');
+    addLibrarySource('$testPackageLibPath/b.dart', 'var x = 0;');
     var library = await checkLibrary('''
 import 'a.dart';
 var y = x;
@@ -32668,7 +32626,7 @@
     checkElementText(library, r'''
 library
   imports
-    a.dart
+    package:test/a.dart
   definingUnit
     topLevelVariables
       static y @21
@@ -32908,8 +32866,8 @@
   }
 
   test_type_inference_multiplyDefinedElement() async {
-    addLibrarySource('/a.dart', 'class C {}');
-    addLibrarySource('/b.dart', 'class C {}');
+    addLibrarySource('$testPackageLibPath/a.dart', 'class C {}');
+    addLibrarySource('$testPackageLibPath/b.dart', 'class C {}');
     var library = await checkLibrary('''
 import 'a.dart';
 import 'b.dart';
@@ -32918,8 +32876,8 @@
     checkElementText(library, r'''
 library
   imports
-    a.dart
-    b.dart
+    package:test/a.dart
+    package:test/b.dart
   definingUnit
     topLevelVariables
       static v @38
@@ -33445,7 +33403,8 @@
   }
 
   test_type_reference_lib_to_part() async {
-    addSource('/a.dart', 'part of l; class C {} enum E { v } typedef F();');
+    addSource('$testPackageLibPath/a.dart',
+        'part of l; class C {} enum E { v } typedef F();');
     var library =
         await checkLibrary('library l; part "a.dart"; C c; E e; F f;');
     checkElementText(library, r'''
@@ -33539,7 +33498,7 @@
   }
 
   test_type_reference_part_to_lib() async {
-    addSource('/a.dart', 'part of l; C c; E e; F f;');
+    addSource('$testPackageLibPath/a.dart', 'part of l; C c; E e; F f;');
     var library = await checkLibrary(
         'library l; part "a.dart"; class C {} enum E { v } typedef F();');
     checkElementText(library, r'''
@@ -33633,8 +33592,9 @@
   }
 
   test_type_reference_part_to_other_part() async {
-    addSource('/a.dart', 'part of l; class C {} enum E { v } typedef F();');
-    addSource('/b.dart', 'part of l; C c; E e; F f;');
+    addSource('$testPackageLibPath/a.dart',
+        'part of l; class C {} enum E { v } typedef F();');
+    addSource('$testPackageLibPath/b.dart', 'part of l; C c; E e; F f;');
     var library =
         await checkLibrary('library l; part "a.dart"; part "b.dart";');
     checkElementText(library, r'''
@@ -33729,7 +33689,7 @@
   }
 
   test_type_reference_part_to_part() async {
-    addSource('/a.dart',
+    addSource('$testPackageLibPath/a.dart',
         'part of l; class C {} enum E { v } typedef F(); C c; E e; F f;');
     var library = await checkLibrary('library l; part "a.dart";');
     checkElementText(library, r'''
@@ -33960,12 +33920,13 @@
   }
 
   test_type_reference_to_import() async {
-    addLibrarySource('/a.dart', 'class C {} enum E { v } typedef F();');
+    addLibrarySource(
+        '$testPackageLibPath/a.dart', 'class C {} enum E { v } typedef F();');
     var library = await checkLibrary('import "a.dart"; C c; E e; F f;');
     checkElementText(library, r'''
 library
   imports
-    a.dart
+    package:test/a.dart
   definingUnit
     topLevelVariables
       static c @19
@@ -33974,7 +33935,7 @@
         type: E
       static f @29
         type: dynamic Function()
-          alias: a.dart::@typeAlias::F
+          alias: package:test/a.dart::@typeAlias::F
     accessors
       synthetic static get c @-1
         returnType: C
@@ -33992,24 +33953,25 @@
         returnType: void
       synthetic static get f @-1
         returnType: dynamic Function()
-          alias: a.dart::@typeAlias::F
+          alias: package:test/a.dart::@typeAlias::F
       synthetic static set f @-1
         parameters
           requiredPositional _f @-1
             type: dynamic Function()
-              alias: a.dart::@typeAlias::F
+              alias: package:test/a.dart::@typeAlias::F
         returnType: void
 ''');
   }
 
   test_type_reference_to_import_export() async {
-    addLibrarySource('/a.dart', 'export "b.dart";');
-    addLibrarySource('/b.dart', 'class C {} enum E { v } typedef F();');
+    addLibrarySource('$testPackageLibPath/a.dart', 'export "b.dart";');
+    addLibrarySource(
+        '$testPackageLibPath/b.dart', 'class C {} enum E { v } typedef F();');
     var library = await checkLibrary('import "a.dart"; C c; E e; F f;');
     checkElementText(library, r'''
 library
   imports
-    a.dart
+    package:test/a.dart
   definingUnit
     topLevelVariables
       static c @19
@@ -34018,7 +33980,7 @@
         type: E
       static f @29
         type: dynamic Function()
-          alias: b.dart::@typeAlias::F
+          alias: package:test/b.dart::@typeAlias::F
     accessors
       synthetic static get c @-1
         returnType: C
@@ -34036,25 +33998,26 @@
         returnType: void
       synthetic static get f @-1
         returnType: dynamic Function()
-          alias: b.dart::@typeAlias::F
+          alias: package:test/b.dart::@typeAlias::F
       synthetic static set f @-1
         parameters
           requiredPositional _f @-1
             type: dynamic Function()
-              alias: b.dart::@typeAlias::F
+              alias: package:test/b.dart::@typeAlias::F
         returnType: void
 ''');
   }
 
   test_type_reference_to_import_export_export() async {
-    addLibrarySource('/a.dart', 'export "b.dart";');
-    addLibrarySource('/b.dart', 'export "c.dart";');
-    addLibrarySource('/c.dart', 'class C {} enum E { v } typedef F();');
+    addLibrarySource('$testPackageLibPath/a.dart', 'export "b.dart";');
+    addLibrarySource('$testPackageLibPath/b.dart', 'export "c.dart";');
+    addLibrarySource(
+        '$testPackageLibPath/c.dart', 'class C {} enum E { v } typedef F();');
     var library = await checkLibrary('import "a.dart"; C c; E e; F f;');
     checkElementText(library, r'''
 library
   imports
-    a.dart
+    package:test/a.dart
   definingUnit
     topLevelVariables
       static c @19
@@ -34063,7 +34026,7 @@
         type: E
       static f @29
         type: dynamic Function()
-          alias: c.dart::@typeAlias::F
+          alias: package:test/c.dart::@typeAlias::F
     accessors
       synthetic static get c @-1
         returnType: C
@@ -34081,25 +34044,26 @@
         returnType: void
       synthetic static get f @-1
         returnType: dynamic Function()
-          alias: c.dart::@typeAlias::F
+          alias: package:test/c.dart::@typeAlias::F
       synthetic static set f @-1
         parameters
           requiredPositional _f @-1
             type: dynamic Function()
-              alias: c.dart::@typeAlias::F
+              alias: package:test/c.dart::@typeAlias::F
         returnType: void
 ''');
   }
 
   test_type_reference_to_import_export_export_in_subdirs() async {
-    addLibrarySource('/a/a.dart', 'export "b/b.dart";');
-    addLibrarySource('/a/b/b.dart', 'export "../c/c.dart";');
-    addLibrarySource('/a/c/c.dart', 'class C {} enum E { v } typedef F();');
+    addLibrarySource('$testPackageLibPath/a/a.dart', 'export "b/b.dart";');
+    addLibrarySource('$testPackageLibPath/a/b/b.dart', 'export "../c/c.dart";');
+    addLibrarySource('$testPackageLibPath/a/c/c.dart',
+        'class C {} enum E { v } typedef F();');
     var library = await checkLibrary('import "a/a.dart"; C c; E e; F f;');
     checkElementText(library, r'''
 library
   imports
-    a.dart
+    package:test/a/a.dart
   definingUnit
     topLevelVariables
       static c @21
@@ -34108,7 +34072,7 @@
         type: E
       static f @31
         type: dynamic Function()
-          alias: c.dart::@typeAlias::F
+          alias: package:test/a/c/c.dart::@typeAlias::F
     accessors
       synthetic static get c @-1
         returnType: C
@@ -34126,24 +34090,25 @@
         returnType: void
       synthetic static get f @-1
         returnType: dynamic Function()
-          alias: c.dart::@typeAlias::F
+          alias: package:test/a/c/c.dart::@typeAlias::F
       synthetic static set f @-1
         parameters
           requiredPositional _f @-1
             type: dynamic Function()
-              alias: c.dart::@typeAlias::F
+              alias: package:test/a/c/c.dart::@typeAlias::F
         returnType: void
 ''');
   }
 
   test_type_reference_to_import_export_in_subdirs() async {
-    addLibrarySource('/a/a.dart', 'export "b/b.dart";');
-    addLibrarySource('/a/b/b.dart', 'class C {} enum E { v } typedef F();');
+    addLibrarySource('$testPackageLibPath/a/a.dart', 'export "b/b.dart";');
+    addLibrarySource('$testPackageLibPath/a/b/b.dart',
+        'class C {} enum E { v } typedef F();');
     var library = await checkLibrary('import "a/a.dart"; C c; E e; F f;');
     checkElementText(library, r'''
 library
   imports
-    a.dart
+    package:test/a/a.dart
   definingUnit
     topLevelVariables
       static c @21
@@ -34152,7 +34117,7 @@
         type: E
       static f @31
         type: dynamic Function()
-          alias: b.dart::@typeAlias::F
+          alias: package:test/a/b/b.dart::@typeAlias::F
     accessors
       synthetic static get c @-1
         returnType: C
@@ -34170,24 +34135,25 @@
         returnType: void
       synthetic static get f @-1
         returnType: dynamic Function()
-          alias: b.dart::@typeAlias::F
+          alias: package:test/a/b/b.dart::@typeAlias::F
       synthetic static set f @-1
         parameters
           requiredPositional _f @-1
             type: dynamic Function()
-              alias: b.dart::@typeAlias::F
+              alias: package:test/a/b/b.dart::@typeAlias::F
         returnType: void
 ''');
   }
 
   test_type_reference_to_import_part() async {
-    addLibrarySource('/a.dart', 'library l; part "b.dart";');
-    addSource('/b.dart', 'part of l; class C {} enum E { v } typedef F();');
+    addLibrarySource('$testPackageLibPath/a.dart', 'library l; part "b.dart";');
+    addSource('$testPackageLibPath/b.dart',
+        'part of l; class C {} enum E { v } typedef F();');
     var library = await checkLibrary('import "a.dart"; C c; E e; F f;');
     checkElementText(library, r'''
 library
   imports
-    a.dart
+    package:test/a.dart
   definingUnit
     topLevelVariables
       static c @19
@@ -34196,7 +34162,7 @@
         type: E
       static f @29
         type: dynamic Function()
-          alias: a.dart::@typeAlias::F
+          alias: package:test/a.dart::@typeAlias::F
     accessors
       synthetic static get c @-1
         returnType: C
@@ -34214,25 +34180,26 @@
         returnType: void
       synthetic static get f @-1
         returnType: dynamic Function()
-          alias: a.dart::@typeAlias::F
+          alias: package:test/a.dart::@typeAlias::F
       synthetic static set f @-1
         parameters
           requiredPositional _f @-1
             type: dynamic Function()
-              alias: a.dart::@typeAlias::F
+              alias: package:test/a.dart::@typeAlias::F
         returnType: void
 ''');
   }
 
   test_type_reference_to_import_part2() async {
-    addLibrarySource('/a.dart', 'library l; part "p1.dart"; part "p2.dart";');
-    addSource('/p1.dart', 'part of l; class C1 {}');
-    addSource('/p2.dart', 'part of l; class C2 {}');
+    addLibrarySource('$testPackageLibPath/a.dart',
+        'library l; part "p1.dart"; part "p2.dart";');
+    addSource('$testPackageLibPath/p1.dart', 'part of l; class C1 {}');
+    addSource('$testPackageLibPath/p2.dart', 'part of l; class C2 {}');
     var library = await checkLibrary('import "a.dart"; C1 c1; C2 c2;');
     checkElementText(library, r'''
 library
   imports
-    a.dart
+    package:test/a.dart
   definingUnit
     topLevelVariables
       static c1 @20
@@ -34258,13 +34225,15 @@
   }
 
   test_type_reference_to_import_part_in_subdir() async {
-    addLibrarySource('/a/b.dart', 'library l; part "c.dart";');
-    addSource('/a/c.dart', 'part of l; class C {} enum E { v } typedef F();');
+    addLibrarySource(
+        '$testPackageLibPath/a/b.dart', 'library l; part "c.dart";');
+    addSource('$testPackageLibPath/a/c.dart',
+        'part of l; class C {} enum E { v } typedef F();');
     var library = await checkLibrary('import "a/b.dart"; C c; E e; F f;');
     checkElementText(library, r'''
 library
   imports
-    b.dart
+    package:test/a/b.dart
   definingUnit
     topLevelVariables
       static c @21
@@ -34273,7 +34242,7 @@
         type: E
       static f @31
         type: dynamic Function()
-          alias: b.dart::@typeAlias::F
+          alias: package:test/a/b.dart::@typeAlias::F
     accessors
       synthetic static get c @-1
         returnType: C
@@ -34291,23 +34260,24 @@
         returnType: void
       synthetic static get f @-1
         returnType: dynamic Function()
-          alias: b.dart::@typeAlias::F
+          alias: package:test/a/b.dart::@typeAlias::F
       synthetic static set f @-1
         parameters
           requiredPositional _f @-1
             type: dynamic Function()
-              alias: b.dart::@typeAlias::F
+              alias: package:test/a/b.dart::@typeAlias::F
         returnType: void
 ''');
   }
 
   test_type_reference_to_import_relative() async {
-    addLibrarySource('/a.dart', 'class C {} enum E { v } typedef F();');
+    addLibrarySource(
+        '$testPackageLibPath/a.dart', 'class C {} enum E { v } typedef F();');
     var library = await checkLibrary('import "a.dart"; C c; E e; F f;');
     checkElementText(library, r'''
 library
   imports
-    a.dart
+    package:test/a.dart
   definingUnit
     topLevelVariables
       static c @19
@@ -34316,7 +34286,7 @@
         type: E
       static f @29
         type: dynamic Function()
-          alias: a.dart::@typeAlias::F
+          alias: package:test/a.dart::@typeAlias::F
     accessors
       synthetic static get c @-1
         returnType: C
@@ -34334,12 +34304,12 @@
         returnType: void
       synthetic static get f @-1
         returnType: dynamic Function()
-          alias: a.dart::@typeAlias::F
+          alias: package:test/a.dart::@typeAlias::F
       synthetic static set f @-1
         parameters
           requiredPositional _f @-1
             type: dynamic Function()
-              alias: a.dart::@typeAlias::F
+              alias: package:test/a.dart::@typeAlias::F
         returnType: void
 ''');
   }
@@ -36359,14 +36329,13 @@
     checkElementText(library, r'''
 library
   imports
-    a.dart
+    package:test/a.dart
   definingUnit
     functions
       f @37
         parameters
           requiredPositional a @41
-            type: List<int*>*
-              alias: a.dart::@typeAlias::A
+            type: dynamic
         returnType: void
 ''');
   }
@@ -37030,8 +36999,8 @@
   }
 
   test_unresolved_annotation_simpleIdentifier_multiplyDefined() async {
-    addLibrarySource('/a.dart', 'const v = 0;');
-    addLibrarySource('/b.dart', 'const v = 0;');
+    addLibrarySource('$testPackageLibPath/a.dart', 'const v = 0;');
+    addLibrarySource('$testPackageLibPath/b.dart', 'const v = 0;');
     var library = await checkLibrary('''
 import 'a.dart';
 import 'b.dart';
@@ -37042,8 +37011,8 @@
     checkElementText(library, r'''
 library
   imports
-    a.dart
-    b.dart
+    package:test/a.dart
+    package:test/b.dart
   definingUnit
     classes
       class C @44
@@ -37088,7 +37057,7 @@
     checkElementText(library, r'''
 library
   exports
-    foo.dart
+    package:test/foo.dart
   definingUnit
 ''');
   }
@@ -37102,7 +37071,7 @@
     checkElementText(library, r'''
 library
   imports
-    foo.dart
+    package:test/foo.dart
   definingUnit
 ''');
   }
@@ -37256,7 +37225,7 @@
   }
 
   test_variable_getterInLib_setterInPart() async {
-    addSource('/a.dart', '''
+    addSource('$testPackageLibPath/a.dart', '''
 part of my.lib;
 void set x(int _) {}
 ''');
@@ -37290,7 +37259,7 @@
   }
 
   test_variable_getterInPart_setterInLib() async {
-    addSource('/a.dart', '''
+    addSource('$testPackageLibPath/a.dart', '''
 part of my.lib;
 int get x => 42;
 ''');
@@ -37325,8 +37294,9 @@
   }
 
   test_variable_getterInPart_setterInPart() async {
-    addSource('/a.dart', 'part of my.lib; int get x => 42;');
-    addSource('/b.dart', 'part of my.lib; void set x(int _) {}');
+    addSource('$testPackageLibPath/a.dart', 'part of my.lib; int get x => 42;');
+    addSource(
+        '$testPackageLibPath/b.dart', 'part of my.lib; void set x(int _) {}');
     var library =
         await checkLibrary('library my.lib; part "a.dart"; part "b.dart";');
     checkElementText(library, r'''
@@ -37580,12 +37550,12 @@
   }
 
   test_variable_propagatedType_final_dep_inLib() async {
-    addLibrarySource('/a.dart', 'final a = 1;');
+    addLibrarySource('$testPackageLibPath/a.dart', 'final a = 1;');
     var library = await checkLibrary('import "a.dart"; final b = a / 2;');
     checkElementText(library, r'''
 library
   imports
-    a.dart
+    package:test/a.dart
   definingUnit
     topLevelVariables
       static final b @23
@@ -37597,7 +37567,7 @@
   }
 
   test_variable_propagatedType_final_dep_inPart() async {
-    addSource('/a.dart', 'part of lib; final a = 1;');
+    addSource('$testPackageLibPath/a.dart', 'part of lib; final a = 1;');
     var library =
         await checkLibrary('library lib; part "a.dart"; final b = a / 2;');
     checkElementText(library, r'''
@@ -37638,13 +37608,14 @@
 
   test_variable_propagatedType_implicit_dep() async {
     // The propagated type is defined in a library that is not imported.
-    addLibrarySource('/a.dart', 'class C {}');
-    addLibrarySource('/b.dart', 'import "a.dart"; C f() => null;');
+    addLibrarySource('$testPackageLibPath/a.dart', 'class C {}');
+    addLibrarySource(
+        '$testPackageLibPath/b.dart', 'import "a.dart"; C f() => null;');
     var library = await checkLibrary('import "b.dart"; final x = f();');
     checkElementText(library, r'''
 library
   imports
-    b.dart
+    package:test/b.dart
   definingUnit
     topLevelVariables
       static final x @23
@@ -37656,8 +37627,9 @@
   }
 
   test_variable_setterInPart_getterInPart() async {
-    addSource('/a.dart', 'part of my.lib; void set x(int _) {}');
-    addSource('/b.dart', 'part of my.lib; int get x => 42;');
+    addSource(
+        '$testPackageLibPath/a.dart', 'part of my.lib; void set x(int _) {}');
+    addSource('$testPackageLibPath/b.dart', 'part of my.lib; int get x => 42;');
     var library =
         await checkLibrary('library my.lib; part "a.dart"; part "b.dart";');
     checkElementText(library, r'''
@@ -37731,7 +37703,7 @@
   }
 
   test_variable_type_inferred_nonNullify() async {
-    addSource('/a.dart', '''
+    addSource('$testPackageLibPath/a.dart', '''
 // @dart = 2.7
 var a = 0;
 ''');
@@ -37744,7 +37716,7 @@
     checkElementText(library, r'''
 library
   imports
-    a.dart
+    package:test/a.dart
   definingUnit
     topLevelVariables
       static b @21
diff --git a/pkg/front_end/lib/src/fasta/source/source_class_builder.dart b/pkg/front_end/lib/src/fasta/source/source_class_builder.dart
index bbadbf0..7646843 100644
--- a/pkg/front_end/lib/src/fasta/source/source_class_builder.dart
+++ b/pkg/front_end/lib/src/fasta/source/source_class_builder.dart
@@ -66,12 +66,17 @@
     int startCharOffset,
     int charOffset,
     int charEndOffset,
-    IndexedClass? referencesFrom) {
+    IndexedClass? referencesFrom,
+    {required bool isAugmentation}) {
   cls ??= new Class(
       name: name,
       typeParameters:
           TypeVariableBuilder.typeParametersFromBuilders(typeVariables),
-      reference: referencesFrom?.cls.reference,
+      // If the class is an augmentation class it shouldn't use the reference
+      // from index even when available.
+      // TODO(johnniwinther): Avoid creating [Class] so early in the builder
+      // that we end up creating unneeded nodes.
+      reference: isAugmentation ? null : referencesFrom?.cls.reference,
       fileUri: parent.fileUri);
   if (cls.startFileOffset == TreeNode.noOffset) {
     cls.startFileOffset = startCharOffset;
@@ -129,7 +134,8 @@
       this.isMacro = false,
       this.isAugmentation = false})
       : actualCls = initializeClass(cls, typeVariables, name, parent,
-            startCharOffset, nameOffset, charEndOffset, referencesFromIndexed),
+            startCharOffset, nameOffset, charEndOffset, referencesFromIndexed,
+            isAugmentation: isAugmentation),
         super(metadata, modifiers, name, typeVariables, supertype, interfaces,
             onTypes, scope, constructors, parent, nameOffset) {
     actualCls.hasConstConstructor = declaresConstConstructor;
diff --git a/pkg/front_end/lib/src/fasta/source/source_library_builder.dart b/pkg/front_end/lib/src/fasta/source/source_library_builder.dart
index 8c5da3c..17257de 100644
--- a/pkg/front_end/lib/src/fasta/source/source_library_builder.dart
+++ b/pkg/front_end/lib/src/fasta/source/source_library_builder.dart
@@ -530,7 +530,8 @@
         isUnsupported: false,
         target: library,
         origin: this,
-        isAugmentation: true);
+        isAugmentation: true,
+        referencesFrom: referencesFrom);
     addPatchLibrary(augmentationLibrary);
     loader.registerUnparsedLibrarySource(augmentationLibrary, source);
     return augmentationLibrary;
@@ -801,7 +802,8 @@
       builder = loader.read(resolvedUri, uriOffset,
           origin: isAugmentationImport ? this : null,
           accessor: this,
-          isAugmentation: isAugmentationImport);
+          isAugmentation: isAugmentationImport,
+          referencesFrom: isAugmentationImport ? referencesFrom : null);
     }
 
     imports.add(new Import(
@@ -1880,6 +1882,7 @@
             isMixinDeclaration,
             typeVariables: typeVariables,
             isMacro: false,
+            // TODO(johnniwinther): How can we support class with mixins?
             isAugmentation: false),
         interfaces,
         // TODO(johnniwinther): Add the `on` clause types of a mixin declaration
diff --git a/pkg/front_end/test/macros/incremental/data/pkgs/macro/lib/macro.dart b/pkg/front_end/test/macros/incremental/data/pkgs/macro/lib/macro.dart
index dcfe2f7..9b3df34 100644
--- a/pkg/front_end/test/macros/incremental/data/pkgs/macro/lib/macro.dart
+++ b/pkg/front_end/test/macros/incremental/data/pkgs/macro/lib/macro.dart
@@ -37,3 +37,19 @@
     }
   }
 }
+
+macro
+
+class InjectMacro implements ClassDeclarationsMacro {
+  const InjectMacro();
+
+  @override
+  FutureOr<void> buildDeclarationsForClass(ClassDeclaration clazz,
+      ClassMemberDeclarationBuilder builder) async {
+    Iterable<MethodDeclaration> methods = await builder.methodsOf(clazz);
+    if (!methods.any((m) => m.identifier.name == 'injectedMethod')) {
+      builder.declareInClass(new DeclarationCode.fromString('''
+ void injectedMethod() {}'''));
+    }
+  }
+}
diff --git a/pkg/front_end/test/macros/incremental/data/tests/inject_macro.0.dart b/pkg/front_end/test/macros/incremental/data/tests/inject_macro.0.dart
new file mode 100644
index 0000000..31bf8ab
--- /dev/null
+++ b/pkg/front_end/test/macros/incremental/data/tests/inject_macro.0.dart
@@ -0,0 +1,10 @@
+// Copyright (c) 2022, 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.
+
+import 'package:macro/macro.dart';
+
+@InjectMacro()
+class Class {
+  void existingMethod() {}
+}
diff --git a/pkg/front_end/test/macros/incremental/data/tests/inject_macro.0.dart.expect b/pkg/front_end/test/macros/incremental/data/tests/inject_macro.0.dart.expect
new file mode 100644
index 0000000..a288219
--- /dev/null
+++ b/pkg/front_end/test/macros/incremental/data/tests/inject_macro.0.dart.expect
@@ -0,0 +1,19 @@
+library /*isNonNullableByDefault*/;
+import self as self;
+import "package:macro/macro.dart" as mac;
+import "dart:core" as core;
+
+import "package:macro/macro.dart";
+
+@#C1
+class Class extends core::Object {
+  synthetic constructor •() → self::Class
+    : super core::Object::•()
+    ;
+  method /* from org-dartlang-augmentation:/a/b/c/inject_macro.dart-0 */ injectedMethod() → void {}
+  method existingMethod() → void {}
+}
+
+constants  {
+  #C1 = #lib1::InjectMacro {}
+}
diff --git a/pkg/front_end/test/macros/incremental/data/tests/inject_macro.1.dart b/pkg/front_end/test/macros/incremental/data/tests/inject_macro.1.dart
new file mode 100644
index 0000000..d5aad15
--- /dev/null
+++ b/pkg/front_end/test/macros/incremental/data/tests/inject_macro.1.dart
@@ -0,0 +1,12 @@
+// Copyright (c) 2022, 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.
+
+import 'package:macro/macro.dart';
+
+@InjectMacro()
+class Class {
+  void existingMethod() {
+    print('existingMethod');
+  }
+}
diff --git a/pkg/front_end/test/macros/incremental/data/tests/inject_macro.1.dart.expect b/pkg/front_end/test/macros/incremental/data/tests/inject_macro.1.dart.expect
new file mode 100644
index 0000000..20889b9
--- /dev/null
+++ b/pkg/front_end/test/macros/incremental/data/tests/inject_macro.1.dart.expect
@@ -0,0 +1,21 @@
+library /*isNonNullableByDefault*/;
+import self as self;
+import "package:macro/macro.dart" as mac;
+import "dart:core" as core;
+
+import "package:macro/macro.dart";
+
+@#C1
+class Class extends core::Object {
+  synthetic constructor •() → self::Class
+    : super core::Object::•()
+    ;
+  method /* from org-dartlang-augmentation:/a/b/c/inject_macro.dart-0 */ injectedMethod() → void {}
+  method existingMethod() → void {
+    core::print("existingMethod");
+  }
+}
+
+constants  {
+  #C1 = #lib1::InjectMacro {}
+}
diff --git a/pkg/front_end/test/macros/incremental/incremental_macro_test.dart b/pkg/front_end/test/macros/incremental/incremental_macro_test.dart
index 7fb1af7..2213b4c 100644
--- a/pkg/front_end/test/macros/incremental/incremental_macro_test.dart
+++ b/pkg/front_end/test/macros/incremental/incremental_macro_test.dart
@@ -20,7 +20,7 @@
 import 'package:front_end/src/isolate_macro_serializer.dart';
 import 'package:front_end/src/macro_serializer.dart';
 import 'package:front_end/src/testing/compiler_common.dart';
-import 'package:kernel/ast.dart';
+import 'package:kernel/kernel.dart';
 import 'package:kernel/target/targets.dart';
 import 'package:kernel/text/ast_to_text.dart';
 import 'package:vm/target/vm.dart';
@@ -154,6 +154,9 @@
           throw 'Please use -g option to create file ${expectationFileName} '
               'with this content:\n$actual';
         }
+
+        /// Test serialization
+        writeComponentToBytes(component);
       }
     }
   }, errorOnMissingInput: false);
diff --git a/runtime/bin/builtin_impl_sources.gni b/runtime/bin/builtin_impl_sources.gni
index ff6a6c3..feb1ee8 100644
--- a/runtime/bin/builtin_impl_sources.gni
+++ b/runtime/bin/builtin_impl_sources.gni
@@ -45,6 +45,8 @@
   "isolate_data.h",
   "lockers.h",
   "thread.h",
+  "thread_absl.cc",
+  "thread_absl.h",
   "thread_android.cc",
   "thread_android.h",
   "thread_fuchsia.cc",
diff --git a/runtime/bin/thread.h b/runtime/bin/thread.h
index d6716c9..bff42e9 100644
--- a/runtime/bin/thread.h
+++ b/runtime/bin/thread.h
@@ -16,7 +16,9 @@
 }  // namespace dart
 
 // Declare the OS-specific types ahead of defining the generic classes.
-#if defined(DART_HOST_OS_ANDROID)
+#if defined(DART_USE_ABSL)
+#include "bin/thread_absl.h"
+#elif defined(DART_HOST_OS_ANDROID)
 #include "bin/thread_android.h"
 #elif defined(DART_HOST_OS_FUCHSIA)
 #include "bin/thread_fuchsia.h"
diff --git a/runtime/bin/thread_absl.cc b/runtime/bin/thread_absl.cc
new file mode 100644
index 0000000..5db7af1
--- /dev/null
+++ b/runtime/bin/thread_absl.cc
@@ -0,0 +1,221 @@
+// Copyright (c) 2022, 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/globals.h"
+#if defined(DART_USE_ABSL)
+
+#include <errno.h>         // NOLINT
+#include <sys/resource.h>  // NOLINT
+#include <sys/time.h>      // NOLINT
+
+#include "bin/thread.h"
+#include "bin/thread_absl.h"
+#include "platform/assert.h"
+#include "platform/utils.h"
+
+namespace dart {
+namespace bin {
+
+#define VALIDATE_PTHREAD_RESULT(result)                                        \
+  if (result != 0) {                                                           \
+    const int kBufferSize = 1024;                                              \
+    char error_buf[kBufferSize];                                               \
+    FATAL2("pthread error: %d (%s)", result,                                   \
+           Utils::StrError(result, error_buf, kBufferSize));                   \
+  }
+
+#ifdef DEBUG
+#define RETURN_ON_PTHREAD_FAILURE(result)                                      \
+  if (result != 0) {                                                           \
+    const int kBufferSize = 1024;                                              \
+    char error_buf[kBufferSize];                                               \
+    fprintf(stderr, "%s:%d: pthread error: %d (%s)\n", __FILE__, __LINE__,     \
+            result, Utils::StrError(result, error_buf, kBufferSize));          \
+    return result;                                                             \
+  }
+#else
+#define RETURN_ON_PTHREAD_FAILURE(result)                                      \
+  if (result != 0) {                                                           \
+    return result;                                                             \
+  }
+#endif
+
+class ThreadStartData {
+ public:
+  ThreadStartData(const char* name,
+                  Thread::ThreadStartFunction function,
+                  uword parameter)
+      : name_(name), function_(function), parameter_(parameter) {}
+
+  const char* name() const { return name_; }
+  Thread::ThreadStartFunction function() const { return function_; }
+  uword parameter() const { return parameter_; }
+
+ private:
+  const char* name_;
+  Thread::ThreadStartFunction function_;
+  uword parameter_;
+
+  DISALLOW_COPY_AND_ASSIGN(ThreadStartData);
+};
+
+// Dispatch to the thread start function provided by the caller. This trampoline
+// is used to ensure that the thread is properly destroyed if the thread just
+// exits.
+static void* ThreadStart(void* data_ptr) {
+  ThreadStartData* data = reinterpret_cast<ThreadStartData*>(data_ptr);
+
+  const char* name = data->name();
+  Thread::ThreadStartFunction function = data->function();
+  uword parameter = data->parameter();
+  delete data;
+
+  // Set the thread name. There is 16 bytes limit on the name (including \0).
+  // pthread_setname_np ignores names that are too long rather than truncating.
+  char truncated_name[16];
+  snprintf(truncated_name, sizeof(truncated_name), "%s", name);
+  pthread_setname_np(pthread_self(), truncated_name);
+
+  // Call the supplied thread start function handing it its parameters.
+  function(parameter);
+
+  return NULL;
+}
+
+int Thread::Start(const char* name,
+                  ThreadStartFunction function,
+                  uword parameter) {
+  pthread_attr_t attr;
+  int result = pthread_attr_init(&attr);
+  RETURN_ON_PTHREAD_FAILURE(result);
+
+  result = pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
+  RETURN_ON_PTHREAD_FAILURE(result);
+
+  result = pthread_attr_setstacksize(&attr, Thread::GetMaxStackSize());
+  RETURN_ON_PTHREAD_FAILURE(result);
+
+  ThreadStartData* data = new ThreadStartData(name, function, parameter);
+
+  pthread_t tid;
+  result = pthread_create(&tid, &attr, ThreadStart, data);
+  RETURN_ON_PTHREAD_FAILURE(result);
+
+  result = pthread_attr_destroy(&attr);
+  RETURN_ON_PTHREAD_FAILURE(result);
+
+  return 0;
+}
+
+const ThreadLocalKey Thread::kUnsetThreadLocalKey =
+    static_cast<pthread_key_t>(-1);
+const ThreadId Thread::kInvalidThreadId = static_cast<ThreadId>(0);
+
+ThreadLocalKey Thread::CreateThreadLocal() {
+  pthread_key_t key = kUnsetThreadLocalKey;
+  int result = pthread_key_create(&key, NULL);
+  VALIDATE_PTHREAD_RESULT(result);
+  ASSERT(key != kUnsetThreadLocalKey);
+  return key;
+}
+
+void Thread::DeleteThreadLocal(ThreadLocalKey key) {
+  ASSERT(key != kUnsetThreadLocalKey);
+  int result = pthread_key_delete(key);
+  VALIDATE_PTHREAD_RESULT(result);
+}
+
+void Thread::SetThreadLocal(ThreadLocalKey key, uword value) {
+  ASSERT(key != kUnsetThreadLocalKey);
+  int result = pthread_setspecific(key, reinterpret_cast<void*>(value));
+  VALIDATE_PTHREAD_RESULT(result);
+}
+
+intptr_t Thread::GetMaxStackSize() {
+  const int kStackSize = (128 * kWordSize * KB);
+  return kStackSize;
+}
+
+ThreadId Thread::GetCurrentThreadId() {
+  return pthread_self();
+}
+
+intptr_t Thread::ThreadIdToIntPtr(ThreadId id) {
+  ASSERT(sizeof(id) == sizeof(intptr_t));
+  return static_cast<intptr_t>(id);
+}
+
+bool Thread::Compare(ThreadId a, ThreadId b) {
+  return (pthread_equal(a, b) != 0);
+}
+
+Mutex::Mutex() : data_() {}
+
+Mutex::~Mutex() {}
+
+ABSL_NO_THREAD_SAFETY_ANALYSIS
+void Mutex::Lock() {
+  data_.mutex()->Lock();
+}
+
+ABSL_NO_THREAD_SAFETY_ANALYSIS
+bool Mutex::TryLock() {
+  if (!data_.mutex()->TryLock()) {
+    return false;
+  }
+  return true;
+}
+
+ABSL_NO_THREAD_SAFETY_ANALYSIS
+void Mutex::Unlock() {
+  data_.mutex()->Unlock();
+}
+
+Monitor::Monitor() : data_() {}
+
+Monitor::~Monitor() {}
+
+ABSL_NO_THREAD_SAFETY_ANALYSIS
+void Monitor::Enter() {
+  data_.mutex()->Lock();
+}
+
+ABSL_NO_THREAD_SAFETY_ANALYSIS
+void Monitor::Exit() {
+  data_.mutex()->Unlock();
+}
+
+Monitor::WaitResult Monitor::Wait(int64_t millis) {
+  return WaitMicros(millis * kMicrosecondsPerMillisecond);
+}
+
+ABSL_NO_THREAD_SAFETY_ANALYSIS
+Monitor::WaitResult Monitor::WaitMicros(int64_t micros) {
+  Monitor::WaitResult retval = kNotified;
+  if (micros == kNoTimeout) {
+    // Wait forever.
+    data_.cond()->Wait(data_.mutex());
+  } else {
+    if (data_.cond()->WaitWithTimeout(data_.mutex(),
+                                      absl::Microseconds(micros))) {
+      retval = kTimedOut;
+    }
+  }
+  return retval;
+}
+
+ABSL_NO_THREAD_SAFETY_ANALYSIS
+void Monitor::Notify() {
+  data_.cond()->Signal();
+}
+
+ABSL_NO_THREAD_SAFETY_ANALYSIS
+void Monitor::NotifyAll() {
+  data_.cond()->SignalAll();
+}
+
+}  // namespace bin
+}  // namespace dart
+
+#endif  // defined(DART_USE_ABSL)
diff --git a/runtime/bin/thread_absl.h b/runtime/bin/thread_absl.h
new file mode 100644
index 0000000..649f2e7
--- /dev/null
+++ b/runtime/bin/thread_absl.h
@@ -0,0 +1,76 @@
+// Copyright (c) 2022, 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.
+
+#ifndef RUNTIME_BIN_THREAD_ABSL_H_
+#define RUNTIME_BIN_THREAD_ABSL_H_
+
+#if !defined(RUNTIME_BIN_THREAD_H_)
+#error Do not include thread_absl.h directly; use thread.h instead.
+#endif
+
+#include <pthread.h>
+
+#include "platform/assert.h"
+#include "platform/globals.h"
+#include "third_party/absl/synchronization/mutex.h"
+
+namespace dart {
+namespace bin {
+
+typedef pthread_key_t ThreadLocalKey;
+typedef pthread_t ThreadId;
+
+class ThreadInlineImpl {
+ private:
+  ThreadInlineImpl() {}
+  ~ThreadInlineImpl() {}
+
+  static uword GetThreadLocal(ThreadLocalKey key) {
+    static ThreadLocalKey kUnsetThreadLocalKey = static_cast<pthread_key_t>(-1);
+    ASSERT(key != kUnsetThreadLocalKey);
+    return reinterpret_cast<uword>(pthread_getspecific(key));
+  }
+
+  friend class Thread;
+
+  DISALLOW_ALLOCATION();
+  DISALLOW_COPY_AND_ASSIGN(ThreadInlineImpl);
+};
+
+class MutexData {
+ private:
+  MutexData() : mutex_() {}
+  ~MutexData() {}
+
+  absl::Mutex* mutex() { return &mutex_; }
+
+  absl::Mutex mutex_;
+
+  friend class Mutex;
+
+  DISALLOW_ALLOCATION();
+  DISALLOW_COPY_AND_ASSIGN(MutexData);
+};
+
+class MonitorData {
+ private:
+  MonitorData() : mutex_(), cond_() {}
+  ~MonitorData() {}
+
+  absl::Mutex* mutex() { return &mutex_; }
+  absl::CondVar* cond() { return &cond_; }
+
+  absl::Mutex mutex_;
+  absl::CondVar cond_;
+
+  friend class Monitor;
+
+  DISALLOW_ALLOCATION();
+  DISALLOW_COPY_AND_ASSIGN(MonitorData);
+};
+
+}  // namespace bin
+}  // namespace dart
+
+#endif  // RUNTIME_BIN_THREAD_ABSL_H_
diff --git a/runtime/bin/thread_android.cc b/runtime/bin/thread_android.cc
index 60c911a..2848e46 100644
--- a/runtime/bin/thread_android.cc
+++ b/runtime/bin/thread_android.cc
@@ -3,7 +3,7 @@
 // BSD-style license that can be found in the LICENSE file.
 
 #include "platform/globals.h"
-#if defined(DART_HOST_OS_ANDROID)
+#if defined(DART_HOST_OS_ANDROID) && !defined(DART_USE_ABSL)
 
 #include "bin/thread.h"
 #include "bin/thread_android.h"
@@ -301,4 +301,4 @@
 }  // namespace bin
 }  // namespace dart
 
-#endif  // defined(DART_HOST_OS_ANDROID)
+#endif  // defined(DART_HOST_OS_ANDROID) && !defined(DART_USE_ABSL)
diff --git a/runtime/bin/thread_fuchsia.cc b/runtime/bin/thread_fuchsia.cc
index 66b847d..ef839f1 100644
--- a/runtime/bin/thread_fuchsia.cc
+++ b/runtime/bin/thread_fuchsia.cc
@@ -3,7 +3,7 @@
 // BSD-style license that can be found in the LICENSE file.
 
 #include "platform/globals.h"
-#if defined(DART_HOST_OS_FUCHSIA)
+#if defined(DART_HOST_OS_FUCHSIA) && !defined(DART_USE_ABSL)
 
 #include "bin/thread.h"
 #include "bin/thread_fuchsia.h"
@@ -305,4 +305,4 @@
 }  // namespace bin
 }  // namespace dart
 
-#endif  // defined(DART_HOST_OS_FUCHSIA)
+#endif  // defined(DART_HOST_OS_FUCHSIA) && !defined(DART_USE_ABSL)
diff --git a/runtime/bin/thread_linux.cc b/runtime/bin/thread_linux.cc
index 1a46a3e..bd8688d 100644
--- a/runtime/bin/thread_linux.cc
+++ b/runtime/bin/thread_linux.cc
@@ -3,7 +3,7 @@
 // BSD-style license that can be found in the LICENSE file.
 
 #include "platform/globals.h"
-#if defined(DART_HOST_OS_LINUX)
+#if defined(DART_HOST_OS_LINUX) && !defined(DART_USE_ABSL)
 
 #include "bin/thread.h"
 #include "bin/thread_linux.h"
@@ -304,4 +304,4 @@
 }  // namespace bin
 }  // namespace dart
 
-#endif  // defined(DART_HOST_OS_LINUX)
+#endif  // defined(DART_HOST_OS_LINUX) && !defined(DART_USE_ABSL)
diff --git a/runtime/bin/thread_macos.cc b/runtime/bin/thread_macos.cc
index a38c441..3b22fb3 100644
--- a/runtime/bin/thread_macos.cc
+++ b/runtime/bin/thread_macos.cc
@@ -3,7 +3,7 @@
 // BSD-style license that can be found in the LICENSE file.
 
 #include "platform/globals.h"
-#if defined(DART_HOST_OS_MACOS)
+#if defined(DART_HOST_OS_MACOS) && !defined(DART_USE_ABSL)
 
 #include "bin/thread.h"
 #include "bin/thread_macos.h"
@@ -294,4 +294,4 @@
 }  // namespace bin
 }  // namespace dart
 
-#endif  // defined(DART_HOST_OS_MACOS)
+#endif  // defined(DART_HOST_OS_MACOS) && !defined(DART_USE_ABSL)
diff --git a/runtime/bin/thread_win.cc b/runtime/bin/thread_win.cc
index 53809f3..a0c20ba 100644
--- a/runtime/bin/thread_win.cc
+++ b/runtime/bin/thread_win.cc
@@ -3,7 +3,7 @@
 // BSD-style license that can be found in the LICENSE file.
 
 #include "platform/globals.h"
-#if defined(DART_HOST_OS_WINDOWS)
+#if defined(DART_HOST_OS_WINDOWS) && !defined(DART_USE_ABSL)
 
 #include "bin/thread.h"
 #include "bin/thread_win.h"
@@ -192,4 +192,4 @@
 }  // namespace bin
 }  // namespace dart
 
-#endif  // defined(DART_HOST_OS_WINDOWS)
+#endif  // defined(DART_HOST_OS_WINDOWS) && !defined(DART_USE_ABSL)
diff --git a/runtime/tools/run_clang_tidy.dart b/runtime/tools/run_clang_tidy.dart
index 84b66e8..2c12e45 100644
--- a/runtime/tools/run_clang_tidy.dart
+++ b/runtime/tools/run_clang_tidy.dart
@@ -64,6 +64,7 @@
   'runtime/bin/socket_base_linux.h',
   'runtime/bin/socket_base_macos.h',
   'runtime/bin/socket_base_win.h',
+  'runtime/bin/thread_absl.h',
   'runtime/bin/thread_android.h',
   'runtime/bin/thread_fuchsia.h',
   'runtime/bin/thread_linux.h',
@@ -100,6 +101,7 @@
   'runtime/vm/instructions_ia32.h',
   'runtime/vm/instructions_riscv.h',
   'runtime/vm/instructions_x64.h',
+  'runtime/vm/os_thread_absl.h',
   'runtime/vm/os_thread_android.h',
   'runtime/vm/os_thread_fuchsia.h',
   'runtime/vm/os_thread_linux.h',
diff --git a/runtime/vm/compiler/assembler/assembler_riscv.cc b/runtime/vm/compiler/assembler/assembler_riscv.cc
index 897c9d7..7ff6002 100644
--- a/runtime/vm/compiler/assembler/assembler_riscv.cc
+++ b/runtime/vm/compiler/assembler/assembler_riscv.cc
@@ -3474,12 +3474,12 @@
   subi(SP, SP, frame_size + 2 * target::kWordSize);
   sx(RA, Address(SP, frame_size + 1 * target::kWordSize));
   sx(FP, Address(SP, frame_size + 0 * target::kWordSize));
-  addi(FP, SP, frame_size + 0 * target::kWordSize);
+  addi(FP, SP, frame_size + 2 * target::kWordSize);
 }
 void Assembler::LeaveFrame() {
   // N.B. The ordering here is important. We must never read beyond SP or
   // it may have already been clobbered by a signal handler.
-  mv(SP, FP);
+  subi(SP, FP, 2 * target::kWordSize);
   lx(FP, Address(SP, 0 * target::kWordSize));
   lx(RA, Address(SP, 1 * target::kWordSize));
   addi(SP, SP, 2 * target::kWordSize);
@@ -3666,7 +3666,7 @@
     subi(SP, SP, frame_size + 2 * target::kWordSize);
     sx(RA, Address(SP, frame_size + 1 * target::kWordSize));
     sx(FP, Address(SP, frame_size + 0 * target::kWordSize));
-    addi(FP, SP, frame_size + 0 * target::kWordSize);
+    addi(FP, SP, frame_size + 2 * target::kWordSize);
   } else {
     subi(SP, SP, frame_size + 4 * target::kWordSize);
     sx(RA, Address(SP, frame_size + 3 * target::kWordSize));
@@ -3674,7 +3674,7 @@
     sx(CODE_REG, Address(SP, frame_size + 1 * target::kWordSize));
     addi(PP, PP, kHeapObjectTag);
     sx(PP, Address(SP, frame_size + 0 * target::kWordSize));
-    addi(FP, SP, frame_size + 2 * target::kWordSize);
+    addi(FP, SP, frame_size + 4 * target::kWordSize);
     if (new_pp == kNoRegister) {
       LoadPoolPointer();
     } else {
@@ -3711,7 +3711,7 @@
     }
   }
   set_constant_pool_allowed(false);
-  mv(SP, FP);
+  subi(SP, FP, 2 * target::kWordSize);
   lx(FP, Address(SP, 0 * target::kWordSize));
   lx(RA, Address(SP, 1 * target::kWordSize));
   addi(SP, SP, 2 * target::kWordSize);
@@ -3730,13 +3730,13 @@
   subi(SP, SP, frame_space + 2 * target::kWordSize);
   sx(RA, Address(SP, frame_space + 1 * target::kWordSize));
   sx(FP, Address(SP, frame_space + 0 * target::kWordSize));
-  addi(FP, SP, frame_space);
+  addi(FP, SP, frame_space + 2 * target::kWordSize);
 }
 
 void Assembler::LeaveCFrame() {
   // N.B. The ordering here is important. We must never read beyond SP or
   // it may have already been clobbered by a signal handler.
-  mv(SP, FP);
+  subi(SP, FP, 2 * target::kWordSize);
   lx(FP, Address(SP, 0 * target::kWordSize));
   lx(RA, Address(SP, 1 * target::kWordSize));
   addi(SP, SP, 2 * target::kWordSize);
@@ -4179,7 +4179,7 @@
     subi(SP, SP, 2 * target::kWordSize + frame_size);
     sx(RA, Address(SP, 1 * target::kWordSize + frame_size));
     sx(FP, Address(SP, 0 * target::kWordSize + frame_size));
-    addi(FP, SP, 0 * target::kWordSize + frame_size);
+    addi(FP, SP, 2 * target::kWordSize + frame_size);
   } else {
     subi(SP, SP, 4 * target::kWordSize + frame_size);
     sx(RA, Address(SP, 3 * target::kWordSize + frame_size));
@@ -4187,7 +4187,7 @@
     sx(CODE_REG, Address(SP, 1 * target::kWordSize + frame_size));
     addi(PP, PP, kHeapObjectTag);
     sx(PP, Address(SP, 0 * target::kWordSize + frame_size));
-    addi(FP, SP, 2 * target::kWordSize + frame_size);
+    addi(FP, SP, 4 * target::kWordSize + frame_size);
   }
 
   PushRegisters(kRuntimeCallSavedRegisters);
@@ -4201,8 +4201,7 @@
   const intptr_t kPushedRegistersSize =
       kRuntimeCallSavedRegisters.CpuRegisterCount() * target::kWordSize +
       kRuntimeCallSavedRegisters.FpuRegisterCount() * kFpuRegisterSize +
-      (target::frame_layout.dart_fixed_frame_size - 2) *
-          target::kWordSize;  // From EnterStubFrame (excluding PC / FP)
+      (target::frame_layout.dart_fixed_frame_size * target::kWordSize);
 
   subi(SP, FP, kPushedRegistersSize);
 
diff --git a/runtime/vm/compiler/backend/il.cc b/runtime/vm/compiler/backend/il.cc
index 256e184..5a742d0 100644
--- a/runtime/vm/compiler/backend/il.cc
+++ b/runtime/vm/compiler/backend/il.cc
@@ -4400,15 +4400,15 @@
 }
 
 void NativeParameterInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
-  // The native entry frame has size -kExitLinkSlotFromFp. In order to access
-  // the top of stack from above the entry frame, we add a constant to account
-  // for the two frame pointers and two return addresses of the entry frame.
-  constexpr intptr_t kEntryFramePadding = 4;
-  compiler::ffi::FrameRebase rebase(
-      compiler->zone(),
-      /*old_base=*/SPREG, /*new_base=*/FPREG,
-      (-kExitLinkSlotFromEntryFp + kEntryFramePadding) *
-          compiler::target::kWordSize);
+  // There are two frames between SaveArguments and the NativeParameterInstr
+  // moves.
+  constexpr intptr_t delta =
+      kCallerSpSlotFromFp          // second frame FP to exit link slot
+      + -kExitLinkSlotFromEntryFp  // exit link slot to first frame FP
+      + kCallerSpSlotFromFp;       // first frame FP to argument save SP
+  compiler::ffi::FrameRebase rebase(compiler->zone(),
+                                    /*old_base=*/SPREG, /*new_base=*/FPREG,
+                                    delta * compiler::target::kWordSize);
   const auto& location =
       marshaller_.NativeLocationOfNativeParameter(def_index_);
   const auto& src =
diff --git a/runtime/vm/compiler/backend/il_arm.cc b/runtime/vm/compiler/backend/il_arm.cc
index 2d14822..637569c 100644
--- a/runtime/vm/compiler/backend/il_arm.cc
+++ b/runtime/vm/compiler/backend/il_arm.cc
@@ -1590,7 +1590,8 @@
   // Save the argument registers, in reverse order.
   SaveArguments(compiler);
 
-  // Enter the entry frame.
+  // Enter the entry frame. NativeParameterInstr expects this frame has size
+  // -exit_link_slot_from_entry_fp, verified below.
   SPILLS_LR_TO_FRAME(__ EnterFrame((1 << FP) | (1 << LR), 0));
 
   // Save a space for the code object.
diff --git a/runtime/vm/compiler/backend/il_arm64.cc b/runtime/vm/compiler/backend/il_arm64.cc
index 33b02c1..db2aa45 100644
--- a/runtime/vm/compiler/backend/il_arm64.cc
+++ b/runtime/vm/compiler/backend/il_arm64.cc
@@ -1431,7 +1431,8 @@
   // Save the argument registers, in reverse order.
   SaveArguments(compiler);
 
-  // Enter the entry frame.
+  // Enter the entry frame. NativeParameterInstr expects this frame has size
+  // -exit_link_slot_from_entry_fp, verified below.
   __ EnterFrame(0);
 
   // Save a space for the code object.
diff --git a/runtime/vm/compiler/backend/il_ia32.cc b/runtime/vm/compiler/backend/il_ia32.cc
index 99b20f7..b410840 100644
--- a/runtime/vm/compiler/backend/il_ia32.cc
+++ b/runtime/vm/compiler/backend/il_ia32.cc
@@ -1140,7 +1140,8 @@
 void NativeEntryInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
   __ Bind(compiler->GetJumpLabel(this));
 
-  // Enter the entry frame.
+  // Enter the entry frame. NativeParameterInstr expects this frame has size
+  // -exit_link_slot_from_entry_fp, verified below.
   __ EnterFrame(0);
 
   // Save a space for the code object.
diff --git a/runtime/vm/compiler/backend/il_riscv.cc b/runtime/vm/compiler/backend/il_riscv.cc
index 51aa2b4..d4e8b39 100644
--- a/runtime/vm/compiler/backend/il_riscv.cc
+++ b/runtime/vm/compiler/backend/il_riscv.cc
@@ -1585,7 +1585,8 @@
   // Save the argument registers, in reverse order.
   SaveArguments(compiler);
 
-  // Enter the entry frame.
+  // Enter the entry frame. NativeParameterInstr expects this frame has size
+  // -exit_link_slot_from_entry_fp, verified below.
   __ EnterFrame(0);
 
   // Save a space for the code object.
diff --git a/runtime/vm/compiler/backend/il_x64.cc b/runtime/vm/compiler/backend/il_x64.cc
index de70052..d5ca6ba 100644
--- a/runtime/vm/compiler/backend/il_x64.cc
+++ b/runtime/vm/compiler/backend/il_x64.cc
@@ -1322,7 +1322,8 @@
   SaveArguments(compiler);
 
   // Enter the entry frame. Push a dummy return address for consistency with
-  // EnterFrame on ARM(64).
+  // EnterFrame on ARM(64). NativeParameterInstr expects this frame has size
+  // -exit_link_slot_from_entry_fp, verified below.
   __ PushImmediate(compiler::Immediate(0));
   __ EnterFrame(0);
 
diff --git a/runtime/vm/compiler/stub_code_compiler.h b/runtime/vm/compiler/stub_code_compiler.h
index 6c4b3ae..b1ee80e 100644
--- a/runtime/vm/compiler/stub_code_compiler.h
+++ b/runtime/vm/compiler/stub_code_compiler.h
@@ -135,11 +135,11 @@
   static constexpr intptr_t kNativeCallbackTrampolineStackDelta = 2;
 #elif defined(TARGET_ARCH_RISCV32)
   static constexpr intptr_t kNativeCallbackTrampolineSize = 8;
-  static constexpr intptr_t kNativeCallbackSharedStubSize = 192;
+  static constexpr intptr_t kNativeCallbackSharedStubSize = 198;
   static constexpr intptr_t kNativeCallbackTrampolineStackDelta = 2;
 #elif defined(TARGET_ARCH_RISCV64)
   static constexpr intptr_t kNativeCallbackTrampolineSize = 8;
-  static constexpr intptr_t kNativeCallbackSharedStubSize = 196;
+  static constexpr intptr_t kNativeCallbackSharedStubSize = 202;
   static constexpr intptr_t kNativeCallbackTrampolineStackDelta = 2;
 #else
 #error What architecture?
diff --git a/runtime/vm/compiler/stub_code_compiler_arm.cc b/runtime/vm/compiler/stub_code_compiler_arm.cc
index 8c3ce77..2bb3db2 100644
--- a/runtime/vm/compiler/stub_code_compiler_arm.cc
+++ b/runtime/vm/compiler/stub_code_compiler_arm.cc
@@ -584,7 +584,9 @@
 
   // Set retval in NativeArgs.
   ASSERT(retval_offset == 3 * target::kWordSize);
-  __ add(R3, FP, Operand(2 * target::kWordSize));
+  __ add(R3, FP,
+         Operand((target::frame_layout.param_end_from_fp + 1) *
+                 target::kWordSize));
 
   // Passing the structure by value as in runtime calls would require changing
   // Dart API for native functions.
diff --git a/runtime/vm/compiler/stub_code_compiler_arm64.cc b/runtime/vm/compiler/stub_code_compiler_arm64.cc
index fe3b109..13a3f8f 100644
--- a/runtime/vm/compiler/stub_code_compiler_arm64.cc
+++ b/runtime/vm/compiler/stub_code_compiler_arm64.cc
@@ -700,7 +700,8 @@
 
   // Set retval in NativeArgs.
   ASSERT(retval_offset == 3 * target::kWordSize);
-  __ AddImmediate(R3, FP, 2 * target::kWordSize);
+  __ AddImmediate(
+      R3, FP, (target::frame_layout.param_end_from_fp + 1) * target::kWordSize);
 
   // Passing the structure by value as in runtime calls would require changing
   // Dart API for native functions.
@@ -1411,6 +1412,9 @@
   ASSERT(target::frame_layout.exit_link_slot_from_entry_fp == -23);
 #endif
   __ Push(R6);
+  // In debug mode, verify that we've pushed the top exit frame info at the
+  // correct offset from FP.
+  __ EmitEntryFrameVerification();
 
   // Mark that the thread is executing Dart code. Do this after initializing the
   // exit link for the profiler.
diff --git a/runtime/vm/compiler/stub_code_compiler_ia32.cc b/runtime/vm/compiler/stub_code_compiler_ia32.cc
index 52f6ed0..352036d 100644
--- a/runtime/vm/compiler/stub_code_compiler_ia32.cc
+++ b/runtime/vm/compiler/stub_code_compiler_ia32.cc
@@ -436,16 +436,21 @@
   }
 
   // Pass NativeArguments structure by value and call native function.
-  __ movl(Address(ESP, thread_offset), THR);    // Set thread in NativeArgs.
-  __ movl(Address(ESP, argc_tag_offset), EDX);  // Set argc in NativeArguments.
-  __ movl(Address(ESP, argv_offset), EAX);      // Set argv in NativeArguments.
-  __ leal(EAX,
-          Address(EBP, 2 * target::kWordSize));  // Compute return value addr.
-  __ movl(Address(ESP, retval_offset), EAX);  // Set retval in NativeArguments.
-  __ leal(
-      EAX,
-      Address(ESP, 2 * target::kWordSize));  // Pointer to the NativeArguments.
-  __ movl(Address(ESP, 0), EAX);  // Pass the pointer to the NativeArguments.
+  // Set thread in NativeArgs.
+  __ movl(Address(ESP, thread_offset), THR);
+  // Set argc in NativeArguments.
+  __ movl(Address(ESP, argc_tag_offset), EDX);
+  // Set argv in NativeArguments.
+  __ movl(Address(ESP, argv_offset), EAX);
+  // Compute return value addr.
+  __ leal(EAX, Address(EBP, (target::frame_layout.param_end_from_fp + 1) *
+                                target::kWordSize));
+  // Set retval in NativeArguments.
+  __ movl(Address(ESP, retval_offset), EAX);
+  // Pointer to the NativeArguments.
+  __ leal(EAX, Address(ESP, 2 * target::kWordSize));
+  // Pass the pointer to the NativeArguments.
+  __ movl(Address(ESP, 0), EAX);
 
   __ movl(Address(ESP, target::kWordSize), ECX);  // Function to call.
   __ call(wrapper_address);
diff --git a/runtime/vm/compiler/stub_code_compiler_riscv.cc b/runtime/vm/compiler/stub_code_compiler_riscv.cc
index 8283688..934a2b4 100644
--- a/runtime/vm/compiler/stub_code_compiler_riscv.cc
+++ b/runtime/vm/compiler/stub_code_compiler_riscv.cc
@@ -322,11 +322,11 @@
          kNativeCallbackTrampolineSize *
              NativeCallbackTrampolines::NumCallbackTrampolinesPerPage());
 
+  const intptr_t shared_stub_start = __ CodeSize();
+
   __ Bind(&loaded_callback_id_hi);
   __ srai(T1, T1, 12);
 
-  const intptr_t shared_stub_start = __ CodeSize();
-
   // Save THR (callee-saved) and RA. Keeps stack aligned.
   COMPILE_ASSERT(StubCodeCompiler::kNativeCallbackTrampolineStackDelta == 2);
   __ PushRegisterPair(RA, THR);
@@ -630,7 +630,8 @@
   // Set argv in target::NativeArguments: R2 already contains argv.
   // Set retval in NativeArgs.
   ASSERT(retval_offset == 3 * target::kWordSize);
-  __ AddImmediate(T3, FP, 2 * target::kWordSize);
+  __ AddImmediate(
+      T3, FP, (target::frame_layout.param_end_from_fp + 1) * target::kWordSize);
 
   // Passing the structure by value as in runtime calls would require changing
   // Dart API for native functions.
@@ -843,11 +844,11 @@
 //   +------------------+
 //   | PC marker        | <- TOS
 //   +------------------+
-//   | Saved FP         | <- FP of stub
+//   | Saved FP         |
 //   +------------------+
 //   | return-address   |  (deoptimization point)
 //   +------------------+
-//   | Saved CODE_REG   |
+//   | Saved CODE_REG   | <- FP of stub
 //   +------------------+
 //   | ...              | <- SP of optimized frame
 //
@@ -880,7 +881,7 @@
       // Save the original value of CODE_REG pushed before invoking this stub
       // instead of the value used to call this stub.
       COMPILE_ASSERT(TMP > CODE_REG);  // TMP saved first
-      __ lx(TMP, Address(FP, 2 * target::kWordSize));
+      __ lx(TMP, Address(FP, 0 * target::kWordSize));
       __ sx(TMP, Address(SP, i * target::kWordSize));
     } else {
       __ sx(r, Address(SP, i * target::kWordSize));
@@ -1318,10 +1319,13 @@
   // target::frame_layout.exit_link_slot_from_entry_fp must be kept in sync
   // with the code below.
 #if XLEN == 32
-  ASSERT_EQUAL(target::frame_layout.exit_link_slot_from_entry_fp, -40);
+  ASSERT_EQUAL(target::frame_layout.exit_link_slot_from_entry_fp, -42);
 #elif XLEN == 64
-  ASSERT_EQUAL(target::frame_layout.exit_link_slot_from_entry_fp, -28);
+  ASSERT_EQUAL(target::frame_layout.exit_link_slot_from_entry_fp, -30);
 #endif
+  // In debug mode, verify that we've pushed the top exit frame info at the
+  // correct offset from FP.
+  __ EmitEntryFrameVerification();
 
   // Mark that the thread is executing Dart code. Do this after initializing the
   // exit link for the profiler.
diff --git a/runtime/vm/compiler/stub_code_compiler_x64.cc b/runtime/vm/compiler/stub_code_compiler_x64.cc
index 0268696..7ae8fbc 100644
--- a/runtime/vm/compiler/stub_code_compiler_x64.cc
+++ b/runtime/vm/compiler/stub_code_compiler_x64.cc
@@ -729,15 +729,17 @@
     }
 
     // Pass target::NativeArguments structure by value and call native function.
-    __ movq(Address(RSP, thread_offset), THR);  // Set thread in NativeArgs.
-    __ movq(Address(RSP, argc_tag_offset),
-            R10);  // Set argc in target::NativeArguments.
-    __ movq(Address(RSP, argv_offset),
-            R13);  // Set argv in target::NativeArguments.
-    __ leaq(RAX,
-            Address(RBP, 2 * target::kWordSize));  // Compute return value addr.
-    __ movq(Address(RSP, retval_offset),
-            RAX);  // Set retval in target::NativeArguments.
+    // Set thread in NativeArgs.
+    __ movq(Address(RSP, thread_offset), THR);
+    // Set argc in target::NativeArguments.
+    __ movq(Address(RSP, argc_tag_offset), R10);
+    // Set argv in target::NativeArguments.
+    __ movq(Address(RSP, argv_offset), R13);
+    // Compute return value addr.
+    __ leaq(RAX, Address(RBP, (target::frame_layout.param_end_from_fp + 1) *
+                                  target::kWordSize));
+    // Set retval in target::NativeArguments.
+    __ movq(Address(RSP, retval_offset), RAX);
 
     // Pass the pointer to the target::NativeArguments.
     __ movq(CallingConventions::kArg1Reg, RSP);
diff --git a/runtime/vm/deopt_instructions.cc b/runtime/vm/deopt_instructions.cc
index 0a63ce4..76ee165c 100644
--- a/runtime/vm/deopt_instructions.cc
+++ b/runtime/vm/deopt_instructions.cc
@@ -201,7 +201,7 @@
 
 intptr_t DeoptContext::GetSourceFp() const {
   return source_frame_[source_frame_size_ - 1 - num_args_ -
-                       kParamEndSlotFromFp];
+                       kParamEndSlotFromFp + kSavedCallerFpSlotFromFp];
 }
 
 intptr_t DeoptContext::GetSourcePp() const {
diff --git a/runtime/vm/os_thread.h b/runtime/vm/os_thread.h
index 1f6a0e3..5df7fb2 100644
--- a/runtime/vm/os_thread.h
+++ b/runtime/vm/os_thread.h
@@ -13,7 +13,9 @@
 #include "vm/globals.h"
 
 // Declare the OS-specific types ahead of defining the generic classes.
-#if defined(DART_HOST_OS_ANDROID)
+#if defined(DART_USE_ABSL)
+#include "vm/os_thread_absl.h"
+#elif defined(DART_HOST_OS_ANDROID)
 #include "vm/os_thread_android.h"
 #elif defined(DART_HOST_OS_FUCHSIA)
 #include "vm/os_thread_fuchsia.h"
diff --git a/runtime/vm/os_thread_absl.cc b/runtime/vm/os_thread_absl.cc
new file mode 100644
index 0000000..d922da8
--- /dev/null
+++ b/runtime/vm/os_thread_absl.cc
@@ -0,0 +1,417 @@
+// Copyright (c) 2022, 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/globals.h"  // NOLINT
+
+#if defined(DART_USE_ABSL)
+
+#include <errno.h>  // NOLINT
+#include <stdio.h>
+#include <sys/resource.h>  // NOLINT
+#include <sys/syscall.h>   // NOLINT
+#include <sys/time.h>      // NOLINT
+
+#include "platform/address_sanitizer.h"
+#include "platform/assert.h"
+#include "platform/safe_stack.h"
+#include "platform/signal_blocker.h"
+#include "platform/utils.h"
+#include "vm/flags.h"
+#include "vm/os_thread.h"
+
+namespace dart {
+
+DEFINE_FLAG(int,
+            worker_thread_priority,
+            kMinInt,
+            "The thread priority the VM should use for new worker threads.");
+
+#define VALIDATE_PTHREAD_RESULT(result)                                        \
+  if (result != 0) {                                                           \
+    const int kBufferSize = 1024;                                              \
+    char error_buf[kBufferSize];                                               \
+    FATAL2("pthread error: %d (%s)", result,                                   \
+           Utils::StrError(result, error_buf, kBufferSize));                   \
+  }
+
+// Variation of VALIDATE_PTHREAD_RESULT for named objects.
+#if defined(PRODUCT)
+#define VALIDATE_PTHREAD_RESULT_NAMED(result) VALIDATE_PTHREAD_RESULT(result)
+#else
+#define VALIDATE_PTHREAD_RESULT_NAMED(result)                                  \
+  if (result != 0) {                                                           \
+    const int kBufferSize = 1024;                                              \
+    char error_buf[kBufferSize];                                               \
+    FATAL3("[%s] pthread error: %d (%s)", name_, result,                       \
+           Utils::StrError(result, error_buf, kBufferSize));                   \
+  }
+#endif
+
+#if defined(DEBUG)
+#define ASSERT_PTHREAD_SUCCESS(result) VALIDATE_PTHREAD_RESULT(result)
+#else
+// NOTE: This (currently) expands to a no-op.
+#define ASSERT_PTHREAD_SUCCESS(result) ASSERT(result == 0)
+#endif
+
+#ifdef DEBUG
+#define RETURN_ON_PTHREAD_FAILURE(result)                                      \
+  if (result != 0) {                                                           \
+    const int kBufferSize = 1024;                                              \
+    char error_buf[kBufferSize];                                               \
+    fprintf(stderr, "%s:%d: pthread error: %d (%s)\n", __FILE__, __LINE__,     \
+            result, Utils::StrError(result, error_buf, kBufferSize));          \
+    return result;                                                             \
+  }
+#else
+#define RETURN_ON_PTHREAD_FAILURE(result)                                      \
+  if (result != 0) return result;
+#endif
+
+class ThreadStartData {
+ public:
+  ThreadStartData(const char* name,
+                  OSThread::ThreadStartFunction function,
+                  uword parameter)
+      : name_(name), function_(function), parameter_(parameter) {}
+
+  const char* name() const { return name_; }
+  OSThread::ThreadStartFunction function() const { return function_; }
+  uword parameter() const { return parameter_; }
+
+ private:
+  const char* name_;
+  OSThread::ThreadStartFunction function_;
+  uword parameter_;
+
+  DISALLOW_COPY_AND_ASSIGN(ThreadStartData);
+};
+
+// TODO(bkonyi): remove this call once the prebuilt SDK is updated.
+// Spawned threads inherit their spawner's signal mask. We sometimes spawn
+// threads for running Dart code from a thread that is blocking SIGPROF.
+// This function explicitly unblocks SIGPROF so the profiler continues to
+// sample this thread.
+static void UnblockSIGPROF() {
+  sigset_t set;
+  sigemptyset(&set);
+  sigaddset(&set, SIGPROF);
+  int r = pthread_sigmask(SIG_UNBLOCK, &set, NULL);
+  USE(r);
+  ASSERT(r == 0);
+  ASSERT(!CHECK_IS_BLOCKING(SIGPROF));
+}
+
+// Dispatch to the thread start function provided by the caller. This trampoline
+// is used to ensure that the thread is properly destroyed if the thread just
+// exits.
+static void* ThreadStart(void* data_ptr) {
+  if (FLAG_worker_thread_priority != kMinInt) {
+    if (setpriority(PRIO_PROCESS, syscall(__NR_gettid),
+                    FLAG_worker_thread_priority) == -1) {
+      FATAL2("Setting thread priority to %d failed: errno = %d\n",
+             FLAG_worker_thread_priority, errno);
+    }
+  }
+
+  ThreadStartData* data = reinterpret_cast<ThreadStartData*>(data_ptr);
+
+  const char* name = data->name();
+  OSThread::ThreadStartFunction function = data->function();
+  uword parameter = data->parameter();
+  delete data;
+
+  // Set the thread name. There is 16 bytes limit on the name (including \0).
+  // pthread_setname_np ignores names that are too long rather than truncating.
+  char truncated_name[16];
+  snprintf(truncated_name, ARRAY_SIZE(truncated_name), "%s", name);
+  pthread_setname_np(pthread_self(), truncated_name);
+
+  // Create new OSThread object and set as TLS for new thread.
+  OSThread* thread = OSThread::CreateOSThread();
+  if (thread != NULL) {
+    OSThread::SetCurrent(thread);
+    thread->set_name(name);
+    UnblockSIGPROF();
+    // Call the supplied thread start function handing it its parameters.
+    function(parameter);
+  }
+
+  return NULL;
+}
+
+int OSThread::Start(const char* name,
+                    ThreadStartFunction function,
+                    uword parameter) {
+  pthread_attr_t attr;
+  int result = pthread_attr_init(&attr);
+  RETURN_ON_PTHREAD_FAILURE(result);
+
+  result = pthread_attr_setstacksize(&attr, OSThread::GetMaxStackSize());
+  RETURN_ON_PTHREAD_FAILURE(result);
+
+  ThreadStartData* data = new ThreadStartData(name, function, parameter);
+
+  pthread_t tid;
+  result = pthread_create(&tid, &attr, ThreadStart, data);
+  RETURN_ON_PTHREAD_FAILURE(result);
+
+  result = pthread_attr_destroy(&attr);
+  RETURN_ON_PTHREAD_FAILURE(result);
+
+  return 0;
+}
+
+const ThreadId OSThread::kInvalidThreadId = static_cast<ThreadId>(0);
+const ThreadJoinId OSThread::kInvalidThreadJoinId =
+    static_cast<ThreadJoinId>(0);
+
+ThreadLocalKey OSThread::CreateThreadLocal(ThreadDestructor destructor) {
+  pthread_key_t key = kUnsetThreadLocalKey;
+  int result = pthread_key_create(&key, destructor);
+  VALIDATE_PTHREAD_RESULT(result);
+  ASSERT(key != kUnsetThreadLocalKey);
+  return key;
+}
+
+void OSThread::DeleteThreadLocal(ThreadLocalKey key) {
+  ASSERT(key != kUnsetThreadLocalKey);
+  int result = pthread_key_delete(key);
+  VALIDATE_PTHREAD_RESULT(result);
+}
+
+void OSThread::SetThreadLocal(ThreadLocalKey key, uword value) {
+  ASSERT(key != kUnsetThreadLocalKey);
+  int result = pthread_setspecific(key, reinterpret_cast<void*>(value));
+  VALIDATE_PTHREAD_RESULT(result);
+}
+
+intptr_t OSThread::GetMaxStackSize() {
+  const int kStackSize = (128 * kWordSize * KB);
+  return kStackSize;
+}
+
+ThreadId OSThread::GetCurrentThreadId() {
+  return pthread_self();
+}
+
+#ifdef SUPPORT_TIMELINE
+ThreadId OSThread::GetCurrentThreadTraceId() {
+  return syscall(__NR_gettid);
+}
+#endif  // PRODUCT
+
+ThreadJoinId OSThread::GetCurrentThreadJoinId(OSThread* thread) {
+  ASSERT(thread != NULL);
+  // Make sure we're filling in the join id for the current thread.
+  ASSERT(thread->id() == GetCurrentThreadId());
+  // Make sure the join_id_ hasn't been set, yet.
+  DEBUG_ASSERT(thread->join_id_ == kInvalidThreadJoinId);
+  pthread_t id = pthread_self();
+#if defined(DEBUG)
+  thread->join_id_ = id;
+#endif
+  return id;
+}
+
+void OSThread::Join(ThreadJoinId id) {
+  int result = pthread_join(id, NULL);
+  ASSERT(result == 0);
+}
+
+intptr_t OSThread::ThreadIdToIntPtr(ThreadId id) {
+  ASSERT(sizeof(id) == sizeof(intptr_t));
+  return static_cast<intptr_t>(id);
+}
+
+ThreadId OSThread::ThreadIdFromIntPtr(intptr_t id) {
+  return static_cast<ThreadId>(id);
+}
+
+bool OSThread::Compare(ThreadId a, ThreadId b) {
+  return pthread_equal(a, b) != 0;
+}
+
+bool OSThread::GetCurrentStackBounds(uword* lower, uword* upper) {
+  pthread_attr_t attr;
+  // May fail on the main thread.
+  if (pthread_getattr_np(pthread_self(), &attr) != 0) {
+    return false;
+  }
+
+  void* base;
+  size_t size;
+  int error = pthread_attr_getstack(&attr, &base, &size);
+  pthread_attr_destroy(&attr);
+  if (error != 0) {
+    return false;
+  }
+
+  *lower = reinterpret_cast<uword>(base);
+  *upper = *lower + size;
+  return true;
+}
+
+#if defined(USING_SAFE_STACK)
+NO_SANITIZE_ADDRESS
+NO_SANITIZE_SAFE_STACK
+uword OSThread::GetCurrentSafestackPointer() {
+#error "SAFE_STACK is unsupported on this platform"
+  return 0;
+}
+
+NO_SANITIZE_ADDRESS
+NO_SANITIZE_SAFE_STACK
+void OSThread::SetCurrentSafestackPointer(uword ssp) {
+#error "SAFE_STACK is unsupported on this platform"
+}
+#endif
+
+Mutex::Mutex(NOT_IN_PRODUCT(const char* name))
+#if !defined(PRODUCT)
+    : name_(name)
+#endif
+{
+#if defined(DEBUG)
+  // When running with assertions enabled we track the owner.
+  owner_ = OSThread::kInvalidThreadId;
+#endif  // defined(DEBUG)
+}
+
+Mutex::~Mutex() {
+#if defined(DEBUG)
+  // When running with assertions enabled we track the owner.
+  ASSERT(owner_ == OSThread::kInvalidThreadId);
+#endif  // defined(DEBUG)
+}
+
+ABSL_NO_THREAD_SAFETY_ANALYSIS
+void Mutex::Lock() {
+  data_.mutex()->Lock();
+#if defined(DEBUG)
+  // When running with assertions enabled we track the owner.
+  owner_ = OSThread::GetCurrentThreadId();
+#endif  // defined(DEBUG)
+}
+
+ABSL_NO_THREAD_SAFETY_ANALYSIS
+bool Mutex::TryLock() {
+  if (!data_.mutex()->TryLock()) {
+    return false;
+  }
+#if defined(DEBUG)
+  // When running with assertions enabled we track the owner.
+  owner_ = OSThread::GetCurrentThreadId();
+#endif  // defined(DEBUG)
+  return true;
+}
+
+ABSL_NO_THREAD_SAFETY_ANALYSIS
+void Mutex::Unlock() {
+#if defined(DEBUG)
+  // When running with assertions enabled we track the owner.
+  ASSERT(IsOwnedByCurrentThread());
+  owner_ = OSThread::kInvalidThreadId;
+#endif  // defined(DEBUG)
+  data_.mutex()->Unlock();
+}
+
+Monitor::Monitor() {
+#if defined(DEBUG)
+  // When running with assertions enabled we track the owner.
+  owner_ = OSThread::kInvalidThreadId;
+#endif  // defined(DEBUG)
+}
+
+Monitor::~Monitor() {
+#if defined(DEBUG)
+  // When running with assertions enabled we track the owner.
+  ASSERT(owner_ == OSThread::kInvalidThreadId);
+#endif  // defined(DEBUG)
+}
+
+ABSL_NO_THREAD_SAFETY_ANALYSIS
+bool Monitor::TryEnter() {
+  if (!data_.mutex()->TryLock()) {
+    return false;
+  }
+#if defined(DEBUG)
+  // When running with assertions enabled we track the owner.
+  ASSERT(owner_ == OSThread::kInvalidThreadId);
+  owner_ = OSThread::GetCurrentThreadId();
+#endif  // defined(DEBUG)
+  return true;
+}
+
+ABSL_NO_THREAD_SAFETY_ANALYSIS
+void Monitor::Enter() {
+  data_.mutex()->Lock();
+#if defined(DEBUG)
+  // When running with assertions enabled we track the owner.
+  ASSERT(owner_ == OSThread::kInvalidThreadId);
+  owner_ = OSThread::GetCurrentThreadId();
+#endif  // defined(DEBUG)
+}
+
+ABSL_NO_THREAD_SAFETY_ANALYSIS
+void Monitor::Exit() {
+#if defined(DEBUG)
+  // When running with assertions enabled we track the owner.
+  ASSERT(IsOwnedByCurrentThread());
+  owner_ = OSThread::kInvalidThreadId;
+#endif  // defined(DEBUG)
+  data_.mutex()->Unlock();
+}
+
+Monitor::WaitResult Monitor::Wait(int64_t millis) {
+  Monitor::WaitResult retval = WaitMicros(millis * kMicrosecondsPerMillisecond);
+  return retval;
+}
+
+ABSL_NO_THREAD_SAFETY_ANALYSIS
+Monitor::WaitResult Monitor::WaitMicros(int64_t micros) {
+#if defined(DEBUG)
+  // When running with assertions enabled we track the owner.
+  ASSERT(IsOwnedByCurrentThread());
+  ThreadId saved_owner = owner_;
+  owner_ = OSThread::kInvalidThreadId;
+#endif  // defined(DEBUG)
+
+  Monitor::WaitResult retval = kNotified;
+  if (micros == kNoTimeout) {
+    // Wait forever.
+    data_.cond()->Wait(data_.mutex());
+  } else {
+    if (data_.cond()->WaitWithTimeout(data_.mutex(),
+                                      absl::Microseconds(micros))) {
+      retval = kTimedOut;
+    }
+  }
+
+#if defined(DEBUG)
+  // When running with assertions enabled we track the owner.
+  ASSERT(owner_ == OSThread::kInvalidThreadId);
+  owner_ = OSThread::GetCurrentThreadId();
+  ASSERT(owner_ == saved_owner);
+#endif  // defined(DEBUG)
+  return retval;
+}
+
+ABSL_NO_THREAD_SAFETY_ANALYSIS
+void Monitor::Notify() {
+  // When running with assertions enabled we track the owner.
+  ASSERT(IsOwnedByCurrentThread());
+  data_.cond()->Signal();
+}
+
+ABSL_NO_THREAD_SAFETY_ANALYSIS
+void Monitor::NotifyAll() {
+  // When running with assertions enabled we track the owner.
+  ASSERT(IsOwnedByCurrentThread());
+  xdata_.cond()->SignalAll();
+}
+
+}  // namespace dart
+
+#endif  // defined(DART_USE_ABSL)
diff --git a/runtime/vm/os_thread_absl.h b/runtime/vm/os_thread_absl.h
new file mode 100644
index 0000000..e10793b
--- /dev/null
+++ b/runtime/vm/os_thread_absl.h
@@ -0,0 +1,77 @@
+// Copyright (c) 2022, 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.
+
+#ifndef RUNTIME_VM_OS_THREAD_ABSL_H_
+#define RUNTIME_VM_OS_THREAD_ABSL_H_
+
+#if !defined(RUNTIME_VM_OS_THREAD_H_)
+#error Do not include os_thread_absl.h directly; use os_thread.h instead.
+#endif
+
+#include <pthread.h>
+
+#include "platform/assert.h"
+#include "platform/globals.h"
+#include "third_party/absl/synchronization/mutex.h"
+
+namespace dart {
+
+typedef pthread_key_t ThreadLocalKey;
+typedef pthread_t ThreadId;
+typedef pthread_t ThreadJoinId;
+
+static const ThreadLocalKey kUnsetThreadLocalKey =
+    static_cast<pthread_key_t>(-1);
+
+class ThreadInlineImpl {
+ private:
+  ThreadInlineImpl() {}
+  ~ThreadInlineImpl() {}
+
+  static uword GetThreadLocal(ThreadLocalKey key) {
+    ASSERT(key != kUnsetThreadLocalKey);
+    return reinterpret_cast<uword>(pthread_getspecific(key));
+  }
+
+  friend class OSThread;
+
+  DISALLOW_ALLOCATION();
+  DISALLOW_COPY_AND_ASSIGN(ThreadInlineImpl);
+};
+
+class MutexData {
+ private:
+  MutexData() : mutex_() {}
+  ~MutexData() {}
+
+  absl::Mutex* mutex() { return &mutex_; }
+
+  absl::Mutex mutex_;
+
+  friend class Mutex;
+
+  DISALLOW_ALLOCATION();
+  DISALLOW_COPY_AND_ASSIGN(MutexData);
+};
+
+class MonitorData {
+ private:
+  MonitorData() : mutex_(), cond_() {}
+  ~MonitorData() {}
+
+  absl::Mutex* mutex() { return &mutex_; }
+  absl::CondVar* cond() { return &cond_; }
+
+  absl::Mutex mutex_;
+  absl::CondVar cond_;
+
+  friend class Monitor;
+
+  DISALLOW_ALLOCATION();
+  DISALLOW_COPY_AND_ASSIGN(MonitorData);
+};
+
+}  // namespace dart
+
+#endif  // RUNTIME_VM_OS_THREAD_ABSL_H_
diff --git a/runtime/vm/os_thread_android.cc b/runtime/vm/os_thread_android.cc
index 8c09320..a9a1413 100644
--- a/runtime/vm/os_thread_android.cc
+++ b/runtime/vm/os_thread_android.cc
@@ -4,7 +4,7 @@
 
 #include "platform/globals.h"  // NOLINT
 
-#if defined(DART_HOST_OS_ANDROID)
+#if defined(DART_HOST_OS_ANDROID) && !defined(DART_USE_ABSL)
 
 #include "vm/os_thread.h"
 
@@ -491,4 +491,4 @@
 
 }  // namespace dart
 
-#endif  // defined(DART_HOST_OS_ANDROID)
+#endif  // defined(DART_HOST_OS_ANDROID) && !defined(DART_USE_ABSL)
diff --git a/runtime/vm/os_thread_fuchsia.cc b/runtime/vm/os_thread_fuchsia.cc
index 1eb8a3a..3cf8193 100644
--- a/runtime/vm/os_thread_fuchsia.cc
+++ b/runtime/vm/os_thread_fuchsia.cc
@@ -3,7 +3,7 @@
 // BSD-style license that can be found in the LICENSE file.
 
 #include "platform/globals.h"  // NOLINT
-#if defined(DART_HOST_OS_FUCHSIA)
+#if defined(DART_HOST_OS_FUCHSIA) && !defined(DART_USE_ABSL)
 
 #include "vm/os.h"
 #include "vm/os_thread.h"
@@ -492,4 +492,4 @@
 
 }  // namespace dart
 
-#endif  // defined(DART_HOST_OS_FUCHSIA)
+#endif  // defined(DART_HOST_OS_FUCHSIA) && !defined(DART_USE_ABSL)
diff --git a/runtime/vm/os_thread_linux.cc b/runtime/vm/os_thread_linux.cc
index 409b03b..ea44790 100644
--- a/runtime/vm/os_thread_linux.cc
+++ b/runtime/vm/os_thread_linux.cc
@@ -4,7 +4,7 @@
 
 #include "platform/globals.h"  // NOLINT
 
-#if defined(DART_HOST_OS_LINUX)
+#if defined(DART_HOST_OS_LINUX) && !defined(DART_USE_ABSL)
 
 #include "vm/os_thread.h"
 
@@ -497,4 +497,4 @@
 
 }  // namespace dart
 
-#endif  // defined(DART_HOST_OS_LINUX)
+#endif  // defined(DART_HOST_OS_LINUX) && !defined(DART_USE_ABSL)
diff --git a/runtime/vm/os_thread_macos.cc b/runtime/vm/os_thread_macos.cc
index 401fdc7..cbbc226 100644
--- a/runtime/vm/os_thread_macos.cc
+++ b/runtime/vm/os_thread_macos.cc
@@ -3,7 +3,7 @@
 // BSD-style license that can be found in the LICENSE file.
 
 #include "platform/globals.h"  // NOLINT
-#if defined(DART_HOST_OS_MACOS)
+#if defined(DART_HOST_OS_MACOS) && !defined(DART_USE_ABSL)
 
 #include "vm/os_thread.h"
 
diff --git a/runtime/vm/os_thread_win.cc b/runtime/vm/os_thread_win.cc
index 8b859a8..49eda86 100644
--- a/runtime/vm/os_thread_win.cc
+++ b/runtime/vm/os_thread_win.cc
@@ -3,7 +3,7 @@
 // BSD-style license that can be found in the LICENSE file.
 
 #include "platform/globals.h"  // NOLINT
-#if defined(DART_HOST_OS_WINDOWS)
+#if defined(DART_HOST_OS_WINDOWS) && !defined(DART_USE_ABSL)
 
 #include "vm/growable_array.h"
 #include "vm/lockers.h"
@@ -530,4 +530,4 @@
 #endif  // _WIN64
 }  // extern "C"
 
-#endif  // defined(DART_HOST_OS_WINDOWS)
+#endif  // defined(DART_HOST_OS_WINDOWS) && !defined(DART_USE_ABSL)
diff --git a/runtime/vm/stack_frame.cc b/runtime/vm/stack_frame.cc
index 55eebc9..0297144 100644
--- a/runtime/vm/stack_frame.cc
+++ b/runtime/vm/stack_frame.cc
@@ -722,7 +722,7 @@
   for (intptr_t index = index_; index < deopt_instructions_.length(); index++) {
     DeoptInstr* deopt_instr = deopt_instructions_[index];
     if (deopt_instr->kind() == DeoptInstr::kCallerFp) {
-      return index - num_materializations_;
+      return index - num_materializations_ - kSavedCallerFpSlotFromFp;
     }
   }
   UNREACHABLE();
diff --git a/runtime/vm/stack_frame_riscv.h b/runtime/vm/stack_frame_riscv.h
index 4bf58ab..58b31a6 100644
--- a/runtime/vm/stack_frame_riscv.h
+++ b/runtime/vm/stack_frame_riscv.h
@@ -23,10 +23,10 @@
                | first local       T|
                | caller's PP       T|
                | code object       T|    (current frame's code object)
-               | caller's FP        | <- FP of current frame
+               | caller's FP        |
                | caller's RA        |    (PC of caller frame)
                +--------------------+
-Caller frame   | last parameter     | <- SP of caller frame
+Caller frame   | last parameter     | <- SP of caller frame, FP of current frame
                |  ...               |
 
                T against a slot indicates it needs to be traversed during GC.
@@ -35,24 +35,24 @@
 static const int kDartFrameFixedSize = 4;  // PP, FP, RA, PC marker.
 static const int kSavedPcSlotFromSp = -1;
 
-static const int kFirstObjectSlotFromFp = -1;  // Used by GC to traverse stack.
-static const int kLastFixedObjectSlotFromFp = -2;
+static const int kFirstObjectSlotFromFp = -3;  // Used by GC to traverse stack.
+static const int kLastFixedObjectSlotFromFp = -4;
 
-static const int kFirstLocalSlotFromFp = -3;
-static const int kSavedCallerPpSlotFromFp = -2;
-static const int kPcMarkerSlotFromFp = -1;
-static const int kSavedCallerFpSlotFromFp = 0;
-static const int kSavedCallerPcSlotFromFp = 1;
+static const int kFirstLocalSlotFromFp = -5;
+static const int kSavedCallerPpSlotFromFp = -4;
+static const int kPcMarkerSlotFromFp = -3;
+static const int kSavedCallerFpSlotFromFp = -2;
+static const int kSavedCallerPcSlotFromFp = -1;
 
-static const int kParamEndSlotFromFp = 1;  // One slot past last parameter.
-static const int kCallerSpSlotFromFp = 2;
+static const int kParamEndSlotFromFp = -1;  // One slot past last parameter.
+static const int kCallerSpSlotFromFp = 0;
 static const int kLastParamSlotFromEntrySp = 0;
 
 // Entry and exit frame layout.
 #if defined(TARGET_ARCH_RISCV64)
-static const int kExitLinkSlotFromEntryFp = -28;
+static const int kExitLinkSlotFromEntryFp = -30;
 #elif defined(TARGET_ARCH_RISCV32)
-static const int kExitLinkSlotFromEntryFp = -40;
+static const int kExitLinkSlotFromEntryFp = -42;
 #endif
 COMPILE_ASSERT(kAbiPreservedCpuRegCount == 11);
 COMPILE_ASSERT(kAbiPreservedFpuRegCount == 12);
diff --git a/runtime/vm/vm_sources.gni b/runtime/vm/vm_sources.gni
index 059703c..0a2264a 100644
--- a/runtime/vm/vm_sources.gni
+++ b/runtime/vm/vm_sources.gni
@@ -210,6 +210,8 @@
   "os_macos.cc",
   "os_thread.cc",
   "os_thread.h",
+  "os_thread_absl.cc",
+  "os_thread_absl.h",
   "os_thread_android.cc",
   "os_thread_android.h",
   "os_thread_fuchsia.cc",
diff --git a/tools/VERSION b/tools/VERSION
index 79f9a08..bd4b086 100644
--- a/tools/VERSION
+++ b/tools/VERSION
@@ -27,5 +27,5 @@
 MAJOR 2
 MINOR 17
 PATCH 0
-PRERELEASE 201
+PRERELEASE 202
 PRERELEASE_PATCH 0
\ No newline at end of file