Skip to content

Commit cebb4a9

Browse files
committed
core: migrate to jdc-core 0.2.17 (Arc<str> IR, FxHash, borrowed APIs)
jdc-core 0.2 moved the machine-neutral IR to Arc<str> payloads and Fx-hashed maps. This ports the JVM front-end: - Expr::Field/Method/New payloads are Arc<str>; Method.desc is Arc<MethodDescriptor>; ConstVal::Str is Arc<str>; Catch.exc is Vec<Arc<str>>. A small JStr bridge keeps the comparisons readable. - Expr::New carries arg_tys: the folded <init> descriptor's formals (the private-inner marker drop keeps it in step with args) for the core's typed-argument rendering; raw `new` sites leave it empty. - The structurer keys fold regions with the core's Fx maps; the textual map is converted at the two with_diamonds call sites. - pool::referenced_outside_nest builds its reverse index once per pool (OnceLock) instead of once per render worker. All 18 workers used to build it simultaneously while contending the pool mutex: JDK 28 image sys time 19.3 s -> 11.1 s, wall 8.2 s -> 5.1 s; rt.jar 3.4 s -> 2.4 s. Verification: - workspace build with zero warnings; all tests green; - features 59/59 on both structurer paths (one jdk6 SIGBUS launcher flake with identical output); - jclassd syntax gate: 1 syntax-bad (the established asm '()' baseline); - corpus spot (jdk8, 30 sources): identical stats to the 0.1.11 build (303 methods, 195 byte-equal, same failure set); - rt.jar output differs from 0.1.11 only in the expected core-0.2 shape families: static-member qualifiers, member-access downcast witnesses, redundant-paren cleanup, and the while(true) loop rotation (it drops a fabricated condition that re-evaluated the header call); - deterministic: parallel x2 and JCDC_THREADS=1 byte-identical. Perf (18 cores, medians): rt.jar 2.4 s / 694 MB parallel, 10.0 s / 426 MB single-threaded; JDK 28 image 5.1 s / 947 MB parallel, 25.0 s / 526 MB single-threaded. Both READMEs refreshed.
1 parent 0c46b48 commit cebb4a9

14 files changed

Lines changed: 427 additions & 364 deletions

File tree

‎Cargo.lock‎

Lines changed: 1 addition & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎Cargo.toml‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,9 @@ homepage = "https://github.com/ejfkdev/jcdc"
1313
jcdc-classfile = { path = "crates/classfile", version = "0.1.2" }
1414
jcdc-jvm = { path = "crates/jvm", version = "0.1.2" }
1515
jcdc-decompiler = { path = "crates/decompiler", version = "0.1.2" }
16-
# Pinned to the published 0.1.11 while ../jdc-core carries unreleased
17-
# perf work (0.2.0-pre: Arc<str> IR payloads, FxHash, borrowed group/dom
18-
# APIs). Restore `path = "../jdc-core"` when migrating to 0.2.
19-
jdc-core = "0.1.11"
16+
# Sibling path dep (the release job clones the tag this pin names). 0.2:
17+
# Arc<str> IR payloads, FxHash maps, borrowed group/dom APIs.
18+
jdc-core = { path = "../jdc-core", version = "0.2.17" }
2019
anyhow = "1"
2120
thiserror = "2"
2221
serde = { version = "1", features = ["derive"] }

‎README.md‎

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ fresh Rust implementation.
2525
source corpus in which **100% of decompiled families recompile** with zero
2626
run-mismatches; full `rt.jar` (12,609 classes) renders panic-free and
2727
byte-deterministically on both structurizer pipelines.
28-
- **Fast** — whole `rt.jar` in ~3.6 s and the entire Java 28 runtime image
29-
(27,766 classes) in ~6.2 s on 18 cores, under 1 GB peak RSS (458–945 MB);
28+
- **Fast** — whole `rt.jar` in ~2.4 s and the entire Java 28 runtime image
29+
(27,766 classes) in ~5.1 s on 18 cores, under 1 GB peak RSS (426–947 MB);
3030
parallel by default with deterministic, schedule-independent output.
3131
- **Faithful control flow** — loops/conditions/switch/try-catch-finally
3232
structuring with per-arrival shared-tail copies; source-exact
@@ -48,8 +48,8 @@ cache. Reproduce with [`scripts/bench.sh`](scripts/bench.sh).
4848

