Skip to content

Refactor VMStructs#368

Open
zhengyu123 wants to merge 34 commits intomainfrom
zgu/refactor-vmstructs
Open

Refactor VMStructs#368
zhengyu123 wants to merge 34 commits intomainfrom
zgu/refactor-vmstructs

Conversation

@zhengyu123
Copy link
Contributor

@zhengyu123 zhengyu123 commented Feb 17, 2026

What does this PR do?:
This is the first part of efforts to eliminating/reducing dependence on jmethodID.

A significant refactoring of vmStructs.cpp/h that replaces ~60 manual if/strcmp chains in initOffsets() with a declarative, macro-driven system (DECLARE_TYPE_FILED_DO). The core design:

  • Splits the monolithic initOffsets() into init_type_sizes(), init_offsets_and_addresses(), and init_constants()
  • Introduces field_with_version(...) to express per-field JDK version ranges cleanly
  • Adds a verify_offsets() function (debug-only) to catch incomplete initialization
  • Separates pointer-typed fields into offset vs address variants for correctness
  • Standardizes NULL → nullptr, adds cast_to() template with safety assertions

Also fixed memory leak and locking bug in VMStructs::NativeMethodBind()

Motivation:
Code cleanup and reduce maintenance cost.

Additional Notes:
Disable verification phase is due to CI failure with JDK25.
Not sure what are the versions of JDK25 used by CI, but I cannot reproduce the verification failure with Zulu, Temurin and JDK25u local build.

How to test the change?:

For Datadog employees:

  • If this PR touches code that signs or publishes builds or packages, or handles
    credentials of any kind, I've requested a review from @DataDog/security-design-and-guidance.
  • This PR doesn't touch any of that.
  • JIRA: PROF-13808

Unsure? Have a question? Request a review!

@dd-octo-sts
Copy link

dd-octo-sts bot commented Feb 17, 2026

CI Test Results

Run: #23265404314 | Commit: 83fce9b | Duration: 11m 17s (longest job)

All 32 test jobs passed

Status Overview

JDK glibc-aarch64/debug glibc-amd64/debug musl-aarch64/debug musl-amd64/debug
8 - - -
8-ibm - - -
8-j9 - -
8-librca - -
8-orcl - - -
11 - - -
11-j9 - -
11-librca - -
17 - -
17-graal - -
17-j9 - -
17-librca - -
21 - -
21-graal - -
21-librca - -
25 - -
25-graal - -
25-librca - -

Legend: ✅ passed | ❌ failed | ⚪ skipped | 🚫 cancelled

Summary: Total: 32 | Passed: 32 | Failed: 0


Updated: 2026-03-18 20:42:24 UTC

@zhengyu123 zhengyu123 changed the title WIP: Refactor VMStructs Refactor VMStructs Mar 18, 2026
@zhengyu123 zhengyu123 marked this pull request as ready for review March 18, 2026 14:07
@zhengyu123 zhengyu123 requested a review from a team as a code owner March 18, 2026 14:07
@zhengyu123 zhengyu123 marked this pull request as draft March 18, 2026 14:07
@zhengyu123 zhengyu123 marked this pull request as ready for review March 18, 2026 14:46
@pr-commenter
Copy link

pr-commenter bot commented Mar 18, 2026

Integration Tests

All 40 integration tests passed

📊 Dashboard · 👷 Pipeline · 📦 d3a35654

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant