-
Notifications
You must be signed in to change notification settings - Fork 160
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
Add Handler for Copying Immutable Plists and Strings #1520
Conversation
Previously the code overwrote the handlers for immutable objects. This didn't show up before because there was only one handler for mutable and immutable objects and the handler checked itself whether an object was immutable. Adding the asserts made this show up.
Codecov Report
@@ Coverage Diff @@
## master #1520 +/- ##
==========================================
- Coverage 64.19% 64.18% -0.01%
==========================================
Files 992 992
Lines 322094 322631 +537
Branches 13072 13243 +171
==========================================
+ Hits 206755 207092 +337
- Misses 112521 112688 +167
- Partials 2818 2851 +33
|
Now also fixes a bug in the installation of string |
CopyBlistImm, CopyPlistImm an CopyStringImm are all actually the same function. Not sure if it is worth combining them. |
What exactly does this gain us? We seem to replace a single function by two, which opens up the possibility for ambiguity, so we end up adding assertions to detect just the ambiguity we just introduced. |
@fingolfin I think you either buy into the dispatch tables or you don't. If you do then it is absolutely natural that immutable objects, which have a different TNUM are handled by a different function. The asserts are basically just to check against someone in the kernel calling the handler directly rather than via the dispatch. |
@stevelinton I generally do "buy" into the dispatch tables, but I have my doubts for this particular case. Indeed, I was thinking about the whole "IMMUTABLE is a bit in the TNUM" business. It might actually simplify things to get rid of that, and turn #define IS_MUTABLE_OBJ(obj) \
((*IsMutableObjFuncs[ TNUM_OBJ(obj) ])( obj )) by static inline int IS_MUTABLE_OBJ(Obj obj) {
UInt tnum = TNUM_OBJ(obj);
if (tnum <= LAST_IMM_MUT_TNUM)
return TEST_OBJ_FLAG(obj, IMMUTABLE_FLAG);
return ((*IsMutableObjFuncs[ tnum ])( obj ));
} |
@fingolfin That makes sense. I hadn't come across OBJ_FLAGS before. Way back when, object headers were 2 32 bit words and there wasn't room for anything else. Now I guess there are a few spare bits even in 64 bit, as long as we think it's OK to limit object sizes to 256TB or so (should be OK for a few more years). We should probably use them for copying as well. |
If we hit the dreaded 48 bit / 256 TB barrier one day, we can simply adjust So I am not concerned ;-) And yes, Anyway, that's why I would kind of prefer to rewrite the COPYING code, say by using the traversal code introduced by HPC-GAP. @rbehrends made some ominous remarks on how one could be much faster by somehow using an array plus a "COPIED" bit, but I have no idea what he had in mind, and he has not responded to my request for an explanation. |
All sounds sensible to me. |
This does the same for Plists and String Objects as is done for Blists in #1514, and adds
GAP_ASSERT
s