Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[move][move-vm][rewrite][cleanup] Replace type info with a datatype descriptor pointers in VTables #21132

Open
wants to merge 2 commits into
base: cgsworsd/vm_rewrite_jit_opt
Choose a base branch
from

Conversation

cgswords
Copy link
Contributor

@cgswords cgswords commented Feb 7, 2025

Description

Toward arena values everywhere, and to mirror the current situation for the function pointers in the virtual tables, we swap out types with a DatatypeDescriptor.

Two notes:

  1. This deletes the type instantiation cache, as planned. We can reintroduce something later with more runtime elegance.
  2. The previous implementation would update type depth formulae during execution by grabbing Arc locks to do that. We no longer do this, and instead the VMDispatchTables struct holds the formulae separately. This is toward future-proofing for signatures and type ugradability.

Test plan

Tests all still pass.


Release notes

Check each box that your changes affect. If none of the boxes relate to your changes, release notes aren't required.

For each box you select, include information after the relevant heading that describes the impact of your changes that a user might notice and any actions they must take to implement updates.

  • Protocol:
  • Nodes (Validators and Full nodes):
  • gRPC:
  • JSON-RPC:
  • GraphQL:
  • CLI:
  • Rust SDK:

@cgswords cgswords requested a review from tzakian February 7, 2025 09:38
Copy link

vercel bot commented Feb 7, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
sui-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 8, 2025 0:50am
2 Skipped Deployments
Name Status Preview Comments Updated (UTC)
multisig-toolkit ⬜️ Ignored (Inspect) Visit Preview Feb 8, 2025 0:50am
sui-kiosk ⬜️ Ignored (Inspect) Visit Preview Feb 8, 2025 0:50am

@cgswords cgswords temporarily deployed to sui-typescript-aws-kms-test-env February 7, 2025 09:38 — with GitHub Actions Inactive
Copy link
Contributor

@tzakian tzakian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes look overall good to me, although there are some debug_assert issues that must get fixed before this is ready to go.

Comment on lines +56 to +60
if let Ok(value) = self.0.try_alloc(item) {
Ok(value)
} else {
Err(PartialVMError::new(StatusCode::PACKAGE_ARENA_LIMIT_REACHED))
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit:

Suggested change
if let Ok(value) = self.0.try_alloc(item) {
Ok(value)
} else {
Err(PartialVMError::new(StatusCode::PACKAGE_ARENA_LIMIT_REACHED))
}
self.0.try_alloc(item).map_err(|_| PartialVMError::new(StatusCode::PACKAGE_ARENA_LIMIT_REACHED))

Copy link
Contributor Author

@cgswords cgswords Feb 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I appreciate this is more-concise, but the next PR needs the code like this anyway -- it has a more-complicated Ok case.

pub struct DatatypeDescriptor {
pub abilities: AbilitySet,
pub type_parameters: Vec<DatatypeTyParameter>,
pub name: Identifier,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No needed for this PR, but just for future changes here this name should probably be an IdentifierKey eventually.

package_context,
link_context,
package_context.runtime_id,
package_id,
&module.compiled_module,
)?;
// NB: Note that this assumes the datatype descriptors will live at least as long as the
// vtable -- if that is not true, we _will_ segfault.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to worry about drop order of fields possibly here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We do not: VMPointer forms are only "dropped" in the sense that they are discarded -- the underlying pointer is unmodified. As such, dropping in either order will be safe.

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.

2 participants