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

16495-Wrong-source-for-CompiledBlocks-due-to-incorrect-bytecode-to-AST-nodes-mapping #16664

Conversation

tesonep
Copy link
Collaborator

@tesonep tesonep commented May 16, 2024

Fix #16495
When removing an undeclared variable we recompile the methods that are accessing through a message send.
It is a WIP. We need to refactor the code as it is quite ugly to have everything in #at:put:

When removing an undeclared variable we recompile the methods that are accessing through a message send.
@MarcusDenker
Copy link
Member

Ah, nice.

One problem that it does not solve is that of methods on the stack: it will still read/write by message send, but when creating the mapping, it recompiles with the Undeclared now really there and create a wrong mapping.

I was thinking to solve this the following way:

  • when compiling a method with undeclared vars, record the names in a method property
  • add a compiler API to force compiling with reflective read/write for certain names
  • when asking for the AST of a method that has fixed Undeclared reads that was not recompiled, ask the compiler to compile for these variables with a message to access

(this would require some more cleanup before)

I think this would be in addition to this fix and just fixe the case of methods that are not installed.

@tesonep
Copy link
Collaborator Author

tesonep commented May 17, 2024

Fixing the method in the stack is not trivial at all. We usually not do that, for example when we have a deprecation we are doing the same, just changing the method and leaving the old in the stack. The problem with the method in the stack is that will produce bad BC->ast mappings, but that is another story

@MarcusDenker
Copy link
Member

Yes, exactly. I want to improve how we compile the AST by forcing Undeclared compilation for methods that are not repaired. This way the mapping will be in sync

@MarcusDenker
Copy link
Member

MarcusDenker commented May 17, 2024

For the Undeclared recompile there is another case that I completly overlooked before: How do we deal with removing a global (e.g. deleting a class)?

If the variable is still referenced, it will use the pushLiteral bytecode, no message send. But the Variable should now be an UndeclaredVariable, with access done by message send so we can raise the Exception.

We could recompile, but that might be slow.

At some point in the past we checked if a Class was still used after removing it (to cleanup the Undeclared)
And already that destoyed performance to a point that we stopped doing it.

Finding all using methods and recompiling might slow down class removal (e.g. unloading packages) quite a lot

@demarey
Copy link
Contributor

demarey commented May 29, 2024

This PR fixes a loading problem I had on Pharo12.

@MarcusDenker
Copy link
Member

Great! Pablo mentioned that a good idea is to merge this PR as the next step. And we should backport it, too

@MarcusDenker MarcusDenker changed the title [WIP] 16495-Wrong-source-for-CompiledBlocks-due-to-incorrect-bytecode-to-AST-nodes-mapping 16495-Wrong-source-for-CompiledBlocks-due-to-incorrect-bytecode-to-AST-nodes-mapping May 29, 2024
@MarcusDenker MarcusDenker marked this pull request as ready for review May 29, 2024 12:59
@MarcusDenker
Copy link
Member

I remove the WIP Staus from this

@MarcusDenker MarcusDenker merged commit 4121c86 into pharo-project:Pharo13 May 31, 2024
2 checks passed
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.

Wrong source for CompiledBlocks due to incorrect bytecode to AST nodes mapping
3 participants