Repository navigation
psi: admit shared scalar recasts of fields and borrowed scalars - #6313
Merged
Merged
Conversation
Shared scalar representation recasts of record fields and borrowed scalars (such as `@cell.other as @i8` and `byte as @i8`) now check, run in Psi, and agree with native Windows x86_64 execution. Previously, the compiler refused every such recast during descriptor replay or returned-reference analysis, and native code generation encoded the source scalar's storage codec rather than the target view's codec. Three gaps in the shared representation-view path caused these failures: - In `locations.rs` (`descriptor_location_with`, `view_element_descriptor_prefix`, `resolved_path_with`, and `resolved_tip_with`), walking a `RepresentationView` segment required a preceding structural type declaration, which failed whenever the prefix ended at an inline scalar field. Handling `RepresentationView` before requiring a structural declaration (matching `primitive_place.rs` while still rejecting case namespaces, opaque types, references, and atomic cells) preserves the descriptor's origin account. - In `descriptor_regions.rs` (`append_projection` and `reference_sources_for_leaves`), returned reference origins did not admit `StructuralPathSegment::RepresentationView`, causing machines returning `@cell.other as @i8` or `byte as @i8` to fail returned-origin construction. - In `instruction_selection/selection/inputs.rs`, `EstablishReference` stored `storage.stored_scalar` (for example `u8`, unsigned) as the scalar reference's runtime codec instead of the presented `semantic_scalar` (`i8`, signed) for same-width recasts, causing `LoadEncodedScalar` on x86_64 to zero-extend `0xFF` to `255` instead of sign-extending it to `-1`. Unproved recasts to targets with invalid bit patterns (such as `@cell.other as @bool` or `byte as @bool`) remain refused, and competing writes while a recast view is live still reject. Updated `representation_views::scalar_reference_recasts_keep_their_backing_and_presented_fields` (replacing its temporary refusal assertion with acceptance, Psi execution, and competing-write rejection), added `shared_scalar_recasts_of_fields_and_borrowed_scalars_read_and_return_views` with negative twins, added `shared_scalar_recasts_of_fields_and_borrowed_scalars_agree_natively_and_in_psi` in `domain_access_field_observations.rs`, and removed the resolved sentences from `TASKS.md`. Gate: RC-SOURCE-SEMANTICS | Shared scalar representation recasts of fields and borrowed scalars check, run in Psi, and agree natively on Windows x86_64 Spec: wiki/spec/layouts/recasts.md#shared-and-mutable-views Proof: mbx test -p terminal-semantics --lib (332 passed), mbx test -p lowered-program-to-checked-program --lib representation_views (11 passed, updated scalar_reference_recasts_keep_their_backing_and_presented_fields from temporary refusal check to acceptance + Psi execution), mbx test -p omega --test domain_access_field_observations shared_scalar_recasts_of_fields_and_borrowed_scalars_agree_natively_and_in_psi (passed, native Windows x86_64 + Psi), mbx clippy --no-deps on touched crates, mbx xtask fmt --check --base origin/main, mbx xtask check-rules, mbx xtask check-boundary | clean (unrelated pre-existing errors in omega tests data_layout_queries.rs and build_dependency_provider_layouts.rs on --all-targets; domain_access_field_observations clean) Agent: Antigravity | Model: unknown | Effort: high | Tokens: 10.81M in (10.51M cached), 43.5k out | Steps: 62 | Time: 36m41s | Steers: 0
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Shared scalar representation recasts of record fields and borrowed scalars (such as
@cell.other as @i8andbyte as @i8) now check, run in Psi, and agree with native Windows x86_64 execution. Previously, the compiler refused every such recast during descriptor replay or returned-reference analysis, and native code generation encoded the source scalar's storage codec rather than the target view's codec.Three gaps in the shared representation-view path caused these failures:
locations.rs(descriptor_location_with,view_element_descriptor_prefix,resolved_path_with, andresolved_tip_with), walking aRepresentationViewsegment required a preceding structural type declaration, which failed whenever the prefix ended at an inline scalar field. HandlingRepresentationViewbefore requiring a structural declaration (matchingprimitive_place.rswhile still rejecting case namespaces, opaque types, references, and atomic cells) preserves the descriptor's origin account.descriptor_regions.rs(append_projectionandreference_sources_for_leaves), returned reference origins did not admitStructuralPathSegment::RepresentationView, causing machines returning@cell.other as @i8orbyte as @i8to fail returned-origin construction.instruction_selection/selection/inputs.rs,EstablishReferencestoredstorage.stored_scalar(for exampleu8, unsigned) as the scalar reference's runtime codec instead of the presentedsemantic_scalar(i8, signed) for same-width recasts, causingLoadEncodedScalaron x86_64 to zero-extend0xFFto255instead of sign-extending it to-1.Unproved recasts to targets with invalid bit patterns (such as
@cell.other as @boolorbyte as @bool) remain refused, and competing writes while a recast view is live still reject.Updated
representation_views::scalar_reference_recasts_keep_their_backing_and_presented_fields(replacing its temporary refusal assertion with acceptance, Psi execution, and competing-write rejection), addedshared_scalar_recasts_of_fields_and_borrowed_scalars_read_and_return_viewswith negative twins, addedshared_scalar_recasts_of_fields_and_borrowed_scalars_agree_natively_and_in_psiindomain_access_field_observations.rs, and removed the resolved sentences fromTASKS.md.Gate: RC-SOURCE-SEMANTICS | Shared scalar representation recasts of fields and borrowed scalars check, run in Psi, and agree natively on Windows x86_64
Spec: wiki/spec/layouts/recasts.md#shared-and-mutable-views
Proof: mbx test -p terminal-semantics --lib (332 passed), mbx test -p lowered-program-to-checked-program --lib representation_views (11 passed, updated scalar_reference_recasts_keep_their_backing_and_presented_fields from temporary refusal check to acceptance + Psi execution), mbx test -p omega --test domain_access_field_observations shared_scalar_recasts_of_fields_and_borrowed_scalars_agree_natively_and_in_psi (passed, native Windows x86_64 + Psi), mbx clippy --no-deps on touched crates, mbx xtask fmt --check --base origin/main, mbx xtask check-rules, mbx xtask check-boundary | clean (unrelated pre-existing errors in omega tests data_layout_queries.rs and build_dependency_provider_layouts.rs on --all-targets; domain_access_field_observations clean)
Agent: Antigravity | Model: unknown | Effort: high | Tokens: 10.81M in (10.51M cached), 43.5k out | Steps: 62 | Time: 36m41s | Steers: 0