Skip to main content

DexPool

Struct DexPool 

Source
pub struct DexPool {
    pub dex_labels: Vec<String>,
    pub order: Vec<String>,
    /* private fields */
}

Fields§

§dex_labels: Vec<String>

Human label per image (“weibo!classes.dex”) for the provenance header; defaults to “dex N” until the CLI names the inputs.

§order: Vec<String>

Class names in insertion order (stable for output).

Implementations§

Source§

impl DexPool

Source

pub fn new() -> Self

Source

pub fn ctor_ref_sigs(&self, class: &str) -> Option<&FxHashSet<String>>

Referenced <init> argument-descriptor set for a class internal name (see ctor_refs). Builds the whole index on first call by scanning every image’s method-id table for <init> refs — cheap (flat table, integer name-idx compare against the interned “” string) and done once for the whole decompile.

Source

pub fn proto_desc_parsed( &self, di: usize, proto_idx: u32, ) -> Arc<MethodDescriptor> ⓘ

Shared MethodDescriptor of a proto (one parse per image).

Source

pub fn type_name_arc(&self, di: usize, type_idx: u32) -> Arc<str> ⓘ

Shared internal class name of a type id (one strip+alloc per image).

Source

pub fn type_java(&self, di: usize, type_idx: u32) -> Arc<JavaType> ⓘ

Shared parsed type of a type id.

Source

pub fn outer_of(&self, name: &str) -> Option<&str>

The outer class of name, from the cached map (borrowed).

Source

pub fn children_of(&self, internal: &str) -> &[String]

Direct nested children of internal (any $ depth 1), cached. (Perf: returns a borrowed slice — the owned-Vec clone ran once per class on 98k-class runs.)

Source

pub fn add_dex(&mut self, dex: DexFile) -> usize

Adds one image; duplicate class names keep their first definition. Returns the image’s index — call set_dex_label with it to give the provenance header a real origin instead of the default “dex N”.

Source

pub fn add_names(&mut self, names: impl IntoIterator<Item = String>)

Registers class NAMES only; the PoolClass (annotation reads included) is materialized on first get. Duplicate class names keep their first definition, matching add_dex. Register class names without any image. Later add_dex_lazy for a real image keeps the first registration (first-wins, matching the eager/lazy builders); names never materialize.

Source

pub fn add_dex_lazy(&mut self, dex: DexFile) -> usize

Source

pub fn add_dex_lazy_arc(&mut self, dex: Arc<DexFile>) -> usize

Lazy registration from a shared image. The two-tier single-class path rebuilds its pool after loading additional images; keeping the parsed image in an Arc avoids re-parsing it on every round.

Source

pub fn set_dex_label(&mut self, idx: usize, label: impl Into<String>)

Label the image at idx (see add_dex).

Source

pub fn len(&self) -> usize

Source

pub fn is_empty(&self) -> bool

Source

pub fn get(&self, internal: &str) -> Option<&PoolClass>

Source

pub fn set_facade_skip_unparsed(&self)

Skip unparsed NameOnly classes during Kotlin facade analysis.

Source

pub fn clear_name_only_miss(&self)

Clear the NameOnly-materialization marker (call before rendering).

Source

pub fn name_only_miss_name(&self) -> Option<String>

Name of the first NameOnly class the renderer requested.

Source

pub fn name_only_misses(&self) -> Vec<String>

Every NameOnly class the renderer requested since the last clear.

Source

pub fn name_only_missed(&self) -> bool

True when rendering needed a class whose image was not parsed.

Source

pub fn materialize_all(&self, threads: usize)

Materialize every lazy entry (parallel across the given chunk count). After this the pool is observationally identical to an eagerly-built one — including the annotation-aware outer-map — while the annotation reads ran on worker threads instead of the serial pool build (~0.2s on weibo).

Source

pub fn has_name(&self, internal: &str) -> bool

Name registered (no materialization).

Source

pub fn dex(&self, idx: usize) -> Option<Arc<DexFile>>

One image as an Arc snapshot (borrows of the snapshot live as long as the caller holds the Arc).

Source

pub fn dex_count(&self) -> usize

Source

pub fn dexes(&self) -> &[Arc<DexFile>]

Raw image list (install-phase whole-program scans).

Source

pub fn root_pkg_segs(&self) -> &FxHashSet<String>

First path segments of every package in the pool (cached once).

Source

pub fn package_simples(&self) -> &FxHashMap<String, Arc<FxHashSet<String>>>

Package → simple names of its direct classes, cached once per pool (the import-collision gate consults it per class — the uncached scan was O(classes²) and 10×’d weixin’s wall time).

Source

pub fn kotlin_facade_map( &self, ) -> &FxHashMap<String, (String, Option<Arc<(FxHashSet<(String, String)>, FxHashSet<String>)>>)>

Kotlin multi-file class facades: the compiler splits a file facade (kotlin.text.StringsKt) into package-private parts (StringsKt__StringsKt, StringsKt__StringsJVMKt) and call sites target the PARTS directly. Java cannot access a package-private class cross-package (“StringsKt__StringsKt在kotlin.text中不是公共的” — 1.4k lark root errors), but the public facade EXTENDS the parts, so static members resolve through it: rewrite the reference’s owner class to the facade. part → base, gated on base existing, being public, and transitively extending the part (static inheritance is the resolution guarantee).

Source

pub fn class_names(&self) -> impl Iterator<Item = &str>

Source

pub fn is_subtype(&self, sub: &str, sup: &str) -> bool

True when sub is assignable to sup (internal names), walking the pool’s hierarchy. Unknown classes are never assignable (conservative).

Source§

impl DexPool

Classes to emit as their own compilation units: top-level classes plus anonymous/local/lambda-shaped ones (clean members render inline).

Source

pub fn snapshot_accessor_code(&self)

Arm image retirement (full-decompile driver only): count one pending class per image by pool ownership. Snapshot every synthetic-static accessor body (the exact predicate inline_accessors uses) as RAW code_item bytes, so cross-image accessor reads during worker runs survive image retirement. Call AFTER materialization and BEFORE arm_retirement; idempotent (first fill wins). Raw memcpy, no decode — accessors are numerous (weixin ~100k) but only a fraction are ever inlined, so decoding stays lazy at the use site. The slice bound covers the fixed header + insns + try items with generous handler slack (accessor tries are vanishingly rare; the snapshot is a deterministic function of the image either way).

Source

pub fn accessor_code(&self, dex_idx: usize, code_off: u32) -> Option<Arc<[u8]>>

Snapshotted accessor code_item bytes, when the snapshot was taken. Parse with CodeItem::parse(&bytes, 0).

Source

pub fn arm_retirement(&self)

Source

pub fn report_class_done(&self, class_name: &str) -> Option<usize>

Report one class finished; Some(image) when it was the image’s last class (driver batches these into release_images).

Source

pub fn release_images(&self, indexes: &[usize])

Release the images’ inflated bytes. Safe: the driver calls this only when every class of each image is emitted or failed; new dex() snapshots still work (tables valid, code accessors empty).

Trait Implementations§

Source§

impl Default for DexPool

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.