[kernel] add ability to disable offsets for bazel worker to use
This is a lightly modified version of Jennys CL @
https://dart-review.googlesource.com/100275
Change-Id: I46a1665d84d04602af1f338cf963bc25b4e6b25c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/101280
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Kevin Millikin <kmillikin@google.com>
diff --git a/pkg/front_end/lib/src/fasta/kernel/utils.dart b/pkg/front_end/lib/src/fasta/kernel/utils.dart
index 1b96164..c074608 100644
--- a/pkg/front_end/lib/src/fasta/kernel/utils.dart
+++ b/pkg/front_end/lib/src/fasta/kernel/utils.dart
@@ -60,12 +60,15 @@
/// Serialize the libraries in [component] that match [filter].
List<int> serializeComponent(Component component,
- {bool filter(Library library), bool includeSources: true}) {
+ {bool filter(Library library),
+ bool includeSources: true,
+ bool includeOffsets: true}) {
ByteSink byteSink = new ByteSink();
BinaryPrinter printer = filter == null
- ? new BinaryPrinter(byteSink, includeSources: includeSources)
- : new LimitedBinaryPrinter(
- byteSink, filter ?? (_) => true, !includeSources);
+ ? new BinaryPrinter(byteSink,
+ includeSources: includeSources, includeOffsets: includeOffsets)
+ : new LimitedBinaryPrinter(byteSink, filter, !includeSources,
+ includeOffsets: includeOffsets);
printer.writeComponentFile(component);
return byteSink.builder.takeBytes();
}
diff --git a/pkg/kernel/lib/binary/ast_to_binary.dart b/pkg/kernel/lib/binary/ast_to_binary.dart
index 4b3434c..0292314 100644
--- a/pkg/kernel/lib/binary/ast_to_binary.dart
+++ b/pkg/kernel/lib/binary/ast_to_binary.dart
@@ -37,6 +37,7 @@
BufferedSink _constantsSink;
BufferedSink _sink;
bool includeSources;
+ bool includeOffsets;
List<int> libraryOffsets;
List<int> classOffsets;
@@ -57,7 +58,9 @@
/// The BinaryPrinter will use its own buffer, so the [sink] does not need
/// one.
BinaryPrinter(Sink<List<int>> sink,
- {StringIndexer stringIndexer, this.includeSources = true})
+ {StringIndexer stringIndexer,
+ this.includeSources = true,
+ this.includeOffsets = true})
: _mainSink = new BufferedSink(sink),
_metadataSink = new BufferedSink(new BytesSink()),
_constantsBytesSink = new BytesSink(),
@@ -875,7 +878,11 @@
// TODO(jensj): Delta-encoding.
// File offset ranges from -1 and up,
// but is here saved as unsigned (thus the +1)
- writeUInt30(offset + 1);
+ if (!includeOffsets) {
+ writeUInt30(0);
+ } else {
+ writeUInt30(offset + 1);
+ }
}
void writeClassReference(Class class_) {
diff --git a/pkg/kernel/lib/binary/limited_ast_to_binary.dart b/pkg/kernel/lib/binary/limited_ast_to_binary.dart
index 0cef7c7..104cfe6 100644
--- a/pkg/kernel/lib/binary/limited_ast_to_binary.dart
+++ b/pkg/kernel/lib/binary/limited_ast_to_binary.dart
@@ -23,8 +23,11 @@
final bool excludeUriToSource;
LimitedBinaryPrinter(
- Sink<List<int>> sink, this.predicate, this.excludeUriToSource)
- : super(sink, includeSources: !excludeUriToSource);
+ Sink<List<int>> sink, this.predicate, this.excludeUriToSource,
+ {bool includeOffsets = true})
+ : super(sink,
+ includeSources: !excludeUriToSource,
+ includeOffsets: includeOffsets);
@override
void computeCanonicalNames(Component component) {
diff --git a/utils/bazel/kernel_worker.dart b/utils/bazel/kernel_worker.dart
index fdd2348..c2f3c1e 100644
--- a/utils/bazel/kernel_worker.dart
+++ b/utils/bazel/kernel_worker.dart
@@ -291,6 +291,8 @@
incrementalComponent.problemsAsJson = null;
incrementalComponent.mainMethod = null;
target.performOutlineTransformations(incrementalComponent);
+ return Future.value(fe.serializeComponent(incrementalComponent,
+ includeSources: false, includeOffsets: false));
}
return Future.value(fe.serializeComponent(incrementalComponent));