Skip to content

Commit ea746d2

Browse files
alexmarkovCommit Queue
authored andcommitted
[vm,dyn_modules] Remove unused library dependencies from bytecode
Fixes #61362 TEST=ci Change-Id: I1e15b100a9d5f486addce11e85ea6d69389a6bb7 Cq-Include-Trybots: luci.dart.try:vm-aot-dyn-linux-debug-x64-try,vm-aot-dyn-linux-product-x64-try,vm-dyn-linux-debug-x64-try Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/446101 Reviewed-by: Tess Strickland <[email protected]> Commit-Queue: Alexander Markov <[email protected]>
1 parent aa0e081 commit ea746d2

File tree

1 file changed

+1
-62
lines changed

1 file changed

+1
-62
lines changed

pkg/dart2bytecode/lib/bytecode_generator.dart

Lines changed: 1 addition & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ class BytecodeGenerator extends RecursiveVisitor {
348348
flags |= ClassDeclaration.hasSourcePositionsFlag;
349349
position = library.fileOffset;
350350
}
351-
Annotations annotations = getLibraryAnnotations(library);
351+
Annotations annotations = getAnnotations(library.annotations);
352352
if (annotations.object != null) {
353353
flags |= ClassDeclaration.hasAnnotationsFlag;
354354
if (annotations.hasPragma) {
@@ -441,67 +441,6 @@ class BytecodeGenerator extends RecursiveVisitor {
441441
return new Annotations(functionDecl, hasPragma);
442442
}
443443

444-
// Insert annotations for library and its dependencies into the
445-
// annotations section. Returns annotations for the library only.
446-
// Bytecode reader will implicitly find library dependencies by reading
447-
// an extra object after reading library annotations.
448-
Annotations getLibraryAnnotations(Library library) {
449-
Annotations annotations = getAnnotations(library.annotations);
450-
final bool emitDependencies =
451-
options.emitAnnotations && library.dependencies.isNotEmpty;
452-
if (annotations.object == null && !emitDependencies) {
453-
return annotations;
454-
}
455-
456-
// We need to emit both annotations and dependencies objects, appending
457-
// null if an object is missing.
458-
if (annotations.object == null) {
459-
final annotationsDecl = new AnnotationsDeclaration(null);
460-
bytecodeComponent.annotations.add(annotationsDecl);
461-
annotations = new Annotations(annotationsDecl, false);
462-
}
463-
if (!emitDependencies) {
464-
bytecodeComponent.annotations.add(new AnnotationsDeclaration(null));
465-
return annotations;
466-
}
467-
468-
// Create a constant object representing library dependencies.
469-
// These objects are used by dart:mirrors and vm-service implementation.
470-
final deps = <Constant>[];
471-
for (var dependency in library.dependencies) {
472-
final dependencyName = dependency.name;
473-
final prefix = dependencyName != null
474-
? StringConstant(dependencyName)
475-
: NullConstant();
476-
final showNames = dependency.combinators
477-
.where((c) => c.isShow)
478-
.expand((c) => c.names)
479-
.map((name) => StringConstant(name))
480-
.toList();
481-
final hideNames = dependency.combinators
482-
.where((c) => c.isHide)
483-
.expand((c) => c.names)
484-
.map((name) => StringConstant(name))
485-
.toList();
486-
final depAnnots = dependency.annotations.map(_getConstant).toList();
487-
deps.add(ListConstant(const DynamicType(), <Constant>[
488-
StringConstant(dependency.targetLibrary.importUri.toString()),
489-
BoolConstant(dependency.isExport),
490-
BoolConstant(dependency.isDeferred),
491-
prefix,
492-
ListConstant(const DynamicType(), showNames),
493-
ListConstant(const DynamicType(), hideNames),
494-
ListConstant(const DynamicType(), depAnnots),
495-
]));
496-
}
497-
final ObjectHandle dependenciesObject =
498-
objectTable.getHandle(ListConstant(const DynamicType(), deps))!;
499-
final dependenciesDecl = new AnnotationsDeclaration(dependenciesObject);
500-
bytecodeComponent.annotations.add(dependenciesDecl);
501-
502-
return annotations;
503-
}
504-
505444
FieldDeclaration getFieldDeclaration(Field field, Code? initializer) {
506445
int flags = 0;
507446
Constant? value;

0 commit comments

Comments
 (0)