From e270bbe95c8d0e0739ed09ef55d4b8ee430407b6 Mon Sep 17 00:00:00 2001 From: Alexander Aprelev Date: Fri, 8 Oct 2021 20:22:28 +0000 Subject: [PATCH] [io/unix-domain-sockets] Ensure runtime-looked up entry points are marked as such. This is needed to ensure that entry points looked from native code are preserved, not tree-shaken. This is follow-up to https://dart.googlesource.com/sdk/+/935ee25f3b72e7fe81047220cadae1f61c505da4 Fixes https://github.com/dart-lang/sdk/issues/47416 TEST=unix_socket_test on dartkp bots Change-Id: I5cf3071507947b1c24b2808e46dc92186e4b9476 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/216062 Commit-Queue: Alexander Aprelev Reviewed-by: Ben Konyi --- .../transformer/enum_from_lib_used_as_type.dart.expect | 2 +- .../transformer/tree_shake_enum_from_lib.dart.expect | 2 +- sdk/lib/_internal/vm/bin/socket_patch.dart | 8 ++++++++ sdk/lib/io/file_impl.dart | 2 ++ 4 files changed, 12 insertions(+), 2 deletions(-) diff --git a/pkg/vm/testcases/transformations/type_flow/transformer/enum_from_lib_used_as_type.dart.expect b/pkg/vm/testcases/transformations/type_flow/transformer/enum_from_lib_used_as_type.dart.expect index 8ddda1154e8..ef7f8eef25c 100644 --- a/pkg/vm/testcases/transformations/type_flow/transformer/enum_from_lib_used_as_type.dart.expect +++ b/pkg/vm/testcases/transformations/type_flow/transformer/enum_from_lib_used_as_type.dart.expect @@ -22,6 +22,6 @@ class Class extends core::Object { synthetic constructor •() → self::Class : super core::Object::•() ; -[@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasTearOffUses:false,methodOrSetterSelectorId:3261,getterSelectorId:3262] method method([@vm.inferred-type.metadata=dart.core::Null? (value: null)] self::Enum e) → core::int +[@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasTearOffUses:false,methodOrSetterSelectorId:3266,getterSelectorId:3267] method method([@vm.inferred-type.metadata=dart.core::Null? (value: null)] self::Enum e) → core::int return [@vm.inferred-type.metadata=!] e.{core::_Enum::index}{core::int}; } diff --git a/pkg/vm/testcases/transformations/type_flow/transformer/tree_shake_enum_from_lib.dart.expect b/pkg/vm/testcases/transformations/type_flow/transformer/tree_shake_enum_from_lib.dart.expect index 64e1bc1c886..4a6892032bd 100644 --- a/pkg/vm/testcases/transformations/type_flow/transformer/tree_shake_enum_from_lib.dart.expect +++ b/pkg/vm/testcases/transformations/type_flow/transformer/tree_shake_enum_from_lib.dart.expect @@ -51,6 +51,6 @@ class ConstClass extends core::Object { synthetic constructor •() → self::ConstClass : super core::Object::•() ; -[@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasTearOffUses:false,methodOrSetterSelectorId:3265,getterSelectorId:3266] method method([@vm.inferred-type.metadata=dart.core::Null? (value: null)] self::ConstEnum e) → core::int +[@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasTearOffUses:false,methodOrSetterSelectorId:3270,getterSelectorId:3271] method method([@vm.inferred-type.metadata=dart.core::Null? (value: null)] self::ConstEnum e) → core::int return [@vm.inferred-type.metadata=!] e.{core::_Enum::index}{core::int}; } diff --git a/sdk/lib/_internal/vm/bin/socket_patch.dart b/sdk/lib/_internal/vm/bin/socket_patch.dart index 9a68d6f1b2e..5f0379e4b14 100644 --- a/sdk/lib/_internal/vm/bin/socket_patch.dart +++ b/sdk/lib/_internal/vm/bin/socket_patch.dart @@ -2545,7 +2545,9 @@ class ResourceHandle { @pragma("vm:entry-point") class _ResourceHandleImpl implements ResourceHandle { + @pragma("vm:entry-point") int _handle; // file descriptor on linux + @pragma("vm:entry-point") _ResourceHandleImpl(this._handle); @pragma("vm:external-name", "ResourceHandleImpl_toFile") @@ -2572,6 +2574,7 @@ class _ResourceHandleImpl implements ResourceHandle { @pragma("vm:external-name", "ResourceHandleImpl_toRawDatagramSocket") external RawDatagramSocket toRawDatagramSocket(); + @pragma("vm:entry-point") static final _ResourceHandleImpl _sentinel = _ResourceHandleImpl(-1); } @@ -2581,11 +2584,16 @@ class SocketControlMessage { native "SocketControlMessage_fromHandles"; } +@pragma("vm:entry-point") class _SocketControlMessageImpl implements SocketControlMessage { + @pragma("vm:entry-point") final int level; + @pragma("vm:entry-point") final int type; + @pragma("vm:entry-point") final Uint8List data; + @pragma("vm:entry-point") _SocketControlMessageImpl(this.level, this.type, this.data); @pragma("vm:external-name", "SocketControlMessageImpl_extractHandles") diff --git a/sdk/lib/io/file_impl.dart b/sdk/lib/io/file_impl.dart index 13114440c3f..b8361d0fd5e 100644 --- a/sdk/lib/io/file_impl.dart +++ b/sdk/lib/io/file_impl.dart @@ -662,6 +662,7 @@ abstract class _RandomAccessFileOps { lock(int lock, int start, int end); } +@pragma("vm:entry-point") class _RandomAccessFile implements RandomAccessFile { static bool _connectedResourceHandler = false; @@ -672,6 +673,7 @@ class _RandomAccessFile implements RandomAccessFile { late _FileResourceInfo _resourceInfo; _RandomAccessFileOps _ops; + @pragma("vm:entry-point") _RandomAccessFile(int pointer, this.path) : _ops = new _RandomAccessFileOps(pointer) { _resourceInfo = new _FileResourceInfo(this);