Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 8c2b1fa

Browse files
askeksacommit-bot@chromium.org
authored andcommitted
[ffi] Construct instance constant directly for entry point pragmas.
When we perform constant evaluation in the CFE, the FFI transform runs after constant evaluation. Thus, it needs to generate pragmas by directly producing a constant, rather than calling the pragma constructor. Change-Id: I3659fe77fde95e7797550900ff896748996758ea Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/111734 Commit-Queue: Aske Simon Christensen <[email protected]> Reviewed-by: Daco Harkes <[email protected]>
1 parent 5121a2e commit 8c2b1fa

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

pkg/vm/lib/transformations/ffi.dart

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,9 @@ class FfiTransformer extends Transformer {
9797

9898
final Class intClass;
9999
final Class doubleClass;
100-
final Constructor pragmaConstructor;
100+
final Class pragmaClass;
101+
final Field pragmaName;
102+
final Field pragmaOptions;
101103

102104
final Library ffiLibrary;
103105
final Class nativeFunctionClass;
@@ -123,7 +125,9 @@ class FfiTransformer extends Transformer {
123125
: env = new TypeEnvironment(coreTypes, hierarchy),
124126
intClass = coreTypes.intClass,
125127
doubleClass = coreTypes.doubleClass,
126-
pragmaConstructor = coreTypes.pragmaConstructor,
128+
pragmaClass = coreTypes.pragmaClass,
129+
pragmaName = coreTypes.pragmaName,
130+
pragmaOptions = coreTypes.pragmaOptions,
127131
ffiLibrary = index.getLibrary('dart:ffi'),
128132
nativeFunctionClass = index.getClass('dart:ffi', 'NativeFunction'),
129133
pointerClass = index.getClass('dart:ffi', 'Pointer'),

pkg/vm/lib/transformations/ffi_definitions.dart

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -410,8 +410,12 @@ class _FfiDefinitionTransformer extends FfiTransformer {
410410
}
411411

412412
void _makeEntryPoint(Annotatable node) {
413-
node.addAnnotation(ConstructorInvocation(
414-
pragmaConstructor, Arguments([StringLiteral("vm:entry-point")])));
413+
node.addAnnotation(ConstantExpression(
414+
InstanceConstant(pragmaClass.reference, [], {
415+
pragmaName.reference: StringConstant("vm:entry-point"),
416+
pragmaOptions.reference: NullConstant()
417+
}),
418+
InterfaceType(pragmaClass, [])));
415419
}
416420

417421
NativeType _getFieldType(Class c) {

0 commit comments

Comments
 (0)