FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Put RefCell around frames member of VirtualMachine. by windelbouwman · Pull Request #706 · RustPython/RustPython · GitHub

Repository navigation

Put RefCell around frames member of VirtualMachine. - #706

Merged
windelbouwman merged 1 commit into
masterfrom
immutable-vm
Mar 22, 2019
Merged

windelbouwman merged 1 commit into
masterfrom
immutable-vm

Conversation

Copy link
Copy Markdown
Contributor

This allows for VirtualMachine to be immutable. This is a first work into the direction that VirtualMachine is immutable.

This enables a few things:

  • Store a virtualmachine reference into each python object (a sort of handle). This would reduce the amount of VirtualMachine passing around.
  • Share the VirtualMachine accross threads in a memory safe way.

OddCoincidence commented Mar 20, 2019 •
edited
Loading

Copy link
Copy Markdown
Contributor

Share the VirtualMachine accross threads in a memory safe way.

Note that RefCell is not Sync so VirtualMachine will not be accessible from multiple threads with this change. A possible way around this would be to change the RefCell to a Mutex and go with @cthulahoops's solution by returning a PyRef<Frame>. (Because Mutex has no map method.)

(This comment actually applies to every other use of RefCell in this project also.)

(This isn't to say we shouldn't merge this PR as it still moves in the right direction of allowing us to change from &mut VirtualMachine to &VirtualMachine everywhere.)

Copy link
Copy Markdown
Contributor Author

I'm aware that this makes it not fully cross thread safe, but it is a good step. We can change each occurence of RefCell into the proper thread safe thing to achieve this.

Note that I would like to merge this first, before the second change which involves a lot of search and replace.

Copy link
Copy Markdown
Contributor Author

I also replaced 'some' occurrences of mut VirtualMachine now.

Copy link
Copy Markdown
Contributor Author

Okay, how to proceed with this change? I see a lot of merge conflicts coming up. Maybe wait with this a little while and redo the changes? Advice and opinions welcome!

Copy link
Copy Markdown
Contributor

Is there a reason to wait? I thought this was ready to merge (prior to the conflicts)

Copy link
Copy Markdown
Collaborator

I would merge the first commit now - it's approved and ready to go.

Then do the big remove all the muts as separate PR - no need to review we all know it's coming and what it does. It's going to cause conflicts with in progress work whenever we do it. (I guess that's equivalent to just fixing the merge conflicts and merging this now.)

Copy link
Copy Markdown
Member

Yeah, I'd recommend rolling back the &mut VM -> &VM to make merging this easier, and then doing everything at once with sed or something.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants


Back | FazBrowse Home | New Git URL