b6c060a6ab
In addition to passing in the libraries that should be visited to the bytecode generator, also pass the libraries which are needed by the component and either are not in the component or should not be visited (e.g., libraries from the platform when the platform is not included). This way, the bytecode generator can create appropriate LibraryIndexes to detect the use of `dart:` libraries which aren't already in VmTarget.extraIndexedLibraries, and thus in coreTypes.index (e.g., 'dart:ffi'). TEST=pkg/dart2bytecode Cq-Include-Trybots: luci.dart.try:vm-dyn-linux-debug-x64-try,vm-dyn-mac-debug-arm64-try Change-Id: Ic08f2022753950bf639c446c0b2594e1e269872a Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/476760 Commit-Queue: Tess Strickland <sstrickl@google.com> Reviewed-by: Alexander Markov <alexmarkov@google.com>
48 lines
1.7 KiB
Dart
48 lines
1.7 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,
|
|
{Set<Library> extraLoadedLibraries = const {}}) {
|
|
final byteSink = new BytesSink();
|
|
generateBytecode(component, byteSink,
|
|
libraries: libraries,
|
|
extraLoadedLibraries: extraLoadedLibraries,
|
|
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);
|
|
}
|