Skip to content

Commit cd3dded

Browse files
a-sivacommit-bot@chromium.org
authored andcommitted
Move flags strong/sync-async/reify-generic-functions back to global vm flags (they are not set as isolate specific flags).
Change-Id: I4d5cba4f5ac657a0834e3755312147cff1fbc001 Reviewed-on: https://dart-review.googlesource.com/71426 Commit-Queue: Siva Annamalai <[email protected]> Reviewed-by: Zach Anderson <[email protected]>
1 parent 3903b5b commit cd3dded

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+182
-188
lines changed

runtime/bin/BUILD.gn

+7
Original file line numberDiff line numberDiff line change
@@ -661,6 +661,13 @@ gen_snapshot_action("generate_snapshot_bin") {
661661
]
662662
args = [
663663
"--deterministic",
664+
665+
# TODO(asiva) remove these flags once the core snapshot is switched to
666+
# dart 2.
667+
"--no-strong",
668+
"--no-sync-async",
669+
"--reify-generic-functions",
670+
664671
"--snapshot_kind=" + dart_core_snapshot_kind,
665672
"--vm_snapshot_data=" + rebase_path(vm_snapshot_data, root_build_dir),
666673
"--vm_snapshot_instructions=" +

runtime/bin/main.cc

+7-5
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,7 @@ static Dart_Isolate CreateAndSetupKernelIsolate(const char* script_uri,
448448
packages_config = Options::packages_file();
449449
}
450450

451-
Dart_Isolate isolate;
451+
Dart_Isolate isolate = NULL;
452452
IsolateData* isolate_data = NULL;
453453
bool isolate_run_app_snapshot = false;
454454
AppSnapshot* app_snapshot = NULL;
@@ -470,7 +470,8 @@ static Dart_Isolate CreateAndSetupKernelIsolate(const char* script_uri,
470470
DART_KERNEL_ISOLATE_NAME, main, isolate_snapshot_data,
471471
isolate_snapshot_instructions, app_isolate_shared_data,
472472
app_isolate_shared_instructions, flags, isolate_data, error);
473-
} else {
473+
}
474+
if (isolate == NULL) {
474475
const uint8_t* kernel_service_buffer = NULL;
475476
intptr_t kernel_service_buffer_size = 0;
476477
dfe.LoadKernelService(&kernel_service_buffer, &kernel_service_buffer_size);
@@ -890,7 +891,7 @@ bool RunMainIsolate(const char* script_name, CommandLineOptions* dart_options) {
890891
}
891892

892893
Dart_Isolate isolate = NULL;
893-
if (flags.strong && Options::gen_snapshot_kind() == kAppAOT) {
894+
if (Options::preview_dart_2() && Options::gen_snapshot_kind() == kAppAOT) {
894895
isolate = IsolateSetupHelperAotCompilationDart2(
895896
script_name, "main", Options::package_root(), Options::packages_file(),
896897
&flags, &error, &exit_code);
@@ -1261,8 +1262,9 @@ void main(int argc, char** argv) {
12611262
init_params.entropy_source = DartUtils::EntropySource;
12621263
init_params.get_service_assets = GetVMServiceAssetsArchiveCallback;
12631264
#if !defined(DART_PRECOMPILED_RUNTIME)
1264-
init_params.start_kernel_isolate =
1265-
dfe.UseDartFrontend() && dfe.CanUseDartFrontend();
1265+
init_params.start_kernel_isolate = Options::preview_dart_2() &&
1266+
dfe.UseDartFrontend() &&
1267+
dfe.CanUseDartFrontend();
12661268
#else
12671269
init_params.start_kernel_isolate = false;
12681270
#endif

runtime/bin/main_options.cc

-9
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,6 @@ ENUM_OPTIONS_LIST(ENUM_OPTION_DEFINITION)
6363
CB_OPTIONS_LIST(CB_OPTION_DEFINITION)
6464
#undef CB_OPTION_DEFINITION
6565

66-
void Options::SetDart2Options(CommandLineOptions* vm_options) {
67-
vm_options->AddArgument("--strong");
68-
vm_options->AddArgument("--reify-generic-functions");
69-
vm_options->AddArgument("--sync-async");
70-
}
71-
7266
void Options::SetDart1Options(CommandLineOptions* vm_options) {
7367
vm_options->AddArgument("--no-strong");
7468
vm_options->AddArgument("--no-reify-generic-functions");
@@ -348,9 +342,6 @@ int Options::ParseArguments(int argc,
348342
const char* kPrefix = "--";
349343
const intptr_t kPrefixLen = strlen(kPrefix);
350344

351-
// Set Dart 2 as the default option.
352-
Options::SetDart2Options(vm_options);
353-
354345
// Store the executable name.
355346
Platform::SetExecutableName(argv[0]);
356347

runtime/bin/main_options.h

-1
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,6 @@ class Options {
112112
#undef CB_OPTIONS_DECL
113113

114114
static bool preview_dart_2() { return !no_preview_dart_2(); }
115-
static void SetDart2Options(CommandLineOptions* vm_options);
116115
static void SetDart1Options(CommandLineOptions* vm_options);
117116

118117
static dart::SimpleHashMap* environment() { return environment_; }

runtime/bin/run_vm_tests.cc

+18-3
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,8 @@ static Dart_Isolate CreateIsolateAndSetup(const char* script_uri,
150150
isolate = Dart_CreateIsolate(
151151
DART_KERNEL_ISOLATE_NAME, main, isolate_snapshot_data,
152152
isolate_snapshot_instructions, NULL, NULL, flags, isolate_data, error);
153-
} else {
153+
}
154+
if (isolate == NULL) {
154155
bin::dfe.Init();
155156
bin::dfe.LoadKernelService(&kernel_service_buffer,
156157
&kernel_service_buffer_size);
@@ -262,13 +263,27 @@ static int Main(int argc, const char** argv) {
262263
dart_argc = argc - 2;
263264
dart_argv = &argv[1];
264265
}
266+
const char* error;
267+
if (!start_kernel_isolate) {
268+
int extra_argc = dart_argc + 3;
269+
const char** extra_argv = new const char*[extra_argc];
270+
for (intptr_t i = 0; i < dart_argc; i++) {
271+
extra_argv[i] = dart_argv[i];
272+
}
273+
extra_argv[dart_argc] = "--no-strong";
274+
extra_argv[dart_argc + 1] = "--no-reify-generic-arguments";
275+
extra_argv[dart_argc + 2] = "--no-sync-async";
276+
error = Flags::ProcessCommandLineFlags(extra_argc, extra_argv);
277+
ASSERT(error == NULL);
278+
} else {
279+
error = Flags::ProcessCommandLineFlags(dart_argc, dart_argv);
280+
ASSERT(error == NULL);
281+
}
265282

266283
bin::Thread::InitOnce();
267284
bin::TimerUtils::InitOnce();
268285
bin::EventHandler::Start();
269286

270-
const char* error = Flags::ProcessCommandLineFlags(dart_argc, dart_argv);
271-
ASSERT(error == NULL);
272287

273288
error = Dart::InitOnce(
274289
dart::bin::vm_snapshot_data, dart::bin::vm_snapshot_instructions,

runtime/include/dart_api.h

+1-4
Original file line numberDiff line numberDiff line change
@@ -553,7 +553,7 @@ typedef struct {
553553
* for each part.
554554
*/
555555

556-
#define DART_FLAGS_CURRENT_VERSION (0x00000006)
556+
#define DART_FLAGS_CURRENT_VERSION (0x00000007)
557557

558558
typedef struct {
559559
int32_t version;
@@ -566,10 +566,7 @@ typedef struct {
566566
bool use_dart_frontend;
567567
bool obfuscate;
568568
Dart_QualifiedFunctionName* entry_points;
569-
bool reify_generic_functions;
570-
bool strong;
571569
bool load_vmservice_library;
572-
bool sync_async;
573570
bool unsafe_trust_strong_mode_types;
574571
} Dart_IsolateFlags;
575572

runtime/lib/isolate.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ DEFINE_NATIVE_ENTRY(Isolate_spawnUri, 12) {
361361
Dart_IsolateFlags* flags = state->isolate_flags();
362362
flags->enable_asserts = is_checked;
363363
// Do not enable type checks in strong mode.
364-
flags->enable_type_checks = is_checked && !flags->strong;
364+
flags->enable_type_checks = is_checked && !FLAG_strong;
365365
}
366366

367367
ThreadPool::Task* spawn_task = new SpawnIsolateTask(state);

runtime/lib/object.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ DEFINE_NATIVE_ENTRY(Internal_extractTypeArguments, 2) {
380380
Class& interface_cls = Class::Handle(zone);
381381
intptr_t num_type_args = 0; // Remains 0 when executing Dart 1.0 code.
382382
// TODO(regis): Check for strong mode too?
383-
if (Isolate::Current()->reify_generic_functions()) {
383+
if (FLAG_reify_generic_functions) {
384384
const TypeArguments& function_type_args =
385385
TypeArguments::Handle(zone, arguments->NativeTypeArgs());
386386
if (function_type_args.Length() == 1) {

runtime/vm/class_finalizer.cc

+8-9
Original file line numberDiff line numberDiff line change
@@ -449,8 +449,7 @@ void ClassFinalizer::ResolveRedirectingFactoryTarget(
449449
return;
450450
}
451451

452-
Isolate* isolate = Isolate::Current();
453-
if (isolate->error_on_bad_override() && !isolate->strong()) {
452+
if (!FLAG_strong && Isolate::Current()->error_on_bad_override()) {
454453
// Verify that the target is compatible with the redirecting factory.
455454
Error& error = Error::Handle();
456455
if (!target.HasCompatibleParametersWith(factory, &error)) {
@@ -564,7 +563,7 @@ void ClassFinalizer::ResolveTypeClass(const Class& cls, const Type& type) {
564563
(type.signature() != Function::null()));
565564

566565
// In non-strong mode, replace FutureOr<T> type of async library with dynamic.
567-
if (type_class.IsFutureOrClass() && !Isolate::Current()->strong()) {
566+
if (type_class.IsFutureOrClass() && !FLAG_strong) {
568567
Type::Cast(type).set_type_class(Class::Handle(Object::dynamic_class()));
569568
type.set_arguments(Object::null_type_arguments());
570569
}
@@ -1226,7 +1225,7 @@ RawAbstractType* ClassFinalizer::FinalizeType(const Class& cls,
12261225
// malformed.
12271226
if ((finalization >= kCanonicalize) && !type.IsMalformed() &&
12281227
!type.IsCanonical() && type.IsType()) {
1229-
if (!Isolate::Current()->strong()) {
1228+
if (!FLAG_strong) {
12301229
CheckTypeBounds(cls, type);
12311230
}
12321231
return type.Canonicalize();
@@ -1370,7 +1369,7 @@ RawAbstractType* ClassFinalizer::FinalizeType(const Class& cls,
13701369

13711370
// If we are done finalizing a graph of mutually recursive types, check their
13721371
// bounds.
1373-
if (is_root_type && !Isolate::Current()->strong()) {
1372+
if (is_root_type && !FLAG_strong) {
13741373
for (intptr_t i = pending_types->length() - 1; i >= 0; i--) {
13751374
const AbstractType& type = pending_types->At(i);
13761375
if (!type.IsMalformed() && !type.IsCanonical()) {
@@ -1634,7 +1633,7 @@ void ClassFinalizer::ResolveAndFinalizeMemberTypes(const Class& cls) {
16341633
String& other_name = String::Handle(zone);
16351634
Class& super_class = Class::Handle(zone);
16361635
const intptr_t num_fields = array.Length();
1637-
const bool track_exactness = isolate->strong() && isolate->use_field_guards();
1636+
const bool track_exactness = FLAG_strong && isolate->use_field_guards();
16381637
for (intptr_t i = 0; i < num_fields; i++) {
16391638
field ^= array.At(i);
16401639
type = field.type();
@@ -1743,7 +1742,7 @@ void ClassFinalizer::ResolveAndFinalizeMemberTypes(const Class& cls) {
17431742
// If we check for bad overrides, collect interfaces, super interfaces, and
17441743
// super classes of this class.
17451744
GrowableArray<const Class*> interfaces(zone, 4);
1746-
if (isolate->error_on_bad_override() && !isolate->strong()) {
1745+
if (isolate->error_on_bad_override() && !FLAG_strong) {
17471746
CollectInterfaces(cls, &interfaces);
17481747
// Include superclasses in list of interfaces and super interfaces.
17491748
super_class = cls.SuperClass();
@@ -1765,7 +1764,7 @@ void ClassFinalizer::ResolveAndFinalizeMemberTypes(const Class& cls) {
17651764
FinalizeSignature(cls, function);
17661765
name = function.name();
17671766
// Report signature conflicts only.
1768-
if (isolate->error_on_bad_override() && !isolate->strong() &&
1767+
if (isolate->error_on_bad_override() && !FLAG_strong &&
17691768
!function.is_static() && !function.IsGenerativeConstructor()) {
17701769
// A constructor cannot override anything.
17711770
for (intptr_t i = 0; i < interfaces.length(); i++) {
@@ -2787,7 +2786,7 @@ void ClassFinalizer::FinalizeClass(const Class& cls) {
27872786
}
27882787
// Ensure interfaces are finalized in case we check for bad overrides.
27892788
Isolate* isolate = Isolate::Current();
2790-
if (isolate->error_on_bad_override() && !isolate->strong()) {
2789+
if (isolate->error_on_bad_override() && !FLAG_strong) {
27912790
GrowableArray<const Class*> interfaces(4);
27922791
CollectInterfaces(cls, &interfaces);
27932792
for (intptr_t i = 0; i < interfaces.length(); i++) {

runtime/vm/compiler/backend/flow_graph.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -1048,7 +1048,7 @@ void FlowGraph::Rename(GrowableArray<PhiInstr*>* live_phis,
10481048

10491049
// Check if inlining_parameters include a type argument vector parameter.
10501050
const intptr_t inlined_type_args_param =
1051-
(isolate()->reify_generic_functions() && (inlining_parameters != NULL) &&
1051+
(FLAG_reify_generic_functions && (inlining_parameters != NULL) &&
10521052
function().IsGeneric())
10531053
? 1
10541054
: 0;
@@ -1091,7 +1091,7 @@ void FlowGraph::Rename(GrowableArray<PhiInstr*>* live_phis,
10911091

10921092
if (!IsCompiledForOsr()) {
10931093
const bool reify_generic_argument =
1094-
function().IsGeneric() && isolate()->reify_generic_functions();
1094+
function().IsGeneric() && FLAG_reify_generic_functions;
10951095

10961096
// Replace the type arguments slot with a special parameter.
10971097
if (reify_generic_argument) {

runtime/vm/compiler/backend/flow_graph_compiler_arm.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -1119,7 +1119,7 @@ void FlowGraphCompiler::EmitOptimizedStaticCall(
11191119
Code::EntryKind entry_kind) {
11201120
ASSERT(!function.IsClosureFunction());
11211121
if (function.HasOptionalParameters() ||
1122-
(isolate()->reify_generic_functions() && function.IsGeneric())) {
1122+
(FLAG_reify_generic_functions && function.IsGeneric())) {
11231123
__ LoadObject(R4, arguments_descriptor);
11241124
} else {
11251125
__ LoadImmediate(R4, 0); // GC safe smi zero because of stub.

runtime/vm/compiler/backend/flow_graph_compiler_arm64.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -1088,7 +1088,7 @@ void FlowGraphCompiler::EmitOptimizedStaticCall(
10881088
// TODO(sjindel/entrypoints): Support multiple entrypoints on ARM64.
10891089
ASSERT(!function.IsClosureFunction());
10901090
if (function.HasOptionalParameters() ||
1091-
(isolate()->reify_generic_functions() && function.IsGeneric())) {
1091+
(FLAG_reify_generic_functions && function.IsGeneric())) {
10921092
__ LoadObject(R4, arguments_descriptor);
10931093
} else {
10941094
__ LoadImmediate(R4, 0); // GC safe smi zero because of stub.

runtime/vm/compiler/backend/flow_graph_compiler_ia32.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -1001,7 +1001,7 @@ void FlowGraphCompiler::EmitOptimizedStaticCall(
10011001
Code::EntryKind entry_kind) {
10021002
// TODO(sjindel/entrypoints): Support multiple entrypoints on IA32.
10031003
if (function.HasOptionalParameters() ||
1004-
(isolate()->reify_generic_functions() && function.IsGeneric())) {
1004+
(FLAG_reify_generic_functions && function.IsGeneric())) {
10051005
__ LoadObject(EDX, arguments_descriptor);
10061006
} else {
10071007
__ xorl(EDX, EDX); // GC safe smi zero because of stub.

runtime/vm/compiler/backend/flow_graph_compiler_x64.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -1096,7 +1096,7 @@ void FlowGraphCompiler::EmitOptimizedStaticCall(
10961096
Code::EntryKind entry_kind) {
10971097
ASSERT(!function.IsClosureFunction());
10981098
if (function.HasOptionalParameters() ||
1099-
(isolate()->reify_generic_functions() && function.IsGeneric())) {
1099+
(FLAG_reify_generic_functions && function.IsGeneric())) {
11001100
__ LoadObject(R10, arguments_descriptor);
11011101
} else {
11021102
__ xorl(R10, R10); // GC safe smi zero because of stub.

runtime/vm/compiler/backend/il.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -2695,7 +2695,7 @@ Definition* AssertBooleanInstr::Canonicalize(FlowGraph* flow_graph) {
26952695

26962696
// In strong mode type is already verified either by static analysis
26972697
// or runtime checks, so AssertBoolean just ensures that value is not null.
2698-
if (Isolate::Current()->strong() && !value()->Type()->is_nullable()) {
2698+
if (FLAG_strong && !value()->Type()->is_nullable()) {
26992699
return value()->definition();
27002700
}
27012701
}

runtime/vm/compiler/backend/il.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -4251,7 +4251,7 @@ class StoreInstanceFieldInstr : public TemplateDefinition<2, NoThrow> {
42514251

42524252
Assembler::CanBeSmi CanValueBeSmi() const {
42534253
Isolate* isolate = Isolate::Current();
4254-
if (isolate->type_checks() && !isolate->strong()) {
4254+
if (isolate->type_checks() && !FLAG_strong) {
42554255
// Dart 1 sometimes places a store into a context before a parameter
42564256
// type check.
42574257
return Assembler::kValueCanBeSmi;
@@ -4424,7 +4424,7 @@ class StoreStaticFieldInstr : public TemplateDefinition<1, NoThrow> {
44244424
private:
44254425
Assembler::CanBeSmi CanValueBeSmi() const {
44264426
Isolate* isolate = Isolate::Current();
4427-
if (isolate->type_checks() && !isolate->strong()) {
4427+
if (isolate->type_checks() && !FLAG_strong) {
44284428
// Dart 1 sometimes places a store into a context before a parameter
44294429
// type check.
44304430
return Assembler::kValueCanBeSmi;

runtime/vm/compiler/backend/il_arm.cc

+4-4
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,7 @@ static void EmitAssertBoolean(Register reg,
501501
__ CompareObject(reg, Bool::False());
502502
__ b(&done, EQ);
503503
} else {
504-
ASSERT(isolate->asserts() || isolate->strong());
504+
ASSERT(isolate->asserts() || FLAG_strong);
505505
__ CompareObject(reg, Object::null_instance());
506506
__ b(&done, NE);
507507
}
@@ -937,9 +937,9 @@ void NativeCallInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
937937
const Register result = locs()->out(0).reg();
938938

939939
// All arguments are already @SP due to preceding PushArgument()s.
940-
ASSERT(ArgumentCount() == function().NumParameters() +
941-
(function().IsGeneric() &&
942-
Isolate::Current()->reify_generic_functions())
940+
ASSERT(ArgumentCount() ==
941+
function().NumParameters() +
942+
(function().IsGeneric() && FLAG_reify_generic_functions)
943943
? 1
944944
: 0);
945945

runtime/vm/compiler/backend/il_arm64.cc

+4-4
Original file line numberDiff line numberDiff line change
@@ -497,7 +497,7 @@ static void EmitAssertBoolean(Register reg,
497497
__ CompareObject(reg, Bool::False());
498498
__ b(&done, EQ);
499499
} else {
500-
ASSERT(isolate->asserts() || isolate->strong());
500+
ASSERT(isolate->asserts() || FLAG_strong);
501501
__ CompareObject(reg, Object::null_instance());
502502
__ b(&done, NE);
503503
}
@@ -824,9 +824,9 @@ void NativeCallInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
824824
const Register result = locs()->out(0).reg();
825825

826826
// All arguments are already @SP due to preceding PushArgument()s.
827-
ASSERT(ArgumentCount() == function().NumParameters() +
828-
(function().IsGeneric() &&
829-
Isolate::Current()->reify_generic_functions())
827+
ASSERT(ArgumentCount() ==
828+
function().NumParameters() +
829+
(function().IsGeneric() && FLAG_reify_generic_functions)
830830
? 1
831831
: 0);
832832

runtime/vm/compiler/backend/il_ia32.cc

+4-4
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ static void EmitAssertBoolean(Register reg,
320320
__ CompareObject(reg, Bool::False());
321321
__ j(EQUAL, &done, Assembler::kNearJump);
322322
} else {
323-
ASSERT(isolate->asserts() || isolate->strong());
323+
ASSERT(isolate->asserts() || FLAG_strong);
324324
__ CompareObject(reg, Object::null_instance());
325325
__ j(NOT_EQUAL, &done, Assembler::kNearJump);
326326
}
@@ -821,9 +821,9 @@ void NativeCallInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
821821
const intptr_t argc_tag = NativeArguments::ComputeArgcTag(function());
822822

823823
// All arguments are already @ESP due to preceding PushArgument()s.
824-
ASSERT(ArgumentCount() == function().NumParameters() +
825-
(function().IsGeneric() &&
826-
Isolate::Current()->reify_generic_functions())
824+
ASSERT(ArgumentCount() ==
825+
function().NumParameters() +
826+
(function().IsGeneric() && FLAG_reify_generic_functions)
827827
? 1
828828
: 0);
829829

0 commit comments

Comments
 (0)