[record_use] Remove definition loading unit (#3061)

In `dart2js`, definitions currently include a `loading_unit` property which typically represents the "dominating" loading unit (the shared ancestor of all loading units where that definition is used). 

When assets are associated with a definition, using this definition-level `loading_unit` can lead to assets being loaded too early. For example, if a definition is used in two different deferred loading units, its dominating unit might be the main bundle. Loading the asset in the main bundle defeats the purpose of deferring it.

To fix this, we want to postpone asset loading until one of the actual loading units that uses the definition is loaded. Since every recorded `Call` and `Instance` already includes its own `loading_unit`, the property on the `Definition` itself is redundant and misleading for the web backend.

Closes: https://github.com/dart-lang/native/issues/2986

Issues to be addressed in follow up PRs:

* https://github.com/dart-lang/native/issues/3022
* https://github.com/dart-lang/native/issues/2888

## Changes

### 1. JSON Schema & Syntax
- Removed `loading_unit` from the `Definition` object in `record_use.schema.json`.
- Updated `Recording` to use `identifier` directly as its key property.

### 2. Dart API
- Removed the `Definition` class. `Recordings` now uses `Identifier` as the primary key for the `callsForDefinition` and `instancesForDefinition` maps.
- Added a `TODO` to `Identifier` to rename it to `Definition` in a future refactor ([#2888](https://github.com/dart-lang/native/issues/2888)).
68 files changed
tree: 8c7adecdb674715125fec270f27a1059933eb249
  1. .gemini/
  2. .github/
  3. .idx/
  4. doc/
  5. pkgs/
  6. tool/
  7. .gitignore
  8. AUTHORS
  9. CONTRIBUTING.md
  10. LICENSE
  11. pubspec.yaml
  12. README.md
README.md

Coverage Status

Overview

This repository is home to Dart packages related to FFI and native assets building and bundling.

Documentation

See the doc directory for more documentation.

Packages

PackageDescriptionIssuesVersion
code_assetsThis package contains the Dart API for code assets in hook/build.dart and hook/link.dart.issuespub package
data_assetsThis package contains the Dart API for data assets in hook/build.dart and hook/link.dart.issuespub package
ffiUtilities for working with Foreign Function Interface (FFI) code.issuespub package
ffigenGenerator for FFI bindings, using LibClang to parse C, Objective-C, and Swift files.issuespub package
hooksThis package contains the API for hook/build.dart and hook/link.dart.issuespub package
hooks_runnerThis package is the backend that invokes hook/build.dart and hook/link.dart from Dart and Flutter.issuespub package
jniA library to access JNI from Dart and Flutter that acts as a support library for package:jnigen.issuespub package
jnigenA Dart bindings generator for Java and Kotlin that uses JNI under the hood to interop with Java virtual machine.issuespub package
native_doc_dartifierA library that converts code snippets from other languages into Dart.issuespub package
native_toolchain_cA library to invoke the native C compiler installed on the host machine.issuespub package
objective_cA library to access Objective C from Flutter that acts as a support library for package:ffigen.issuespub package
swift2objcA tool for generating bindings that allow interop between Dart and Swift code.issuespub package
swiftgenA tool for generating bindings that allow interop between Dart and Swift code.issuespub package

External packages

Packages not on this repo but also related to FFI and native assets. ❤️

PackageDescriptionVersion
native_toolchain_cmakeA library to invoke CMake for Dart Native Assets.pub package
native_toolchain_goA library to invoke the native Go compiler installed on the host machine.pub package
native_toolchain_rustA library to invoke the native Rust compiler installed on the host machine.pub package
native_toolchain_rsA library to build and bundle Rust code for Dart Native Assets.pub package

Publishing automation

For information about our publishing automation and release process, see https://github.com/dart-lang/ecosystem/wiki/Publishing-automation.

For additional information about contributing, see our contributing page.