mirror of
https://github.com/dart-lang/sdk
synced 2024-09-16 00:58:29 +00:00
Reenable source map tests
- and fixes regressions + add more coverage for the regressed parts Change-Id: Ied0aa54389164650b4fcd8f0363ddabb60c00a77 Reviewed-on: https://dart-review.googlesource.com/20204 Reviewed-by: Sigmund Cherem <sigmund@google.com>
This commit is contained in:
parent
57e05b9d0b
commit
e8e3fb5224
|
@ -189,7 +189,7 @@ abstract class SourceLocation {
|
|||
sourceName == other.sourceName;
|
||||
}
|
||||
|
||||
String get shortText => '${sourceUri.pathSegments.last}:[$line,$column]';
|
||||
String get shortText => '${sourceUri?.pathSegments?.last}:[$line,$column]';
|
||||
|
||||
String toString() => '${sourceUri}:[${line},${column}]';
|
||||
}
|
||||
|
|
|
@ -59,7 +59,7 @@ class InterceptorStubGenerator {
|
|||
}
|
||||
|
||||
/**
|
||||
* Build a JavaScrit AST node for doing a type check on
|
||||
* Build a JavaScript AST node for doing a type check on
|
||||
* [cls]. [cls] must be a non-native interceptor class.
|
||||
*/
|
||||
jsAst.Statement buildInterceptorCheck(ClassEntity cls) {
|
||||
|
|
|
@ -2333,7 +2333,8 @@ class SsaCodeGenerator implements HVisitor, HBlockInformationVisitor {
|
|||
js.Block oldContainer = currentContainer;
|
||||
currentContainer = thenBody;
|
||||
generateThrowWithHelper(_commonElements.throwIndexOutOfRangeException,
|
||||
[node.array, node.reportedIndex]);
|
||||
[node.array, node.reportedIndex],
|
||||
sourceInformation: node.sourceInformation);
|
||||
currentContainer = oldContainer;
|
||||
thenBody = unwrapStatement(thenBody);
|
||||
pushStatement(new js.If.noElse(underOver, thenBody)
|
||||
|
@ -2910,8 +2911,10 @@ class SsaCodeGenerator implements HVisitor, HBlockInformationVisitor {
|
|||
use(node.checkedInput);
|
||||
js.Name methodName =
|
||||
_namer.invocationName(node.receiverTypeCheckSelector);
|
||||
js.Expression call = js.propertyCall(pop(), methodName, []);
|
||||
pushStatement(new js.Return(call));
|
||||
js.Expression call = js.propertyCall(pop(), methodName,
|
||||
[]).withSourceInformation(node.sourceInformation);
|
||||
pushStatement(
|
||||
new js.Return(call).withSourceInformation(node.sourceInformation));
|
||||
}
|
||||
currentContainer = oldContainer;
|
||||
body = unwrapStatement(body);
|
||||
|
@ -2978,14 +2981,22 @@ class SsaCodeGenerator implements HVisitor, HBlockInformationVisitor {
|
|||
_registry.registerStaticUse(
|
||||
new StaticUse.staticInvoke(helperElement, CallStructure.THREE_ARGS));
|
||||
js.Expression helper = _emitter.staticFunctionAccess(helperElement);
|
||||
push(js.js(
|
||||
r'#(#, #, #)', [helper, receiver, typeName, js.js.number(index)]));
|
||||
push(js.js(r'#(#, #, #)', [
|
||||
helper,
|
||||
receiver,
|
||||
typeName,
|
||||
js.js.number(index)
|
||||
]).withSourceInformation(node.sourceInformation));
|
||||
} else {
|
||||
FunctionEntity helperElement = _commonElements.getTypeArgumentByIndex;
|
||||
_registry.registerStaticUse(
|
||||
new StaticUse.staticInvoke(helperElement, CallStructure.TWO_ARGS));
|
||||
js.Expression helper = _emitter.staticFunctionAccess(helperElement);
|
||||
push(js.js(r'#(#, #)', [helper, receiver, js.js.number(index)]));
|
||||
push(js.js(r'#(#, #)', [
|
||||
helper,
|
||||
receiver,
|
||||
js.js.number(index)
|
||||
]).withSourceInformation(node.sourceInformation));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -419,7 +419,8 @@ class SsaSimplifyInterceptors extends HBaseVisitor
|
|||
List<HInstruction> inputs = new List<HInstruction>.from(node.inputs);
|
||||
inputs[0] = constant;
|
||||
instruction = new HInvokeDynamicMethod(
|
||||
selector, mask, inputs, node.instructionType, true);
|
||||
selector, mask, inputs, node.instructionType, true)
|
||||
..sourceInformation = node.sourceInformation;
|
||||
}
|
||||
|
||||
HBasicBlock block = node.block;
|
||||
|
|
|
@ -1423,7 +1423,8 @@ class SsaCheckInserter extends HBaseVisitor implements OptimizationPhase {
|
|||
TypeMask type = indexArgument.isPositiveInteger(closedWorld)
|
||||
? indexArgument.instructionType
|
||||
: closedWorld.commonMasks.positiveIntType;
|
||||
HBoundsCheck check = new HBoundsCheck(indexArgument, length, array, type);
|
||||
HBoundsCheck check = new HBoundsCheck(indexArgument, length, array, type)
|
||||
..sourceInformation = indexNode.sourceInformation;
|
||||
indexNode.block.addBefore(indexNode, check);
|
||||
// If the index input to the bounds check was not known to be an integer
|
||||
// then we replace its uses with the bounds check, which is known to be an
|
||||
|
|
|
@ -15,8 +15,7 @@
|
|||
|
||||
"exclude": [
|
||||
"^tests/compiler/dart2js/data/.*",
|
||||
"^tests/compiler/dart2js/path with spaces/.*",
|
||||
"^tests/compiler/dart2js/sourcemaps/data/.*"
|
||||
"^tests/compiler/dart2js/path with spaces/.*"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
|
|
@ -92,7 +92,6 @@
|
|||
"^tests/compiler/dart2js/simple_inferrer_test\\.dart",
|
||||
"^tests/compiler/dart2js/size_test\\.dart",
|
||||
"^tests/compiler/dart2js/source_map_validator_helper\\.dart",
|
||||
"^tests/compiler/dart2js/sourcemaps/data/invokes_test_file\\.dart",
|
||||
"^tests/compiler/dart2js/sourcemaps/diff_view\\.dart",
|
||||
"^tests/compiler/dart2js/sourcemaps/html_parts\\.dart",
|
||||
"^tests/compiler/dart2js/sourcemaps/lax_json\\.dart",
|
||||
|
|
|
@ -39,6 +39,9 @@ invokes(parameter) {
|
|||
|
||||
parameter.dynamicInvoke();
|
||||
new C(parameter).instanceInvokes();
|
||||
new C(parameter).superInvokes();
|
||||
new C(parameter).invalidInvokes();
|
||||
new C(parameter).thisInstanceInvokes();
|
||||
}
|
||||
|
||||
toplevelFunction() {
|
||||
|
@ -108,19 +111,30 @@ class C<T> extends B {
|
|||
|
||||
instanceInvokes() {
|
||||
instanceMethod();
|
||||
this.instanceMethod();
|
||||
instanceField();
|
||||
this.instanceField();
|
||||
instanceGetter();
|
||||
this.instanceGetter();
|
||||
}
|
||||
|
||||
superInvokes() {
|
||||
super.superMethod();
|
||||
super.superField();
|
||||
super.superGetter();
|
||||
}
|
||||
|
||||
invalidInvokes() {
|
||||
// ignore: invocation_of_non_function
|
||||
C();
|
||||
// ignore: undefined_method
|
||||
dynamic();
|
||||
// ignore: invocation_of_non_function
|
||||
F();
|
||||
// ignore: invocation_of_non_function
|
||||
T();
|
||||
}
|
||||
|
||||
thisInstanceInvokes() {
|
||||
this.instanceMethod();
|
||||
this.instanceField();
|
||||
this.instanceGetter();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,6 +14,8 @@ main(args) {
|
|||
counter++;
|
||||
operations(args.length > 0, 0, 1.5, args[0], new Complex(0, 1),
|
||||
new Complex(1.5, 2.5));
|
||||
specialized(args.length > 0, null, 2, []);
|
||||
specialized(args.length > 0, 2, 2, []);
|
||||
return counter;
|
||||
}
|
||||
|
||||
|
@ -45,6 +47,30 @@ void operations(cond, a, b, c, d, e) {
|
|||
if (cond) record(e + e);
|
||||
}
|
||||
|
||||
void specialized(cond, a, b, c) {
|
||||
if (cond) record(a + b);
|
||||
if (cond) record(a & b);
|
||||
if (cond) record(~a);
|
||||
if (cond) record(a | b);
|
||||
if (cond) record(a ^ b);
|
||||
if (cond) record(a / b);
|
||||
if (cond) record(a == b);
|
||||
if (cond) record(a >= b);
|
||||
if (cond) record(a > b);
|
||||
if (cond) record(a <= b);
|
||||
if (cond) record(a < b);
|
||||
if (cond) record(a % b);
|
||||
if (cond) record(a * b);
|
||||
if (cond) record(a << b);
|
||||
if (cond) record(a >> b);
|
||||
if (cond) record(a - b);
|
||||
if (cond) record(a ~/ b);
|
||||
if (cond) record(-a);
|
||||
|
||||
if (cond) record(c[a] = b);
|
||||
if (cond) record(c[a]);
|
||||
}
|
||||
|
||||
class Complex {
|
||||
final num re;
|
||||
final num im;
|
||||
|
|
|
@ -103,8 +103,9 @@ const Map<String, List<String>> TEST_CONFIGURATIONS = const {
|
|||
};
|
||||
|
||||
const Map<String, String> TEST_FILES = const <String, String>{
|
||||
'invokes': 'tests/compiler/dart2js/sourcemaps/invokes_test_file.dart',
|
||||
'operators': 'tests/compiler/dart2js/sourcemaps/operators_test_file.dart',
|
||||
'invokes': 'tests/compiler/dart2js/sourcemaps/data/invokes_test_file.dart',
|
||||
'operators':
|
||||
'tests/compiler/dart2js/sourcemaps/data/operators_test_file.dart',
|
||||
};
|
||||
|
||||
Future<TestResult> runTests(
|
||||
|
|
|
@ -331,6 +331,9 @@ class SourceMapProcessor {
|
|||
backend.sourceInformationStrategy);
|
||||
backend.sourceInformationStrategy = strategy;
|
||||
await compiler.run(inputUri);
|
||||
if (compiler.compilationFailed) {
|
||||
throw "Compilation failed.";
|
||||
}
|
||||
|
||||
SourceMapInfo mainSourceMapInfo;
|
||||
Map<Element, SourceMapInfo> elementSourceMapInfos =
|
||||
|
|
|
@ -483,6 +483,7 @@ String computeDartHtmlPart(String name, SourceFileManager sourceFileManager,
|
|||
StringBuffer dartCodeBuffer = new StringBuffer();
|
||||
Map<Uri, Map<int, List<SourceLocation>>> sourceLocationMap = {};
|
||||
collection.sourceLocations.forEach((SourceLocation sourceLocation) {
|
||||
if (sourceLocation.sourceUri == null || sourceLocation.line == null) return;
|
||||
Map<int, List<SourceLocation>> uriMap =
|
||||
sourceLocationMap.putIfAbsent(sourceLocation.sourceUri, () => {});
|
||||
List<SourceLocation> lineList =
|
||||
|
@ -509,10 +510,12 @@ String computeDartHtmlPart(String name, SourceFileManager sourceFileManager,
|
|||
'${lastLineIndex + windowSize + 1}'
|
||||
'</h4>\n');
|
||||
dartCodeBuffer.write('<pre>\n');
|
||||
dartCodeBuffer.write('<p class="line">');
|
||||
for (int line = firstLineIndex - windowSize;
|
||||
line < firstLineIndex;
|
||||
line++) {
|
||||
if (line >= 0) {
|
||||
dartCodeBuffer.write('</p><p class="line">');
|
||||
dartCodeBuffer.write(lineNumber(line, width: lineNoWidth));
|
||||
dartCodeBuffer.write(sourceFile.kernelSource.getTextLine(line + 1));
|
||||
}
|
||||
|
@ -522,10 +525,12 @@ String computeDartHtmlPart(String name, SourceFileManager sourceFileManager,
|
|||
line <= lastLineIndex + windowSize;
|
||||
line++) {
|
||||
if (line < sourceFile.lines) {
|
||||
dartCodeBuffer.write('</p><p class="line">');
|
||||
dartCodeBuffer.write(lineNumber(line, width: lineNoWidth));
|
||||
dartCodeBuffer.write(sourceFile.kernelSource.getTextLine(line + 1));
|
||||
}
|
||||
}
|
||||
dartCodeBuffer.write('</p>');
|
||||
dartCodeBuffer.write('</pre>\n');
|
||||
firstLineIndex = null;
|
||||
lastLineIndex = null;
|
||||
|
@ -542,6 +547,7 @@ String computeDartHtmlPart(String name, SourceFileManager sourceFileManager,
|
|||
firstLineIndex = lineIndex;
|
||||
} else {
|
||||
for (int line = lastLineIndex + 1; line < lineIndex; line++) {
|
||||
codeBuffer.write('</p><p class="line">');
|
||||
codeBuffer.write(lineNumber(line, width: lineNoWidth));
|
||||
codeBuffer.write(sourceFile.kernelSource.getTextLine(line + 1));
|
||||
}
|
||||
|
@ -557,6 +563,7 @@ String computeDartHtmlPart(String name, SourceFileManager sourceFileManager,
|
|||
end = locations[i + 1].column - 1;
|
||||
}
|
||||
if (i == 0) {
|
||||
codeBuffer.write('</p><p class="line">');
|
||||
codeBuffer.write(lineNumber(lineIndex, width: lineNoWidth));
|
||||
codeBuffer.write(line.substring(0, start));
|
||||
}
|
||||
|
|
|
@ -268,7 +268,10 @@ void main(List<String> arguments) {
|
|||
}
|
||||
|
||||
Future runTest(int index, Test test,
|
||||
{bool printJs: false, bool writeJs, bool verbose: false}) async {
|
||||
{bool printJs: false,
|
||||
bool writeJs,
|
||||
bool verbose: false,
|
||||
List<String> options: const <String>[]}) async {
|
||||
Directory tmpDir = await createTempDir();
|
||||
String input = '${tmpDir.path}/$INPUT_FILE_NAME';
|
||||
new File(input).writeAsStringSync(test.code);
|
||||
|
@ -279,13 +282,16 @@ Future runTest(int index, Test test,
|
|||
'--packages=${Platform.packageConfig}',
|
||||
Flags.useNewSourceInfo,
|
||||
input,
|
||||
];
|
||||
]..addAll(options);
|
||||
print("--$index------------------------------------------------------------");
|
||||
print("Compiling dart2js ${arguments.join(' ')}\n${test.code}");
|
||||
CompilationResult compilationResult = await entry.internalMain(arguments);
|
||||
Expect.isTrue(compilationResult.isSuccess,
|
||||
"Unsuccessful compilation of test:\n${test.code}");
|
||||
String sourceMapText = new File('$output.map').readAsStringSync();
|
||||
File sourceMapFile = new File('$output.map');
|
||||
Expect.isTrue(
|
||||
sourceMapFile.existsSync(), "Source map not generated for $arguments");
|
||||
String sourceMapText = sourceMapFile.readAsStringSync();
|
||||
SingleMapping sourceMap = parse(sourceMapText);
|
||||
|
||||
if (printJs) {
|
||||
|
|
Loading…
Reference in a new issue