Skip to content

Commit aa569df

Browse files
liamappelbecommit-bot@chromium.org
authored andcommitted
[vm] Enable non-nullable experiment when building platform dill with --nnbd flag.
Change-Id: I00632cc2dcf5e929698ee6b88eefbd5c58752297 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/122174 Commit-Queue: Liam Appelbe <liama@google.com> Reviewed-by: Ryan Macnak <rmacnak@google.com> Reviewed-by: Alexander Markov <alexmarkov@google.com>
1 parent bf4d4b2 commit aa569df

File tree

5 files changed

+26
-1
lines changed

5 files changed

+26
-1
lines changed

runtime/bin/BUILD.gn

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
import("../../build/config/gclient_args.gni")
66
import("../../build/dart/dart_action.gni")
7+
import("../../sdk_args.gni")
78
import("../runtime_args.gni")
89
import("../vm/compiler/compiler_sources.gni")
910
import("../vm/heap/heap_sources.gni")
@@ -537,7 +538,11 @@ gen_snapshot_action("generate_snapshot_bin") {
537538
isolate_snapshot_data,
538539
isolate_snapshot_instructions,
539540
]
540-
args = [
541+
args = []
542+
if (use_nnbd) {
543+
args += [ "--enable-experiment=non-nullable" ]
544+
}
545+
args += [
541546
"--deterministic",
542547
"--snapshot_kind=" + dart_core_snapshot_kind,
543548
"--vm_snapshot_data=" + rebase_path(vm_snapshot_data, root_build_dir),

runtime/vm/BUILD.gn

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import("../../sdk/lib/mirrors/mirrors_sources.gni")
1616
import("../../sdk/lib/typed_data/typed_data_sources.gni")
1717
import("../../sdk/lib/vmservice/vmservice_sources.gni")
1818
import("../../sdk/lib/wasm/wasm_sources.gni")
19+
import("../../sdk_args.gni")
1920
import("../../utils/compile_platform.gni")
2021
import("../bin/cli_sources.gni")
2122
import("../bin/io_sources.gni")
@@ -146,6 +147,9 @@ template("gen_vm_platform") {
146147
"-Ddart.developer.causal_async_stacks=$allow_causal_async_stacks",
147148
"-Ddart.isVM=true",
148149
]
150+
if (use_nnbd) {
151+
args += [ "--enable-experiment=non-nullable" ]
152+
}
149153
if (defined(invoker.exclude_source) && invoker.exclude_source) {
150154
args += [ "--exclude-source" ]
151155
}

runtime/vm/kernel_isolate.cc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,15 @@ void KernelIsolate::AddExperimentalFlag(const char* value) {
395395
experimental_flags_->Add(strdup(value));
396396
}
397397

398+
bool KernelIsolate::GetExperimentalFlag(const char* value) {
399+
for (const char* str : *experimental_flags_) {
400+
if (strcmp(str, value) == 0) {
401+
return true;
402+
}
403+
}
404+
return false;
405+
}
406+
398407
DEFINE_OPTION_HANDLER(KernelIsolate::AddExperimentalFlag,
399408
enable_experiment,
400409
"Comma separated list of experimental features.");

runtime/vm/kernel_isolate.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ class KernelIsolate : public AllStatic {
6969
static void NotifyAboutIsolateShutdown(const Isolate* isolate);
7070

7171
static void AddExperimentalFlag(const char* value);
72+
static bool GetExperimentalFlag(const char* value);
7273

7374
protected:
7475
static void InitCallback(Isolate* I);

runtime/vm/object.cc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8210,6 +8210,12 @@ bool Function::CheckSourceFingerprint(const char* prefix, int32_t fp) const {
82108210
return true;
82118211
}
82128212

8213+
if (KernelIsolate::GetExperimentalFlag("non-nullable")) {
8214+
// The non-nullable experiment changes the fingerprints, and we only track
8215+
// one fingerprint set.
8216+
return true;
8217+
}
8218+
82138219
if (SourceFingerprint() != fp) {
82148220
const bool recalculatingFingerprints = false;
82158221
if (recalculatingFingerprints) {

0 commit comments

Comments
 (0)