Skip to content

Commit 962b2f2

Browse files
aamCommit Queue
authored andcommitted
[shared] Mark Platforms constants and Stopwatch frequence as shared.
BUG=#61030 TEST=ci CoreLibraryReviewExempt: this cl adds vm-specific pragma decoration Change-Id: Ia238c901d7b94f2ff7e5ad578f829e25cd1ba804 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/445560 Reviewed-by: Slava Egorov <[email protected]> Commit-Queue: Alexander Aprelev <[email protected]>
1 parent 0416fd1 commit 962b2f2

File tree

4 files changed

+14
-1
lines changed

4 files changed

+14
-1
lines changed

pkg/vm/testcases/transformations/vm_constant_evaluator/errors/not_constant_field.dart.linux.expect

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Constant evaluation error: Constant evaluation error:
2-
platform_impl.dart:2772 Constant evaluation error: The invocation of '_environmentCache' is not allowed in a constant expression.
2+
platform_impl.dart:2841 Constant evaluation error: The invocation of '_environmentCache' is not allowed in a constant expression.
33
Member: notConstant
44
File: not_constant_field.dart
55
Offset: 350

sdk/lib/core/stopwatch.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ class Stopwatch {
4949
/// Cached frequency of the system in Hz (ticks per second).
5050
///
5151
/// Value must be returned by [_initTicker], which is called only once.
52+
@pragma("vm:shared")
5253
static final int _frequency = _initTicker();
5354

5455
// The _start and _stop fields capture the time when [start] and [stop]

sdk/lib/io/platform.dart

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ abstract final class Platform {
8080
/// Note that this list may change over time so platform-specific logic
8181
/// should be guarded by the appropriate Boolean getter e.g. [isMacOS].
8282
@pragma("vm:platform-const")
83+
@pragma("vm:shared")
8384
static final operatingSystem = _Platform.operatingSystem;
8485

8586
/// A string representing the version of the operating system or platform.
@@ -89,6 +90,7 @@ abstract final class Platform {
8990
/// "Linux 5.11.0-1018-gcp #20~20.04.2-Ubuntu SMP Fri Sep 3 01:01:37 UTC 2021"
9091
/// "Version 14.5 (Build 18E182)"
9192
/// '"Windows 10 Pro" 10.0 (Build 19043)'
93+
@pragma("vm:shared")
9294
static final operatingSystemVersion = _Platform.operatingSystemVersion;
9395

9496
/// The local hostname for the system.
@@ -100,6 +102,7 @@ abstract final class Platform {
100102
/// Uses the platform
101103
/// [`gethostname`](https://pubs.opengroup.org/onlinepubs/9699919799/functions/gethostname.html)
102104
/// implementation.
105+
@pragma("vm:shared")
103106
static final localHostname = _Platform.localHostname;
104107

105108
/// The version of the current Dart runtime.
@@ -108,6 +111,7 @@ abstract final class Platform {
108111
/// string representing the version of the current Dart runtime,
109112
/// possibly followed by whitespace and other version and
110113
/// build details.
114+
@pragma("vm:shared")
111115
static final version = _Platform.version;
112116

113117
/// Get the name of the current locale.
@@ -138,11 +142,13 @@ abstract final class Platform {
138142
/// version of Linux that identifies itself by a different name,
139143
/// for example Android (see [isAndroid]).
140144
@pragma("vm:platform-const")
145+
@pragma("vm:shared")
141146
static final bool isLinux = (operatingSystem == "linux");
142147

143148
/// Whether the operating system is a version of
144149
/// [macOS](https://en.wikipedia.org/wiki/MacOS).
145150
@pragma("vm:platform-const")
151+
@pragma("vm:shared")
146152
static final bool isMacOS = (operatingSystem == "macos");
147153

148154
/// Whether the operating system is a version of
@@ -154,16 +160,19 @@ abstract final class Platform {
154160
/// Whether the operating system is a version of
155161
/// [Android](https://en.wikipedia.org/wiki/Android_%28operating_system%29).
156162
@pragma("vm:platform-const")
163+
@pragma("vm:shared")
157164
static final bool isAndroid = (operatingSystem == "android");
158165

159166
/// Whether the operating system is a version of
160167
/// [iOS](https://en.wikipedia.org/wiki/IOS).
161168
@pragma("vm:platform-const")
169+
@pragma("vm:shared")
162170
static final bool isIOS = (operatingSystem == "ios");
163171

164172
/// Whether the operating system is a version of
165173
/// [Fuchsia](https://en.wikipedia.org/wiki/Google_Fuchsia).
166174
@pragma("vm:platform-const")
175+
@pragma("vm:shared")
167176
static final bool isFuchsia = (operatingSystem == "fuchsia");
168177

169178
/// The environment for this process as a map from string key to string value.

sdk/lib/io/platform_impl.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,11 @@ class _Platform {
3333
external static String _localeName();
3434
external static Uri _script();
3535

36+
@pragma("vm:shared")
3637
static String executable = _executable();
38+
@pragma("vm:shared")
3739
static String resolvedExecutable = _resolvedExecutable();
40+
@pragma("vm:shared")
3841
static String? packageConfig = _packageConfig();
3942

4043
@pragma("vm:entry-point")

0 commit comments

Comments
 (0)