Skip to content

Commit a7472ba

Browse files
a-sivacommit-bot@chromium.org
authored andcommitted
Cache value of "non-nullable" flag so it can be used in the VM code without having to search through the array of experimental flags array.
Change-Id: I297dca48711ef2bdd80a102086dea1bb075ea357 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/125081 Reviewed-by: Régis Crelier <regis@google.com> Commit-Queue: Siva Annamalai <asiva@google.com>
1 parent 8938a5e commit a7472ba

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

runtime/vm/dart.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ Dart_FileReadCallback Dart::file_read_callback_ = NULL;
6969
Dart_FileWriteCallback Dart::file_write_callback_ = NULL;
7070
Dart_FileCloseCallback Dart::file_close_callback_ = NULL;
7171
Dart_EntropySource Dart::entropy_source_callback_ = NULL;
72+
bool Dart::non_nullable_flag_ = false;
7273

7374
// Structure for managing read-only global handles allocation used for
7475
// creating global read-only handles that are pre created and initialized
@@ -222,6 +223,9 @@ char* Dart::Init(const uint8_t* vm_isolate_snapshot,
222223
ASSERT(Flags::Initialized());
223224
const bool is_vm_isolate = true;
224225

226+
// Cache value of "non-nullable" experimental flag.
227+
set_non_nullable_flag(KernelIsolate::GetExperimentalFlag("non-nullable"));
228+
225229
// Setup default flags for the VM isolate.
226230
Dart_IsolateFlags api_flags;
227231
Isolate::FlagsInitialize(&api_flags);

runtime/vm/dart.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,8 @@ class Dart : public AllStatic {
123123
static Dart_EntropySource entropy_source_callback() {
124124
return entropy_source_callback_;
125125
}
126+
static void set_non_nullable_flag(bool value) { non_nullable_flag_ = value; }
127+
static bool non_nullable_flag() { return non_nullable_flag_; }
126128

127129
private:
128130
static void WaitForIsolateShutdown();
@@ -141,6 +143,7 @@ class Dart : public AllStatic {
141143
static Dart_FileWriteCallback file_write_callback_;
142144
static Dart_FileCloseCallback file_close_callback_;
143145
static Dart_EntropySource entropy_source_callback_;
146+
static bool non_nullable_flag_;
144147
};
145148

146149
} // namespace dart

runtime/vm/object.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8244,7 +8244,7 @@ bool Function::CheckSourceFingerprint(const char* prefix, int32_t fp) const {
82448244
return true;
82458245
}
82468246

8247-
if (KernelIsolate::GetExperimentalFlag("non-nullable")) {
8247+
if (Dart::non_nullable_flag()) {
82488248
// The non-nullable experiment changes the fingerprints, and we only track
82498249
// one fingerprint set.
82508250
return true;

0 commit comments

Comments
 (0)