0xMiden / 0xMiden/compiler

Test multiple data segment with a global var that holds a pointer to a data in one of the data segments

Aberta
#574 0 comentários 0 reações 0 responsáveis Ver no GitHub
Linguagem predominante
Rust
Estrelas
115
Forks
84
Merge médio
1d 8h
PRs com merge (30d)
15

Descrição

From https://github.com/0xMiden/compiler/pull/572#issuecomment-3000997752

> My suggestion was that we create a test that does the following:
>
> * Creates a basic component skeleton in HIR
> * In randomized order (e.g. using `[]::shuffle`), insert N non-overlapping data segments (where N is `1..=3`) and 2 global variables. Where one of the global variables is a pointer to data in one of the inserted data segments, one of them is just a simple integer value (like a counter basically) - the differing types here are just to represent global variables that have a dependency on a data segment vs those that don't.
> * Emit a program entrypoint in the component module that reads the value of both global variables and asserts that their values match what is expected. NOTE: The global variable referencing a data segment requires that the data segment contain some non-zero data at the address referenced by the global variable so that this test is useful.
> * Compute the data/global layout for the component, and verify that none of the computed layouts overlap, and that the global variables are always laid out following the last data segment, and that in the case of the global variable that is a pointer; that the computed address of that pointer refers to a location in the corresponding data segment.
> * Convert the component to MASM and execute it to verify that all of the test assertions in the emitted code pass.
>
> The idea here is to capture a few different details:
>
> 1. That the order in which data segments and global variables are encountered during lowering does not affect the correctness of the data layout computed by the backend. If the order of the global variables is random, we'd expect that the order they appear in the final layout could differ, but it should never be the case that they overlap with any of the data segments that were defined.
> 2. That the number of data segments does not affect the correctness of the data layout
> 3. That whether a global variable references data in a data segment or not does not affect the correctness of the data layout (we currently don't do anything that would cause a difference in behavior, but in the future we may, and this will ensure we catch if any changes in behavior break the data layout).
> 4. That the computed layout information is correctly reflected in the compiled code, and verified by executing that code.
> 5. Catch future regressions

Guia de contribuição

Abrir o guia de contribuição

Avaliação

Esta issue ainda não foi avaliada.

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.