mirror of
https://github.com/dart-lang/sdk
synced 2024-09-05 16:41:07 +00:00
add debugging compiler flags:
--human-readable-output : generates readable source code in optimized output. --disable-type-optimizations : disables type optimizations. Review URL: https://chromereviews.googleplex.com/3513020 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@70 260f80e4-7a28-3924-810f-c04153c831b5
This commit is contained in:
parent
b4be3ca2fe
commit
02fc5cc91f
|
@ -38,6 +38,10 @@ public class CommandLineOptions {
|
|||
usage = "do not generate output, only analyze")
|
||||
private boolean checkOnly = false;
|
||||
|
||||
@Option(name = "--disable-type-optimizations",
|
||||
usage = "Debugging: disable type optimizations")
|
||||
private boolean disableTypeOptimizations = false;
|
||||
|
||||
@Option(name = "-documentation-lib",
|
||||
usage = "only generate documentation for the given library")
|
||||
private String documentationLibrary = null;
|
||||
|
@ -53,6 +57,10 @@ public class CommandLineOptions {
|
|||
usage = "classes to generate stubs for, comma-separated")
|
||||
private String generateIsolateStubs = null;
|
||||
|
||||
@Option(name = "--human-readable-output",
|
||||
usage = "Debugging: generates human readable javascript output")
|
||||
private boolean generateHumanReadableOutput = false;
|
||||
|
||||
@Option(name = "--ignore-unrecognized-flags", usage = "ignore unrecognized command line flags")
|
||||
private boolean ignoreUnrecognizedFlags = false;
|
||||
|
||||
|
@ -180,6 +188,14 @@ public class CommandLineOptions {
|
|||
return batch;
|
||||
}
|
||||
|
||||
public boolean disableTypeOptimizations() {
|
||||
return disableTypeOptimizations;
|
||||
}
|
||||
|
||||
public boolean generateHumanReadableOutput() {
|
||||
return generateHumanReadableOutput;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enables optimization of the generated JavaScript.
|
||||
*/
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
package com.google.dart.compiler;
|
||||
|
||||
import com.google.dart.compiler.CommandLineOptions.CompilerOptions;
|
||||
import com.google.dart.compiler.metrics.CompilerMetrics;
|
||||
|
||||
import java.io.File;
|
||||
|
@ -87,4 +88,10 @@ public interface CompilerConfiguration {
|
|||
* Return the system library corresponding to the specified "dart:<libname>" spec.
|
||||
*/
|
||||
LibrarySource getSystemLibraryFor(String importSpec);
|
||||
|
||||
/**
|
||||
* Return {@link CompilerOptions} instance.
|
||||
* @return command line options passed to the compiler.
|
||||
*/
|
||||
CompilerOptions getCompilerOptions();
|
||||
}
|
||||
|
|
|
@ -53,7 +53,7 @@ public class DefaultCompilerConfiguration implements CompilerConfiguration {
|
|||
return new DartIsolateStubGenerator(compilerOptions.getIsolateStubClasses(),
|
||||
compilerOptions.getIsolateStubOutputFile());
|
||||
} else if (compilerOptions.shouldOptimize()) {
|
||||
return new ClosureJsBackend();
|
||||
return new ClosureJsBackend(compilerOptions.generateHumanReadableOutput());
|
||||
} else {
|
||||
return new JavascriptBackend();
|
||||
}
|
||||
|
@ -205,4 +205,9 @@ public class DefaultCompilerConfiguration implements CompilerConfiguration {
|
|||
}
|
||||
return new UrlLibrarySource(systemUri, this.systemLibraryManager);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompilerOptions getCompilerOptions() {
|
||||
return compilerOptions;
|
||||
}
|
||||
}
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
package com.google.dart.compiler;
|
||||
|
||||
import com.google.dart.compiler.CommandLineOptions.CompilerOptions;
|
||||
import com.google.dart.compiler.metrics.CompilerMetrics;
|
||||
|
||||
import java.io.File;
|
||||
|
@ -100,4 +101,9 @@ public class DelegatingCompilerConfiguration implements CompilerConfiguration {
|
|||
public LibrarySource getSystemLibraryFor(String importSpec) {
|
||||
return delegate.getSystemLibraryFor(importSpec);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompilerOptions getCompilerOptions() {
|
||||
return delegate.getCompilerOptions();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@ import com.google.common.collect.Maps;
|
|||
import com.google.common.collect.Multimap;
|
||||
import com.google.common.collect.Multimaps;
|
||||
import com.google.common.collect.Multiset;
|
||||
import com.google.dart.compiler.CommandLineOptions.CompilerOptions;
|
||||
import com.google.dart.compiler.DartCompilerContext;
|
||||
import com.google.dart.compiler.DartSource;
|
||||
import com.google.dart.compiler.ast.DartClass;
|
||||
|
@ -308,9 +309,13 @@ public abstract class AbstractJsBackend extends AbstractBackend {
|
|||
Tracer.canTrace() ? Tracer.start(DartEventType.TRANSLATE_TO_JS, "unit",
|
||||
unit.getSourceName()) : null;
|
||||
|
||||
OptimizationStrategy optimizationStrategy = shouldOptimize() ?
|
||||
new BasicOptimizationStrategy(unit, typeProvider) :
|
||||
new NoOptimizationStrategy(unit, typeProvider);
|
||||
CompilerOptions options = context.getCompilerConfiguration().getCompilerOptions();
|
||||
OptimizationStrategy optimizationStrategy;
|
||||
if (shouldOptimize() && !options.disableTypeOptimizations()) {
|
||||
optimizationStrategy = new BasicOptimizationStrategy(unit, typeProvider);
|
||||
} else {
|
||||
optimizationStrategy = new NoOptimizationStrategy(unit, typeProvider);
|
||||
}
|
||||
|
||||
try {
|
||||
TraceEvent normalizeEvent =
|
||||
|
|
|
@ -66,7 +66,18 @@ public class ClosureJsBackend extends AbstractJsBackend {
|
|||
private long totalJsOutputCharCount;
|
||||
|
||||
// Generate "readable" output for debugging
|
||||
private boolean generateHumanReadableOutput = false;
|
||||
private final boolean generateHumanReadableOutput;
|
||||
|
||||
public ClosureJsBackend() {
|
||||
this.generateHumanReadableOutput = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param generateHumanReadableOutput - generates human readable javascript output.
|
||||
*/
|
||||
public ClosureJsBackend(boolean generateHumanReadableOutput) {
|
||||
this.generateHumanReadableOutput = generateHumanReadableOutput;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOutOfDate(DartSource src, DartCompilerContext context) {
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
package com.google.dart.compiler.testing;
|
||||
|
||||
import com.google.dart.compiler.Backend;
|
||||
import com.google.dart.compiler.CommandLineOptions.CompilerOptions;
|
||||
import com.google.dart.compiler.CompilerConfiguration;
|
||||
import com.google.dart.compiler.DartCompilationPhase;
|
||||
import com.google.dart.compiler.LibrarySource;
|
||||
|
@ -109,4 +110,9 @@ public class TestCompilerConfiguration implements CompilerConfiguration {
|
|||
}
|
||||
return new UrlLibrarySource(systemUri, this.systemLibraryManager);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompilerOptions getCompilerOptions() {
|
||||
throw new AssertionError();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue