f6af8ccba8
As number of bytecode generation options grows, it becomes cumbersome to add them and propagate from the place where they are parsed to the place where they are used. In order to make it easier to change and add new bytecode generation options, this CL introduces BytecodeOptions class which consolidates all options for bytecode generation. Also, command line options --emit-bytecode-*** are gathered into a single multi-option --bytecode-options=opt1,opt2,... Also, unused --use-future-bytecode-format option is cleaned up. If needed, it could be easily re-introduced in the new BytecodeOptions. Change-Id: I637bf28ceb4233ead2562afe7ad51c69a99f2d60 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/106965 Reviewed-by: Ryan Macnak <rmacnak@google.com> Commit-Queue: Alexander Markov <alexmarkov@google.com>
64 lines
1.9 KiB
Dart
64 lines
1.9 KiB
Dart
// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
|
|
// for details. All rights reserved. Use of this source code is governed by a
|
|
// BSD-style license that can be found in the LICENSE file.
|
|
|
|
library vm.bytecode.options;
|
|
|
|
/// Collection of options for bytecode generator.
|
|
class BytecodeOptions {
|
|
static Map<String, String> commandLineFlags = {
|
|
'annotations': 'Emit Dart annotations',
|
|
'local-var-info': 'Emit debug information about local variables',
|
|
'show-bytecode-size-stat': 'Show bytecode size breakdown',
|
|
'source-positions': 'Emit source positions',
|
|
};
|
|
|
|
bool enableAsserts;
|
|
bool causalAsyncStacks;
|
|
bool emitSourcePositions;
|
|
bool emitSourceFiles;
|
|
bool emitLocalVarInfo;
|
|
bool emitAnnotations;
|
|
bool omitAssertSourcePositions;
|
|
bool showBytecodeSizeStatistics;
|
|
Map<String, String> environmentDefines;
|
|
|
|
BytecodeOptions(
|
|
{this.enableAsserts = false,
|
|
this.causalAsyncStacks,
|
|
this.emitSourcePositions = false,
|
|
this.emitSourceFiles = false,
|
|
this.emitLocalVarInfo = false,
|
|
this.emitAnnotations = false,
|
|
this.omitAssertSourcePositions = false,
|
|
this.showBytecodeSizeStatistics = false,
|
|
this.environmentDefines = const <String, String>{}}) {
|
|
causalAsyncStacks ??=
|
|
environmentDefines['dart.developer.causal_async_stacks'] == 'true';
|
|
}
|
|
|
|
void parseCommandLineFlags(List<String> flags) {
|
|
if (flags == null) {
|
|
return;
|
|
}
|
|
for (String flag in flags) {
|
|
switch (flag) {
|
|
case 'source-positions':
|
|
emitSourcePositions = true;
|
|
break;
|
|
case 'local-var-info':
|
|
emitLocalVarInfo = true;
|
|
break;
|
|
case 'annotations':
|
|
emitAnnotations = true;
|
|
break;
|
|
case 'show-bytecode-size-stat':
|
|
showBytecodeSizeStatistics = true;
|
|
break;
|
|
default:
|
|
throw 'Unexpected bytecode flag $flag';
|
|
}
|
|
}
|
|
}
|
|
}
|