Skip to content

Commit

Permalink
Version 3.4.0-137.0.dev
Browse files Browse the repository at this point in the history
Merge 3d1f22a into dev
  • Loading branch information
Dart CI committed Feb 13, 2024
2 parents f4cc213 + 3d1f22a commit 105312b
Show file tree
Hide file tree
Showing 6 changed files with 126 additions and 12 deletions.
2 changes: 1 addition & 1 deletion DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ vars = {
"ply_rev": "604b32590ffad5cbb82e4afef1d305512d06ae93",
"protobuf_gn_rev": "ca669f79945418f6229e4fef89b666b2a88cbb10",
"WebCore_rev": "bcb10901266c884e7b3740abc597ab95373ab55c",
"zlib_rev": "646b7f569718921d7d4b5b8e22572ff6c76f2596",
"zlib_rev": "14dd4c4455602c9b71a1a89b5cafd1f4030d2e3f",

### /third_party/pkg dependencies
# 'tools/rev_sdk_deps.dart' can rev pkg dependencies to their latest; put an
Expand Down
8 changes: 0 additions & 8 deletions build/config/dcheck_always_on.gni

This file was deleted.

16 changes: 14 additions & 2 deletions pkg/kernel/lib/src/tool/find_referenced_libraries.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@

import 'package:kernel/ast.dart';

Set<Library> findAllReferencedLibraries(List<Library> from) {
_LibraryCollector collector = new _LibraryCollector();
Set<Library> findAllReferencedLibraries(List<Library> from,
{bool collectViaReferencesToo = false}) {
_LibraryCollector collector =
new _LibraryCollector(collectViaReferencesToo: collectViaReferencesToo);
for (Library library in from) {
collector.visitLibrary(library);
}
Expand All @@ -21,13 +23,23 @@ bool duplicateLibrariesReachable(List<Library> from) {
}

class _LibraryCollector extends RecursiveVisitor {
final bool collectViaReferencesToo;
Set<Library> allSeenLibraries = {};

_LibraryCollector({required this.collectViaReferencesToo});

@override
void defaultNode(Node node) {
if (node is NamedNode) {
// Named nodes can be linked to.
seen(node);
if (collectViaReferencesToo) {
TreeNode? refNode = node.reference.node;
if (refNode != null && !identical(refNode, node)) {
// This is generally pretty bad.
seen(refNode);
}
}
} else if (node is Name) {
if (node.library != null) {
seen(node.library!);
Expand Down
87 changes: 87 additions & 0 deletions pkg/kernel/test/binary/relink_platform_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
// Copyright (c) 2024, 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 'dart:io';

import 'package:kernel/binary/ast_from_binary.dart';
import 'package:kernel/kernel.dart';
import 'package:kernel/src/tool/find_referenced_libraries.dart';

import '../relink_test.dart';
import 'find_sdk_dills.dart';

void main() {
List<File> dills = findSdkDills();
print("Found ${dills.length} dills!");

for (File dill in dills) {
readAndRelink(dill);
}
}

void readAndRelink(File dill) {
print("Reading $dill");
List<int> bytes = dill.readAsBytesSync();

try {
// Loading a component it should be self-contained.
Component component1 = new Component();
new BinaryBuilder(bytes,
alwaysCreateNewNamedNodes: true, disableLazyReading: true)
.readComponent(component1);
checkReachable(component1);

// Loading a component it should be self-contained.
Component component2 = new Component(nameRoot: component1.root);
new BinaryBuilder(bytes,
alwaysCreateNewNamedNodes: true, disableLazyReading: true)
.readComponent(component2);
checkReachable(component2);

// Now that we read "component 2" on top of "component 1" the 1-version is
// no longer self-contained.
try {
checkReachable(component1);
throw "Expected this one to fail.";
} catch (e) {
// Expected.
}

// Relinking it it should be back to being self contained though.
component1.relink();
checkReachable(component1);

// Now that component 1 is relinked component 2 is no longer self contained.
try {
checkReachable(component2);
throw "Expected this one to fail.";
} catch (e) {
// Expected.
}

// But relinking makes it self-contained again.
component2.relink();
checkReachable(component2);
} catch (e, st) {
print("Error for $dill:");
print(e);
print(st);
print("");
print("--------------------");
print("");
exitCode = 1;
}
}

void checkReachable(Component component) {
expectReachable(
findAllReferencedLibraries(component.libraries), component.libraries);
expectReachable(
findAllReferencedLibraries(component.libraries,
collectViaReferencesToo: true),
component.libraries);
if (duplicateLibrariesReachable(component.libraries)) {
throw "Didn't expect duplicates libraries!";
}
}
23 changes: 23 additions & 0 deletions pkg/kernel/test/relink_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ void main() {
// After the relink only the libs from component1Prime are reachable!
expectReachable(findAllReferencedLibraries(component1Prime.libraries),
component1Prime.libraries);
expectReachable(
findAllReferencedLibraries(component1Prime.libraries,
collectViaReferencesToo: true),
component1Prime.libraries);
if (duplicateLibrariesReachable(component1Prime.libraries)) {
throw "Didn't expect duplicates libraries!";
}
Expand All @@ -103,6 +107,10 @@ void main() {
// After the relink only the libs from component1Prime are reachable!
expectReachable(findAllReferencedLibraries(component2Prime.libraries),
component2Prime.libraries);
expectReachable(
findAllReferencedLibraries(component2Prime.libraries,
collectViaReferencesToo: true),
component2Prime.libraries);
if (duplicateLibrariesReachable(component2Prime.libraries)) {
throw "Didn't expect duplicates libraries!";
}
Expand Down Expand Up @@ -160,6 +168,21 @@ Component createComponent(int literal) {
fileUri: libUri);
lib.addProcedure(libProcedure);

ExtensionTypeDeclaration extensionTypeDeclaration =
new ExtensionTypeDeclaration(name: "Foo", fileUri: libUri);
extensionTypeDeclaration.declaredRepresentationType = DynamicType();
extensionTypeDeclaration.representationName = "extensionTypeMethod";
final Block extensionTypeProcedureBody =
new Block([new ReturnStatement(new IntLiteral(literal))]);
final Procedure extensionTypeProcedure = new Procedure(
new Name("extensionTypeMethod"),
ProcedureKind.Method,
new FunctionNode(extensionTypeProcedureBody,
returnType: new DynamicType()),
fileUri: libUri);
extensionTypeDeclaration.addProcedure(extensionTypeProcedure);
lib.addExtensionTypeDeclaration(extensionTypeDeclaration);

final Uri mainUri = Uri.parse('org-dartlang:///main.dart');
final Library main = new Library(mainUri, fileUri: mainUri);
final Block mainProcedureBody = new Block([
Expand Down
2 changes: 1 addition & 1 deletion tools/VERSION
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@ CHANNEL dev
MAJOR 3
MINOR 4
PATCH 0
PRERELEASE 136
PRERELEASE 137
PRERELEASE_PATCH 0

0 comments on commit 105312b

Please sign in to comment.