[standalone, io] Don't register service extensions in product mode.

dart2js.aot.x64 20942544 -> 20852448 (-90k)

TEST=ci
Bug: https://github.com/dart-lang/sdk/issues/45469
CoreLibraryReviewExempt: VM-only
Change-Id: I5ee6a4019af1fa4a0815ac05a42bb4883d74d8a3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/323503
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
This commit is contained in:
Ryan Macnak 2023-08-30 21:46:17 +00:00 committed by Commit Queue
parent 734e9c3c5b
commit 54faa31964
4 changed files with 9 additions and 5 deletions

View file

@ -9,11 +9,12 @@ abstract final class HttpProfiler {
static final Map<String, _HttpProfileData> _profile = {};
static _HttpProfileData startRequest(
static _HttpProfileData? startRequest(
String method,
Uri uri, {
_HttpProfileData? parentRequest,
}) {
if (const bool.fromEnvironment("dart.vm.product")) return null;
final data = _HttpProfileData(method, uri, parentRequest?._timeline);
_profile[data.id] = data;
return data;
@ -2778,7 +2779,8 @@ class _HttpClient implements HttpClient {
}
}
_HttpProfileData? profileData;
if (HttpClient.enableTimelineLogging) {
if (HttpClient.enableTimelineLogging &&
!const bool.fromEnvironment("dart.vm.product")) {
profileData = HttpProfiler.startRequest(method, uri);
}
return _getConnection(uri, uri.host, port, proxyConf, isSecure, profileData)

View file

@ -235,7 +235,8 @@ base class _ProcessImpl extends _ProcessImplNativeWrapper implements _Process {
}
ArgumentError.checkNotNull(_mode, "mode");
if (!connectedResourceHandler) {
if (!const bool.fromEnvironment("dart.vm.product") &&
!connectedResourceHandler) {
registerExtension('ext.dart.io.getSpawnedProcesses',
_SpawnedProcessResourceInfo.getStartedProcesses);
registerExtension('ext.dart.io.getSpawnedProcessById',

View file

@ -727,7 +727,8 @@ class _RandomAccessFile implements RandomAccessFile {
}
_maybeConnectHandler() {
if (!_connectedResourceHandler) {
if (!const bool.fromEnvironment("dart.vm.product") &&
!_connectedResourceHandler) {
// TODO(ricow): We probably need to set these in some initialization code.
// We need to make sure that these are always available from the
// observatory even if no files (or sockets for the socket ones) are

View file

@ -40,7 +40,7 @@ abstract class _NetworkProfiling {
// if more methods added to dart:io,
static const _kGetVersionRPC = 'ext.dart.io.getVersion';
@pragma('vm:entry-point')
@pragma('vm:entry-point', !const bool.fromEnvironment("dart.vm.product"))
static void _registerServiceExtension() {
registerExtension(_kGetHttpEnableTimelineLogging, _serviceExtensionHandler);
registerExtension(_kSetHttpEnableTimelineLogging, _serviceExtensionHandler);