Skip to content

Commit

Permalink
Version 2.1.0-dev.9.2
Browse files Browse the repository at this point in the history
Cherry-pick 2cf0ca3 to dev
Cherry-pick c7e6cdf to dev
Cherry-pick a651838 to dev
Cherry-pick 2085277 to dev
Cherry-pick 0fd4a51 to dev
Cherry-pick be815e1 to dev
Cherry-pick 61df5fd to dev
Cherry-pick d8d6835 to dev
Cherry-pick 9c95624 to dev
Cherry-pick cde4793 to dev
  • Loading branch information
whesse committed Nov 7, 2018
2 parents 2f1b417 + a5b61ca commit 9c07fb6
Show file tree
Hide file tree
Showing 60 changed files with 1,174 additions and 1,215 deletions.
22 changes: 22 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,25 @@
## 2.1.0-dev.9.2

Cherry-pick 2cf0ca381ce33d1e6597c778eb1a915eecdac109 to dev

Cherry-pick c7e6cdf81ca2f6113cc132d85d5f73a9441d3643 to dev

Cherry-pick a6518386520af63764ad40dde3b53e5e160b9bff to dev

Cherry-pick 2085277771bb91d488edb6e6e55552ba7116dd72 to dev

Cherry-pick 0fd4a51e2c805aec79d4d0e42f446f5395c6113a to dev

Cherry-pick be815e1a867d302ad2fbc8db8d7467cfe85319d2 to dev

Cherry-pick 61df5fdec81be4f8f04c18a774147856931ebbb9 to dev

Cherry-pick d8d68358498c83127e26ad1796359146772decad to dev

Cherry-pick 9c95624a6307f09f1cdc49054bdd08125acb6f53 to dev

Cherry-pick cde479301a81f9fbaec3fb007457a4ec8e5a65a7 to dev

## 2.1.0-dev.9.1

