mirror of
https://github.com/dart-lang/sdk
synced 2024-09-18 22:01:19 +00:00
[vm/nnbd] Read null-safety mode from snapshots with code
Snapshots which contain code are compiled with a particular null-safety mode and it is not possible to change their mode at run time. When running from such snapshot, VM now reads null-safety mode from the snapshot if it is not specified at the command line. This avoids the need for embedders to pass null-safety flag used during snapshot generation also to the runtime, similarly to other VM flags listed in VM_GLOBAL_FLAG_LIST (such as use_bare_instructions). In addition, error for incompatibility of kernel libraries with current null-safety mode is changed from ReportError (which attempts to throw an exception) to a FATAL, because throwing an exception crashes when bootstrapping from a kernel file. Change-Id: I93a791825c25c2da4e33634f1c71736c17928fea Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/146460 Reviewed-by: Régis Crelier <regis@google.com> Commit-Queue: Alexander Markov <alexmarkov@google.com>
This commit is contained in:
parent
491e022aa2
commit
16fb650d25
|
@ -6511,6 +6511,19 @@ char* SnapshotHeaderReader::InitializeGlobalVMFlagsFromSnapshot(
|
||||||
#undef CHECK_FLAG
|
#undef CHECK_FLAG
|
||||||
#undef SET_FLAG
|
#undef SET_FLAG
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
cursor = end;
|
cursor = end;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1038,7 +1038,7 @@ LibraryPtr KernelLoader::LoadLibrary(intptr_t index) {
|
||||||
}
|
}
|
||||||
if (I->null_safety() && (mode == NNBDCompiledMode::kWeak ||
|
if (I->null_safety() && (mode == NNBDCompiledMode::kWeak ||
|
||||||
mode == NNBDCompiledMode::kDisabled)) {
|
mode == NNBDCompiledMode::kDisabled)) {
|
||||||
H.ReportError(
|
FATAL1(
|
||||||
"Library '%s' was compiled without null safety (in weak mode) and it "
|
"Library '%s' was compiled without null safety (in weak mode) and it "
|
||||||
"cannot be used with --null-safety at runtime",
|
"cannot be used with --null-safety at runtime",
|
||||||
String::Handle(library.url()).ToCString());
|
String::Handle(library.url()).ToCString());
|
||||||
|
|
Loading…
Reference in a new issue