mirror of
https://github.com/dart-lang/sdk
synced 2024-09-05 08:24:39 +00:00
[VM/Runtime] - Fix for issue https://github.com/dart-lang/sdk/issues/42421
Set global null safety flag based on the snapshot instead of trying to detect it per isolate (was causing issues with the vm isolate loading). Should fix https://github.com/dart-lang/sdk/issues/42421 Bug:42421 Change-Id: I9143560b76fedcb991e96522cbf5d820fde99f7f Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/151866 Reviewed-by: Alexander Markov <alexmarkov@google.com> Commit-Queue: Siva Annamalai <asiva@google.com>
This commit is contained in:
parent
c909e16ee2
commit
bbc8aedada
|
@ -6713,6 +6713,21 @@ char* SnapshotHeaderReader::InitializeGlobalVMFlagsFromSnapshot(
|
|||
#undef CHECK_FLAG
|
||||
#undef SET_FLAG
|
||||
|
||||
#if defined(DART_PRECOMPILED_RUNTIME)
|
||||
if (FLAG_null_safety == kNullSafetyOptionUnspecified) {
|
||||
if (strncmp(cursor, "null-safety", end - cursor) == 0) {
|
||||
FLAG_null_safety = kNullSafetyOptionStrong;
|
||||
cursor = end;
|
||||
continue;
|
||||
}
|
||||
if (strncmp(cursor, "no-null-safety", end - cursor) == 0) {
|
||||
FLAG_null_safety = kNullSafetyOptionWeak;
|
||||
cursor = end;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
#endif // defined(DART_PRECOMPILED_RUNTIME)
|
||||
|
||||
cursor = end;
|
||||
}
|
||||
|
||||
|
|
|
@ -753,12 +753,13 @@ bool Dart::DetectNullSafety(const char* script_uri,
|
|||
intptr_t kernel_buffer_size,
|
||||
const char* package_config,
|
||||
const char* original_working_directory) {
|
||||
#if !defined(DART_PRECOMPILED_RUNTIME)
|
||||
// Before creating the isolate we first determine the null safety mode
|
||||
// in which the isolate needs to run based on one of these factors :
|
||||
// - if loading from source, based on opt-in status of the source
|
||||
// - if loading from a kernel file, based on the mode used when
|
||||
// generating the kernel file
|
||||
// - if loading from an appJIT or AOT snapshot, based on the mode used
|
||||
// - if loading from an appJIT, based on the mode used
|
||||
// when generating the snapshot.
|
||||
ASSERT(FLAG_null_safety == kNullSafetyOptionUnspecified);
|
||||
|
||||
|
@ -772,7 +773,6 @@ bool Dart::DetectNullSafety(const char* script_uri,
|
|||
}
|
||||
}
|
||||
|
||||
#if !defined(DART_PRECOMPILED_RUNTIME)
|
||||
// If kernel_buffer is specified, it could be a self contained
|
||||
// kernel file or the kernel file of the application,
|
||||
// figure out the null safety mode by sniffing the kernel file.
|
||||
|
@ -791,8 +791,10 @@ bool Dart::DetectNullSafety(const char* script_uri,
|
|||
return KernelIsolate::DetectNullSafety(script_uri, package_config,
|
||||
original_working_directory);
|
||||
}
|
||||
#endif // !defined(DART_PRECOMPILED_RUNTIME)
|
||||
return false;
|
||||
#else
|
||||
UNREACHABLE();
|
||||
#endif // !defined(DART_PRECOMPILED_RUNTIME)
|
||||
}
|
||||
|
||||
#if defined(DART_PRECOMPILED_RUNTIME)
|
||||
|
|
|
@ -6032,6 +6032,10 @@ DART_EXPORT bool Dart_DetectNullSafety(const char* script_uri,
|
|||
const uint8_t* snapshot_instructions,
|
||||
const uint8_t* kernel_buffer,
|
||||
intptr_t kernel_buffer_size) {
|
||||
#if defined(DART_PRECOMPILED_RUNTIME)
|
||||
ASSERT(FLAG_null_safety != kNullSafetyOptionUnspecified);
|
||||
return (FLAG_null_safety == kNullSafetyOptionStrong);
|
||||
#else
|
||||
bool null_safety;
|
||||
if (FLAG_null_safety == kNullSafetyOptionUnspecified) {
|
||||
null_safety = Dart::DetectNullSafety(
|
||||
|
@ -6041,6 +6045,7 @@ DART_EXPORT bool Dart_DetectNullSafety(const char* script_uri,
|
|||
null_safety = (FLAG_null_safety == kNullSafetyOptionStrong);
|
||||
}
|
||||
return null_safety;
|
||||
#endif // defined(DART_PRECOMPILED_RUNTIME)
|
||||
}
|
||||
|
||||
// --- Service support ---
|
||||
|
|
Loading…
Reference in a new issue