question about understand interp generate transform code

Open
#109,072 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
25/100
Issue type
Documentation
Clarity
Needs clarification
Activity status
Stale
Tech stack
c
Domain
compilers

Research direction

Start in src/mono/mono/mini/interp/transform.c at generate(), TransformData, interp_add_ins(), and generate_compacted_code(). Trace how td->stack, data_items, and InterpInst are allocated, consumed, and released through the linked line ranges. Done means documenting where the stack state is retained or explaining why it does not need to be copied into InterpMethod.

Written by the indexing model from the issue text.

Description

area-Codegen-Interpreter-mono question

mono interp transfer il code to opcode in generate function: https://github.com/dotnet/runtime/blob/1e5bae2e56180897c95ac3f9adaa5609d14d20b3/src/mono/mono/mini/interp/transform.c#L9424

theTransformData allocate stack at below:
https://github.com/dotnet/runtime/blob/1e5bae2e56180897c95ac3f9adaa5609d14d20b3/src/mono/mono/mini/interp/transform.c#L9501-L9508

and will store the custom data in data_items: https://github.com/dotnet/runtime/blob/1e5bae2e56180897c95ac3f9adaa5609d14d20b3/src/mono/mono/mini/interp/transform.c#L9476

at end of the function generate, I found the opcode or data_items will copy to InterpMethod in below code:

https://github.com/dotnet/runtime/blob/1e5bae2e56180897c95ac3f9adaa5609d14d20b3/src/mono/mono/mini/interp/transform.c#L9584-L9614

and copy InterpInst(allocated in interp_add_ins) at generate_compacted_code:

https://github.com/dotnet/runtime/blob/1e5bae2e56180897c95ac3f9adaa5609d14d20b3/src/mono/mono/mini/interp/transform.c#L9286-L9289

but I could not found the td->stack been copy before being freed at :

https://github.com/dotnet/runtime/blob/1e5bae2e56180897c95ac3f9adaa5609d14d20b3/src/mono/mono/mini/interp/transform.c#L9675-L9688

why not these data not restore to InterpMethod or maybe other place restore it?

could you help me? @BrzVlad

Dominant language
C#
Stars
18.3k
Forks
5.6k
PR merge metrics
PR metrics pending

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from dotnet/runtime

All issues in dotnet/runtime

Similar issues

More C# issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.