1
0
mirror of https://github.com/dart-lang/sdk synced 2024-07-03 00:08:46 +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:
asiva 2024-04-05 19:38:12 +00:00 committed by Commit Queue
parent 6e11b5dd40
commit 8e2acda7d6
31 changed files with 107 additions and 422 deletions

View File

@ -1,5 +1,9 @@
## 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
### Language

View File

@ -514,7 +514,6 @@ gen_snapshot_action("generate_snapshot_bin") {
isolate_snapshot_instructions,
]
args = [
"--sound-null-safety",
"--deterministic",
"--snapshot_kind=core",
"--vm_snapshot_data=" + rebase_path(vm_snapshot_data, root_build_dir),

View File

@ -216,10 +216,6 @@ int RunAnalyzer(int argc, char** argv) {
Dart_IsolateFlags 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,
vm_isolate_instructions, &isolate_flags,

View File

@ -42,7 +42,6 @@ DartDevIsolate::DartDev_Result DartDevIsolate::DartDevRunner::result_ =
DartDevIsolate::DartDev_Result_Unknown;
char** DartDevIsolate::DartDevRunner::script_ = nullptr;
char** DartDevIsolate::DartDevRunner::package_config_override_ = nullptr;
bool* DartDevIsolate::DartDevRunner::force_no_sound_null_safety_ = nullptr;
std::unique_ptr<char*[], void (*)(char*[])>
DartDevIsolate::DartDevRunner::argv_ =
std::unique_ptr<char*[], void (*)(char**)>(nullptr, [](char**) {});
@ -109,13 +108,11 @@ void DartDevIsolate::DartDevRunner::Run(
Dart_IsolateGroupCreateCallback create_isolate,
char** packages_file,
char** script,
bool* force_no_sound_null_safety,
CommandLineOptions* dart_options) {
create_isolate_ = create_isolate;
dart_options_ = dart_options;
package_config_override_ = packages_file;
script_ = script;
force_no_sound_null_safety_ = force_no_sound_null_safety;
// We've encountered an error during preliminary argument parsing so we'll
// 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);
}
*force_no_sound_null_safety_ = item3->value.as_bool;
ASSERT(GetArrayItem(message, 4)->type == Dart_CObject_kArray);
Dart_CObject* args = GetArrayItem(message, 4);
argc_ = args->value.as_array.length;
@ -230,7 +225,6 @@ void DartDevIsolate::DartDevRunner::RunCallback(uword args) {
Dart_IsolateFlags flags;
Dart_IsolateFlagsInitialize(&flags);
flags.enable_asserts = false;
flags.null_safety = true;
flags.use_field_guards = true;
flags.use_osr = true;
flags.is_system_isolate = true;
@ -306,10 +300,8 @@ DartDevIsolate::DartDev_Result DartDevIsolate::RunDartDev(
Dart_IsolateGroupCreateCallback create_isolate,
char** packages_file,
char** script,
bool* force_no_sound_null_safety,
CommandLineOptions* dart_options) {
runner_.Run(create_isolate, packages_file, script, force_no_sound_null_safety,
dart_options);
runner_.Run(create_isolate, packages_file, script, dart_options);
return runner_.result();
}

View File

@ -58,7 +58,6 @@ class DartDevIsolate {
Dart_IsolateGroupCreateCallback create_isolate,
char** packages_file,
char** script,
bool* sound_null_safety,
CommandLineOptions* dart_options);
protected:
@ -69,7 +68,6 @@ class DartDevIsolate {
void Run(Dart_IsolateGroupCreateCallback create_isolate,
char** package_config_override_,
char** script,
bool* force_no_sound_null_safety,
CommandLineOptions* dart_options);
DartDev_Result result() const { return result_; }
@ -83,7 +81,6 @@ class DartDevIsolate {
static DartDev_Result result_;
static char** script_;
static char** package_config_override_;
static bool* force_no_sound_null_safety_;
static std::unique_ptr<char*[], void (*)(char**)> argv_;
static intptr_t argc_;

View File

@ -112,13 +112,16 @@ static const char* const kSnapshotKindNames[] = {
V(save_debugging_info, debugging_info_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) \
V(compile_all, compile_all) \
V(help, help) \
V(obfuscate, obfuscate) \
V(strip, strip) \
V(verbose, verbose) \
V(version, version)
V(version, version) \
V(sound_null_safety, sound_null_safety)
#define STRING_OPTION_DEFINITION(flag, variable) \
static const char* variable = nullptr; \
@ -680,9 +683,6 @@ static int CreateIsolateAndSnapshot(const CommandLineOptions& inputs) {
Dart_IsolateFlags isolate_flags;
Dart_IsolateFlagsInitialize(&isolate_flags);
isolate_flags.null_safety =
Dart_DetectNullSafety(nullptr, nullptr, nullptr, nullptr, nullptr,
kernel_buffer, kernel_buffer_size);
if (IsSnapshottingForPrecompilation()) {
isolate_flags.obfuscate = obfuscate;
}

View File

@ -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_instructions =
app_isolate_snapshot_instructions;
flags->null_safety =
Dart_DetectNullSafety(nullptr, nullptr, nullptr, isolate_snapshot_data,
isolate_snapshot_instructions, nullptr, -1);
isolate = Dart_CreateIsolateGroup(
script_uri, DART_VM_SERVICE_ISOLATE_NAME, isolate_snapshot_data,
isolate_snapshot_instructions, flags, isolate_group_data,
@ -678,8 +675,7 @@ static Dart_Isolate CreateIsolateGroupAndSetupHelper(
Dart_IsolateFlags* flags,
void* callback_data,
char** error,
int* exit_code,
bool force_no_sound_null_safety = false) {
int* exit_code) {
int64_t start = Dart_TimelineGetMicros();
ASSERT(script_uri != nullptr);
uint8_t* kernel_buffer = nullptr;
@ -714,9 +710,6 @@ static Dart_Isolate CreateIsolateGroupAndSetupHelper(
}
bool isolate_run_app_snapshot = true;
flags->null_safety =
Dart_DetectNullSafety(nullptr, nullptr, nullptr, isolate_snapshot_data,
isolate_snapshot_instructions, nullptr, -1);
#else
// JIT: Main isolate starts from the app snapshot, if any. Other isolates
// use the core libraries snapshot.
@ -757,15 +750,6 @@ static Dart_Isolate CreateIsolateGroupAndSetupHelper(
}
PathSanitizer script_uri_sanitizer(script_uri);
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)
auto isolate_group_data = new IsolateGroupData(
@ -991,7 +975,6 @@ static void CompileAndSaveKernel(const char* script_name,
void RunMainIsolate(const char* script_name,
const char* package_config_override,
bool force_no_sound_null_safety,
CommandLineOptions* dart_options) {
if (script_name != nullptr) {
const char* base_name = strrchr(script_name, '/');
@ -1030,8 +1013,7 @@ void RunMainIsolate(const char* script_name,
/* is_main_isolate */ true, script_name, "main",
Options::packages_file() == nullptr ? package_config_override
: Options::packages_file(),
&flags, nullptr /* callback_data */, &error, &exit_code,
force_no_sound_null_safety);
&flags, nullptr /* callback_data */, &error, &exit_code);
if (isolate == nullptr) {
Syslog::PrintErr("%s\n", error);
@ -1411,13 +1393,12 @@ void main(int argc, char** argv) {
Dart_SetEmbedderInformationCallback(&EmbedderInformationCallback);
bool ran_dart_dev = false;
bool should_run_user_program = true;
bool force_no_sound_null_safety = false;
#if !defined(DART_PRECOMPILED_RUNTIME)
if (DartDevIsolate::should_run_dart_dev() && !Options::disable_dart_dev() &&
Options::gen_snapshot_kind() == SnapshotKind::kNone) {
DartDevIsolate::DartDev_Result dartdev_result = DartDevIsolate::RunDartDev(
CreateIsolateGroupAndSetup, &package_config_override, &script_name,
&force_no_sound_null_safety, &dart_options);
&dart_options);
ASSERT(dartdev_result != DartDevIsolate::DartDev_Result_Unknown);
ran_dart_dev = true;
should_run_user_program =
@ -1439,8 +1420,7 @@ void main(int argc, char** argv) {
CompileAndSaveKernel(script_name, package_config_override, &dart_options);
} else {
// Run the main isolate until we aren't told to restart.
RunMainIsolate(script_name, package_config_override,
force_no_sound_null_safety, &dart_options);
RunMainIsolate(script_name, package_config_override, &dart_options);
}
}

View File

@ -30,6 +30,8 @@ namespace bin {
// 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.
// 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) \
V(version, version_option) \
V(compile_all, compile_all) \
@ -53,7 +55,8 @@ namespace bin {
V(serve_devtools, enable_devtools) \
V(no_serve_observatory, disable_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.
#define SHORT_BOOL_OPTIONS_LIST(V) \

View File

@ -3812,41 +3812,7 @@ DART_EXPORT void Dart_SetDartLibrarySourcesKernel(
const intptr_t platform_kernel_size);
/**
* Detect the null safety opt-in status.
*
* 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`.
*
* Always return true as the VM only supports strong null safety.
*/
DART_EXPORT bool Dart_DetectNullSafety(const char* script_uri,
const char* package_config,

View File

@ -9854,65 +9854,12 @@ char* SnapshotHeaderReader::InitializeGlobalVMFlagsFromSnapshot(
#undef CHECK_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;
}
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() {
SnapshotHeaderReader header_reader(kind_, buffer_, size_);

View File

@ -72,7 +72,6 @@ class LoadingUnitSerializationData : public ZoneAllocated {
class SnapshotHeaderReader {
public:
static char* InitializeGlobalVMFlagsFromSnapshot(const Snapshot* snapshot);
static bool NullSafetyFromSnapshot(const Snapshot* snapshot);
explicit SnapshotHeaderReader(const Snapshot* snapshot)
: SnapshotHeaderReader(snapshot->kind(),

View File

@ -220,9 +220,6 @@ static Dart_NativeFunction NativeResolver(Dart_Handle name,
//
BENCHMARK(KernelServiceCompileAll) {
// 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::kIOLibrary);
bin::Builtin::SetNativeResolver(bin::Builtin::kCLILibrary);

View File

@ -328,12 +328,6 @@ ISOLATE_UNIT_TEST_CASE(FlowGraph_PhiUnboxingHeuristic_Double) {
RELEASE_ASSERT(cursor.TryMatch({
kMatchAndMoveFunctionEntry,
}));
if (!FLAG_sound_null_safety) {
RELEASE_ASSERT(cursor.TryMatch({
kMatchAndMoveBranchFalse,
kMatchAndMoveTargetEntry,
}));
}
RELEASE_ASSERT(cursor.TryMatch({
kMatchAndMoveUnbox, // outside of loop
kMatchAndMoveCheckSmi,
@ -382,12 +376,6 @@ static void TestPhiUnboxingHeuristicSimd(const char* script) {
RELEASE_ASSERT(cursor.TryMatch({
kMatchAndMoveFunctionEntry,
}));
if (!FLAG_sound_null_safety) {
RELEASE_ASSERT(cursor.TryMatch({
kMatchAndMoveBranchFalse,
kMatchAndMoveTargetEntry,
}));
}
RELEASE_ASSERT(cursor.TryMatch({
kMatchAndMoveUnbox, // outside of loop
kMatchAndMoveCheckSmi,

View File

@ -71,7 +71,7 @@ class IlTestPrinter : public AllStatic {
AttributesSerializer(&writer).WriteDescriptors();
writer.CloseObject();
writer.OpenObject("flags");
writer.PrintPropertyBool("nnbd", IsolateGroup::Current()->null_safety());
writer.PrintPropertyBool("nnbd", true);
writer.CloseObject();
writer.CloseObject();
THR_Print("%s\n", writer.ToCString());

View File

@ -934,8 +934,6 @@ FlowGraph* SetupFfiFlowgraph(TestPipeline* pipeline,
// Additionally test that register allocation is done correctly by clobbering
// all volatile registers in the native function being called.
ISOLATE_UNIT_TEST_CASE(IRTest_FfiCallInstrLeafDoesntSpill) {
SetFlagScope<bool> sfs(&FLAG_sound_null_safety, true);
const char* kScript = R"(
import 'dart:ffi';

View File

@ -111,7 +111,7 @@ static bool IsSmiValue(Value* val, intptr_t* int_val) {
}
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.

View File

@ -1337,11 +1337,6 @@ main() {
kMatchAndMoveFunctionEntry,
kMatchAndMoveCheckStackOverflow,
}));
if (!FLAG_sound_null_safety) {
RELEASE_ASSERT(cursor.TryMatch({
kMatchAndMoveCheckClass,
}));
}
RELEASE_ASSERT(cursor.TryMatch({
kMatchAndMoveUnbox,
kMatchAndMoveBinaryDoubleOp,
@ -1986,10 +1981,6 @@ ISOLATE_UNIT_TEST_CASE(LICM_Deopt_Regress51220) {
// Verifies that deoptimization at the hoisted GuardFieldClass
// doesn't result in the infinite re-optimization loop.
ISOLATE_UNIT_TEST_CASE(LICM_Deopt_Regress50245) {
if (!FLAG_sound_null_safety) {
return;
}
const char* kScript = R"(
class A {
List<int> foo;

View File

@ -534,11 +534,6 @@ ISOLATE_UNIT_TEST_CASE(TypePropagator_RegressFlutter76919) {
// is non-nullable with sound null safety.
// Regression test for https://github.com/dart-lang/sdk/issues/47119.
ISOLATE_UNIT_TEST_CASE(TypePropagator_NonNullableLoadStaticField) {
if (!IsolateGroup::Current()->null_safety()) {
// This test requires sound null safety.
return;
}
const char* kScript = R"(
const y = 0xDEADBEEF;
final int x = int.parse('0xFEEDFEED');

View File

@ -39,43 +39,25 @@ ISOLATE_UNIT_TEST_CASE(IRTest_TypedDataAOT_Inlining) {
auto entry = flow_graph->graph_entry()->normal_entry();
EXPECT(entry != nullptr);
CheckNullInstr* check_null = nullptr;
LoadFieldInstr* load_field = nullptr;
GenericCheckBoundInstr* bounds_check = nullptr;
LoadFieldInstr* load_untagged = nullptr;
LoadIndexedInstr* load_indexed = nullptr;
ILMatcher cursor(flow_graph, entry);
if (IsolateGroup::Current()->null_safety()) {
RELEASE_ASSERT(cursor.TryMatch({
kMoveGlob,
{kMatchAndMoveLoadField, &load_field},
kMoveGlob,
kMatchAndMoveBranchTrue,
kMoveGlob,
{kMatchAndMoveGenericCheckBound, &bounds_check},
{kMatchAndMoveLoadField, &load_untagged},
kMoveParallelMoves,
{kMatchAndMoveLoadIndexed, &load_indexed},
kMoveGlob,
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,
}));
}
RELEASE_ASSERT(cursor.TryMatch({
kMoveGlob,
{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(bounds_check->length()
@ -127,94 +109,48 @@ ISOLATE_UNIT_TEST_CASE(IRTest_TypedDataAOT_FunctionalGetSet) {
// Ensure the IL matches what we expect.
ILMatcher cursor(flow_graph, entry);
if (IsolateGroup::Current()->null_safety()) {
EXPECT(cursor.TryMatch({
// Before loop
kMoveGlob,
kMatchAndMoveLoadField,
kMoveGlob,
kMatchAndMoveBranchTrue,
EXPECT(cursor.TryMatch({
// Before loop
kMoveGlob,
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,
// 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,
}));
} 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,
}));
}
// Exit the loop.
kMatchAndMoveBranchFalse,
kMoveGlob,
kMatchDartReturn,
}));
};
check_il("Uint8List");
@ -270,63 +206,27 @@ ISOLATE_UNIT_TEST_CASE(IRTest_TypedDataAOT_FunctionalIndexError) {
// Ensure the IL matches what we expect.
ILMatcher cursor(flow_graph, entry, /*trace=*/true);
if (IsolateGroup::Current()->null_safety()) {
EXPECT(cursor.TryMatch({
// LoadField length
kMoveGlob,
kMatchAndMoveLoadField,
EXPECT(cursor.TryMatch({
// LoadField length
kMoveGlob,
kMatchAndMoveLoadField,
// Bounds check
kMoveGlob,
kMatchAndMoveGenericCheckBound,
// Bounds check
kMoveGlob,
kMatchAndMoveGenericCheckBound,
// Store value.
kMoveGlob,
kMatchAndMoveLoadField,
kMoveParallelMoves,
kMatchAndMoveOptionalUnbox,
kMoveParallelMoves,
kMatchAndMoveStoreIndexed,
// Store value.
kMoveGlob,
kMatchAndMoveLoadField,
kMoveParallelMoves,
kMatchAndMoveOptionalUnbox,
kMoveParallelMoves,
kMatchAndMoveStoreIndexed,
// Return
kMoveGlob,
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,
}));
}
// Return
kMoveGlob,
kMatchDartReturn,
}));
// Compile the graph and attach the code.
pipeline.CompileGraphAndAttachFunction();
@ -377,8 +277,7 @@ ISOLATE_UNIT_TEST_CASE(IRTest_TypedDataAOT_FunctionalIndexError) {
const auto& float_value = Double::Handle(Double::New(4.2));
// With null safety nulls cannot be passed as non-nullable arguments, so
// skip all error stages and only run the last stage.
const intptr_t first_stage =
IsolateGroup::Current()->null_safety() ? kLastStage : 0;
const intptr_t first_stage = kLastStage;
for (intptr_t stage = first_stage; stage <= kLastStage; ++stage) {
run_test("Uint8List", "int", int8_list, int_value, stage);
run_test("Int8List", "int", uint8_list, int_value, stage);

View File

@ -1084,22 +1084,6 @@ char* Dart::FeaturesString(IsolateGroup* isolate_group,
#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_D
#undef ADD_C

View File

@ -3069,8 +3069,7 @@ static TypeArgumentsPtr TypeArgumentsForElementType(
DART_EXPORT Dart_Handle Dart_NewListOf(Dart_CoreType_Id element_type_id,
intptr_t length) {
DARTSCOPE(Thread::Current());
if (T->isolate_group()->null_safety() &&
element_type_id != Dart_CoreType_Dynamic) {
if (element_type_id != Dart_CoreType_Dynamic) {
return Api::NewError(
"Cannot use legacy types with --sound-null-safety enabled. "
"Use Dart_NewListOfType or Dart_NewListOfTypeFilled instead.");
@ -5602,13 +5601,9 @@ DART_EXPORT Dart_Handle Dart_GetType(Dart_Handle library,
Dart_Handle class_name,
intptr_t number_of_type_arguments,
Dart_Handle* type_arguments) {
if (IsolateGroup::Current()->null_safety()) {
return Api::NewError(
"Cannot use legacy types with --sound-null-safety enabled. "
"Use Dart_GetNullableType or Dart_GetNonNullableType instead.");
}
return GetTypeCommon(library, class_name, number_of_type_arguments,
type_arguments, Nullability::kLegacy);
return Api::NewError(
"Cannot use legacy types with --sound-null-safety enabled. "
"Use Dart_GetNullableType or Dart_GetNonNullableType instead.");
}
DART_EXPORT Dart_Handle Dart_GetNullableType(Dart_Handle library,
@ -6113,30 +6108,7 @@ 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 we have a snapshot then try to figure out the mode by
// 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;
return true;
}
// --- Service support ---

View File

@ -250,8 +250,6 @@ constexpr bool FLAG_support_il_printer = false;
P(verify_entry_points, bool, false, \
"Throw API error on invalid member access through native API. See " \
"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")
#endif // RUNTIME_VM_FLAG_LIST_H_

View File

@ -1544,6 +1544,7 @@ void IsolateGroup::FlagsInitialize(Dart_IsolateFlags* api_flags) {
#undef INIT_FROM_FLAG
api_flags->is_service_isolate = false;
api_flags->is_kernel_isolate = false;
api_flags->null_safety = true;
}
void IsolateGroup::FlagsCopyTo(Dart_IsolateFlags* api_flags) {
@ -1554,6 +1555,7 @@ void IsolateGroup::FlagsCopyTo(Dart_IsolateFlags* api_flags) {
#undef INIT_FROM_FIELD
api_flags->is_service_isolate = false;
api_flags->is_kernel_isolate = false;
api_flags->null_safety = true;
}
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)
// Needs to be called manually, otherwise we don't set the null_safety_set
// bit.
set_null_safety(api_flags.null_safety);
set_null_safety(true);
#undef FLAG_FOR_NONPRODUCT
#undef FLAG_FOR_PRECOMPILER
#undef FLAG_FOR_PRODUCT
@ -1595,6 +1597,7 @@ void Isolate::FlagsInitialize(Dart_IsolateFlags* api_flags) {
#undef INIT_FROM_FLAG
api_flags->is_service_isolate = false;
api_flags->is_kernel_isolate = false;
api_flags->null_safety = true;
}
void Isolate::FlagsCopyTo(Dart_IsolateFlags* api_flags) const {
@ -1607,6 +1610,7 @@ void Isolate::FlagsCopyTo(Dart_IsolateFlags* api_flags) const {
#undef INIT_FROM_FIELD
api_flags->is_service_isolate = false;
api_flags->is_kernel_isolate = false;
api_flags->null_safety = true;
}
void Isolate::FlagsCopyFrom(const Dart_IsolateFlags& api_flags) {

View File

@ -61,9 +61,6 @@ enum LogicalOperator { kAnd, kOr };
class Program {
public:
static NNBDCompiledMode DetectNullSafety(const uint8_t* buffer,
intptr_t buffer_length);
// Read a kernel Program from the given Reader. Note the returned Program
// can potentially contain several "sub programs", though the library count
// etc will reference the last "sub program" only.

View File

@ -85,14 +85,6 @@ bool IsValidSdkHash(const uint8_t* sdk_hash) {
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) {
if (reader->size() < 70) {
// A kernel file (v43) currently contains at least the following:

View File

@ -866,9 +866,7 @@ class KernelCompilationRequest : public ValueObject {
Dart_CObject sound_null_safety;
sound_null_safety.type = Dart_CObject_kBool;
sound_null_safety.value.as_bool = (isolate_group != nullptr)
? isolate_group->null_safety()
: FLAG_sound_null_safety;
sound_null_safety.value.as_bool = true;
intptr_t num_experimental_flags = experimental_flags->length();
Dart_CObject** experimental_flags_array =

View File

@ -69,10 +69,6 @@ class KernelIsolate : public AllStatic {
Dart_KernelCompilationVerbosityLevel verbosity =
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 RejectCompilation();
static Dart_KernelCompilationResult UpdateInMemorySources(

View File

@ -819,14 +819,7 @@ LibraryPtr KernelLoader::LoadLibrary(intptr_t index) {
"null safety and not sound null safety.",
String::Handle(library.url()).ToCString());
}
if (!IG->null_safety() && mode == NNBDCompiledMode::kStrong) {
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)) {
if (mode == NNBDCompiledMode::kWeak) {
H.ReportError(
"Library '%s' was compiled without sound null safety (in weak mode) "
"and it "

View File

@ -115,7 +115,7 @@ Dart_Isolate TestCase::CreateIsolate(const uint8_t* data_buffer,
char* err;
Dart_IsolateFlags api_flags;
Isolate::FlagsInitialize(&api_flags);
api_flags.null_safety = FLAG_sound_null_safety;
api_flags.null_safety = true;
Dart_Isolate isolate = nullptr;
if (len == 0) {
isolate = Dart_CreateIsolateGroup(

View File

@ -28,7 +28,7 @@ application_snapshot("generate_dartdev_snapshot") {
"../dtd:dtd",
]
vm_args = [ "--sound-null-safety" ]
vm_args = []
output = "$root_gen_dir/dartdev.dart.snapshot"
}

View File

@ -20,6 +20,6 @@ application_snapshot("generate_dtd_snapshot") {
main_dart = "../../pkg/dtd_impl/bin/dtd.dart"
training_args = [ "--train" ]
vm_args = [ "--sound-null-safety" ]
vm_args = []
output = "$root_gen_dir/dart_tooling_daemon.dart.snapshot"
}