Files
sdk/pkg/dart2bytecode/bin/kernel_service.dart
T
Tess Strickland 19d6b1d003 [vm,dyn_modules] Emit script file contents in bytecode when requested.
To enable this for pkg/dart2bytecode/bin/dart2bytecode:
dart2bytecode --bytecode-options=script-file-contents ...

This option is disabled by default, but enabled by the bytecode kernel
service and by the test runner when running in non-product
configurations.

TEST=pkg/vm_service/test/local_variable_declaration

Cq-Include-Trybots: luci.dart.try:vm-dyn-linux-debug-x64-try,vm-aot-dyn-linux-debug-x64-try,vm-aot-dyn-linux-product-x64-try,vm-dyn-mac-debug-arm64-try
Change-Id: Ibeeb7d212f6be27002b972d67867b2581d97a0aa
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/449860
Commit-Queue: Tess Strickland <sstrickl@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2025-09-26 05:06:22 -07:00

47 lines
1.6 KiB
Dart

// Copyright (c) 2025, 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.
import 'dart:typed_data' show Uint8List;
import 'package:dart2bytecode/bytecode_generator.dart' show generateBytecode;
import 'package:dart2bytecode/options.dart' show BytecodeOptions;
import 'package:kernel/ast.dart' show Component, Library;
import 'package:kernel/binary/ast_to_binary.dart' show BytesSink;
import 'package:kernel/class_hierarchy.dart' show ClassHierarchy;
import 'package:kernel/core_types.dart' show CoreTypes;
import 'package:kernel/target/targets.dart' show Target;
import '../../vm/bin/kernel_service.dart' as kernel_service;
Uint8List _generateBytecode(
Component component,
List<Library> libraries,
CoreTypes coreTypes,
ClassHierarchy hierarchy,
Target target,
bool enableAsserts,
) {
final byteSink = new BytesSink();
generateBytecode(component, byteSink,
libraries: libraries,
coreTypes: coreTypes,
hierarchy: hierarchy,
target: target,
options: BytecodeOptions(
enableAsserts: enableAsserts,
emitSourcePositions: true,
emitLocalVarInfo: true,
emitInstanceFieldInitializers: true,
embedSourceText: true,
));
return byteSink.builder.takeBytes();
}
// Wire up bytecode generator to the kernel service to avoid
// circular dependency between package:vm and package:dart2bytecode.
main([args]) {
kernel_service.bytecodeGenerator = _generateBytecode;
return kernel_service.main(args);
}