Skip to content

Commit

Permalink
Add ./tools/test.py -c precompiler -r dart_precompiled.
Browse files Browse the repository at this point in the history
 - Make --gen/run-precompiled-snapshot take a directory to use for the snapshot pieces.
 - Throw on Platform.executeable to prevent tests from becoming fork-bombs.
 - Update status files so 'dart_precompiled' is generally expected to behave the same as 'vm'.

Currently multitests will fail unless run with --jobs=1 because the test harness assigns them the same temporary directory.

Running this also requires a great deal of space. My out directory is 380G.

BUG=http://dartbug.com/24975
R=fschneider@google.com, srdjan@google.com

Review URL: https://codereview.chromium.org/1507943002 .
  • Loading branch information
rmacnak-google committed Dec 18, 2015
1 parent f1ea359 commit 6b964b8
Show file tree
Hide file tree
Showing 23 changed files with 482 additions and 123 deletions.
99 changes: 72 additions & 27 deletions runtime/bin/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,12 @@ static bool has_gen_precompiled_snapshot = false;
static bool has_run_precompiled_snapshot = false;


// Value of the --gen/run_precompiled_snapshot flag.
// (This pointer points into an argv buffer and does not need to be
// free'd.)
static const char* precompiled_snapshot_directory = NULL;


