mirror of
https://github.com/dart-lang/sdk
synced 2024-09-05 08:24:39 +00:00
[kernel/vm] Address follow-up review comments for bytecode generation
Change-Id: Ifa9dd128ef7179ec521c893ac567b0f81ba5e306 Reviewed-on: https://dart-review.googlesource.com/53120 Reviewed-by: Martin Kustermann <kustermann@google.com> Reviewed-by: Peter von der Ahé <ahe@google.com> Commit-Queue: Alexander Markov <alexmarkov@google.com>
This commit is contained in:
parent
73768a5342
commit
2929b71aa2
|
@ -11,7 +11,7 @@ import 'dart:io' show File, Platform, exitCode;
|
|||
import 'package:compiler/src/kernel/dart2js_target.dart' show Dart2jsTarget;
|
||||
|
||||
import 'package:vm/bytecode/gen_bytecode.dart'
|
||||
show generateBytecode, kEnableKernelBytecodeForPlatform;
|
||||
show generateBytecode, isKernelBytecodeEnabledForPlatform;
|
||||
|
||||
import 'package:vm/target/dart_runner.dart' show DartRunnerTarget;
|
||||
|
||||
|
@ -89,7 +89,7 @@ Future compilePlatformInternal(
|
|||
new File.fromUri(outlineOutput).writeAsBytesSync(result.summary);
|
||||
c.options.ticker.logMs("Wrote outline to ${outlineOutput.toFilePath()}");
|
||||
|
||||
if (kEnableKernelBytecodeForPlatform) {
|
||||
if (isKernelBytecodeEnabledForPlatform) {
|
||||
generateBytecode(result.component, strongMode: c.options.strongMode);
|
||||
}
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ import 'package:kernel/target/targets.dart' show TargetFlags;
|
|||
import 'package:kernel/target/vm.dart' show VmTarget;
|
||||
import 'package:kernel/text/ast_to_text.dart'
|
||||
show globalDebuggingNames, NameSystem;
|
||||
import 'package:vm/bytecode/gen_bytecode.dart' show kEnableKernelBytecode;
|
||||
import 'package:vm/bytecode/gen_bytecode.dart' show isKernelBytecodeEnabled;
|
||||
import 'package:vm/kernel_front_end.dart' show compileToKernel, ErrorDetector;
|
||||
|
||||
final ArgParser _argParser = new ArgParser(allowTrailingOptions: true)
|
||||
|
@ -39,7 +39,7 @@ final ArgParser _argParser = new ArgParser(allowTrailingOptions: true)
|
|||
..addMultiOption('entry-points',
|
||||
help: 'Path to JSON file with the list of entry points')
|
||||
..addFlag('gen-bytecode',
|
||||
help: 'Generate bytecode', defaultsTo: kEnableKernelBytecode);
|
||||
help: 'Generate bytecode', defaultsTo: isKernelBytecodeEnabled);
|
||||
|
||||
final String _usage = '''
|
||||
Usage: dart pkg/vm/bin/gen_kernel.dart --platform vm_platform_strong.dill [options] input.dart
|
||||
|
|
|
@ -122,7 +122,7 @@ void addSymbol(Map<String, dynamic> root, String path, String name, int size) {
|
|||
node['t'] = symbolTypeGlobalText;
|
||||
node['value'] = size;
|
||||
depth += 2;
|
||||
root['maxDepth'] = max(root['maxDepth'], depth);
|
||||
root['maxDepth'] = max<int>(root['maxDepth'], depth);
|
||||
}
|
||||
|
||||
/// Convert all children entries from maps to lists.
|
||||
|
|
|
@ -397,8 +397,8 @@ class ConstantArgDesc extends ConstantPoolEntry {
|
|||
'ArgDesc num-args $numArguments, num-type-args $numTypeArgs, names $argNames';
|
||||
|
||||
@override
|
||||
int get hashCode =>
|
||||
(numArguments * 31 + numTypeArgs) * 31 + listHashCode(argNames);
|
||||
int get hashCode => _combineHashes(
|
||||
_combineHashes(numArguments, numTypeArgs), listHashCode(argNames));
|
||||
|
||||
@override
|
||||
bool operator ==(other) =>
|
||||
|
@ -770,9 +770,9 @@ class ConstantInstance extends ConstantPoolEntry {
|
|||
new MapEntry(fieldRef.asField.name.name, valueIndex))}';
|
||||
|
||||
@override
|
||||
int get hashCode =>
|
||||
(classNode.hashCode * 31 + _typeArgumentsConstantIndex) * 31 +
|
||||
mapHashCode(_fieldValues);
|
||||
int get hashCode => _combineHashes(
|
||||
_combineHashes(classNode.hashCode, _typeArgumentsConstantIndex),
|
||||
mapHashCode(_fieldValues));
|
||||
|
||||
@override
|
||||
bool operator ==(other) =>
|
||||
|
@ -844,7 +844,7 @@ class ConstantTypeArgumentsForInstanceAllocation extends ConstantPoolEntry {
|
|||
|
||||
@override
|
||||
int get hashCode =>
|
||||
instantiatingClass.hashCode * 31 + _typeArgumentsConstantIndex;
|
||||
_combineHashes(instantiatingClass.hashCode, _typeArgumentsConstantIndex);
|
||||
|
||||
@override
|
||||
bool operator ==(other) =>
|
||||
|
@ -893,3 +893,6 @@ class ConstantPool {
|
|||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
||||
int _combineHashes(int hash1, int hash2) =>
|
||||
(((hash1 * 31) & 0x3fffffff) + hash2) & 0x3fffffff;
|
||||
|
|
|
@ -20,12 +20,12 @@ import 'package:vm/bytecode/local_vars.dart' show LocalVariables;
|
|||
import 'package:vm/metadata/bytecode.dart';
|
||||
|
||||
/// Flag to toggle generation of bytecode in kernel files.
|
||||
const bool kEnableKernelBytecode = false;
|
||||
const bool isKernelBytecodeEnabled = false;
|
||||
|
||||
/// Flag to toggle generation of bytecode in platform kernel files.
|
||||
const bool kEnableKernelBytecodeForPlatform = kEnableKernelBytecode;
|
||||
const bool isKernelBytecodeEnabledForPlatform = isKernelBytecodeEnabled;
|
||||
|
||||
const bool kTrace = false;
|
||||
const bool isTraceEnabled = false;
|
||||
|
||||
void generateBytecode(Component component, {bool strongMode: true}) {
|
||||
final coreTypes = new CoreTypes(component);
|
||||
|
@ -114,7 +114,7 @@ class BytecodeGenerator extends RecursiveVisitor<Null> {
|
|||
end(node);
|
||||
}
|
||||
} on UnsupportedOperationError catch (e) {
|
||||
if (kTrace) {
|
||||
if (isTraceEnabled) {
|
||||
print('Unable to generate bytecode for $node: $e');
|
||||
}
|
||||
}
|
||||
|
@ -382,7 +382,7 @@ class BytecodeGenerator extends RecursiveVisitor<Null> {
|
|||
enclosingMember = null;
|
||||
enclosingClass = null;
|
||||
metadata.mapping[node] = new BytecodeMetadata(asm.bytecode, cp);
|
||||
if (kTrace) {
|
||||
if (isTraceEnabled) {
|
||||
print('Generated bytecode for $node');
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue