-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[pkg/vm] Initial work on constant operating system fields and getters.
* Add an `targetOS` argument to `pkg/vm`'s `compileToKernel`, that contains the target operating system's name. * Add a new `--target-os` command line argument for all binaries that use `compileToKernel` for clients to provide the target operating system, if known. * Add a new`"vm:platform:const"` annotation to certain field and getters in the Platform class. This annotation is used to annotate static getters and fields with initializers where the getter body or field initializer must evaluate to a constant value if the target operating system is known. This annotation may be used outside the Platform class and in user code. For example, this annotation can be used on a static `String` field that is initialized with one value if `Platform.isWindows` is true and to a different value if `Platform.isWindows` is false. Note: If the const functions experimental flag is disabled, then any annotated static methods can only contain a single expression whose value is returned. If it is enabled, then the static method is evaluated as if it is a const function with the special handling of annotated static fields and getters above. * Create a VM constant evaluator that evaluates uses of static getters and fields marked with the above annotations when a target operating system is provided. * Use the new VM constant evaluator in the unreachable code elimination transformer. TEST=pkg/vm/test/transformations/platform_use_transformer pkg/vm/test/transformations/unreachable_code_elimination Change-Id: Ie381de70486a767fd7b1d515fd9e6bb58c6bf090 Bug: #31969 Cq-Include-Trybots: luci.dart.try:pkg-linux-release-try CoreLibraryReviewExempt: Just adding vm-specific annotations. Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/274386 Commit-Queue: Tess Strickland <sstrickl@google.com> Reviewed-by: Chloe Stefantsova <cstefantsova@google.com> Reviewed-by: Alexander Markov <alexmarkov@google.com> Reviewed-by: Martin Kustermann <kustermann@google.com>
- Loading branch information
Showing
26 changed files
with
784 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// Copyright (c) 2023, the Dart project authors. Please see the AUTHORS file | ||
// for details. All rights reserved. Use of this source code is governed by a | ||
// BSD-style license that can be found in the LICENSE file. | ||
|
||
enum TargetOS { | ||
android('android', '/'), | ||
fuchsia('fuchsia', '/'), | ||
iOS('ios', '/'), | ||
linux('linux', '/'), | ||
macOS('macos', '/'), | ||
windows('windows', '\\'); | ||
|
||
final String name; | ||
final String pathSeparator; | ||
|
||
const TargetOS(this.name, this.pathSeparator); | ||
|
||
static final Iterable<String> names = values.map((v) => v.name); | ||
|
||
static TargetOS? fromString(String s) { | ||
for (final os in values) { | ||
if (os.name == s) return os; | ||
} | ||
return null; | ||
} | ||
|
||
@override | ||
String toString() => name; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.