4949
| Tool | Wall time | Peak RSS | Units emitted |
5050
|---|---:|---:|---:|
51-
| **jcdc** (parallel — default, 1 worker/core) | **3.6 s** | **684 MB** | 12,609 |
52-
| jcdc (`JCDC_THREADS=1`, single-threaded) | 12.0 s | 458 MB | 12,609 |
51+
| **jcdc** (parallel — default, 1 worker/core) | **2.4 s** | **694 MB** | 12,609 |
52+
| jcdc (`JCDC_THREADS=1`, single-threaded) | 10.0 s | 426 MB | 12,609 |
5353
| Vineflower 1.11.1 | 24.7 s | 8,633 MB | 12,609 |
5454
| CFR 0.152 | 51.9 s | 4,516 MB | 12,609 |
5555
| Procyon 0.6.0 | 108.8 s | 2,218 MB | 12,586 |
@@ -59,8 +59,8 @@ cache. Reproduce with [`scripts/bench.sh`](scripts/bench.sh).
5959

6060
| Tool | Wall time | Peak RSS | Units emitted |
6161
|---|---:|---:|---:|
62-
| **jcdc** (parallel — default) | **6.2 s** | **945 MB** | 15,039 |
63-
| jcdc (`JCDC_THREADS=1`, single-threaded) | 31.6 s | 568 MB | 15,039 |
62+
| **jcdc** (parallel — default) | **5.1 s** | **947 MB** | 15,039 |
63+
| jcdc (`JCDC_THREADS=1`, single-threaded) | 25.0 s | 526 MB | 15,039 |
6464
| CFR 0.152 | 144.7 s | 8,245 MB | 15,012 |
6565
| fernflower (JetBrains) | 497.5 s | 5,108 MB | 15,039 |
6666
| Procyon 0.6.0 | 725.2 s | 6,232 MB | 15,011 |
@@ -76,11 +76,11 @@ entries) with a 16 g heap in 41.5 s — still slower than jcdc's whole-image
7676
run.
7777