// Global flag that is used to indicate that we want to compile everything in
// the same way as precompilation before main, then continue running in the
// same process.
Expand Down Expand Up @@ -304,16 +310,18 @@ static bool ProcessCompileAllOption(const char* arg,
static bool ProcessGenPrecompiledSnapshotOption(
const char* arg,
CommandLineOptions* vm_options) {
ASSERT(arg != NULL);
if (*arg != '\0') {
return false;
}
// Ensure that we are not already running using a full snapshot.
if (isolate_snapshot_buffer != NULL) {
Log::PrintErr("Precompiled snapshots must be generated with"
" dart_no_snapshot.\n");
return false;
}
ASSERT(arg != NULL);
if ((arg[0] == '=') || (arg[0] == ':')) {
precompiled_snapshot_directory = &arg[1];
} else {
precompiled_snapshot_directory = arg;
}
has_gen_precompiled_snapshot = true;
vm_options->AddArgument("--precompilation");
return true;
Expand All @@ -324,8 +332,10 @@ static bool ProcessRunPrecompiledSnapshotOption(
const char* arg,
CommandLineOptions* vm_options) {
ASSERT(arg != NULL);
if (*arg != '\0') {
return false;
precompiled_snapshot_directory = arg;
if ((precompiled_snapshot_directory[0] == '=') ||
(precompiled_snapshot_directory[0] == ':')) {
precompiled_snapshot_directory = &precompiled_snapshot_directory[1];
}
has_run_precompiled_snapshot = true;
vm_options->AddArgument("--precompilation");
Expand Down Expand Up @@ -1009,34 +1019,67 @@ static void ServiceStreamCancelCallback(const char* stream_id) {
}


static void WriteSnapshotFile(const char* filename,
const uint8_t* buffer,
const intptr_t size) {
File* file = File::Open(filename, File::kWriteTruncate);
static void WritePrecompiledSnapshotFile(const char* filename,
const uint8_t* buffer,
const intptr_t size) {
char* concat = NULL;
const char* qualified_filename;
if (strlen(precompiled_snapshot_directory) > 0) {
intptr_t len = snprintf(NULL, 0, "%s/%s",
precompiled_snapshot_directory, filename);
concat = new char[len + 1];
snprintf(concat, len + 1, "%s/%s",
precompiled_snapshot_directory, filename);
qualified_filename = concat;
} else {
qualified_filename = filename;
}

File* file = File::Open(qualified_filename, File::kWriteTruncate);
ASSERT(file != NULL);
if (!file->WriteFully(buffer, size)) {
ErrorExit(kErrorExitCode,
"Unable to open file %s for writing snapshot\n",
filename);
qualified_filename);
}
delete file;
if (concat != NULL) {
delete concat;
}
}


static void ReadSnapshotFile(const char* filename,
const uint8_t** buffer) {
void* file = DartUtils::OpenFile(filename, false);
static void ReadPrecompiledSnapshotFile(const char* filename,
const uint8_t** buffer) {
char* concat = NULL;
const char* qualified_filename;
if (strlen(precompiled_snapshot_directory) > 0) {
intptr_t len = snprintf(NULL, 0, "%s/%s",
precompiled_snapshot_directory, filename);
concat = new char[len + 1];
snprintf(concat, len + 1, "%s/%s",
precompiled_snapshot_directory, filename);
qualified_filename = concat;
} else {
qualified_filename = filename;
}

void* file = DartUtils::OpenFile(qualified_filename, false);
if (file == NULL) {
ErrorExit(kErrorExitCode,
"Error: Unable to open file %s for reading snapshot\n", filename);
"Error: Unable to open file %s for reading snapshot\n",
qualified_filename);
}
intptr_t len = -1;
DartUtils::ReadFile(buffer, &len, file);
if (*buffer == NULL || len == -1) {
ErrorExit(kErrorExitCode,
"Error: Unable to read snapshot file %s\n", filename);
"Error: Unable to read snapshot file %s\n", qualified_filename);
}
DartUtils::CloseFile(file);
if (concat != NULL) {
delete concat;
}
}


Expand Down Expand Up @@ -1215,15 +1258,15 @@ bool RunMainIsolate(const char* script_name,
&instructions_buffer,
&instructions_size);
CHECK_RESULT(result);
WriteSnapshotFile(kPrecompiledVmIsolateName,
vm_isolate_buffer,
vm_isolate_size);
WriteSnapshotFile(kPrecompiledIsolateName,
isolate_buffer,
isolate_size);
WriteSnapshotFile(kPrecompiledInstructionsName,
instructions_buffer,
instructions_size);
WritePrecompiledSnapshotFile(kPrecompiledVmIsolateName,
vm_isolate_buffer,
vm_isolate_size);
WritePrecompiledSnapshotFile(kPrecompiledIsolateName,
isolate_buffer,
isolate_size);
WritePrecompiledSnapshotFile(kPrecompiledInstructionsName,
instructions_buffer,
instructions_size);
} else {
if (has_compile_all) {
result = Dart_CompileAll();
Expand Down Expand Up @@ -1426,8 +1469,10 @@ void main(int argc, char** argv) {
if (has_run_precompiled_snapshot) {
instructions_snapshot = reinterpret_cast<const uint8_t*>(
LoadLibrarySymbol(kPrecompiledLibraryName, kPrecompiledSymbolName));
ReadSnapshotFile(kPrecompiledVmIsolateName, &vm_isolate_snapshot_buffer);
ReadSnapshotFile(kPrecompiledIsolateName, &isolate_snapshot_buffer);
ReadPrecompiledSnapshotFile(kPrecompiledVmIsolateName,
&vm_isolate_snapshot_buffer);
ReadPrecompiledSnapshotFile(kPrecompiledIsolateName,
&isolate_snapshot_buffer);
}

// Initialize the Dart VM.
Expand Down
16 changes: 16 additions & 0 deletions runtime/bin/platform.cc
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,28 @@ void FUNCTION_NAME(Platform_LocalHostname)(Dart_NativeArguments args) {

void FUNCTION_NAME(Platform_ExecutableName)(Dart_NativeArguments args) {
ASSERT(Platform::GetExecutableName() != NULL);
if (Dart_IsRunningPrecompiledCode()) {
// This is a work-around to be able to use most of the existing test suite
// for precompilation. Many tests do something like Process.run(
// Platform.executable, some_other_script.dart). But with precompilation
// the script is already fixed, so the spawned process runs the same script
// again and we have a fork-bomb.
Dart_ThrowException(Dart_NewStringFromCString(
"Platform.executable not supported under precompilation"));
UNREACHABLE();
}
Dart_SetReturnValue(
args, Dart_NewStringFromCString(Platform::GetExecutableName()));
}


void FUNCTION_NAME(Platform_ResolvedExecutableName)(Dart_NativeArguments args) {
if (Dart_IsRunningPrecompiledCode()) {
Dart_ThrowException(Dart_NewStringFromCString(
"Platform.resolvedExecutable not supported under precompilation"));
UNREACHABLE();
}

if (Platform::GetResolvedExecutableName() != NULL) {
Dart_SetReturnValue(
args, Dart_NewStringFromCString(Platform::GetResolvedExecutableName()));
Expand Down
3 changes: 3 additions & 0 deletions runtime/include/dart_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -2819,4 +2819,7 @@ DART_EXPORT Dart_Handle Dart_CreatePrecompiledSnapshot(
uint8_t** instructions_snapshot_buffer,
intptr_t* instructions_snapshot_size);


DART_EXPORT bool Dart_IsRunningPrecompiledCode();

#endif /* INCLUDE_DART_API_H_ */ /* NOLINT */
4 changes: 2 additions & 2 deletions runtime/observatory/tests/service/service.status
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# 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.

[ $compiler == none && $runtime == vm ]
[ ($compiler == none || $compiler == precompiler) && ($runtime == vm || $runtime == dart_precompiled) ]
evaluate_activation_test/instance: RuntimeError # http://dartbug.com/20047
evaluate_activation_test/scope: RuntimeError # http://dartbug.com/20047

Expand All @@ -21,5 +21,5 @@ developer_extension_test: SkipByDesign
[ $arch == arm ]
process_service_test: Pass, Fail # Issue 24344

[ $noopt ]
[ ($noopt || $compiler == precompiler) ]
*: Skip # Issue 24651
12 changes: 9 additions & 3 deletions runtime/tests/vm/vm.status
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ dart/inline_stack_frame_test: RuntimeError, Pass # Issue 7953
# Data uri's not supported by dart2js or the analyzer.
dart/data_uri*test: Skip

[ $runtime == vm ]
[ ($runtime == vm || $runtime == dart_precompiled) ]
dart/data_uri_import_test/wrongmime: RuntimeError, OK # VM is more restrictive than the browser
dart/data_uri_import_test/nomime: RuntimeError, OK
dart/data_uri_import_test/nocharset: RuntimeError, OK
Expand All @@ -78,10 +78,16 @@ dart/snapshot_version_test: SkipByDesign # Spawns processes
dart/spawn_infinite_loop_test: Skip # VM shutdown test
dart/spawn_shutdown_test: Skip # VM Shutdown test

[ $runtime == vm && $mode == debug && $builder_tag == asan ]
[ ($runtime == vm || $runtime == dart_precompiled) && $mode == debug && $builder_tag == asan ]
cc/Dart2JSCompileAll: Skip # Timeout.

[ $noopt ]
dart/redirection_type_shuffling_test: CompileTimeError # Imports dart:mirrors
dart/byte_array_test: Crash # Incompatible flag --disable_alloc_stubs_after_gc

[ $noopt || $compiler == precompiler ]
dart/redirection_type_shuffling_test: CompileTimeError # Imports dart:mirrors
dart/inline_stack_frame_test: Fail # Issue 24783 - inlined frames missing

[ $runtime == dart_precompiled ]
dart/optimized_stacktrace_test: Fail
dart/data_uri_spawn_test: RuntimeError # Isolate.spawnUri
5 changes: 5 additions & 0 deletions runtime/vm/dart_api_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5974,4 +5974,9 @@ DART_EXPORT Dart_Handle Dart_CreatePrecompiledSnapshot(
return Api::Success();
}


DART_EXPORT bool Dart_IsRunningPrecompiledCode() {
return Dart::IsRunningPrecompiledCode();
}

} // namespace dart
1 change: 1 addition & 0 deletions runtime/vm/precompiler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1087,6 +1087,7 @@ void Precompiler::VisitFunctions(FunctionVisitor* visitor) {
for (intptr_t j = 0; j < closures.Length(); j++) {
function ^= closures.At(j);
visitor->VisitFunction(function);
ASSERT(!function.HasImplicitClosureFunction());
}
}

Expand Down
2 changes: 2 additions & 0 deletions samples/samples.status
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,5 @@ sample_extension/test/sample_extension_test: Skip # Issue 14705
[ $arch == simarm64 ]
*: Skip

[ $runtime == dart_precompiled ]
sample_extension: RuntimeError # Platform.executable
2 changes: 1 addition & 1 deletion tests/benchmark_smoke/benchmark_smoke.status
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# 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.

[ $runtime == vm ]
[ ($runtime == vm || $runtime == dart_precompiled) ]
*: Skip

[ $compiler == dart2js && $runtime == none ]
Expand Down
33 changes: 18 additions & 15 deletions tests/co19/co19-runtime.status
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# BSD-style license that can be found in the LICENSE file.


[ $compiler == none && ($runtime == vm || $runtime == dartium || $runtime == ContentShellOnAndroid) ]
[ ($compiler == none || $compiler == precompiler) && (($runtime == vm || $runtime == dart_precompiled) || $runtime == dartium || $runtime == ContentShellOnAndroid) ]

LibTest/core/RegExp/Pattern_semantics/firstMatch_NonEmptyClassRanges_A01_t01: Fail # Issue 22200
LibTest/core/RegExp/Pattern_semantics/firstMatch_NonEmptyClassRanges_A01_t05: Fail # Issue 22200
Expand Down Expand Up @@ -38,7 +38,7 @@ LibTest/isolate/Isolate/spawn_A02_t02: RuntimeError # Dart issue 15617
LibTest/core/Symbol/Symbol_A01_t03: RuntimeError # Issue 13596
LibTest/core/Symbol/Symbol_A01_t05: RuntimeError # Issue 13596

[ $compiler == none && $runtime == vm ]
[ ($compiler == none || $compiler == precompiler) && ($runtime == vm || $runtime == dart_precompiled) ]
LibTest/typed_data/Float32x4/reciprocalSqrt_A01_t01: Pass, Fail # co19 issue 599
LibTest/typed_data/Float32x4/reciprocal_A01_t01: Pass, Fail # co19 issue 599
Language/Expressions/Instance_Creation/Const/abstract_class_t01: MissingCompileTimeError # Issue 22007
Expand All @@ -48,47 +48,47 @@ Language/Libraries_and_Scripts/Imports/invalid_uri_t02: Fail
Language/Libraries_and_Scripts/Exports/invalid_uri_t02: Fail
Language/Libraries_and_Scripts/Parts/syntax_t06: Fail

[ $runtime == vm ]
[ ($runtime == vm || $runtime == dart_precompiled) ]
LibTest/math/MutableRectangle/MutableRectangle.fromPoints_A01_t01: Pass, RuntimeError # co19-roll r607: Please triage this failure

[ $compiler == none && $runtime == vm && $mode == debug ]
[ ($compiler == none || $compiler == precompiler) && ($runtime == vm || $runtime == dart_precompiled) && $mode == debug ]
LibTest/core/List/List_class_A01_t02: Pass, Slow

[ $compiler == none && $runtime == vm && ($arch != x64 && $arch != simarm64) ]
[ ($compiler == none || $compiler == precompiler) && ($runtime == vm || $runtime == dart_precompiled) && ($arch != x64 && $arch != simarm64) ]
LibTest/core/int/operator_left_shift_A01_t02: Fail # co19 issue 129

[ $compiler == none && $runtime == vm && $arch == mips ]
[ ($compiler == none || $compiler == precompiler) && ($runtime == vm || $runtime == dart_precompiled) && $arch == mips ]
LibTest/core/double/toInt_A01_t01: Fail
# These tests take too much memory (300 MB) for our 1 GB test machine.
# co19 issue 673. http://code.google.com/p/co19/issues/detail?id=673
LibTest/core/List/List_class_A01_t02: Skip # co19 issue 673
LibTest/collection/ListMixin/ListMixin_class_A01_t02: Skip # co19 issue 673
LibTest/collection/ListBase/ListBase_class_A01_t02: Skip # co19 issue 673

[ $compiler == none && $runtime == vm && $arch == mips && $mode == debug ]
[ ($compiler == none || $compiler == precompiler) && ($runtime == vm || $runtime == dart_precompiled) && $arch == mips && $mode == debug ]
LibTest/isolate/Isolate/spawnUri_A01_t04: Crash, Pass # Issue 17440
LibTest/isolate/Isolate/spawn_A01_t04: Crash, Pass # Issue 17440

[ $compiler == none && $runtime == vm && ($arch == simarm || $arch == simarmv5te || $arch == simmips || $arch == simarm64) ]
[ ($compiler == none || $compiler == precompiler) && ($runtime == vm || $runtime == dart_precompiled) && ($arch == simarm || $arch == simarmv5te || $arch == simmips || $arch == simarm64) ]
LibTest/core/Uri/Uri_A06_t03: Skip # Timeout
LibTest/collection/ListMixin/ListMixin_class_A01_t01: Skip # Timeout
LibTest/collection/ListBase/ListBase_class_A01_t01: Skip # Timeout
LibTest/collection/ListMixin/ListMixin_class_A01_t02: Skip # Timeout
LibTest/collection/ListBase/ListBase_class_A01_t02: Skip # Timeout

[ $runtime == vm ]
[ ($runtime == vm || $runtime == dart_precompiled) ]
LibTest/isolate/Isolate/spawn_A02_t01: Skip # co19 issue 667
LibTest/html/*: SkipByDesign # dart:html not supported on VM.
LayoutTests/fast/*: SkipByDesign # DOM not supported on VM.
WebPlatformTest/*: SkipByDesign # dart:html not supported on VM.

[ $runtime == vm && $mode == debug && $builder_tag == asan ]
[ ($runtime == vm || $runtime == dart_precompiled) && $mode == debug && $builder_tag == asan ]
Language/Types/Interface_Types/subtype_t27: Skip # Issue 21174.

[ $runtime == vm && $arch == arm ]
[ ($runtime == vm || $runtime == dart_precompiled) && $arch == arm ]
LibTest/typed_data/Float32x4/operator_multiplication_A01_t01: Fail # Dart issue 24416

[ $runtime == vm ]
[ ($runtime == vm || $runtime == dart_precompiled) ]
# co19 update Sep 29, 2015 (3ed795ea02e022ef19c77cf1b6095b7c8f5584d0)
Language/Classes/Constructors/Constant_Constructors/initializer_not_a_constant_t01: MissingCompileTimeError # Please triage this failure
Language/Classes/Constructors/Constant_Constructors/initializer_not_a_constant_t02: MissingCompileTimeError # Please triage this failure
Expand Down Expand Up @@ -131,18 +131,18 @@ Language/Mixins/declaring_constructor_t01: MissingCompileTimeError # Please tria
Language/Mixins/not_object_superclass_t01: MissingCompileTimeError # Please triage this failure
Language/Mixins/reference_to_super_t01: MissingCompileTimeError # Please triage this failure

[ $runtime == vm && $mode == debug ]
[ ($runtime == vm || $runtime == dart_precompiled) && $mode == debug ]
Language/Mixins/Mixin_Application/wrong_type_t02: Crash # Please triage this failure

[ $runtime == vm && $checked ]
[ ($runtime == vm || $runtime == dart_precompiled) && $checked ]
Language/Errors_and_Warnings/static_warning_t01: RuntimeError # Please triage this failure
Language/Errors_and_Warnings/static_warning_t02: RuntimeError # Please triage this failure
Language/Errors_and_Warnings/static_warning_t03: RuntimeError # Please triage this failure
Language/Errors_and_Warnings/static_warning_t04: RuntimeError # Please triage this failure
Language/Errors_and_Warnings/static_warning_t05: RuntimeError # Please triage this failure
Language/Errors_and_Warnings/static_warning_t06: RuntimeError # Please triage this failure

[ $runtime == vm && $noopt ]
[ ($noopt || $compiler == precompiler) ]
LibTest/collection/ListBase/ListBase_class_A01_t02: Pass, Timeout
LibTest/collection/ListMixin/ListMixin_class_A01_t02: Pass, Timeout
LibTest/core/Map/Map_class_A01_t04: Pass, Timeout
Expand All @@ -152,3 +152,6 @@ Language/Mixins/Mixin_Application/error_t02: Pass
Language/Mixins/declaring_constructor_t01: Pass
Language/Expressions/Property_Extraction/Named_Constructor_Extraction/deferred_type_t01: Pass
Language/Metadata/*: Skip # Uses dart:mirrors

[ $runtime == dart_precompiled ]
LibTest/isolate/Isolate/spawnUri*: RuntimeError # Isolate.spawnUri
Loading

0 comments on commit 6b964b8

Please sign in to comment.