Skip to content

Commit

Permalink
[VM] Remove support for option --no-preview-dart-2
Browse files Browse the repository at this point in the history
- option --no-preview-dart-2 will now result in an error
- change aot-assembly build rule to generate AOT snapshot using Dart 2
- generate coresnapshot using Dart 2 (this snapshot is not used yet, next CL which switch the isolate create code to use this snapshot)
- by pass all Dart1 test runs in the status file
- change the default compiler setting in test.py to use dartk
- have test.py not pick up any configuration for --no-preview-dart-2

Change-Id: Ia136943ebfd0fed0c52683b330745b3e2c7a7ce6
Reviewed-on: https://dart-review.googlesource.com/75820
Reviewed-by: Zach Anderson <zra@google.com>
Commit-Queue: Siva Annamalai <asiva@google.com>
  • Loading branch information
a-siva authored and commit-bot@chromium.org committed Sep 24, 2018
1 parent 95b8a19 commit 355c73d
Show file tree
Hide file tree
Showing 23 changed files with 121 additions and 2,245 deletions.
7 changes: 0 additions & 7 deletions runtime/bin/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -660,13 +660,6 @@ gen_snapshot_action("generate_snapshot_bin") {
]
args = [
"--deterministic",

# TODO(asiva) remove these flags once the core snapshot is switched to
# dart 2.
"--no-strong",
"--no-sync-async",
"--no-reify-generic-functions",

"--snapshot_kind=" + dart_core_snapshot_kind,
"--vm_snapshot_data=" + rebase_path(vm_snapshot_data, root_build_dir),
"--vm_snapshot_instructions=" +
Expand Down
98 changes: 36 additions & 62 deletions runtime/bin/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -165,18 +165,16 @@ static void WriteDepsFile(Dart_Isolate isolate) {
success &= file->Print("%s ", dep);
free(dep);
}
if (Options::preview_dart_2()) {
if (kernel_isolate_is_running) {
Dart_KernelCompilationResult result = Dart_KernelListDependencies();
if (result.status != Dart_KernelCompilationStatus_Ok) {
ErrorExit(
kErrorExitCode,
"Error: Failed to fetch dependencies from kernel service: %s\n\n",
result.error);
}
success &= file->WriteFully(result.kernel, result.kernel_size);
free(result.kernel);
if (kernel_isolate_is_running) {
Dart_KernelCompilationResult result = Dart_KernelListDependencies();
if (result.status != Dart_KernelCompilationStatus_Ok) {
ErrorExit(
kErrorExitCode,
"Error: Failed to fetch dependencies from kernel service: %s\n\n",
result.error);
}
success &= file->WriteFully(result.kernel, result.kernel_size);
free(result.kernel);
}
success &= file->Print("\n");
if (!success) {
Expand Down Expand Up @@ -300,8 +298,8 @@ static Dart_Isolate IsolateSetupHelper(Dart_Isolate isolate,
CHECK_RESULT(result);

#if !defined(DART_PRECOMPILED_RUNTIME)
if (Options::preview_dart_2() && !isolate_run_app_snapshot &&
kernel_buffer == NULL && !Dart_IsKernelIsolate(isolate)) {
if (!isolate_run_app_snapshot && kernel_buffer == NULL &&
!Dart_IsKernelIsolate(isolate)) {
if (!dfe.CanUseDartFrontend()) {
const char* format = "Dart frontend unavailable to compile script %s.";
intptr_t len = snprintf(NULL, 0, format, script_uri) + 1;
Expand Down Expand Up @@ -520,9 +518,6 @@ static Dart_Isolate CreateAndSetupServiceIsolate(const char* script_uri,
#else
// JIT: Service isolate uses the core libraries snapshot.
bool skip_library_load = false;
const uint8_t* isolate_snapshot_data = core_isolate_snapshot_data;
const uint8_t* isolate_snapshot_instructions =
core_isolate_snapshot_instructions;
#endif // !defined(DART_PRECOMPILED_RUNTIME)

Dart_Isolate isolate = NULL;
Expand All @@ -540,36 +535,28 @@ static Dart_Isolate CreateAndSetupServiceIsolate(const char* script_uri,
ASSERT(flags != NULL);
flags->load_vmservice_library = true;

if (Options::preview_dart_2()) {
// If there is intention to use DFE, then we create the isolate
// 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);
if (kernel_buffer == NULL) {
dfe.application_kernel_buffer(&kernel_buffer, &kernel_buffer_size);
}
// If there is intention to use DFE, then we create the isolate
// 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);
if (kernel_buffer == NULL) {
dfe.application_kernel_buffer(&kernel_buffer, &kernel_buffer_size);
}

// TODO(sivachandra): When the platform program is unavailable, check if
// application kernel binary is self contained or an incremental binary.
// Isolate should be created only if it is a self contained kernel binary.
if (kernel_buffer != NULL) {
isolate = Dart_CreateIsolateFromKernel(script_uri, NULL, kernel_buffer,
kernel_buffer_size, flags,
isolate_data, error);
} else {
*error =
strdup("Platform kernel not available to create service isolate.");
delete isolate_data;
return NULL;
}
skip_library_load = true;
// TODO(sivachandra): When the platform program is unavailable, check if
// application kernel binary is self contained or an incremental binary.
// Isolate should be created only if it is a self contained kernel binary.
if (kernel_buffer != NULL) {
isolate = Dart_CreateIsolateFromKernel(script_uri, NULL, kernel_buffer,
kernel_buffer_size, flags,
isolate_data, error);
} else {
isolate = Dart_CreateIsolate(
script_uri, main, isolate_snapshot_data, isolate_snapshot_instructions,
app_isolate_shared_data, app_isolate_shared_instructions, flags,
isolate_data, error);
*error = strdup("Platform kernel not available to create service isolate.");
delete isolate_data;
return NULL;
}
skip_library_load = true;
#endif // !defined(DART_PRECOMPILED_RUNTIME)
if (isolate == NULL) {
delete isolate_data;
Expand Down Expand Up @@ -663,7 +650,7 @@ static Dart_Isolate CreateIsolateAndSetupHelper(bool is_main_isolate,
Dart_Isolate isolate = NULL;

#if !defined(DART_PRECOMPILED_RUNTIME)
if (Options::preview_dart_2() && !isolate_run_app_snapshot) {
if (!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);
Expand Down Expand Up @@ -891,7 +878,7 @@ bool RunMainIsolate(const char* script_name, CommandLineOptions* dart_options) {
}

Dart_Isolate isolate = NULL;
if (Options::preview_dart_2() && Options::gen_snapshot_kind() == kAppAOT) {
if (Options::gen_snapshot_kind() == kAppAOT) {
isolate = IsolateSetupHelperAotCompilationDart2(
script_name, "main", Options::package_root(), Options::packages_file(),
&flags, &error, &exit_code);
Expand Down Expand Up @@ -935,12 +922,8 @@ bool RunMainIsolate(const char* script_name, CommandLineOptions* dart_options) {
// the core snapshot.
Platform::Exit(kErrorExitCode);
}
if (Options::preview_dart_2()) {
Snapshot::GenerateKernel(Options::snapshot_filename(), script_name,
isolate_data->resolved_packages_config());
} else {
Snapshot::GenerateScript(Options::snapshot_filename());
}
Snapshot::GenerateKernel(Options::snapshot_filename(), script_name,
isolate_data->resolved_packages_config());
} else {
// Lookup the library of the root script.
Dart_Handle root_lib = Dart_RootLibrary();
Expand Down Expand Up @@ -1234,14 +1217,6 @@ void main(int argc, char** argv) {
// Since we loaded the script anyway, save it.
dfe.set_application_kernel_buffer(application_kernel_buffer,
application_kernel_buffer_size);
// Since we saw a dill file, it means we have to turn on all the
// preview_dart_2 options.
if (Options::no_preview_dart_2()) {
Log::PrintErr(
"A kernel file is specified as the input, "
"--no-preview-dart-2 option is incompatible with it\n");
Platform::Exit(kErrorExitCode);
}
Options::dfe()->set_use_dfe();
}
#endif
Expand All @@ -1262,9 +1237,8 @@ void main(int argc, char** argv) {
init_params.entropy_source = DartUtils::EntropySource;
init_params.get_service_assets = GetVMServiceAssetsArchiveCallback;
#if !defined(DART_PRECOMPILED_RUNTIME)
init_params.start_kernel_isolate = Options::preview_dart_2() &&
dfe.UseDartFrontend() &&
dfe.CanUseDartFrontend();
init_params.start_kernel_isolate =
dfe.UseDartFrontend() && dfe.CanUseDartFrontend();
#else
init_params.start_kernel_isolate = false;
#endif
Expand Down
17 changes: 1 addition & 16 deletions runtime/bin/main_options.cc
Original file line number Diff line number Diff line change
Expand Up @@ -63,17 +63,9 @@ ENUM_OPTIONS_LIST(ENUM_OPTION_DEFINITION)
CB_OPTIONS_LIST(CB_OPTION_DEFINITION)
#undef CB_OPTION_DEFINITION

void Options::SetDart1Options(CommandLineOptions* vm_options) {
vm_options->AddArgument("--no-strong");
vm_options->AddArgument("--no-reify-generic-functions");
vm_options->AddArgument("--no-sync-async");
}

#if !defined(DART_PRECOMPILED_RUNTIME)
DFE* Options::dfe_ = NULL;

// TODO(sivachandra): Make it an error to specify --dfe without
// specifying --preview_dart_2.
DEFINE_STRING_OPTION_CB(dfe, { Options::dfe()->set_frontend_filename(value); });
#endif // !defined(DART_PRECOMPILED_RUNTIME)

Expand Down Expand Up @@ -384,13 +376,9 @@ int Options::ParseArguments(int argc,
}
}

if (Options::no_preview_dart_2()) {
Options::SetDart1Options(vm_options);
} else {
#if !defined(DART_PRECOMPILED_RUNTIME)
Options::dfe()->set_use_dfe();
Options::dfe()->set_use_dfe();
#endif // !defined(DART_PRECOMPILED_RUNTIME)
}
if (Options::deterministic()) {
// Both an embedder and VM flag.
vm_options->AddArgument("--deterministic");
Expand Down Expand Up @@ -469,9 +457,6 @@ int Options::ParseArguments(int argc,
}
if (checked_set) {
vm_options->AddArgument("--enable-asserts");
if (Options::no_preview_dart_2()) {
vm_options->AddArgument("--enable-type-checks");
}
}

// If --snapshot is given without --snapshot-kind, default to script snapshot.
Expand Down
4 changes: 1 addition & 3 deletions runtime/bin/main_options.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ namespace bin {
V(short_socket_read, short_socket_read) \
V(short_socket_write, short_socket_write) \
V(disable_exit, exit_disabled) \
V(no_preview_dart_2, no_preview_dart_2) \
V(preview_dart_2, nop_option)

// Boolean flags that have a short form.
Expand Down Expand Up @@ -111,8 +110,7 @@ class Options {
CB_OPTIONS_LIST(CB_OPTIONS_DECL)
#undef CB_OPTIONS_DECL

static bool preview_dart_2() { return !no_preview_dart_2(); }
static void SetDart1Options(CommandLineOptions* vm_options);
static bool preview_dart_2() { return true; }

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

Expand Down
3 changes: 3 additions & 0 deletions runtime/observatory/tests/service/service.status
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ async_scope_test: Pass, Slow
[ $mode == debug && ($arch == simarm || $arch == simarm64) ]
*: SkipSlow

[ !$preview_dart_2 && ($runtime == dart_precompiled || $runtime == vm) ]
*: SkipByDesign # Deprecating all Dart1 modes of execution

[ !$strong && ($compiler == dartk || $compiler == dartkp) ]
*: Skip

Expand Down
6 changes: 2 additions & 4 deletions runtime/tests/vm/dart/snapshot_version_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@ import "dart:io";
import "package:expect/expect.dart";

main() {
var result = Process.runSync(Platform.executable, [
'--no-preview-dart-2',
Platform.script.resolve('./bad_snapshot').toFilePath()
]);
var result = Process.runSync(Platform.executable,
[Platform.script.resolve('./bad_snapshot').toFilePath()]);
print("=== stdout ===\n ${result.stdout}");
print("=== stderr ===\n ${result.stderr}");
Expect.equals(253, result.exitCode);
Expand Down
8 changes: 5 additions & 3 deletions runtime/tests/vm/vm.status
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
# for details. All rights reserved. Use of this source code is governed by a
# BSD-style license that can be found in the LICENSE file.

cc/AllocGeneric_Overflow: Crash, Fail # These tests are expected to crash on all platforms.
cc/ArrayNew_Overflow_Crash: Crash, Fail # These tests are expected to crash on all platforms.
cc/CodeImmutability: Crash, Fail # These tests are expected to crash on all platforms.
Expand All @@ -20,16 +21,14 @@ cc/Profiler_InliningIntervalBoundry: Skip # Differences in ia32, debug, release
cc/SNPrint_BadArgs: Crash, Fail # These tests are expected to crash on all platforms.
dart/data_uri_import_test/none: SkipByDesign
dart/entrypoints/*: Skip # Only supported in Dart 2 JIT (hot-reload -> issue 34199).
dart/snapshot_version_test: Skip # This test is a Dart1 test (script snapshot)

[ $builder_tag == asan ]
cc/CodeImmutability: Fail, OK # Address Sanitizer turns a crash into a failure.

[ $builder_tag == optimization_counter_threshold ]
dart/appjit*: SkipByDesign # Test needs to a particular opt-counter value

[ $compiler == app_jit ]
dart/snapshot_version_test: Fail, OK # Expects to find script snapshot relative to Dart source.

[ $compiler == app_jitk ]
dart/data_uri_import_test/utf16: MissingRuntimeError
dart/redirection_type_shuffling_test/none: RuntimeError
Expand Down Expand Up @@ -363,3 +362,6 @@ dart/slow_path_shared_stub_test: SkipSlow # Too slow with --slow-path-triggers-g
dart/spawn_infinite_loop_test: Skip # We can shutdown an isolate before it reloads.
dart/spawn_shutdown_test: Skip # We can shutdown an isolate before it reloads.
dart/stack_overflow_shared_test: SkipSlow # Too slow with --slow-path-triggers-gc flag and not relevant outside precompiled.

[ ($runtime == vm || $runtime == dart_precompiled) && !$preview_dart_2 ]
*:SkipByDesign # Deprecating all Dart1 modes of execution
2 changes: 1 addition & 1 deletion runtime/vm/unit_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const intptr_t platform_strong_dill_size = kPlatformStrongDillSize;

DEFINE_FLAG(bool,
use_dart_frontend,
false,
true,
"Parse scripts with Dart-to-Kernel parser");

DECLARE_FLAG(bool, strong);
Expand Down
3 changes: 3 additions & 0 deletions samples/samples.status
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ sample_extension/test/sample_extension_app_snapshot_test: Pass, RuntimeError # I
[ $compiler == none && $runtime == vm && $system == fuchsia ]
*: Skip # Not yet triaged.

[ !$preview_dart_2 && ($runtime == dart_precompiled || $runtime == vm) ]
*: SkipByDesign # Deprecating all Dart1 modes of execution

[ $compiler == app_jitk || $compiler == dartk || $compiler == dartkb || $compiler == dartkp ]
sample_extension/test/sample_extension_app_snapshot_test: RuntimeError
sample_extension/test/sample_extension_script_snapshot_test: RuntimeError
Expand Down

0 comments on commit 355c73d

Please sign in to comment.