Unreviewed changes
1 is the latest approved patch-set.
The change was submitted with unreviewed changes in the following files:
```
The name of the file: pkg/dart2bytecode/lib/bytecode_generator.dart
Insertions: 17, Deletions: 21.
@@ -423,7 +423,7 @@
Annotations getAnnotations(List<Expression> nodes) {
if (nodes.isEmpty) {
- return const Annotations(null);
+ return const Annotations(null, false);
}
List<Constant> constants = nodes.map(_getConstant).toList();
bool hasPragma = constants.any(_isPragma);
@@ -431,14 +431,14 @@
if (hasPragma) {
constants = constants.where(_isPragma).toList();
} else {
- return const Annotations(null);
+ return const Annotations(null, false);
}
}
final object = objectTable
.getHandle(new ListConstant(const DynamicType(), constants))!;
final decl = new AnnotationsDeclaration(object);
bytecodeComponent.annotations.add(decl);
- return new Annotations(decl, hasPragma: hasPragma);
+ return new Annotations(decl, hasPragma);
}
// Insert annotations for the function and its parameters into the annotations
@@ -457,13 +457,13 @@
if (annotations.isEmpty &&
parameterNodeLists.every((nodes) => nodes.isEmpty)) {
- return const Annotations(null);
+ return const Annotations(null, false);
}
List<Constant> functionConstants = annotations.map(_getConstant).toList();
bool hasPragma = functionConstants.any(_isPragma);
if (!options.emitAnnotations && !hasPragma) {
- return const Annotations(null);
+ return const Annotations(null, false);
}
final functionObject = objectTable
@@ -480,13 +480,7 @@
bytecodeComponent.annotations.add(parameterDecl);
}
- final isInvisible = hasPragma &&
- pragmaParser
- .parsedPragmas<ParsedVmInvisiblePragma>(annotations)
- .isNotEmpty;
-
- return new Annotations(functionDecl,
- hasPragma: hasPragma, isInvisible: isInvisible);
+ return new Annotations(functionDecl, hasPragma);
}
FieldDeclaration getFieldDeclaration(Field field, Code? initializer) {
@@ -683,12 +677,14 @@
getFunctionAnnotations(member.annotations, function);
if (annotations.object != null) {
flags |= FunctionDeclaration.hasAnnotationsFlag;
- if (annotations.isInvisible) {
- flags |= FunctionDeclaration.isInvisibleFlag;
- }
if (annotations.hasPragma) {
flags |= FunctionDeclaration.hasPragmaFlag;
if (pragmaParser
+ .parsedPragmas<ParsedVmInvisiblePragma>(member.annotations)
+ .isNotEmpty) {
+ flags |= FunctionDeclaration.isInvisibleFlag;
+ }
+ if (pragmaParser
.parsedPragmas<ParsedDynModuleEntryPointPragma>(member.annotations)
.isNotEmpty) {
if (dynModuleEntryPoint != null) {
@@ -2639,9 +2635,11 @@
flags |= ClosureDeclaration.hasAnnotationsFlag;
if (annotations.hasPragma) {
flags |= ClosureDeclaration.hasPragmaFlag;
- }
- if (annotations.isInvisible) {
- flags |= ClosureDeclaration.isInvisibleFlag;
+ if (pragmaParser
+ .parsedPragmas<ParsedVmInvisiblePragma>(astAnnotations)
+ .isNotEmpty) {
+ flags |= ClosureDeclaration.isInvisibleFlag;
+ }
}
}
@@ -4650,8 +4648,6 @@
class Annotations {
final AnnotationsDeclaration? object;
final bool hasPragma;
- final bool isInvisible;
- const Annotations(this.object,
- {this.hasPragma = false, this.isInvisible = false});
+ const Annotations(this.object, this.hasPragma);
}
```
Change information
Commit message:
[vm,dyn_modules] Recognize the vm:invisible pragma.
Adds a new isInvisible flag for both FunctionDeclarations and
ClosureDeclarations and sets it if the function or closure declaration
is annotated with @pragma('vm:invisible'). This way, function visibility
is appropriately recorded even if options.emitAnnotations is false.
The bytecode reader checks for the isInvisible flag when reading
FunctionDeclarations and ClosureDeclarations and appropriately
sets the is_visible flag for the Function object accordingly.
TEST=pkg/dart2bytecode/test/bytecode_generator_test
vm/dart/invisible_function_pragma_test
Cq-Include-Trybots: luci.dart.try:vm-dyn-linux-debug-x64-try
Change-Id: If435afbe5e74adc022ce064784b6b3e5e8a88164
Files:
- M pkg/dart2bytecode/docs/bytecode.md
- M pkg/dart2bytecode/lib/bytecode_generator.dart
- M pkg/dart2bytecode/lib/declarations.dart
- M pkg/dart2bytecode/test/bytecode_generator_test.dart
- A pkg/dart2bytecode/testcases/invisible.dart
- A pkg/dart2bytecode/testcases/invisible.dart.expect
- M pkg/vm/lib/transformations/pragma.dart
- M runtime/vm/bytecode_reader.cc
Change size: L
Delta: 8 files changed, 337 insertions(+), 7 deletions(-)
Branch: refs/heads/main
Submit Requirements:
Code-Review: +1 by Alexander Markov