Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(265)

Side by Side Diff: tools/testing/dart/compiler_configuration.dart

Issue 1732323005: Toward a green tools/build.py -cprecompiler -rdart_precompiled: (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library compiler_configuration; 5 library compiler_configuration;
6 6
7 import 'dart:io' show 7 import 'dart:io' show
8 Platform; 8 Platform;
9 9
10 import 'runtime_configuration.dart' show 10 import 'runtime_configuration.dart' show
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 return new Dart2jsCompilerConfiguration( 71 return new Dart2jsCompilerConfiguration(
72 isDebug: isDebug, isChecked: isChecked, 72 isDebug: isDebug, isChecked: isChecked,
73 isHostChecked: isHostChecked, useCps: useCps, useSdk: useSdk, 73 isHostChecked: isHostChecked, useCps: useCps, useSdk: useSdk,
74 isCsp: isCsp, extraDart2jsOptions: 74 isCsp: isCsp, extraDart2jsOptions:
75 TestUtils.getExtraOptions(configuration, 'dart2js_options')); 75 TestUtils.getExtraOptions(configuration, 'dart2js_options'));
76 case 'dart2app': 76 case 'dart2app':
77 return new Dart2AppSnapshotCompilerConfiguration( 77 return new Dart2AppSnapshotCompilerConfiguration(
78 isDebug: isDebug, isChecked: isChecked); 78 isDebug: isDebug, isChecked: isChecked);
79 case 'precompiler': 79 case 'precompiler':
80 return new PrecompilerCompilerConfiguration( 80 return new PrecompilerCompilerConfiguration(
81 isDebug: isDebug, isChecked: isChecked); 81 isDebug: isDebug, isChecked: isChecked,
82 arch: configuration['arch']);
82 case 'none': 83 case 'none':
83 return new NoneCompilerConfiguration( 84 return new NoneCompilerConfiguration(
84 isDebug: isDebug, isChecked: isChecked, 85 isDebug: isDebug, isChecked: isChecked,
85 isHostChecked: isHostChecked, useSdk: useSdk); 86 isHostChecked: isHostChecked, useSdk: useSdk);
86 default: 87 default:
87 throw "Unknown compiler '$compiler'"; 88 throw "Unknown compiler '$compiler'";
88 } 89 }
89 } 90 }
90 91
91 CompilerConfiguration._subclass({ 92 CompilerConfiguration._subclass({
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 nativeDirectoryToUri(TestUtils.dartDir.toNativePath()).resolve('sdk/'); 296 nativeDirectoryToUri(TestUtils.dartDir.toNativePath()).resolve('sdk/');
296 Uri preambleDir = sdk.resolve( 297 Uri preambleDir = sdk.resolve(
297 'lib/_internal/js_runtime/lib/preambles/'); 298 'lib/_internal/js_runtime/lib/preambles/');
298 return runtimeConfiguration.dart2jsPreambles(preambleDir) 299 return runtimeConfiguration.dart2jsPreambles(preambleDir)
299 ..add(artifact.filename); 300 ..add(artifact.filename);
300 } 301 }
301 } 302 }
302 303
303 304
304 class PrecompilerCompilerConfiguration extends CompilerConfiguration { 305 class PrecompilerCompilerConfiguration extends CompilerConfiguration {
306 final String arch;
307
305 PrecompilerCompilerConfiguration({ 308 PrecompilerCompilerConfiguration({
306 bool isDebug, 309 bool isDebug,
307 bool isChecked}) 310 bool isChecked,
308 : super._subclass(isDebug: isDebug, isChecked: isChecked); 311 String arch})
312 : super._subclass(isDebug: isDebug, isChecked: isChecked), arch = arch;
309 313
310 int computeTimeoutMultiplier() { 314 int computeTimeoutMultiplier() {
311 int multiplier = 2; 315 int multiplier = 2;
312 if (isDebug) multiplier *= 4; 316 if (isDebug) multiplier *= 4;
313 if (isChecked) multiplier *= 2; 317 if (isChecked) multiplier *= 2;
314 return multiplier; 318 return multiplier;
315 } 319 }
316 320
317 CommandArtifact computeCompilationArtifact( 321 CommandArtifact computeCompilationArtifact(
318 String buildDir, 322 String buildDir,
319 String tempDir, 323 String tempDir,
320 CommandBuilder commandBuilder, 324 CommandBuilder commandBuilder,
321 List arguments, 325 List arguments,
322 Map<String, String> environmentOverrides) { 326 Map<String, String> environmentOverrides) {
323 return new CommandArtifact( 327 return new CommandArtifact(
324 <Command>[ 328 <Command>[
325 this.computeCompilationCommand( 329 this.computeCompilationCommand(
326 tempDir, 330 tempDir,
327 buildDir, 331 buildDir,
328 CommandBuilder.instance, 332 CommandBuilder.instance,
329 arguments, 333 arguments,
334 environmentOverrides),
335 this.computeAssembleCommand(
336 tempDir,
337 buildDir,
338 CommandBuilder.instance,
339 arguments,
340 environmentOverrides),
341 this.computeRemoveAssemblyCommand(
342 tempDir,
343 buildDir,
344 CommandBuilder.instance,
345 arguments,
330 environmentOverrides)], 346 environmentOverrides)],
331 '$tempDir', 347 '$tempDir',
332 'application/dart-precompiled'); 348 'application/dart-precompiled');
333 } 349 }
334 350
335 CompilationCommand computeCompilationCommand( 351 CompilationCommand computeCompilationCommand(
336 String tempDir, 352 String tempDir,
337 String buildDir, 353 String buildDir,
338 CommandBuilder commandBuilder, 354 CommandBuilder commandBuilder,
339 List arguments, 355 List arguments,
340 Map<String, String> environmentOverrides) { 356 Map<String, String> environmentOverrides) {
341 var exec = "$buildDir/dart"; 357 var exec = "$buildDir/dart_no_snapshot";
342 var args = new List(); 358 var args = new List();
343 args.add("tools/precompilation/precompiler.dart");
344 args.add("$buildDir/dart_no_snapshot");
345 args.add("--gen-precompiled-snapshot=$tempDir"); 359 args.add("--gen-precompiled-snapshot=$tempDir");
346 args.addAll(arguments); 360 args.addAll(arguments);
347 361
348 return commandBuilder.getCompilationCommand( 362 return commandBuilder.getCompilationCommand(
349 'precompiler.dart', tempDir, !useSdk, 363 'precompiler', tempDir, !useSdk,
350 bootstrapDependencies(buildDir), 364 bootstrapDependencies(buildDir),
351 exec, args, environmentOverrides); 365 exec, args, environmentOverrides);
352 } 366 }
353 367
368 CompilationCommand computeAssembleCommand(
369 String tempDir,
370 String buildDir,
371 CommandBuilder commandBuilder,
372 List arguments,
373 Map<String, String> environmentOverrides) {
374 var cc, cc_flags, shared, libname;
375 if (Platform.isLinux) {
376 cc = 'gcc';
377 shared = '-shared';
378 libname = 'libprecompiled.so';
379 } else if (Platform.isMacOS) {
380 cc = 'clang';
381 shared = '-dynamiclib';
382 libname = 'libprecompiled.dylib';
383 } else {
384 throw "Platform not supported: ${Platform.name}";
385 }
386
387 if (arch == 'x64') {
388 cc_flags = "-m64";
389 } else if (arch == 'simarm64') {
390 cc_flags = "-m64";
391 } else if (arch == 'simarm') {
392 cc_flags = "-m32";
393 } else if (arch == 'simmips') {
394 cc_flags = "-m32";
395 } else if (arch == 'arm') {
396 cc_flags = "";
397 } else if (arch == 'mips') {
398 cc_flags = "-EL";
399 } else {
400 throw "Architecture not supported: $arch";
401 }
402
403 var exec = cc;
404 var args = [shared,
405 cc_flags,
406 '-o',
407 '$tempDir/$libname',
408 '$tempDir/precompiled.S'];
409
410 return commandBuilder.getCompilationCommand(
411 'assemble', tempDir, !useSdk,
412 bootstrapDependencies(buildDir),
413 exec, args, environmentOverrides);
414 }
415
416 // This step reduces the amount of space needed to run the precompilation
417 // tests by 60%.
418 CompilationCommand computeRemoveAssemblyCommand(
419 String tempDir,
420 String buildDir,
421 CommandBuilder commandBuilder,
422 List arguments,
423 Map<String, String> environmentOverrides) {
424 var exec = 'rm';
425 var args = ['$tempDir/precompiled.S'];
426
427 return commandBuilder.getCompilationCommand(
428 'remove_assembly', tempDir, !useSdk,
429 bootstrapDependencies(buildDir),
430 exec, args, environmentOverrides);
431 }
432
433 List<String> filterVmOptions(List<String> vmOptions) {
434 var filtered = new List.from(vmOptions);
435 filtered.removeWhere(
436 (option) => option.startsWith("--optimization-counter-threshold"));
437 filtered.removeWhere(
438 (option) => option.startsWith("--optimization_counter_threshold"));
439 return filtered;
440 }
441
354 List<String> computeCompilerArguments(vmOptions, 442 List<String> computeCompilerArguments(vmOptions,
355 sharedOptions, 443 sharedOptions,
356 originalArguments) { 444 originalArguments) {
357 List<String> args = []; 445 List<String> args = [];
358 if (isChecked) { 446 if (isChecked) {
359 args.add('--enable_asserts'); 447 args.add('--enable_asserts');
360 args.add('--enable_type_checks'); 448 args.add('--enable_type_checks');
361 } 449 }
362 return args 450 return args
363 ..addAll(vmOptions) 451 ..addAll(filterVmOptions(vmOptions))
364 ..addAll(sharedOptions) 452 ..addAll(sharedOptions)
365 ..addAll(originalArguments); 453 ..addAll(originalArguments);
366 } 454 }
367 455
368 List<String> computeRuntimeArguments( 456 List<String> computeRuntimeArguments(
369 RuntimeConfiguration runtimeConfiguration, 457 RuntimeConfiguration runtimeConfiguration,
370 String buildDir, 458 String buildDir,
371 TestInformation info, 459 TestInformation info,
372 List<String> vmOptions, 460 List<String> vmOptions,
373 List<String> sharedOptions, 461 List<String> sharedOptions,
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
531 RuntimeConfiguration runtimeConfiguration, 619 RuntimeConfiguration runtimeConfiguration,
532 String buildDir, 620 String buildDir,
533 TestInformation info, 621 TestInformation info,
534 List<String> vmOptions, 622 List<String> vmOptions,
535 List<String> sharedOptions, 623 List<String> sharedOptions,
536 List<String> originalArguments, 624 List<String> originalArguments,
537 CommandArtifact artifact) { 625 CommandArtifact artifact) {
538 return <String>[]; 626 return <String>[];
539 } 627 }
540 } 628 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698