-
Notifications
You must be signed in to change notification settings - Fork 165
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
Factor out state #579
Factor out state #579
Conversation
This is taken directly from HPC-GAP where part of this structure is the TLS structure.
f521be8
to
7465104
Compare
@@ -71,7 +71,7 @@ | |||
** the statement that was last interpreted (which might have been a | |||
** return-value-statement). | |||
*/ | |||
Obj IntrResult; | |||
/* TL: Obj IntrResult; */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This TL:
prefix is rather cryptic. How about we consistently write something like:
/* Obj IntrResult; -- definition has been moved to InterpreterState */
or so? That would help people trying to understand the code.
This still segfaults. I gather this has something to do with the garbage collector state being messed up, but I haven't found out yet where this happens. If @ChrisJefferson has a quick insight that'd be appreciated. I'll continue hacking at it for now, maybe I'll understand gasman then. |
Two issues. One is easy to fix (need some InitGlobalBag), the other I'm not 100% sure what's going wrong (bags being created at wrong point) but it's easy to fix by calling InitPrintObjStack in InitKernel. Patch follows (as I'm too lazy to push)
|
For the time being just call it in InitKernel. This is created on-demand in HPC-GAP, so it should go back to being created on-demand.
Mhm. There I probably tried doing 2 steps at the same time (and finding again that it's a bad idea). Did you use some magic incantation to find this, or does your system just give you better behaviour than "haha I am going to segfault randomly"? |
Also the current state passes |
Nothing magic, just guessed the problem would be the rearrangement made the GC lose track of something, then scanned through the patch. |
Ah damn, I see what was wrong with my ported HPC-GAP code now I think. Thanks for the pointer, @ChrisJefferson |
Workspaces seem to be broken though (witnessed by the manuals not building) |
Looking more carefully, the whole The easiest option would be to just pop the C arrays you are removing into the struct, rather than replacing them with GAP objects. |
This code does not work with GASMAN since it tries keeping pointers into GASMAN bags.
Note that this is code that I (blindly and stupidly) copied over from HPC-GAP. I'll pay more attention to this stuff in the future. This now passes tests and builds the documentation on my machine. I'll have another look at the differences now. I keep thinking that every module should be able to register its own (global)state with the kernel (obviously without using global variables). With Boehm-GC we could just malloc the state, but with GASMAN we have to me more careful. |
@fingolfin @ChrisJefferson this builds now and passes tests. I am not sure how daring we are with this, but if we want the unification to happen before 4.9 we should probably merge things early and detect problems by using the code. As I commented above, changing names to be more sensible, and rearranging things is in my opinion something we should keep a note of and do post-unification. (Even though for example changing the |
While parts of this patch are a little horrible, my temptation is to merge it, and head towards complete merging. Once that happens, we can then do all kinds of cleanups. |
Weekly tests of the master branch are passing well today, so this could be a good moment to merge this and clean up any problems that may be discovered. |
OK, so let's now merge it and see what happens. |
This pull request is a work-in-progress on the unification of GAP and HPC-GAP.
It takes the approach to remove a lot of globally defined state and put it into a structure currently called
InterpreterState
. Most of the code is taken from thehpcgap-default
branch.This compiles, but immediately segfaults (because of missing initialisation code which I will add next).
This pull request is to be understood as a base for discussion at the moment.
Obviously the first goal is to get GAP and HPC-GAP closer to each other: We mostly copy code from HPC-GAP, but just get rid of state stored in global variables. This is something that is desirable for GAP as well, though we might have a careful think about names (TLS as in ThreadLocalStorage might not be the ideal choice of name), and whether on the long run we want to have a state-struct per module or not.