9
9
#include " vm/compiler/jit/compiler.h"
10
10
#include " vm/dart_api_impl.h"
11
11
#include " vm/dart_entry.h"
12
+ #include " vm/flags.h"
12
13
#include " vm/isolate.h"
13
14
#include " vm/lockers.h"
14
15
#include " vm/message.h"
@@ -343,6 +344,17 @@ static void PassThroughFinalizer(void* isolate_callback_data,
343
344
Dart_WeakPersistentHandle handle,
344
345
void * peer) {}
345
346
347
+ MallocGrowableArray<char *>* KernelIsolate::experimental_flags_ =
348
+ new MallocGrowableArray<char *>();
349
+
350
+ void KernelIsolate::AddExperimentalFlag (const char * value) {
351
+ experimental_flags_->Add (strdup (value));
352
+ }
353
+
354
+ DEFINE_OPTION_HANDLER (KernelIsolate::AddExperimentalFlag,
355
+ enable_experiment,
356
+ " Comma separated list of experimental features." );
357
+
346
358
class KernelCompilationRequest : public ValueObject {
347
359
public:
348
360
KernelCompilationRequest ()
@@ -373,7 +385,8 @@ class KernelCompilationRequest : public ValueObject {
373
385
const Array& type_definitions,
374
386
char const * library_uri,
375
387
char const * klass,
376
- bool is_static) {
388
+ bool is_static,
389
+ const MallocGrowableArray<char *>* experimental_flags) {
377
390
Thread* thread = Thread::Current ();
378
391
TransitionNativeToVM transition (thread);
379
392
Dart_CObject tag;
@@ -443,12 +456,25 @@ class KernelCompilationRequest : public ValueObject {
443
456
isolate_id.value .as_int64 =
444
457
isolate != NULL ? static_cast <int64_t >(isolate->main_port ()) : 0 ;
445
458
446
- Dart_CObject message;
447
- message.type = Dart_CObject_kArray;
448
459
Dart_CObject suppress_warnings;
449
460
suppress_warnings.type = Dart_CObject_kBool;
450
461
suppress_warnings.value .as_bool = FLAG_suppress_fe_warnings;
451
462
463
+ intptr_t num_experimental_flags = experimental_flags->length ();
464
+ Dart_CObject** experimental_flags_array =
465
+ new Dart_CObject*[num_experimental_flags];
466
+ for (intptr_t i = 0 ; i < num_experimental_flags; ++i) {
467
+ experimental_flags_array[i] = new Dart_CObject;
468
+ experimental_flags_array[i]->type = Dart_CObject_kString;
469
+ experimental_flags_array[i]->value .as_string = (*experimental_flags)[i];
470
+ }
471
+ Dart_CObject experimental_flags_object;
472
+ experimental_flags_object.type = Dart_CObject_kArray;
473
+ experimental_flags_object.value .as_array .values = experimental_flags_array;
474
+ experimental_flags_object.value .as_array .length = num_experimental_flags;
475
+
476
+ Dart_CObject message;
477
+ message.type = Dart_CObject_kArray;
452
478
Dart_CObject* message_arr[] = {&tag,
453
479
&send_port,
454
480
&isolate_id,
@@ -458,7 +484,8 @@ class KernelCompilationRequest : public ValueObject {
458
484
&library_uri_object,
459
485
&class_object,
460
486
&is_static_object,
461
- &suppress_warnings};
487
+ &suppress_warnings,
488
+ &experimental_flags_object};
462
489
message.value .as_array .values = message_arr;
463
490
message.value .as_array .length = ARRAY_SIZE (message_arr);
464
491
@@ -486,6 +513,11 @@ class KernelCompilationRequest : public ValueObject {
486
513
}
487
514
delete[] type_definitions_array;
488
515
516
+ for (intptr_t i = 0 ; i < num_experimental_flags; ++i) {
517
+ delete experimental_flags_array[i];
518
+ }
519
+ delete[] experimental_flags_array;
520
+
489
521
return result_;
490
522
}
491
523
@@ -500,7 +532,8 @@ class KernelCompilationRequest : public ValueObject {
500
532
bool incremental_compile,
501
533
const char * package_config,
502
534
const char * multiroot_filepaths,
503
- const char * multiroot_scheme) {
535
+ const char * multiroot_scheme,
536
+ const MallocGrowableArray<char *>* experimental_flags) {
504
537
// Build the [null, send_port, script_uri, platform_kernel,
505
538
// incremental_compile, isolate_id, [files]] message for the Kernel isolate.
506
539
// tag is used to specify which operation the frontend should perform.
@@ -570,6 +603,19 @@ class KernelCompilationRequest : public ValueObject {
570
603
suppress_warnings.type = Dart_CObject_kBool;
571
604
suppress_warnings.value .as_bool = FLAG_suppress_fe_warnings;
572
605
606
+ intptr_t num_experimental_flags = experimental_flags->length ();
607
+ Dart_CObject** experimental_flags_array =
608
+ new Dart_CObject*[num_experimental_flags];
609
+ for (intptr_t i = 0 ; i < num_experimental_flags; ++i) {
610
+ experimental_flags_array[i] = new Dart_CObject;
611
+ experimental_flags_array[i]->type = Dart_CObject_kString;
612
+ experimental_flags_array[i]->value .as_string = (*experimental_flags)[i];
613
+ }
614
+ Dart_CObject experimental_flags_object;
615
+ experimental_flags_object.type = Dart_CObject_kArray;
616
+ experimental_flags_object.value .as_array .values = experimental_flags_array;
617
+ experimental_flags_object.value .as_array .length = num_experimental_flags;
618
+
573
619
Dart_CObject bytecode;
574
620
bytecode.type = Dart_CObject_kBool;
575
621
// Interpreter is supported only on x64 and arm64.
@@ -625,6 +671,7 @@ class KernelCompilationRequest : public ValueObject {
625
671
&isolate_id,
626
672
&files,
627
673
&suppress_warnings,
674
+ &experimental_flags_object,
628
675
&bytecode,
629
676
&package_config_uri,
630
677
&multiroot_filepaths_object,
@@ -643,6 +690,11 @@ class KernelCompilationRequest : public ValueObject {
643
690
ml.Wait ();
644
691
}
645
692
693
+ for (intptr_t i = 0 ; i < num_experimental_flags; ++i) {
694
+ delete experimental_flags_array[i];
695
+ }
696
+ delete[] experimental_flags_array;
697
+
646
698
return result_;
647
699
}
648
700
@@ -774,11 +826,11 @@ Dart_KernelCompilationResult KernelIsolate::CompileToKernel(
774
826
}
775
827
776
828
KernelCompilationRequest request;
777
- return request.SendAndWaitForResponse (kCompileTag , kernel_port, script_uri,
778
- platform_kernel, platform_kernel_size ,
779
- source_file_count, source_files,
780
- incremental_compile, package_config,
781
- multiroot_filepaths, multiroot_scheme );
829
+ return request.SendAndWaitForResponse (
830
+ kCompileTag , kernel_port, script_uri, platform_kernel ,
831
+ platform_kernel_size, source_file_count, source_files,
832
+ incremental_compile, package_config, multiroot_filepaths ,
833
+ multiroot_scheme, experimental_flags_ );
782
834
}
783
835
784
836
Dart_KernelCompilationResult KernelIsolate::ListDependencies () {
@@ -793,7 +845,7 @@ Dart_KernelCompilationResult KernelIsolate::ListDependencies() {
793
845
KernelCompilationRequest request;
794
846
return request.SendAndWaitForResponse (kListDependenciesTag , kernel_port, NULL ,
795
847
NULL , 0 , 0 , NULL , false , NULL , NULL ,
796
- NULL );
848
+ NULL , experimental_flags_ );
797
849
}
798
850
799
851
Dart_KernelCompilationResult KernelIsolate::AcceptCompilation () {
@@ -809,7 +861,8 @@ Dart_KernelCompilationResult KernelIsolate::AcceptCompilation() {
809
861
810
862
KernelCompilationRequest request;
811
863
return request.SendAndWaitForResponse (kAcceptTag , kernel_port, NULL , NULL , 0 ,
812
- 0 , NULL , true , NULL , NULL , NULL );
864
+ 0 , NULL , true , NULL , NULL , NULL ,
865
+ experimental_flags_);
813
866
}
814
867
815
868
Dart_KernelCompilationResult KernelIsolate::CompileExpressionToKernel (
@@ -831,7 +884,7 @@ Dart_KernelCompilationResult KernelIsolate::CompileExpressionToKernel(
831
884
KernelCompilationRequest request;
832
885
return request.SendAndWaitForResponse (kernel_port, expression, definitions,
833
886
type_definitions, library_url, klass,
834
- is_static);
887
+ is_static, experimental_flags_ );
835
888
}
836
889
837
890
Dart_KernelCompilationResult KernelIsolate::UpdateInMemorySources (
@@ -848,9 +901,9 @@ Dart_KernelCompilationResult KernelIsolate::UpdateInMemorySources(
848
901
}
849
902
850
903
KernelCompilationRequest request;
851
- return request.SendAndWaitForResponse (kUpdateSourcesTag , kernel_port, NULL ,
852
- NULL , 0 , source_files_count,
853
- source_files, true , NULL , NULL , NULL );
904
+ return request.SendAndWaitForResponse (
905
+ kUpdateSourcesTag , kernel_port, NULL , NULL , 0 , source_files_count,
906
+ source_files, true , NULL , NULL , NULL , experimental_flags_ );
854
907
}
855
908
856
909
void KernelIsolate::NotifyAboutIsolateShutdown (const Isolate* isolate) {
0 commit comments