mirror of
https://github.com/dart-lang/sdk
synced 2024-10-06 12:57:42 +00:00
[VM] Remove support for --no-sound-null-safety mode
This CL removes support for --no-sound-null-safety option, the VM will only run sound null safety code. First part of deleting support for legacy and unsound null safe code. TEST=CI Change-Id: I9dbed10a18ef102533d6af516ff5075297d17b74 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/357183 Reviewed-by: Ryan Macnak <rmacnak@google.com> Commit-Queue: Siva Annamalai <asiva@google.com>
This commit is contained in:
parent
6e11b5dd40
commit
8e2acda7d6
|
@ -1,5 +1,9 @@
|
||||||
## 3.5.0
|
## 3.5.0
|
||||||
|
|
||||||
|
### Dart Runtime
|
||||||
|
- The Dart VM only executes sound null safe code, running of unsound null
|
||||||
|
safe code using the option `--no-sound-null-safety` has been removed.
|
||||||
|
|
||||||
## 3.4.0
|
## 3.4.0
|
||||||
|
|
||||||
### Language
|
### Language
|
||||||
|
|
|
@ -514,7 +514,6 @@ gen_snapshot_action("generate_snapshot_bin") {
|
||||||
isolate_snapshot_instructions,
|
isolate_snapshot_instructions,
|
||||||
]
|
]
|
||||||
args = [
|
args = [
|
||||||
"--sound-null-safety",
|
|
||||||
"--deterministic",
|
"--deterministic",
|
||||||
"--snapshot_kind=core",
|
"--snapshot_kind=core",
|
||||||
"--vm_snapshot_data=" + rebase_path(vm_snapshot_data, root_build_dir),
|
"--vm_snapshot_data=" + rebase_path(vm_snapshot_data, root_build_dir),
|
||||||
|
|
|
@ -216,10 +216,6 @@ int RunAnalyzer(int argc, char** argv) {
|
||||||
|
|
||||||
Dart_IsolateFlags isolate_flags;
|
Dart_IsolateFlags isolate_flags;
|
||||||
Dart_IsolateFlagsInitialize(&isolate_flags);
|
Dart_IsolateFlagsInitialize(&isolate_flags);
|
||||||
// Null safety can be determined from the snapshot itself
|
|
||||||
isolate_flags.null_safety =
|
|
||||||
Dart_DetectNullSafety(nullptr, nullptr, nullptr, vm_snapshot_data,
|
|
||||||
vm_snapshot_instructions, nullptr, -1);
|
|
||||||
|
|
||||||
Dart_CreateIsolateGroup(nullptr, nullptr, vm_isolate_data,
|
Dart_CreateIsolateGroup(nullptr, nullptr, vm_isolate_data,
|
||||||
vm_isolate_instructions, &isolate_flags,
|
vm_isolate_instructions, &isolate_flags,
|
||||||
|
|
|
@ -42,7 +42,6 @@ DartDevIsolate::DartDev_Result DartDevIsolate::DartDevRunner::result_ =
|
||||||
DartDevIsolate::DartDev_Result_Unknown;
|
DartDevIsolate::DartDev_Result_Unknown;
|
||||||
char** DartDevIsolate::DartDevRunner::script_ = nullptr;
|
char** DartDevIsolate::DartDevRunner::script_ = nullptr;
|
||||||
char** DartDevIsolate::DartDevRunner::package_config_override_ = nullptr;
|
char** DartDevIsolate::DartDevRunner::package_config_override_ = nullptr;
|
||||||
bool* DartDevIsolate::DartDevRunner::force_no_sound_null_safety_ = nullptr;
|
|
||||||
std::unique_ptr<char*[], void (*)(char*[])>
|
std::unique_ptr<char*[], void (*)(char*[])>
|
||||||
DartDevIsolate::DartDevRunner::argv_ =
|
DartDevIsolate::DartDevRunner::argv_ =
|
||||||
std::unique_ptr<char*[], void (*)(char**)>(nullptr, [](char**) {});
|
std::unique_ptr<char*[], void (*)(char**)>(nullptr, [](char**) {});
|
||||||
|
@ -109,13 +108,11 @@ void DartDevIsolate::DartDevRunner::Run(
|
||||||
Dart_IsolateGroupCreateCallback create_isolate,
|
Dart_IsolateGroupCreateCallback create_isolate,
|
||||||
char** packages_file,
|
char** packages_file,
|
||||||
char** script,
|
char** script,
|
||||||
bool* force_no_sound_null_safety,
|
|
||||||
CommandLineOptions* dart_options) {
|
CommandLineOptions* dart_options) {
|
||||||
create_isolate_ = create_isolate;
|
create_isolate_ = create_isolate;
|
||||||
dart_options_ = dart_options;
|
dart_options_ = dart_options;
|
||||||
package_config_override_ = packages_file;
|
package_config_override_ = packages_file;
|
||||||
script_ = script;
|
script_ = script;
|
||||||
force_no_sound_null_safety_ = force_no_sound_null_safety;
|
|
||||||
|
|
||||||
// We've encountered an error during preliminary argument parsing so we'll
|
// We've encountered an error during preliminary argument parsing so we'll
|
||||||
// output the standard help message and exit with an error code.
|
// output the standard help message and exit with an error code.
|
||||||
|
@ -176,8 +173,6 @@ void DartDevIsolate::DartDevRunner::DartDevResultCallback(
|
||||||
*package_config_override_ = Utils::StrDup(item2->value.as_string);
|
*package_config_override_ = Utils::StrDup(item2->value.as_string);
|
||||||
}
|
}
|
||||||
|
|
||||||
*force_no_sound_null_safety_ = item3->value.as_bool;
|
|
||||||
|
|
||||||
ASSERT(GetArrayItem(message, 4)->type == Dart_CObject_kArray);
|
ASSERT(GetArrayItem(message, 4)->type == Dart_CObject_kArray);
|
||||||
Dart_CObject* args = GetArrayItem(message, 4);
|
Dart_CObject* args = GetArrayItem(message, 4);
|
||||||
argc_ = args->value.as_array.length;
|
argc_ = args->value.as_array.length;
|
||||||
|
@ -230,7 +225,6 @@ void DartDevIsolate::DartDevRunner::RunCallback(uword args) {
|
||||||
Dart_IsolateFlags flags;
|
Dart_IsolateFlags flags;
|
||||||
Dart_IsolateFlagsInitialize(&flags);
|
Dart_IsolateFlagsInitialize(&flags);
|
||||||
flags.enable_asserts = false;
|
flags.enable_asserts = false;
|
||||||
flags.null_safety = true;
|
|
||||||
flags.use_field_guards = true;
|
flags.use_field_guards = true;
|
||||||
flags.use_osr = true;
|
flags.use_osr = true;
|
||||||
flags.is_system_isolate = true;
|
flags.is_system_isolate = true;
|
||||||
|
@ -306,10 +300,8 @@ DartDevIsolate::DartDev_Result DartDevIsolate::RunDartDev(
|
||||||
Dart_IsolateGroupCreateCallback create_isolate,
|
Dart_IsolateGroupCreateCallback create_isolate,
|
||||||
char** packages_file,
|
char** packages_file,
|
||||||
char** script,
|
char** script,
|
||||||
bool* force_no_sound_null_safety,
|
|
||||||
CommandLineOptions* dart_options) {
|
CommandLineOptions* dart_options) {
|
||||||
runner_.Run(create_isolate, packages_file, script, force_no_sound_null_safety,
|
runner_.Run(create_isolate, packages_file, script, dart_options);
|
||||||
dart_options);
|
|
||||||
return runner_.result();
|
return runner_.result();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -58,7 +58,6 @@ class DartDevIsolate {
|
||||||
Dart_IsolateGroupCreateCallback create_isolate,
|
Dart_IsolateGroupCreateCallback create_isolate,
|
||||||
char** packages_file,
|
char** packages_file,
|
||||||
char** script,
|
char** script,
|
||||||
bool* sound_null_safety,
|
|
||||||
CommandLineOptions* dart_options);
|
CommandLineOptions* dart_options);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@ -69,7 +68,6 @@ class DartDevIsolate {
|
||||||
void Run(Dart_IsolateGroupCreateCallback create_isolate,
|
void Run(Dart_IsolateGroupCreateCallback create_isolate,
|
||||||
char** package_config_override_,
|
char** package_config_override_,
|
||||||
char** script,
|
char** script,
|
||||||
bool* force_no_sound_null_safety,
|
|
||||||
CommandLineOptions* dart_options);
|
CommandLineOptions* dart_options);
|
||||||
|
|
||||||
DartDev_Result result() const { return result_; }
|
DartDev_Result result() const { return result_; }
|
||||||
|
@ -83,7 +81,6 @@ class DartDevIsolate {
|
||||||
static DartDev_Result result_;
|
static DartDev_Result result_;
|
||||||
static char** script_;
|
static char** script_;
|
||||||
static char** package_config_override_;
|
static char** package_config_override_;
|
||||||
static bool* force_no_sound_null_safety_;
|
|
||||||
static std::unique_ptr<char*[], void (*)(char**)> argv_;
|
static std::unique_ptr<char*[], void (*)(char**)> argv_;
|
||||||
static intptr_t argc_;
|
static intptr_t argc_;
|
||||||
|
|
||||||
|
|
|
@ -112,13 +112,16 @@ static const char* const kSnapshotKindNames[] = {
|
||||||
V(save_debugging_info, debugging_info_filename) \
|
V(save_debugging_info, debugging_info_filename) \
|
||||||
V(save_obfuscation_map, obfuscation_map_filename)
|
V(save_obfuscation_map, obfuscation_map_filename)
|
||||||
|
|
||||||
|
// We define sound_null_safety as an unused option here just to make sure
|
||||||
|
// scripts that were passing in this option do not break.
|
||||||
#define BOOL_OPTIONS_LIST(V) \
|
#define BOOL_OPTIONS_LIST(V) \
|
||||||
V(compile_all, compile_all) \
|
V(compile_all, compile_all) \
|
||||||
V(help, help) \
|
V(help, help) \
|
||||||
V(obfuscate, obfuscate) \
|
V(obfuscate, obfuscate) \
|
||||||
V(strip, strip) \
|
V(strip, strip) \
|
||||||
V(verbose, verbose) \
|
V(verbose, verbose) \
|
||||||
V(version, version)
|
V(version, version) \
|
||||||
|
V(sound_null_safety, sound_null_safety)
|
||||||
|
|
||||||
#define STRING_OPTION_DEFINITION(flag, variable) \
|
#define STRING_OPTION_DEFINITION(flag, variable) \
|
||||||
static const char* variable = nullptr; \
|
static const char* variable = nullptr; \
|
||||||
|
@ -680,9 +683,6 @@ static int CreateIsolateAndSnapshot(const CommandLineOptions& inputs) {
|
||||||
|
|
||||||
Dart_IsolateFlags isolate_flags;
|
Dart_IsolateFlags isolate_flags;
|
||||||
Dart_IsolateFlagsInitialize(&isolate_flags);
|
Dart_IsolateFlagsInitialize(&isolate_flags);
|
||||||
isolate_flags.null_safety =
|
|
||||||
Dart_DetectNullSafety(nullptr, nullptr, nullptr, nullptr, nullptr,
|
|
||||||
kernel_buffer, kernel_buffer_size);
|
|
||||||
if (IsSnapshottingForPrecompilation()) {
|
if (IsSnapshottingForPrecompilation()) {
|
||||||
isolate_flags.obfuscate = obfuscate;
|
isolate_flags.obfuscate = obfuscate;
|
||||||
}
|
}
|
||||||
|
|
|
@ -511,9 +511,6 @@ static Dart_Isolate CreateAndSetupServiceIsolate(const char* script_uri,
|
||||||
const uint8_t* isolate_snapshot_data = app_isolate_snapshot_data;
|
const uint8_t* isolate_snapshot_data = app_isolate_snapshot_data;
|
||||||
const uint8_t* isolate_snapshot_instructions =
|
const uint8_t* isolate_snapshot_instructions =
|
||||||
app_isolate_snapshot_instructions;
|
app_isolate_snapshot_instructions;
|
||||||
flags->null_safety =
|
|
||||||
Dart_DetectNullSafety(nullptr, nullptr, nullptr, isolate_snapshot_data,
|
|
||||||
isolate_snapshot_instructions, nullptr, -1);
|
|
||||||
isolate = Dart_CreateIsolateGroup(
|
isolate = Dart_CreateIsolateGroup(
|
||||||
script_uri, DART_VM_SERVICE_ISOLATE_NAME, isolate_snapshot_data,
|
script_uri, DART_VM_SERVICE_ISOLATE_NAME, isolate_snapshot_data,
|
||||||
isolate_snapshot_instructions, flags, isolate_group_data,
|
isolate_snapshot_instructions, flags, isolate_group_data,
|
||||||
|
@ -678,8 +675,7 @@ static Dart_Isolate CreateIsolateGroupAndSetupHelper(
|
||||||
Dart_IsolateFlags* flags,
|
Dart_IsolateFlags* flags,
|
||||||
void* callback_data,
|
void* callback_data,
|
||||||
char** error,
|
char** error,
|
||||||
int* exit_code,
|
int* exit_code) {
|
||||||
bool force_no_sound_null_safety = false) {
|
|
||||||
int64_t start = Dart_TimelineGetMicros();
|
int64_t start = Dart_TimelineGetMicros();
|
||||||
ASSERT(script_uri != nullptr);
|
ASSERT(script_uri != nullptr);
|
||||||
uint8_t* kernel_buffer = nullptr;
|
uint8_t* kernel_buffer = nullptr;
|
||||||
|
@ -714,9 +710,6 @@ static Dart_Isolate CreateIsolateGroupAndSetupHelper(
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isolate_run_app_snapshot = true;
|
bool isolate_run_app_snapshot = true;
|
||||||
flags->null_safety =
|
|
||||||
Dart_DetectNullSafety(nullptr, nullptr, nullptr, isolate_snapshot_data,
|
|
||||||
isolate_snapshot_instructions, nullptr, -1);
|
|
||||||
#else
|
#else
|
||||||
// JIT: Main isolate starts from the app snapshot, if any. Other isolates
|
// JIT: Main isolate starts from the app snapshot, if any. Other isolates
|
||||||
// use the core libraries snapshot.
|
// use the core libraries snapshot.
|
||||||
|
@ -757,15 +750,6 @@ static Dart_Isolate CreateIsolateGroupAndSetupHelper(
|
||||||
}
|
}
|
||||||
PathSanitizer script_uri_sanitizer(script_uri);
|
PathSanitizer script_uri_sanitizer(script_uri);
|
||||||
PathSanitizer packages_config_sanitizer(packages_config);
|
PathSanitizer packages_config_sanitizer(packages_config);
|
||||||
if (force_no_sound_null_safety) {
|
|
||||||
flags->null_safety = false;
|
|
||||||
} else {
|
|
||||||
flags->null_safety = Dart_DetectNullSafety(
|
|
||||||
script_uri_sanitizer.sanitized_uri(),
|
|
||||||
packages_config_sanitizer.sanitized_uri(),
|
|
||||||
DartUtils::original_working_directory, isolate_snapshot_data,
|
|
||||||
isolate_snapshot_instructions, kernel_buffer, kernel_buffer_size);
|
|
||||||
}
|
|
||||||
#endif // !defined(DART_PRECOMPILED_RUNTIME)
|
#endif // !defined(DART_PRECOMPILED_RUNTIME)
|
||||||
|
|
||||||
auto isolate_group_data = new IsolateGroupData(
|
auto isolate_group_data = new IsolateGroupData(
|
||||||
|
@ -991,7 +975,6 @@ static void CompileAndSaveKernel(const char* script_name,
|
||||||
|
|
||||||
void RunMainIsolate(const char* script_name,
|
void RunMainIsolate(const char* script_name,
|
||||||
const char* package_config_override,
|
const char* package_config_override,
|
||||||
bool force_no_sound_null_safety,
|
|
||||||
CommandLineOptions* dart_options) {
|
CommandLineOptions* dart_options) {
|
||||||
if (script_name != nullptr) {
|
if (script_name != nullptr) {
|
||||||
const char* base_name = strrchr(script_name, '/');
|
const char* base_name = strrchr(script_name, '/');
|
||||||
|
@ -1030,8 +1013,7 @@ void RunMainIsolate(const char* script_name,
|
||||||
/* is_main_isolate */ true, script_name, "main",
|
/* is_main_isolate */ true, script_name, "main",
|
||||||
Options::packages_file() == nullptr ? package_config_override
|
Options::packages_file() == nullptr ? package_config_override
|
||||||
: Options::packages_file(),
|
: Options::packages_file(),
|
||||||
&flags, nullptr /* callback_data */, &error, &exit_code,
|
&flags, nullptr /* callback_data */, &error, &exit_code);
|
||||||
force_no_sound_null_safety);
|
|
||||||
|
|
||||||
if (isolate == nullptr) {
|
if (isolate == nullptr) {
|
||||||
Syslog::PrintErr("%s\n", error);
|
Syslog::PrintErr("%s\n", error);
|
||||||
|
@ -1411,13 +1393,12 @@ void main(int argc, char** argv) {
|
||||||
Dart_SetEmbedderInformationCallback(&EmbedderInformationCallback);
|
Dart_SetEmbedderInformationCallback(&EmbedderInformationCallback);
|
||||||
bool ran_dart_dev = false;
|
bool ran_dart_dev = false;
|
||||||
bool should_run_user_program = true;
|
bool should_run_user_program = true;
|
||||||
bool force_no_sound_null_safety = false;
|
|
||||||
#if !defined(DART_PRECOMPILED_RUNTIME)
|
#if !defined(DART_PRECOMPILED_RUNTIME)
|
||||||
if (DartDevIsolate::should_run_dart_dev() && !Options::disable_dart_dev() &&
|
if (DartDevIsolate::should_run_dart_dev() && !Options::disable_dart_dev() &&
|
||||||
Options::gen_snapshot_kind() == SnapshotKind::kNone) {
|
Options::gen_snapshot_kind() == SnapshotKind::kNone) {
|
||||||
DartDevIsolate::DartDev_Result dartdev_result = DartDevIsolate::RunDartDev(
|
DartDevIsolate::DartDev_Result dartdev_result = DartDevIsolate::RunDartDev(
|
||||||
CreateIsolateGroupAndSetup, &package_config_override, &script_name,
|
CreateIsolateGroupAndSetup, &package_config_override, &script_name,
|
||||||
&force_no_sound_null_safety, &dart_options);
|
&dart_options);
|
||||||
ASSERT(dartdev_result != DartDevIsolate::DartDev_Result_Unknown);
|
ASSERT(dartdev_result != DartDevIsolate::DartDev_Result_Unknown);
|
||||||
ran_dart_dev = true;
|
ran_dart_dev = true;
|
||||||
should_run_user_program =
|
should_run_user_program =
|
||||||
|
@ -1439,8 +1420,7 @@ void main(int argc, char** argv) {
|
||||||
CompileAndSaveKernel(script_name, package_config_override, &dart_options);
|
CompileAndSaveKernel(script_name, package_config_override, &dart_options);
|
||||||
} else {
|
} else {
|
||||||
// Run the main isolate until we aren't told to restart.
|
// Run the main isolate until we aren't told to restart.
|
||||||
RunMainIsolate(script_name, package_config_override,
|
RunMainIsolate(script_name, package_config_override, &dart_options);
|
||||||
force_no_sound_null_safety, &dart_options);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,6 +30,8 @@ namespace bin {
|
||||||
|
|
||||||
// As STRING_OPTIONS_LIST but for boolean valued options. The default value is
|
// As STRING_OPTIONS_LIST but for boolean valued options. The default value is
|
||||||
// always false, and the presence of the flag switches the value to true.
|
// always false, and the presence of the flag switches the value to true.
|
||||||
|
// we define sound_null_safety as an unused option here just to make sure
|
||||||
|
// scripts that were passing in this option do not break.
|
||||||
#define BOOL_OPTIONS_LIST(V) \
|
#define BOOL_OPTIONS_LIST(V) \
|
||||||
V(version, version_option) \
|
V(version, version_option) \
|
||||||
V(compile_all, compile_all) \
|
V(compile_all, compile_all) \
|
||||||
|
@ -53,7 +55,8 @@ namespace bin {
|
||||||
V(serve_devtools, enable_devtools) \
|
V(serve_devtools, enable_devtools) \
|
||||||
V(no_serve_observatory, disable_observatory) \
|
V(no_serve_observatory, disable_observatory) \
|
||||||
V(serve_observatory, enable_observatory) \
|
V(serve_observatory, enable_observatory) \
|
||||||
V(print_dtd, print_dtd)
|
V(print_dtd, print_dtd) \
|
||||||
|
V(sound_null_safety, sound_null_safety)
|
||||||
|
|
||||||
// Boolean flags that have a short form.
|
// Boolean flags that have a short form.
|
||||||
#define SHORT_BOOL_OPTIONS_LIST(V) \
|
#define SHORT_BOOL_OPTIONS_LIST(V) \
|
||||||
|
|
|
@ -3812,41 +3812,7 @@ DART_EXPORT void Dart_SetDartLibrarySourcesKernel(
|
||||||
const intptr_t platform_kernel_size);
|
const intptr_t platform_kernel_size);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Detect the null safety opt-in status.
|
* Always return true as the VM only supports strong null safety.
|
||||||
*
|
|
||||||
* When running from source, it is based on the opt-in status of `script_uri`.
|
|
||||||
* When running from a kernel buffer, it is based on the mode used when
|
|
||||||
* generating `kernel_buffer`.
|
|
||||||
* When running from an appJIT or AOT snapshot, it is based on the mode used
|
|
||||||
* when generating `snapshot_data`.
|
|
||||||
*
|
|
||||||
* \param script_uri Uri of the script that contains the source code
|
|
||||||
*
|
|
||||||
* \param package_config Uri of the package configuration file (either in format
|
|
||||||
* of .packages or .dart_tool/package_config.json) for the null safety
|
|
||||||
* detection to resolve package imports against. If this parameter is not
|
|
||||||
* passed the package resolution of the parent isolate should be used.
|
|
||||||
*
|
|
||||||
* \param original_working_directory current working directory when the VM
|
|
||||||
* process was launched, this is used to correctly resolve the path specified
|
|
||||||
* for package_config.
|
|
||||||
*
|
|
||||||
* \param snapshot_data Buffer containing the snapshot data of the
|
|
||||||
* isolate or NULL if no snapshot is provided. If provided, the buffers must
|
|
||||||
* remain valid until the isolate shuts down.
|
|
||||||
*
|
|
||||||
* \param snapshot_instructions Buffer containing the snapshot instructions of
|
|
||||||
* the isolate or NULL if no snapshot is provided. If provided, the buffers
|
|
||||||
* must remain valid until the isolate shuts down.
|
|
||||||
*
|
|
||||||
* \param kernel_buffer A buffer which contains a kernel/DIL program. Must
|
|
||||||
* remain valid until isolate shutdown.
|
|
||||||
*
|
|
||||||
* \param kernel_buffer_size The size of `kernel_buffer`.
|
|
||||||
*
|
|
||||||
* \return Returns true if the null safety is opted in by the input being
|
|
||||||
* run `script_uri`, `snapshot_data` or `kernel_buffer`.
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
DART_EXPORT bool Dart_DetectNullSafety(const char* script_uri,
|
DART_EXPORT bool Dart_DetectNullSafety(const char* script_uri,
|
||||||
const char* package_config,
|
const char* package_config,
|
||||||
|
|
|
@ -9854,65 +9854,12 @@ char* SnapshotHeaderReader::InitializeGlobalVMFlagsFromSnapshot(
|
||||||
#undef CHECK_FLAG
|
#undef CHECK_FLAG
|
||||||
#undef SET_FLAG
|
#undef SET_FLAG
|
||||||
|
|
||||||
#if defined(DART_PRECOMPILED_RUNTIME)
|
|
||||||
if (strncmp(cursor, "null-safety", end - cursor) == 0) {
|
|
||||||
FLAG_sound_null_safety = true;
|
|
||||||
cursor = end;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (strncmp(cursor, "no-null-safety", end - cursor) == 0) {
|
|
||||||
FLAG_sound_null_safety = false;
|
|
||||||
cursor = end;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
#endif // defined(DART_PRECOMPILED_RUNTIME)
|
|
||||||
|
|
||||||
cursor = end;
|
cursor = end;
|
||||||
}
|
}
|
||||||
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SnapshotHeaderReader::NullSafetyFromSnapshot(const Snapshot* snapshot) {
|
|
||||||
bool null_safety = false;
|
|
||||||
SnapshotHeaderReader header_reader(snapshot);
|
|
||||||
const char* features = nullptr;
|
|
||||||
intptr_t features_length = 0;
|
|
||||||
|
|
||||||
char* error = header_reader.ReadFeatures(&features, &features_length);
|
|
||||||
if (error != nullptr) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
ASSERT(features[features_length] == '\0');
|
|
||||||
const char* cursor = features;
|
|
||||||
while (*cursor != '\0') {
|
|
||||||
while (*cursor == ' ') {
|
|
||||||
cursor++;
|
|
||||||
}
|
|
||||||
|
|
||||||
const char* end = strstr(cursor, " ");
|
|
||||||
if (end == nullptr) {
|
|
||||||
end = features + features_length;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (strncmp(cursor, "null-safety", end - cursor) == 0) {
|
|
||||||
cursor = end;
|
|
||||||
null_safety = true;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (strncmp(cursor, "no-null-safety", end - cursor) == 0) {
|
|
||||||
cursor = end;
|
|
||||||
null_safety = false;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
cursor = end;
|
|
||||||
}
|
|
||||||
|
|
||||||
return null_safety;
|
|
||||||
}
|
|
||||||
|
|
||||||
ApiErrorPtr FullSnapshotReader::ReadVMSnapshot() {
|
ApiErrorPtr FullSnapshotReader::ReadVMSnapshot() {
|
||||||
SnapshotHeaderReader header_reader(kind_, buffer_, size_);
|
SnapshotHeaderReader header_reader(kind_, buffer_, size_);
|
||||||
|
|
||||||
|
|
|
@ -72,7 +72,6 @@ class LoadingUnitSerializationData : public ZoneAllocated {
|
||||||
class SnapshotHeaderReader {
|
class SnapshotHeaderReader {
|
||||||
public:
|
public:
|
||||||
static char* InitializeGlobalVMFlagsFromSnapshot(const Snapshot* snapshot);
|
static char* InitializeGlobalVMFlagsFromSnapshot(const Snapshot* snapshot);
|
||||||
static bool NullSafetyFromSnapshot(const Snapshot* snapshot);
|
|
||||||
|
|
||||||
explicit SnapshotHeaderReader(const Snapshot* snapshot)
|
explicit SnapshotHeaderReader(const Snapshot* snapshot)
|
||||||
: SnapshotHeaderReader(snapshot->kind(),
|
: SnapshotHeaderReader(snapshot->kind(),
|
||||||
|
|
|
@ -220,9 +220,6 @@ static Dart_NativeFunction NativeResolver(Dart_Handle name,
|
||||||
//
|
//
|
||||||
BENCHMARK(KernelServiceCompileAll) {
|
BENCHMARK(KernelServiceCompileAll) {
|
||||||
// kernel_service.dill is built with sound null safety.
|
// kernel_service.dill is built with sound null safety.
|
||||||
if (!FLAG_sound_null_safety) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
bin::Builtin::SetNativeResolver(bin::Builtin::kBuiltinLibrary);
|
bin::Builtin::SetNativeResolver(bin::Builtin::kBuiltinLibrary);
|
||||||
bin::Builtin::SetNativeResolver(bin::Builtin::kIOLibrary);
|
bin::Builtin::SetNativeResolver(bin::Builtin::kIOLibrary);
|
||||||
bin::Builtin::SetNativeResolver(bin::Builtin::kCLILibrary);
|
bin::Builtin::SetNativeResolver(bin::Builtin::kCLILibrary);
|
||||||
|
|
|
@ -328,12 +328,6 @@ ISOLATE_UNIT_TEST_CASE(FlowGraph_PhiUnboxingHeuristic_Double) {
|
||||||
RELEASE_ASSERT(cursor.TryMatch({
|
RELEASE_ASSERT(cursor.TryMatch({
|
||||||
kMatchAndMoveFunctionEntry,
|
kMatchAndMoveFunctionEntry,
|
||||||
}));
|
}));
|
||||||
if (!FLAG_sound_null_safety) {
|
|
||||||
RELEASE_ASSERT(cursor.TryMatch({
|
|
||||||
kMatchAndMoveBranchFalse,
|
|
||||||
kMatchAndMoveTargetEntry,
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
RELEASE_ASSERT(cursor.TryMatch({
|
RELEASE_ASSERT(cursor.TryMatch({
|
||||||
kMatchAndMoveUnbox, // outside of loop
|
kMatchAndMoveUnbox, // outside of loop
|
||||||
kMatchAndMoveCheckSmi,
|
kMatchAndMoveCheckSmi,
|
||||||
|
@ -382,12 +376,6 @@ static void TestPhiUnboxingHeuristicSimd(const char* script) {
|
||||||
RELEASE_ASSERT(cursor.TryMatch({
|
RELEASE_ASSERT(cursor.TryMatch({
|
||||||
kMatchAndMoveFunctionEntry,
|
kMatchAndMoveFunctionEntry,
|
||||||
}));
|
}));
|
||||||
if (!FLAG_sound_null_safety) {
|
|
||||||
RELEASE_ASSERT(cursor.TryMatch({
|
|
||||||
kMatchAndMoveBranchFalse,
|
|
||||||
kMatchAndMoveTargetEntry,
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
RELEASE_ASSERT(cursor.TryMatch({
|
RELEASE_ASSERT(cursor.TryMatch({
|
||||||
kMatchAndMoveUnbox, // outside of loop
|
kMatchAndMoveUnbox, // outside of loop
|
||||||
kMatchAndMoveCheckSmi,
|
kMatchAndMoveCheckSmi,
|
||||||
|
|
|
@ -71,7 +71,7 @@ class IlTestPrinter : public AllStatic {
|
||||||
AttributesSerializer(&writer).WriteDescriptors();
|
AttributesSerializer(&writer).WriteDescriptors();
|
||||||
writer.CloseObject();
|
writer.CloseObject();
|
||||||
writer.OpenObject("flags");
|
writer.OpenObject("flags");
|
||||||
writer.PrintPropertyBool("nnbd", IsolateGroup::Current()->null_safety());
|
writer.PrintPropertyBool("nnbd", true);
|
||||||
writer.CloseObject();
|
writer.CloseObject();
|
||||||
writer.CloseObject();
|
writer.CloseObject();
|
||||||
THR_Print("%s\n", writer.ToCString());
|
THR_Print("%s\n", writer.ToCString());
|
||||||
|
|
|
@ -934,8 +934,6 @@ FlowGraph* SetupFfiFlowgraph(TestPipeline* pipeline,
|
||||||
// Additionally test that register allocation is done correctly by clobbering
|
// Additionally test that register allocation is done correctly by clobbering
|
||||||
// all volatile registers in the native function being called.
|
// all volatile registers in the native function being called.
|
||||||
ISOLATE_UNIT_TEST_CASE(IRTest_FfiCallInstrLeafDoesntSpill) {
|
ISOLATE_UNIT_TEST_CASE(IRTest_FfiCallInstrLeafDoesntSpill) {
|
||||||
SetFlagScope<bool> sfs(&FLAG_sound_null_safety, true);
|
|
||||||
|
|
||||||
const char* kScript = R"(
|
const char* kScript = R"(
|
||||||
import 'dart:ffi';
|
import 'dart:ffi';
|
||||||
|
|
||||||
|
|
|
@ -111,7 +111,7 @@ static bool IsSmiValue(Value* val, intptr_t* int_val) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool IsCompilingForSoundNullSafety() {
|
static bool IsCompilingForSoundNullSafety() {
|
||||||
return dart::Thread::Current()->isolate_group()->null_safety();
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test if a call is recursive by looking in the deoptimization environment.
|
// Test if a call is recursive by looking in the deoptimization environment.
|
||||||
|
|
|
@ -1337,11 +1337,6 @@ main() {
|
||||||
kMatchAndMoveFunctionEntry,
|
kMatchAndMoveFunctionEntry,
|
||||||
kMatchAndMoveCheckStackOverflow,
|
kMatchAndMoveCheckStackOverflow,
|
||||||
}));
|
}));
|
||||||
if (!FLAG_sound_null_safety) {
|
|
||||||
RELEASE_ASSERT(cursor.TryMatch({
|
|
||||||
kMatchAndMoveCheckClass,
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
RELEASE_ASSERT(cursor.TryMatch({
|
RELEASE_ASSERT(cursor.TryMatch({
|
||||||
kMatchAndMoveUnbox,
|
kMatchAndMoveUnbox,
|
||||||
kMatchAndMoveBinaryDoubleOp,
|
kMatchAndMoveBinaryDoubleOp,
|
||||||
|
@ -1986,10 +1981,6 @@ ISOLATE_UNIT_TEST_CASE(LICM_Deopt_Regress51220) {
|
||||||
// Verifies that deoptimization at the hoisted GuardFieldClass
|
// Verifies that deoptimization at the hoisted GuardFieldClass
|
||||||
// doesn't result in the infinite re-optimization loop.
|
// doesn't result in the infinite re-optimization loop.
|
||||||
ISOLATE_UNIT_TEST_CASE(LICM_Deopt_Regress50245) {
|
ISOLATE_UNIT_TEST_CASE(LICM_Deopt_Regress50245) {
|
||||||
if (!FLAG_sound_null_safety) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const char* kScript = R"(
|
const char* kScript = R"(
|
||||||
class A {
|
class A {
|
||||||
List<int> foo;
|
List<int> foo;
|
||||||
|
|
|
@ -534,11 +534,6 @@ ISOLATE_UNIT_TEST_CASE(TypePropagator_RegressFlutter76919) {
|
||||||
// is non-nullable with sound null safety.
|
// is non-nullable with sound null safety.
|
||||||
// Regression test for https://github.com/dart-lang/sdk/issues/47119.
|
// Regression test for https://github.com/dart-lang/sdk/issues/47119.
|
||||||
ISOLATE_UNIT_TEST_CASE(TypePropagator_NonNullableLoadStaticField) {
|
ISOLATE_UNIT_TEST_CASE(TypePropagator_NonNullableLoadStaticField) {
|
||||||
if (!IsolateGroup::Current()->null_safety()) {
|
|
||||||
// This test requires sound null safety.
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const char* kScript = R"(
|
const char* kScript = R"(
|
||||||
const y = 0xDEADBEEF;
|
const y = 0xDEADBEEF;
|
||||||
final int x = int.parse('0xFEEDFEED');
|
final int x = int.parse('0xFEEDFEED');
|
||||||
|
|
|
@ -39,14 +39,12 @@ ISOLATE_UNIT_TEST_CASE(IRTest_TypedDataAOT_Inlining) {
|
||||||
auto entry = flow_graph->graph_entry()->normal_entry();
|
auto entry = flow_graph->graph_entry()->normal_entry();
|
||||||
EXPECT(entry != nullptr);
|
EXPECT(entry != nullptr);
|
||||||
|
|
||||||
CheckNullInstr* check_null = nullptr;
|
|
||||||
LoadFieldInstr* load_field = nullptr;
|
LoadFieldInstr* load_field = nullptr;
|
||||||
GenericCheckBoundInstr* bounds_check = nullptr;
|
GenericCheckBoundInstr* bounds_check = nullptr;
|
||||||
LoadFieldInstr* load_untagged = nullptr;
|
LoadFieldInstr* load_untagged = nullptr;
|
||||||
LoadIndexedInstr* load_indexed = nullptr;
|
LoadIndexedInstr* load_indexed = nullptr;
|
||||||
|
|
||||||
ILMatcher cursor(flow_graph, entry);
|
ILMatcher cursor(flow_graph, entry);
|
||||||
if (IsolateGroup::Current()->null_safety()) {
|
|
||||||
RELEASE_ASSERT(cursor.TryMatch({
|
RELEASE_ASSERT(cursor.TryMatch({
|
||||||
kMoveGlob,
|
kMoveGlob,
|
||||||
{kMatchAndMoveLoadField, &load_field},
|
{kMatchAndMoveLoadField, &load_field},
|
||||||
|
@ -60,22 +58,6 @@ ISOLATE_UNIT_TEST_CASE(IRTest_TypedDataAOT_Inlining) {
|
||||||
kMoveGlob,
|
kMoveGlob,
|
||||||
kMatchDartReturn,
|
kMatchDartReturn,
|
||||||
}));
|
}));
|
||||||
} else {
|
|
||||||
RELEASE_ASSERT(cursor.TryMatch({
|
|
||||||
kMoveGlob,
|
|
||||||
{kMatchAndMoveCheckNull, &check_null},
|
|
||||||
{kMatchAndMoveLoadField, &load_field},
|
|
||||||
kMoveGlob,
|
|
||||||
kMatchAndMoveBranchTrue,
|
|
||||||
kMoveGlob,
|
|
||||||
{kMatchAndMoveGenericCheckBound, &bounds_check},
|
|
||||||
{kMatchAndMoveLoadField, &load_untagged},
|
|
||||||
kMoveParallelMoves,
|
|
||||||
{kMatchAndMoveLoadIndexed, &load_indexed},
|
|
||||||
kMoveGlob,
|
|
||||||
kMatchDartReturn,
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
|
|
||||||
EXPECT(load_field->InputAt(0)->definition()->IsParameter());
|
EXPECT(load_field->InputAt(0)->definition()->IsParameter());
|
||||||
EXPECT(bounds_check->length()
|
EXPECT(bounds_check->length()
|
||||||
|
@ -127,7 +109,6 @@ ISOLATE_UNIT_TEST_CASE(IRTest_TypedDataAOT_FunctionalGetSet) {
|
||||||
|
|
||||||
// Ensure the IL matches what we expect.
|
// Ensure the IL matches what we expect.
|
||||||
ILMatcher cursor(flow_graph, entry);
|
ILMatcher cursor(flow_graph, entry);
|
||||||
if (IsolateGroup::Current()->null_safety()) {
|
|
||||||
EXPECT(cursor.TryMatch({
|
EXPECT(cursor.TryMatch({
|
||||||
// Before loop
|
// Before loop
|
||||||
kMoveGlob,
|
kMoveGlob,
|
||||||
|
@ -170,51 +151,6 @@ ISOLATE_UNIT_TEST_CASE(IRTest_TypedDataAOT_FunctionalGetSet) {
|
||||||
kMoveGlob,
|
kMoveGlob,
|
||||||
kMatchDartReturn,
|
kMatchDartReturn,
|
||||||
}));
|
}));
|
||||||
} else {
|
|
||||||
EXPECT(cursor.TryMatch({
|
|
||||||
// Before loop
|
|
||||||
kMoveGlob,
|
|
||||||
kMatchAndMoveCheckNull,
|
|
||||||
kMatchAndMoveLoadField,
|
|
||||||
kMoveGlob,
|
|
||||||
kMatchAndMoveBranchTrue,
|
|
||||||
|
|
||||||
// Loop
|
|
||||||
kMoveGlob,
|
|
||||||
// Load 1
|
|
||||||
kMatchAndMoveGenericCheckBound,
|
|
||||||
kMoveGlob,
|
|
||||||
kMatchAndMoveLoadField,
|
|
||||||
kMoveParallelMoves,
|
|
||||||
kMatchAndMoveLoadIndexed,
|
|
||||||
kMoveGlob,
|
|
||||||
// Load 2
|
|
||||||
kMatchAndMoveGenericCheckBound,
|
|
||||||
kMoveGlob,
|
|
||||||
kMatchAndMoveLoadField,
|
|
||||||
kMoveParallelMoves,
|
|
||||||
kMatchAndMoveLoadIndexed,
|
|
||||||
kMoveGlob,
|
|
||||||
// Store 1
|
|
||||||
kMatchAndMoveCheckWritable,
|
|
||||||
kMoveParallelMoves,
|
|
||||||
kMatchAndMoveLoadField,
|
|
||||||
kMoveParallelMoves,
|
|
||||||
kMatchAndMoveStoreIndexed,
|
|
||||||
kMoveGlob,
|
|
||||||
// Store 2
|
|
||||||
kMoveParallelMoves,
|
|
||||||
kMatchAndMoveLoadField,
|
|
||||||
kMoveParallelMoves,
|
|
||||||
kMatchAndMoveStoreIndexed,
|
|
||||||
kMoveGlob,
|
|
||||||
|
|
||||||
// Exit the loop.
|
|
||||||
kMatchAndMoveBranchFalse,
|
|
||||||
kMoveGlob,
|
|
||||||
kMatchDartReturn,
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
check_il("Uint8List");
|
check_il("Uint8List");
|
||||||
|
@ -270,7 +206,6 @@ ISOLATE_UNIT_TEST_CASE(IRTest_TypedDataAOT_FunctionalIndexError) {
|
||||||
|
|
||||||
// Ensure the IL matches what we expect.
|
// Ensure the IL matches what we expect.
|
||||||
ILMatcher cursor(flow_graph, entry, /*trace=*/true);
|
ILMatcher cursor(flow_graph, entry, /*trace=*/true);
|
||||||
if (IsolateGroup::Current()->null_safety()) {
|
|
||||||
EXPECT(cursor.TryMatch({
|
EXPECT(cursor.TryMatch({
|
||||||
// LoadField length
|
// LoadField length
|
||||||
kMoveGlob,
|
kMoveGlob,
|
||||||
|
@ -292,41 +227,6 @@ ISOLATE_UNIT_TEST_CASE(IRTest_TypedDataAOT_FunctionalIndexError) {
|
||||||
kMoveGlob,
|
kMoveGlob,
|
||||||
kMatchDartReturn,
|
kMatchDartReturn,
|
||||||
}));
|
}));
|
||||||
} else {
|
|
||||||
EXPECT(cursor.TryMatch({
|
|
||||||
// Receiver null check
|
|
||||||
kMoveGlob,
|
|
||||||
kMatchAndMoveCheckNull,
|
|
||||||
|
|
||||||
// Index null check
|
|
||||||
kMoveGlob,
|
|
||||||
kMatchAndMoveCheckNull,
|
|
||||||
|
|
||||||
// Value null check
|
|
||||||
kMoveGlob,
|
|
||||||
kMatchAndMoveCheckNull,
|
|
||||||
|
|
||||||
// LoadField length
|
|
||||||
kMoveGlob,
|
|
||||||
kMatchAndMoveLoadField,
|
|
||||||
|
|
||||||
// Bounds check
|
|
||||||
kMoveGlob,
|
|
||||||
kMatchAndMoveGenericCheckBound,
|
|
||||||
|
|
||||||
// Store value.
|
|
||||||
kMoveGlob,
|
|
||||||
kMatchAndMoveLoadField,
|
|
||||||
kMoveParallelMoves,
|
|
||||||
kMatchAndMoveOptionalUnbox,
|
|
||||||
kMoveParallelMoves,
|
|
||||||
kMatchAndMoveStoreIndexed,
|
|
||||||
|
|
||||||
// Return
|
|
||||||
kMoveGlob,
|
|
||||||
kMatchDartReturn,
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Compile the graph and attach the code.
|
// Compile the graph and attach the code.
|
||||||
pipeline.CompileGraphAndAttachFunction();
|
pipeline.CompileGraphAndAttachFunction();
|
||||||
|
@ -377,8 +277,7 @@ ISOLATE_UNIT_TEST_CASE(IRTest_TypedDataAOT_FunctionalIndexError) {
|
||||||
const auto& float_value = Double::Handle(Double::New(4.2));
|
const auto& float_value = Double::Handle(Double::New(4.2));
|
||||||
// With null safety nulls cannot be passed as non-nullable arguments, so
|
// With null safety nulls cannot be passed as non-nullable arguments, so
|
||||||
// skip all error stages and only run the last stage.
|
// skip all error stages and only run the last stage.
|
||||||
const intptr_t first_stage =
|
const intptr_t first_stage = kLastStage;
|
||||||
IsolateGroup::Current()->null_safety() ? kLastStage : 0;
|
|
||||||
for (intptr_t stage = first_stage; stage <= kLastStage; ++stage) {
|
for (intptr_t stage = first_stage; stage <= kLastStage; ++stage) {
|
||||||
run_test("Uint8List", "int", int8_list, int_value, stage);
|
run_test("Uint8List", "int", int8_list, int_value, stage);
|
||||||
run_test("Int8List", "int", uint8_list, int_value, stage);
|
run_test("Int8List", "int", uint8_list, int_value, stage);
|
||||||
|
|
|
@ -1084,22 +1084,6 @@ char* Dart::FeaturesString(IsolateGroup* isolate_group,
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Snapshot::IsAgnosticToNullSafety(kind)) {
|
|
||||||
if (isolate_group != nullptr) {
|
|
||||||
if (isolate_group->null_safety()) {
|
|
||||||
buffer.AddString(" null-safety");
|
|
||||||
} else {
|
|
||||||
buffer.AddString(" no-null-safety");
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (FLAG_sound_null_safety) {
|
|
||||||
buffer.AddString(" null-safety");
|
|
||||||
} else {
|
|
||||||
buffer.AddString(" no-null-safety");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#undef ADD_ISOLATE_FLAG
|
#undef ADD_ISOLATE_FLAG
|
||||||
#undef ADD_D
|
#undef ADD_D
|
||||||
#undef ADD_C
|
#undef ADD_C
|
||||||
|
|
|
@ -3069,8 +3069,7 @@ static TypeArgumentsPtr TypeArgumentsForElementType(
|
||||||
DART_EXPORT Dart_Handle Dart_NewListOf(Dart_CoreType_Id element_type_id,
|
DART_EXPORT Dart_Handle Dart_NewListOf(Dart_CoreType_Id element_type_id,
|
||||||
intptr_t length) {
|
intptr_t length) {
|
||||||
DARTSCOPE(Thread::Current());
|
DARTSCOPE(Thread::Current());
|
||||||
if (T->isolate_group()->null_safety() &&
|
if (element_type_id != Dart_CoreType_Dynamic) {
|
||||||
element_type_id != Dart_CoreType_Dynamic) {
|
|
||||||
return Api::NewError(
|
return Api::NewError(
|
||||||
"Cannot use legacy types with --sound-null-safety enabled. "
|
"Cannot use legacy types with --sound-null-safety enabled. "
|
||||||
"Use Dart_NewListOfType or Dart_NewListOfTypeFilled instead.");
|
"Use Dart_NewListOfType or Dart_NewListOfTypeFilled instead.");
|
||||||
|
@ -5602,14 +5601,10 @@ DART_EXPORT Dart_Handle Dart_GetType(Dart_Handle library,
|
||||||
Dart_Handle class_name,
|
Dart_Handle class_name,
|
||||||
intptr_t number_of_type_arguments,
|
intptr_t number_of_type_arguments,
|
||||||
Dart_Handle* type_arguments) {
|
Dart_Handle* type_arguments) {
|
||||||
if (IsolateGroup::Current()->null_safety()) {
|
|
||||||
return Api::NewError(
|
return Api::NewError(
|
||||||
"Cannot use legacy types with --sound-null-safety enabled. "
|
"Cannot use legacy types with --sound-null-safety enabled. "
|
||||||
"Use Dart_GetNullableType or Dart_GetNonNullableType instead.");
|
"Use Dart_GetNullableType or Dart_GetNonNullableType instead.");
|
||||||
}
|
}
|
||||||
return GetTypeCommon(library, class_name, number_of_type_arguments,
|
|
||||||
type_arguments, Nullability::kLegacy);
|
|
||||||
}
|
|
||||||
|
|
||||||
DART_EXPORT Dart_Handle Dart_GetNullableType(Dart_Handle library,
|
DART_EXPORT Dart_Handle Dart_GetNullableType(Dart_Handle library,
|
||||||
Dart_Handle class_name,
|
Dart_Handle class_name,
|
||||||
|
@ -6113,30 +6108,7 @@ DART_EXPORT bool Dart_DetectNullSafety(const char* script_uri,
|
||||||
const uint8_t* snapshot_instructions,
|
const uint8_t* snapshot_instructions,
|
||||||
const uint8_t* kernel_buffer,
|
const uint8_t* kernel_buffer,
|
||||||
intptr_t kernel_buffer_size) {
|
intptr_t kernel_buffer_size) {
|
||||||
// If we have a snapshot then try to figure out the mode by
|
return true;
|
||||||
// sniffing the feature string in the snapshot.
|
|
||||||
if (snapshot_data != nullptr) {
|
|
||||||
// Read the snapshot and check for null safety option.
|
|
||||||
const Snapshot* snapshot = Snapshot::SetupFromBuffer(snapshot_data);
|
|
||||||
if (!Snapshot::IsAgnosticToNullSafety(snapshot->kind())) {
|
|
||||||
return SnapshotHeaderReader::NullSafetyFromSnapshot(snapshot);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#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.
|
|
||||||
if (kernel_buffer != nullptr) {
|
|
||||||
const auto null_safety =
|
|
||||||
kernel::Program::DetectNullSafety(kernel_buffer, kernel_buffer_size);
|
|
||||||
if (null_safety != NNBDCompiledMode::kInvalid) {
|
|
||||||
return null_safety == NNBDCompiledMode::kStrong;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return FLAG_sound_null_safety;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// --- Service support ---
|
// --- Service support ---
|
||||||
|
|
|
@ -250,8 +250,6 @@ constexpr bool FLAG_support_il_printer = false;
|
||||||
P(verify_entry_points, bool, false, \
|
P(verify_entry_points, bool, false, \
|
||||||
"Throw API error on invalid member access through native API. See " \
|
"Throw API error on invalid member access through native API. See " \
|
||||||
"entry_point_pragma.md") \
|
"entry_point_pragma.md") \
|
||||||
P(sound_null_safety, bool, true, \
|
|
||||||
"Respect the nullability of types at runtime.") \
|
|
||||||
C(branch_coverage, false, false, bool, false, "Enable branch coverage")
|
C(branch_coverage, false, false, bool, false, "Enable branch coverage")
|
||||||
|
|
||||||
#endif // RUNTIME_VM_FLAG_LIST_H_
|
#endif // RUNTIME_VM_FLAG_LIST_H_
|
||||||
|
|
|
@ -1544,6 +1544,7 @@ void IsolateGroup::FlagsInitialize(Dart_IsolateFlags* api_flags) {
|
||||||
#undef INIT_FROM_FLAG
|
#undef INIT_FROM_FLAG
|
||||||
api_flags->is_service_isolate = false;
|
api_flags->is_service_isolate = false;
|
||||||
api_flags->is_kernel_isolate = false;
|
api_flags->is_kernel_isolate = false;
|
||||||
|
api_flags->null_safety = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void IsolateGroup::FlagsCopyTo(Dart_IsolateFlags* api_flags) {
|
void IsolateGroup::FlagsCopyTo(Dart_IsolateFlags* api_flags) {
|
||||||
|
@ -1554,6 +1555,7 @@ void IsolateGroup::FlagsCopyTo(Dart_IsolateFlags* api_flags) {
|
||||||
#undef INIT_FROM_FIELD
|
#undef INIT_FROM_FIELD
|
||||||
api_flags->is_service_isolate = false;
|
api_flags->is_service_isolate = false;
|
||||||
api_flags->is_kernel_isolate = false;
|
api_flags->is_kernel_isolate = false;
|
||||||
|
api_flags->null_safety = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void IsolateGroup::FlagsCopyFrom(const Dart_IsolateFlags& api_flags) {
|
void IsolateGroup::FlagsCopyFrom(const Dart_IsolateFlags& api_flags) {
|
||||||
|
@ -1578,7 +1580,7 @@ void IsolateGroup::FlagsCopyFrom(const Dart_IsolateFlags& api_flags) {
|
||||||
BOOL_ISOLATE_GROUP_FLAG_LIST(SET_FROM_FLAG)
|
BOOL_ISOLATE_GROUP_FLAG_LIST(SET_FROM_FLAG)
|
||||||
// Needs to be called manually, otherwise we don't set the null_safety_set
|
// Needs to be called manually, otherwise we don't set the null_safety_set
|
||||||
// bit.
|
// bit.
|
||||||
set_null_safety(api_flags.null_safety);
|
set_null_safety(true);
|
||||||
#undef FLAG_FOR_NONPRODUCT
|
#undef FLAG_FOR_NONPRODUCT
|
||||||
#undef FLAG_FOR_PRECOMPILER
|
#undef FLAG_FOR_PRECOMPILER
|
||||||
#undef FLAG_FOR_PRODUCT
|
#undef FLAG_FOR_PRODUCT
|
||||||
|
@ -1595,6 +1597,7 @@ void Isolate::FlagsInitialize(Dart_IsolateFlags* api_flags) {
|
||||||
#undef INIT_FROM_FLAG
|
#undef INIT_FROM_FLAG
|
||||||
api_flags->is_service_isolate = false;
|
api_flags->is_service_isolate = false;
|
||||||
api_flags->is_kernel_isolate = false;
|
api_flags->is_kernel_isolate = false;
|
||||||
|
api_flags->null_safety = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Isolate::FlagsCopyTo(Dart_IsolateFlags* api_flags) const {
|
void Isolate::FlagsCopyTo(Dart_IsolateFlags* api_flags) const {
|
||||||
|
@ -1607,6 +1610,7 @@ void Isolate::FlagsCopyTo(Dart_IsolateFlags* api_flags) const {
|
||||||
#undef INIT_FROM_FIELD
|
#undef INIT_FROM_FIELD
|
||||||
api_flags->is_service_isolate = false;
|
api_flags->is_service_isolate = false;
|
||||||
api_flags->is_kernel_isolate = false;
|
api_flags->is_kernel_isolate = false;
|
||||||
|
api_flags->null_safety = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Isolate::FlagsCopyFrom(const Dart_IsolateFlags& api_flags) {
|
void Isolate::FlagsCopyFrom(const Dart_IsolateFlags& api_flags) {
|
||||||
|
|
|
@ -61,9 +61,6 @@ enum LogicalOperator { kAnd, kOr };
|
||||||
|
|
||||||
class Program {
|
class Program {
|
||||||
public:
|
public:
|
||||||
static NNBDCompiledMode DetectNullSafety(const uint8_t* buffer,
|
|
||||||
intptr_t buffer_length);
|
|
||||||
|
|
||||||
// Read a kernel Program from the given Reader. Note the returned Program
|
// Read a kernel Program from the given Reader. Note the returned Program
|
||||||
// can potentially contain several "sub programs", though the library count
|
// can potentially contain several "sub programs", though the library count
|
||||||
// etc will reference the last "sub program" only.
|
// etc will reference the last "sub program" only.
|
||||||
|
|
|
@ -85,14 +85,6 @@ bool IsValidSdkHash(const uint8_t* sdk_hash) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
NNBDCompiledMode Program::DetectNullSafety(const uint8_t* buffer,
|
|
||||||
intptr_t buffer_length) {
|
|
||||||
Reader reader(buffer, buffer_length);
|
|
||||||
std::unique_ptr<Program> program = Program::ReadFrom(&reader, nullptr);
|
|
||||||
if (program == nullptr) return NNBDCompiledMode::kInvalid;
|
|
||||||
return program->compilation_mode_;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::unique_ptr<Program> Program::ReadFrom(Reader* reader, const char** error) {
|
std::unique_ptr<Program> Program::ReadFrom(Reader* reader, const char** error) {
|
||||||
if (reader->size() < 70) {
|
if (reader->size() < 70) {
|
||||||
// A kernel file (v43) currently contains at least the following:
|
// A kernel file (v43) currently contains at least the following:
|
||||||
|
|
|
@ -866,9 +866,7 @@ class KernelCompilationRequest : public ValueObject {
|
||||||
|
|
||||||
Dart_CObject sound_null_safety;
|
Dart_CObject sound_null_safety;
|
||||||
sound_null_safety.type = Dart_CObject_kBool;
|
sound_null_safety.type = Dart_CObject_kBool;
|
||||||
sound_null_safety.value.as_bool = (isolate_group != nullptr)
|
sound_null_safety.value.as_bool = true;
|
||||||
? isolate_group->null_safety()
|
|
||||||
: FLAG_sound_null_safety;
|
|
||||||
|
|
||||||
intptr_t num_experimental_flags = experimental_flags->length();
|
intptr_t num_experimental_flags = experimental_flags->length();
|
||||||
Dart_CObject** experimental_flags_array =
|
Dart_CObject** experimental_flags_array =
|
||||||
|
|
|
@ -69,10 +69,6 @@ class KernelIsolate : public AllStatic {
|
||||||
Dart_KernelCompilationVerbosityLevel verbosity =
|
Dart_KernelCompilationVerbosityLevel verbosity =
|
||||||
Dart_KernelCompilationVerbosityLevel_All);
|
Dart_KernelCompilationVerbosityLevel_All);
|
||||||
|
|
||||||
static bool DetectNullSafety(const char* script_uri,
|
|
||||||
const char* package_config,
|
|
||||||
const char* original_working_directory);
|
|
||||||
|
|
||||||
static Dart_KernelCompilationResult AcceptCompilation();
|
static Dart_KernelCompilationResult AcceptCompilation();
|
||||||
static Dart_KernelCompilationResult RejectCompilation();
|
static Dart_KernelCompilationResult RejectCompilation();
|
||||||
static Dart_KernelCompilationResult UpdateInMemorySources(
|
static Dart_KernelCompilationResult UpdateInMemorySources(
|
||||||
|
|
|
@ -819,14 +819,7 @@ LibraryPtr KernelLoader::LoadLibrary(intptr_t index) {
|
||||||
"null safety and not sound null safety.",
|
"null safety and not sound null safety.",
|
||||||
String::Handle(library.url()).ToCString());
|
String::Handle(library.url()).ToCString());
|
||||||
}
|
}
|
||||||
if (!IG->null_safety() && mode == NNBDCompiledMode::kStrong) {
|
if (mode == NNBDCompiledMode::kWeak) {
|
||||||
H.ReportError(
|
|
||||||
"Library '%s' was compiled with sound null safety (in strong mode) and "
|
|
||||||
"it "
|
|
||||||
"requires --sound-null-safety option at runtime",
|
|
||||||
String::Handle(library.url()).ToCString());
|
|
||||||
}
|
|
||||||
if (IG->null_safety() && (mode == NNBDCompiledMode::kWeak)) {
|
|
||||||
H.ReportError(
|
H.ReportError(
|
||||||
"Library '%s' was compiled without sound null safety (in weak mode) "
|
"Library '%s' was compiled without sound null safety (in weak mode) "
|
||||||
"and it "
|
"and it "
|
||||||
|
|
|
@ -115,7 +115,7 @@ Dart_Isolate TestCase::CreateIsolate(const uint8_t* data_buffer,
|
||||||
char* err;
|
char* err;
|
||||||
Dart_IsolateFlags api_flags;
|
Dart_IsolateFlags api_flags;
|
||||||
Isolate::FlagsInitialize(&api_flags);
|
Isolate::FlagsInitialize(&api_flags);
|
||||||
api_flags.null_safety = FLAG_sound_null_safety;
|
api_flags.null_safety = true;
|
||||||
Dart_Isolate isolate = nullptr;
|
Dart_Isolate isolate = nullptr;
|
||||||
if (len == 0) {
|
if (len == 0) {
|
||||||
isolate = Dart_CreateIsolateGroup(
|
isolate = Dart_CreateIsolateGroup(
|
||||||
|
|
|
@ -28,7 +28,7 @@ application_snapshot("generate_dartdev_snapshot") {
|
||||||
"../dtd:dtd",
|
"../dtd:dtd",
|
||||||
]
|
]
|
||||||
|
|
||||||
vm_args = [ "--sound-null-safety" ]
|
vm_args = []
|
||||||
output = "$root_gen_dir/dartdev.dart.snapshot"
|
output = "$root_gen_dir/dartdev.dart.snapshot"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,6 @@ application_snapshot("generate_dtd_snapshot") {
|
||||||
main_dart = "../../pkg/dtd_impl/bin/dtd.dart"
|
main_dart = "../../pkg/dtd_impl/bin/dtd.dart"
|
||||||
training_args = [ "--train" ]
|
training_args = [ "--train" ]
|
||||||
|
|
||||||
vm_args = [ "--sound-null-safety" ]
|
vm_args = []
|
||||||
output = "$root_gen_dir/dart_tooling_daemon.dart.snapshot"
|
output = "$root_gen_dir/dart_tooling_daemon.dart.snapshot"
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue