[VM] Remove vm_platform from the dart binary
- Remove vm_platform from the dart binary
- kernel isolate always compiles in strong mode

Change-Id: I4e3973fdaee0bda1c43244ea04673f253eaae249
Reviewed-on: https://dart-review.googlesource.com/65788
Commit-Queue: Siva Annamalai <asiva@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
diff --git a/runtime/bin/BUILD.gn b/runtime/bin/BUILD.gn
index 3583691..96351e9 100644
--- a/runtime/bin/BUILD.gn
+++ b/runtime/bin/BUILD.gn
@@ -880,16 +880,6 @@
   executable = false
 }
 
-bin_to_linkable("platform_dill_linkable") {
-  deps = [
-    "../vm:vm_legacy_platform",
-  ]
-  input = "$root_out_dir/vm_platform.dill"
-  symbol = "kPlatformDill"
-  size_symbol = "kPlatformDillSize"
-  executable = false
-}
-
 bin_to_linkable("platform_strong_dill_linkable") {
   deps = [
     "../vm:vm_platform",
@@ -918,11 +908,9 @@
   visibility = [ ":*" ]
   deps = [
     ":kernel_service_dill_linkable",
-    ":platform_dill_linkable",
     ":platform_strong_dill_linkable",
   ]
   sources = get_target_outputs(":kernel_service_dill_linkable") +
-            get_target_outputs(":platform_dill_linkable") +
             get_target_outputs(":platform_strong_dill_linkable")
 }
 
diff --git a/runtime/bin/dfe.cc b/runtime/bin/dfe.cc
index b6de97c..5e58c20 100644
--- a/runtime/bin/dfe.cc
+++ b/runtime/bin/dfe.cc
@@ -18,15 +18,11 @@
 #if !defined(EXCLUDE_CFE_AND_KERNEL_PLATFORM)
 extern const uint8_t kKernelServiceDill[];
 extern intptr_t kKernelServiceDillSize;
-extern const uint8_t kPlatformDill[];
-extern intptr_t kPlatformDillSize;
 extern const uint8_t kPlatformStrongDill[];
 extern intptr_t kPlatformStrongDillSize;
 #else
 const uint8_t* kKernelServiceDill = NULL;
 intptr_t kKernelServiceDillSize = 0;
-const uint8_t* kPlatformDill = NULL;
-intptr_t kPlatformDillSize = 0;
 const uint8_t* kPlatformStrongDill = NULL;
 intptr_t kPlatformStrongDillSize = 0;
 #endif  // !defined(EXCLUDE_CFE_AND_KERNEL_PLATFORM)
@@ -42,15 +38,11 @@
 #if defined(DART_NO_SNAPSHOT) || defined(DART_PRECOMPILER)
 const uint8_t* kernel_service_dill = NULL;
 const intptr_t kernel_service_dill_size = 0;
-const uint8_t* platform_dill = NULL;
-const intptr_t platform_dill_size = 0;
 const uint8_t* platform_strong_dill = NULL;
 const intptr_t platform_strong_dill_size = 0;
 #else
 const uint8_t* kernel_service_dill = kKernelServiceDill;
 const intptr_t kernel_service_dill_size = kKernelServiceDillSize;
-const uint8_t* platform_dill = kPlatformDill;
-const intptr_t platform_dill_size = kPlatformDillSize;
 const uint8_t* platform_strong_dill = kPlatformStrongDill;
 const intptr_t platform_strong_dill_size = kPlatformStrongDillSize;
 #endif
@@ -98,7 +90,7 @@
 }
 
 void DFE::Init() {
-  if (platform_dill == NULL) {
+  if (platform_strong_dill == NULL) {
     return;
   }
 
@@ -138,19 +130,13 @@
 }
 
 void DFE::LoadPlatform(const uint8_t** kernel_buffer,
-                       intptr_t* kernel_buffer_size,
-                       bool strong) {
-  if (strong) {
-    *kernel_buffer = platform_strong_dill;
-    *kernel_buffer_size = platform_strong_dill_size;
-  } else {
-    *kernel_buffer = platform_dill;
-    *kernel_buffer_size = platform_dill_size;
-  }
+                       intptr_t* kernel_buffer_size) {
+  *kernel_buffer = platform_strong_dill;
+  *kernel_buffer_size = platform_strong_dill_size;
 }
 
 bool DFE::CanUseDartFrontend() const {
-  return (platform_dill != NULL) &&
+  return (platform_strong_dill != NULL) &&
          (KernelServiceDillAvailable() || (frontend_filename() != NULL));
 }
 
@@ -191,7 +177,6 @@
 };
 
 Dart_KernelCompilationResult DFE::CompileScript(const char* script_uri,
-                                                bool strong,
                                                 bool incremental,
                                                 const char* package_config) {
   // TODO(aam): When Frontend is ready, VM should be passing vm_outline.dill
@@ -203,12 +188,8 @@
   const char* sanitized_uri = script_uri;
 #endif
 
-  const uint8_t* platform_binary =
-      strong ? platform_strong_dill : platform_dill;
-  intptr_t platform_binary_size =
-      strong ? platform_strong_dill_size : platform_dill_size;
-  return Dart_CompileToKernel(sanitized_uri, platform_binary,
-                              platform_binary_size, incremental,
+  return Dart_CompileToKernel(sanitized_uri, platform_strong_dill,
+                              platform_strong_dill_size, incremental,
                               package_config);
 }
 
@@ -217,10 +198,9 @@
                                intptr_t* kernel_buffer_size,
                                char** error,
                                int* exit_code,
-                               bool strong,
                                const char* package_config) {
-  Dart_KernelCompilationResult result = CompileScript(
-      script_uri, strong, use_incremental_compiler(), package_config);
+  Dart_KernelCompilationResult result =
+      CompileScript(script_uri, use_incremental_compiler(), package_config);
   switch (result.status) {
     case Dart_KernelCompilationStatus_Ok:
       *kernel_buffer = result.kernel;
diff --git a/runtime/bin/dfe.h b/runtime/bin/dfe.h
index 433550f..af520658 100644
--- a/runtime/bin/dfe.h
+++ b/runtime/bin/dfe.h
@@ -57,7 +57,6 @@
   // Compiles specified script.
   // Returns result from compiling the script.
   Dart_KernelCompilationResult CompileScript(const char* script_uri,
-                                             bool strong,
                                              bool incremental,
                                              const char* package_config);
 
@@ -70,7 +69,6 @@
                             intptr_t* kernel_buffer_size,
                             char** error,
                             int* exit_code,
-                            bool strong,
                             const char* package_config);
 
   // Reads the script kernel file if specified 'script_uri' is a kernel file.
@@ -98,8 +96,7 @@
   bool CanUseDartFrontend() const;
 
   void LoadPlatform(const uint8_t** kernel_buffer,
-                    intptr_t* kernel_buffer_size,
-                    bool strong = false);
+                    intptr_t* kernel_buffer_size);
   void LoadKernelService(const uint8_t** kernel_service_buffer,
                          intptr_t* kernel_service_buffer_size);
 
diff --git a/runtime/bin/loader.cc b/runtime/bin/loader.cc
index a18b1c0..b3a9074 100644
--- a/runtime/bin/loader.cc
+++ b/runtime/bin/loader.cc
@@ -791,7 +791,7 @@
       uint8_t* kernel_buffer = NULL;
       intptr_t kernel_buffer_size = -1;
       dfe.CompileAndReadScript(url_string, &kernel_buffer, &kernel_buffer_size,
-                               &error, &exit_code, true /* strong */, NULL);
+                               &error, &exit_code, NULL);
       if (exit_code == 0) {
         return Dart_LoadLibraryFromKernel(kernel_buffer, kernel_buffer_size);
       } else if (exit_code == kCompilationErrorExitCode) {
diff --git a/runtime/bin/main.cc b/runtime/bin/main.cc
index caf82ee..5531dd5 100644
--- a/runtime/bin/main.cc
+++ b/runtime/bin/main.cc
@@ -351,7 +351,7 @@
     intptr_t application_kernel_buffer_size = 0;
     dfe.CompileAndReadScript(script_uri, &application_kernel_buffer,
                              &application_kernel_buffer_size, error, exit_code,
-                             flags->strong, resolved_packages_config);
+                             resolved_packages_config);
     if (application_kernel_buffer == NULL) {
       Dart_ExitScope();
       Dart_ShutdownIsolate();
@@ -578,7 +578,7 @@
     // from kernel only if we can.
     const uint8_t* kernel_buffer = NULL;
     intptr_t kernel_buffer_size = 0;
-    dfe.LoadPlatform(&kernel_buffer, &kernel_buffer_size, flags->strong);
+    dfe.LoadPlatform(&kernel_buffer, &kernel_buffer_size);
     if (kernel_buffer == NULL) {
       dfe.application_kernel_buffer(&kernel_buffer, &kernel_buffer_size);
     }
@@ -699,8 +699,7 @@
   if (Options::preview_dart_2() && !isolate_run_app_snapshot) {
     const uint8_t* platform_kernel_buffer = NULL;
     intptr_t platform_kernel_buffer_size = 0;
-    dfe.LoadPlatform(&platform_kernel_buffer, &platform_kernel_buffer_size,
-                     flags->strong);
+    dfe.LoadPlatform(&platform_kernel_buffer, &platform_kernel_buffer_size);
     if (platform_kernel_buffer == NULL) {
       platform_kernel_buffer = kernel_buffer;
       platform_kernel_buffer_size = kernel_buffer_size;
@@ -971,7 +970,6 @@
     }
     if (Options::preview_dart_2()) {
       Snapshot::GenerateKernel(Options::snapshot_filename(), script_name,
-                               flags.strong,
                                isolate_data->resolved_packages_config());
     } else {
       Snapshot::GenerateScript(Options::snapshot_filename());
diff --git a/runtime/bin/snapshot_utils.cc b/runtime/bin/snapshot_utils.cc
index 7f11ffa..2ff01c2 100644
--- a/runtime/bin/snapshot_utils.cc
+++ b/runtime/bin/snapshot_utils.cc
@@ -334,7 +334,6 @@
 
 void Snapshot::GenerateKernel(const char* snapshot_filename,
                               const char* script_name,
-                              bool strong,
                               const char* package_config) {
 #if !defined(EXCLUDE_CFE_AND_KERNEL_PLATFORM) && !defined(TESTING)
   uint8_t* kernel_buffer = NULL;
@@ -344,7 +343,7 @@
     WriteSnapshotFile(snapshot_filename, kernel_buffer, kernel_buffer_size);
   } else {
     Dart_KernelCompilationResult result =
-        dfe.CompileScript(script_name, strong, false, package_config);
+        dfe.CompileScript(script_name, false, package_config);
     if (result.status != Dart_KernelCompilationStatus_Ok) {
       ErrorExit(kErrorExitCode, "%s\n", result.error);
     }
diff --git a/runtime/bin/snapshot_utils.h b/runtime/bin/snapshot_utils.h
index 5f935b5..c1d6edf 100644
--- a/runtime/bin/snapshot_utils.h
+++ b/runtime/bin/snapshot_utils.h
@@ -30,7 +30,6 @@
  public:
   static void GenerateKernel(const char* snapshot_filename,
                              const char* script_name,
-                             bool strong,
                              const char* package_config);
   static void GenerateScript(const char* snapshot_filename);
   static void GenerateAppJIT(const char* snapshot_filename);
diff --git a/runtime/vm/unit_test.cc b/runtime/vm/unit_test.cc
index 1d125a0..7ff72fd 100644
--- a/runtime/vm/unit_test.cc
+++ b/runtime/vm/unit_test.cc
@@ -28,17 +28,13 @@
 using dart::bin::DartUtils;
 
 extern "C" {
-extern const uint8_t kPlatformDill[];
 extern const uint8_t kPlatformStrongDill[];
-extern intptr_t kPlatformDillSize;
 extern intptr_t kPlatformStrongDillSize;
 }
 
 namespace dart {
 
-const uint8_t* platform_dill = kPlatformDill;
 const uint8_t* platform_strong_dill = kPlatformStrongDill;
-const intptr_t platform_dill_size = kPlatformDillSize;
 const intptr_t platform_strong_dill_size = kPlatformStrongDillSize;
 
 DEFINE_FLAG(bool,
@@ -109,8 +105,7 @@
 Dart_Isolate TestCase::CreateTestIsolate(const char* name, void* data) {
   if (FLAG_use_dart_frontend) {
     return CreateIsolate(
-        FLAG_strong ? platform_strong_dill : platform_dill,
-        FLAG_strong ? platform_strong_dill_size : platform_dill_size,
+        platform_strong_dill, platform_strong_dill_size,
         NULL, /* There is no instr buffer in case of dill buffers. */
         name, data);
   } else {
@@ -261,8 +256,7 @@
                                          bool allow_compile_errors) {
   Zone* zone = Thread::Current()->zone();
   Dart_KernelCompilationResult compilation_result = Dart_CompileSourcesToKernel(
-      url, FLAG_strong ? platform_strong_dill : platform_dill,
-      FLAG_strong ? platform_strong_dill_size : platform_dill_size,
+      url, platform_strong_dill, platform_strong_dill_size,
       sourcefiles_count, sourcefiles, incrementally, NULL);
   return ValidateCompilationResult(zone, compilation_result, kernel_pgm);
 }
@@ -311,10 +305,8 @@
                                          const char* multiroot_scheme) {
   Zone* zone = Thread::Current()->zone();
   Dart_KernelCompilationResult compilation_result = Dart_CompileSourcesToKernel(
-      url, FLAG_strong ? platform_strong_dill : platform_dill,
-      FLAG_strong ? platform_strong_dill_size : platform_dill_size,
-      sourcefiles_count, sourcefiles, incrementally, NULL, multiroot_filepaths,
-      multiroot_scheme);
+      url, platform_strong_dill, platform_strong_dill_size, sourcefiles_count,
+      sourcefiles, incrementally, NULL, multiroot_filepaths, multiroot_scheme);
   return ValidateCompilationResult(zone, compilation_result, kernel_buffer,
                                    kernel_buffer_size, allow_compile_errors);
 }
diff --git a/tools/bots/try_benchmarks.sh b/tools/bots/try_benchmarks.sh
index b7c5551..9e5670f 100755
--- a/tools/bots/try_benchmarks.sh
+++ b/tools/bots/try_benchmarks.sh
@@ -77,8 +77,6 @@
       -- \
       third_party/d8/linux/ia32/natives_blob.bin \
       third_party/d8/linux/ia32/snapshot_blob.bin \
-      out/ReleaseIA32/vm_outline.dill \
-      out/ReleaseIA32/vm_platform.dill \
       out/ReleaseIA32/vm_outline_strong.dill \
       out/ReleaseIA32/vm_platform_strong.dill \
       third_party/firefox_jsshell/linux/ \
@@ -178,8 +176,6 @@
       -- \
       third_party/d8/linux/ia32/natives_blob.bin \
       third_party/d8/linux/ia32/snapshot_blob.bin \
-      out/ReleaseIA32/vm_outline.dill \
-      out/ReleaseIA32/vm_platform.dill \
       out/ReleaseIA32/vm_outline_strong.dill \
       out/ReleaseIA32/vm_platform_strong.dill \
       third_party/firefox_jsshell/linux/ \
@@ -244,8 +240,6 @@
       -- \
       third_party/d8/linux/x64/natives_blob.bin \
       third_party/d8/linux/x64/snapshot_blob.bin \
-      out/ReleaseX64/vm_outline.dill \
-      out/ReleaseX64/vm_platform.dill \
       out/ReleaseX64/vm_outline_strong.dill \
       out/ReleaseX64/vm_platform_strong.dill \
       out/ReleaseX64/dart-sdk \
@@ -367,8 +361,6 @@
       -- \
       third_party/d8/linux/x64/natives_blob.bin \
       third_party/d8/linux/x64/snapshot_blob.bin \
-      out/ReleaseX64/vm_outline.dill \
-      out/ReleaseX64/vm_platform.dill \
       out/ReleaseX64/vm_outline_strong.dill \
       out/ReleaseX64/vm_platform_strong.dill \
       out/ReleaseX64/dart-sdk \
@@ -415,12 +407,10 @@
     out/ReleaseX64/dart pkg/analysis_server/benchmark/benchmarks.dart run --quick --repeat 1 analysis-server-cold
     out/ReleaseX64/dart --print_metrics pkg/analyzer_cli/bin/analyzer.dart --dart-sdk=sdk hello.dart
     echo '[{"name":"foo","edits":[["pkg/compiler/lib/src/dart2js.dart","2016","2017"],["pkg/compiler/lib/src/options.dart","2016","2017"]]}]' > appjit_train_edits.json
-    out/ReleaseX64/dart --background-compilation=false --snapshot-kind=app-jit --snapshot=pkg/front_end/tool/incremental_perf.dart.appjit pkg/front_end/tool/incremental_perf.dart --target=vm --sdk-summary=out/ReleaseX64/vm_platform.dill --sdk-library-specification=sdk/lib/libraries.json pkg/compiler/lib/src/dart2js.dart appjit_train_edits.json
+    out/ReleaseX64/dart --background-compilation=false --snapshot-kind=app-jit --snapshot=pkg/front_end/tool/incremental_perf.dart.appjit pkg/front_end/tool/incremental_perf.dart --target=vm --sdk-summary=out/ReleaseX64/vm_platform_strong.dill --sdk-library-specification=sdk/lib/libraries.json pkg/compiler/lib/src/dart2js.dart appjit_train_edits.json
     out/ReleaseX64/dart --background-compilation=false pkg/front_end/tool/incremental_perf.dart.appjit --target=vm --sdk-summary=out/ReleaseX64/vm_platform_strong.dill --sdk-library-specification=sdk/lib/libraries.json pkg/front_end/benchmarks/ikg/hello.dart pkg/front_end/benchmarks/ikg/hello.edits.json
-    out/ReleaseX64/dart --background-compilation=false pkg/front_end/tool/incremental_perf.dart.appjit --target=vm --mode=legacy --sdk-summary=out/ReleaseX64/vm_platform.dill --sdk-library-specification=sdk/lib/libraries.json pkg/front_end/benchmarks/ikg/hello.dart pkg/front_end/benchmarks/ikg/hello.edits.json
     out/ReleaseX64/dart --background-compilation=false pkg/front_end/tool/incremental_perf.dart.appjit --target=vm --implementation=minimal --sdk-summary=out/ReleaseX64/vm_platform_strong.dill --sdk-library-specification=sdk/lib/libraries.json pkg/front_end/benchmarks/ikg/hello.dart pkg/front_end/benchmarks/ikg/hello.edits.json
-    out/ReleaseX64/dart --background-compilation=false pkg/front_end/tool/incremental_perf.dart.appjit --target=vm --mode=legacy --implementation=minimal --sdk-summary=out/ReleaseX64/vm_platform.dill --sdk-library-specification=sdk/lib/libraries.json pkg/front_end/benchmarks/ikg/hello.dart pkg/front_end/benchmarks/ikg/hello.edits.json
-    out/ReleaseX64/dart --packages=.packages pkg/kernel/test/binary_bench.dart --golem AstFromBinaryLazy out/ReleaseX64/vm_platform.dill
+    out/ReleaseX64/dart --packages=.packages pkg/kernel/test/binary_bench.dart --golem AstFromBinaryLazy out/ReleaseX64/vm_platform_strong.dill
     cd ..
     rm -rf tmp
   else