Cherry-pick commit 0fe448a99643e149acb2e7e32d7a30eba7dd646d to update the analysis server edit.dartfix protocol.
Expand Down
2 changes: 1 addition & 1 deletion pkg/analysis_server/lib/src/services/correction/fix.dart
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ class DartFixKind {
static const REMOVE_THIS_EXPRESSION =
const FixKind('REMOVE_THIS_EXPRESSION', 50, "Remove this expression");
static const REMOVE_TYPE_ARGUMENTS =
const FixKind('REMOVE_TYPE_ARGUMENTS', 51, "Remove type arguments");
const FixKind('REMOVE_TYPE_ARGUMENTS', 49, "Remove type arguments");
static const REMOVE_TYPE_NAME =
const FixKind('REMOVE_TYPE_NAME', 50, "Remove type name");
static const REMOVE_UNNECESSARY_CAST = const FixKind(
Expand Down
7 changes: 5 additions & 2 deletions pkg/analyzer/lib/src/dart/analysis/library_analyzer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,14 @@ class LibraryAnalyzer {
// TODO(brianwilkerson) Determine whether this await is necessary.
await null;
return PerformanceStatistics.analysis.makeCurrentWhileAsync(() async {
return _analyze();
return analyzeSync();
});
}

Map<FileState, UnitAnalysisResult> _analyze() {
/**
* Compute analysis results for all units of the library.
*/
Map<FileState, UnitAnalysisResult> analyzeSync() {
Map<FileState, CompilationUnit> units = {};

// Parse all files.
Expand Down
46 changes: 21 additions & 25 deletions pkg/compiler/lib/src/io/source_map_builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -211,48 +211,44 @@ class SourceMapBuilder {
void writeMinifiedNames(Map<String, String> minifiedNames,
IndexMap<String> nameMap, StringBuffer buffer) {
bool first = true;
buffer.write('{');
buffer.write('"');
minifiedNames.forEach((String minifiedName, String name) {
if (!first) buffer.write(',');
buffer.write('"');
writeJsonEscapedCharsOn(minifiedName, buffer);
buffer.write('"');
buffer.write(':');
// minifiedNames are valid JS identifiers so they don't need to be escaped
buffer.write(minifiedName);
buffer.write(',');
buffer.write(nameMap[name]);
first = false;
});
buffer.write('}');
buffer.write('"');
}

void writeFrames(
IndexMap<Uri> uriMap, IndexMap<String> nameMap, StringBuffer buffer) {
bool first = true;
buffer.write('[');
var offsetEncoder = DeltaEncoder();
var uriEncoder = DeltaEncoder();
var lineEncoder = DeltaEncoder();
var columnEncoder = DeltaEncoder();
var nameEncoder = DeltaEncoder();
buffer.write('"');
frames.forEach((int offset, List<FrameEntry> entries) {
if (!first) buffer.write(',');
buffer.write('[');
buffer.write(offset);
for (var entry in entries) {
buffer.write(',');
offsetEncoder.encode(buffer, offset);
if (entry.isPush) {
SourceLocation location = entry.pushLocation;
buffer.write('[');
buffer.write(uriMap[location.sourceUri]);
buffer.write(',');
buffer.write(location.line - 1);
buffer.write(',');
buffer.write(location.column - 1);
buffer.write(',');
buffer.write(nameMap[entry.inlinedMethodName]);
buffer.write(']');
uriEncoder.encode(buffer, uriMap[location.sourceUri]);
lineEncoder.encode(buffer, location.line - 1);
columnEncoder.encode(buffer, location.column - 1);
nameEncoder.encode(buffer, nameMap[entry.inlinedMethodName]);
} else {
buffer.write(entry.isEmptyPop ? 0 : -1);
// ; and , are not used by VLQ so we can distinguish them in the
// encoding, this is the same reason they are used in the mappings
// field.
buffer.write(entry.isEmptyPop ? ";" : ",");
}
}
buffer.write(']');
first = false;
});
buffer.write(']');
buffer.write('"');
}

/// Returns the source map tag to put at the end a .js file in [fileUri] to
Expand Down
105 changes: 67 additions & 38 deletions pkg/dart2js_tools/lib/src/dart2js_mapping.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import 'dart:convert';
import 'dart:io';

import 'package:source_maps/source_maps.dart';
import 'package:source_maps/src/vlq.dart';

import 'util.dart';

Expand All @@ -35,48 +36,16 @@ class Dart2jsMapping {
if (extensions == null) return;
var minifiedNames = extensions['minified_names'];
if (minifiedNames != null) {
minifiedNames['global'].forEach((minifiedName, id) {
globalNames[minifiedName] = sourceMap.names[id];
});
minifiedNames['instance'].forEach((minifiedName, id) {
instanceNames[minifiedName] = sourceMap.names[id];
});
_extractMinifedNames(minifiedNames['global'], sourceMap, globalNames);
_extractMinifedNames(minifiedNames['instance'], sourceMap, instanceNames);
}
List jsonFrames = extensions['frames'];
String jsonFrames = extensions['frames'];
if (jsonFrames != null) {
for (List values in jsonFrames) {
if (values.length < 2) {
warn("warning: incomplete frame data: $values");
continue;
}
int offset = values[0];
List<FrameEntry> entries = frames[offset] ??= [];
if (entries.length > 0) {
warn("warning: duplicate entries for $offset");
continue;
}
for (int i = 1; i < values.length; i++) {
var current = values[i];
if (current == -1) {
entries.add(new FrameEntry.pop(false));
} else if (current == 0) {
entries.add(new FrameEntry.pop(true));
} else {
if (current is List) {
if (current.length == 4) {
entries.add(new FrameEntry.push(sourceMap.urls[current[0]],
current[1], current[2], sourceMap.names[current[3]]));
} else {
warn("warning: unexpected entry $current");
}
} else {
warn("warning: unexpected entry $current");
}
}
}
}
new _FrameDecoder(jsonFrames).parseFrames(frames, sourceMap);
}
}

Dart2jsMapping.json(Map json) : this(parseJson(json), json);
}

class FrameEntry {
Expand Down Expand Up @@ -131,3 +100,63 @@ Dart2jsMapping parseMappingFor(Uri uri) {
var json = jsonDecode(sourcemapFile.readAsStringSync());
return new Dart2jsMapping(parseJson(json), json);
}

class _FrameDecoder implements Iterator<String> {
final String _internal;
final int _length;
int index = -1;
_FrameDecoder(this._internal) : _length = _internal.length;

// Iterator API is used by decodeVlq to consume VLQ entries.
bool moveNext() => ++index < _length;

String get current =>
(index >= 0 && index < _length) ? _internal[index] : null;

bool get hasTokens => index < _length - 1 && _length > 0;

int _readDelta() => decodeVlq(this);

void parseFrames(Map<int, List<FrameEntry>> frames, SingleMapping sourceMap) {
var offset = 0;
var uriId = 0;
var nameId = 0;
var line = 0;
var column = 0;
while (hasTokens) {
offset += _readDelta();
List<FrameEntry> entries = frames[offset] ??= [];
var marker = _internal[index + 1];
if (marker == ';') {
entries.add(new FrameEntry.pop(true));
index++;
continue;
} else if (marker == ',') {
entries.add(new FrameEntry.pop(false));
index++;
continue;
} else {
uriId += _readDelta();
var uri = sourceMap.urls[uriId];
line += _readDelta();
column += _readDelta();
nameId += _readDelta();
var name = sourceMap.names[nameId];
entries.add(new FrameEntry.push(uri, line, column, name));
}
}
}
}

_extractMinifedNames(String encodedInput, SingleMapping sourceMap,
Map<String, String> minifiedNames) {
List<String> input = encodedInput.split(',');
if (input.length % 2 != 0) {
warn("expected an even number of entries");
}
for (int i = 0; i < input.length; i += 2) {
String minifiedName = input[i];
int id = int.tryParse(input[i + 1]);
minifiedNames[minifiedName] = sourceMap.names[id];
}
}
14 changes: 6 additions & 8 deletions pkg/dev_compiler/bin/dartdevc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ Future main(List<String> args, [SendPort sendPort]) async {
class _CompilerWorker extends AsyncWorkerLoop {
/// The original args supplied to the executable.
final ParsedArguments _startupArgs;
InitializedCompilerState _compilerState;
CompilerResult _result;

_CompilerWorker(this._startupArgs, AsyncWorkerConnection workerConnection)
: super(connection: workerConnection);
Expand All @@ -47,14 +47,13 @@ class _CompilerWorker extends AsyncWorkerLoop {
Future<WorkResponse> performRequest(WorkRequest request) async {
var args = _startupArgs.merge(request.arguments);
var output = StringBuffer();
var result = await runZoned(
() => compile(args, compilerState: _compilerState), zoneSpecification:
_result = await runZoned(() => compile(args, previousResult: _result),
zoneSpecification:
ZoneSpecification(print: (self, parent, zone, message) {
output.writeln(message.toString());
}));
_compilerState = result.compilerState;
return WorkResponse()
..exitCode = result.success ? 0 : 1
..exitCode = _result.success ? 0 : 1
..output = output.toString();
}
}
Expand All @@ -68,16 +67,15 @@ Future runBatch(ParsedArguments batchArgs) async {
print('>>> BATCH START');

String line;
InitializedCompilerState compilerState;
CompilerResult result;

while ((line = stdin.readLineSync(encoding: utf8))?.isNotEmpty == true) {
totalTests++;
var args = batchArgs.merge(line.split(RegExp(r'\s+')));

String outcome;
try {
var result = await compile(args, compilerState: compilerState);
compilerState = result.compilerState;
result = await compile(args, previousResult: result);
outcome = result.success ? 'PASS' : (result.crashed ? 'CRASH' : 'FAIL');
} catch (e, s) {
outcome = 'CRASH';
Expand Down
Loading

0 comments on commit 9c07fb6

Please sign in to comment.