7878
Even **single-threaded**, jcdc finishes both workloads faster than every JVM
79-
tool here (12.0 s vs Vineflower's 24.7 s on `rt.jar`), and its whole-run peak
80-
RSS (**458–945 MB** against **2.2–8.7 GB** for the JVM tools) is 2.3×–19×
81-
smaller. With its default parallel pipeline it is ~6.8× faster than
82-
Vineflower, ~14× CFR, ~30× Procyon and ~57× fernflower on `rt.jar`, and
83-
~23× (CFR) / ~80× (fernflower) / ~117× (Procyon) faster on the Java 28
79+
tool here (10.0 s vs Vineflower's 24.7 s on `rt.jar`), and its whole-run peak
80+
RSS (**426–947 MB** against **2.2–8.7 GB** for the JVM tools) is 2.3×–20×
81+
smaller. With its default parallel pipeline it is ~10× faster than
82+
Vineflower, ~21× CFR, ~45× Procyon and ~86× fernflower on `rt.jar`, and
83+
~28× (CFR) / ~98× (fernflower) / ~142× (Procyon) faster on the Java 28
8484
image. Emitted-unit counts differ slightly between tools: jcdc folds `$`-named
8585
hidden classes into their family file (and emits `module-info.java`), while
8686
Procyon skips `package-info` files (−23 on `rt.jar`). (jcdc runs with

‎README.zh.md‎

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ Java 源码。设计参考了 fernflower/Vineflower、garlic、CFR、Procyon、K
2323
重编译 → 运行」输出全等;另有 630 个源码族的语料,**反编译产物
2424
100% 可重编译**、零 run-mismatch;完整 `rt.jar`(12,609 个类)在双结构化
2525
管线下零 panic、逐字节确定。
26-
- **快**——18 核机器上整包 `rt.jar` 约 3.6 秒、Java 28 完整运行时镜像
27-
(27,766 个类)约 6.2 秒,峰值内存低于 1GB(458–945MB);默认并行且输出
26+
- **快**——18 核机器上整包 `rt.jar` 约 2.4 秒、Java 28 完整运行时镜像
27+
(27,766 个类)约 5.1 秒,峰值内存低于 1GB(426–947MB);默认并行且输出
2828
与调度无关(确定性)。
2929
- **控制流忠实**——循环/条件/switch/try-catch-finally 结构化 + per-arrival
3030
共享尾拷贝;短路(`&&`/`||`)与 `assert` 习语源码级还原。
@@ -44,8 +44,8 @@ Java 源码。设计参考了 fernflower/Vineflower、garlic、CFR、Procyon、K
4444

4545
| 工具 | 墙钟时间 | 峰值内存 | 产出文件 |
4646
|---|---:|---:|---:|
47-
| **jcdc**(并行——默认,每核 1 worker) | **3.6 秒** | **684 MB** | 12,609 |
48-
| jcdc(`JCDC_THREADS=1` 单线程) | 12.0 秒 | 458 MB | 12,609 |
47+
| **jcdc**(并行——默认,每核 1 worker) | **2.4 秒** | **694 MB** | 12,609 |
48+
| jcdc(`JCDC_THREADS=1` 单线程) | 10.0 秒 | 426 MB | 12,609 |
4949
| Vineflower 1.11.1 | 24.7 秒 | 8,633 MB | 12,609 |
5050
| CFR 0.152 | 51.9 秒 | 4,516 MB | 12,609 |
5151
| Procyon 0.6.0 | 108.8 秒 | 2,218 MB | 12,586 |
@@ -55,8 +55,8 @@ Java 源码。设计参考了 fernflower/Vineflower、garlic、CFR、Procyon、K
5555

5656
| 工具 | 墙钟时间 | 峰值内存 | 产出文件 |
5757
|---|---:|---:|---:|
58-
| **jcdc**(并行——默认) | **6.2 秒** | **945 MB** | 15,039 |
59-
| jcdc(`JCDC_THREADS=1` 单线程) | 31.6 秒 | 568 MB | 15,039 |
58+
| **jcdc**(并行——默认) | **5.1 秒** | **947 MB** | 15,039 |
59+
| jcdc(`JCDC_THREADS=1` 单线程) | 25.0 秒 | 526 MB | 15,039 |
6060
| CFR 0.152 | 144.7 秒 | 8,245 MB | 15,012 |
6161
| fernflower(JetBrains) | 497.5 秒 | 5,108 MB | 15,039 |
6262
| Procyon 0.6.0 | 725.2 秒 | 6,232 MB | 15,011 |
@@ -70,11 +70,11 @@ Java 源码。设计参考了 fernflower/Vineflower、garlic、CFR、Procyon、K
7070
16g 堆 41.5 秒——但仍慢于 jcdc 跑完整镜像。
7171

7272
即便**单线程**,jcdc 跑完两组负载也比这里所有 Java 工具快(`rt.jar` 上
73-
12.0 秒 vs Vineflower 24.7 秒),整轮峰值内存(**458–945 MB**,对比
74-
Java 工具的 **2.2–8.7 GB**)低 2.3×–19×。默认并行管线下:`rt.jar` 上比
75-
Vineflower 快约 6.8 倍、比 CFR 快约 14 倍、比 Procyon 快约 30 倍、比
76-
fernflower 快约 57 倍;Java 28 镜像上比 CFR 快约 23 倍、比 fernflower 快
77-
约 80 倍、比 Procyon 快约 117 倍。各工具产出文件数的细微差异来自归类口径:
73+
10.0 秒 vs Vineflower 24.7 秒),整轮峰值内存(**426–947 MB**,对比
74+
Java 工具的 **2.2–8.7 GB**)低 2.3×–20×。默认并行管线下:`rt.jar` 上比
75+
Vineflower 快约 10 倍、比 CFR 快约 21 倍、比 Procyon 快约 45 倍、比
76+
fernflower 快约 86 倍;Java 28 镜像上比 CFR 快约 28 倍、比 fernflower 快
77+
约 98 倍、比 Procyon 快约 142 倍。各工具产出文件数的细微差异来自归类口径:
7878
jcdc 把 `$` 命名的隐藏类折叠进所属族文件(并输出 `module-info.java`),
7979
Procyon 则跳过 `package-info` 文件(`rt.jar` 上少 23 个)。(jcdc 带
8080
`-cp <jar>` 提供完整类型上下文;Java 工具从输入 jar 自行解析。)

‎crates/cli/src/main.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ fn print_help() {
2929
env!("CARGO_PKG_VERSION")
3030
);
3131
println!();
32-
println!("Decompiles .class files (class version 45-70, Java 1.1-26) back");
32+
println!("Decompiles .class files (class version 45-72, Java 1.1-28) back");
3333
println!("into readable, recompilable Java source.");
3434
println!();
3535
println!("Usage: jcdc [OPTIONS] <INPUT>...");

‎crates/decompiler/src/block.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ impl Cfg {
288288
start: r.start as u32,
289289
end: r.end as u32,
290290
handler: r.handler as u32,
291-
catch_type: r.catch_type.clone(),
291+
catch_type: (r.catch_type.clone()).map(Into::into),
292292
})
293293
.collect();
294294
// The view must be EXACTLY this graph's — including predecessor and

0 commit comments

Comments
 (0)