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
64-bit NaN-boxing support #1655
Conversation
In windows' mpconfigport there's a Anyway when applying the change as per the last commit message I get
anywhere nlr_raise is used (MICROPY_NLR_SETJMP=1 for msvc build). |
Thinking out loud: does this mean that we could add a "compactable" pointer type which perhaps needs a double dereference? It's obviously not as simple as that, but seems like it might be a first step. So if I'm reading this correctly, MICROPY_OBJ_REPR_C could be used on 32-bit machines with a penalty in that the size of an mp_obj_t just increased. And with the appropriate sw floating point support, you could then use 64-bit floats. |
The reason I added MP_OBJ_CAST/MP_OBJ_UNCAST is because I did initial steps of experimenting with compaction and other advanced GC types. |
The GC works with concrete pointers and so the types should reflect this.
9eaff1a
to
f529407
Compare
This allows the mp_obj_t type to be configured to something other than a pointer-sized primitive type. This patch also includes additional changes to allow the code to compile when sizeof(mp_uint_t) != sizeof(void*), such as using size_t instead of mp_uint_t, and various casts.
To use, put the following in mpconfigport.h: #define MICROPY_OBJ_REPR (MICROPY_OBJ_REPR_D) #define MICROPY_FLOAT_IMPL (MICROPY_FLOAT_IMPL_DOUBLE) typedef int64_t mp_int_t; typedef uint64_t mp_uint_t; #define UINT_FMT "%llu" #define INT_FMT "%lld" Currently does not work with native emitter enabled.
f529407
to
758a97f
Compare
Thanks guys, PR updated based on your comments:
Yes, BYTES_PER_WORD is now confusing. In the code it seems to be used exclusively for mp_uint_t and mp_int_t sized things, so should really be BYTES_PER_OBJECT_WORD (or, should just use sizeof(mp_uint_t) in the code itself, this is clearer I think). We can fix this later.
Correct, and it wouldn't use the heap for fp objects. You could also just use double precision heap objects at the moment by #define MICROPY_FLOAT_IMPL (MICROPY_FLOAT_IMPL_DOUBLE). |
I predict people (including me) doing mistakes with that for a long time. It would with having "now set of rules to use for types is: ...", to be able to refer to. |
nlr_raise is fixed, thanks. I ran the tests now and there are some failures but I guess you know about these? Range printing is broken because mp_vprintf does not handle %lld and the float2int 'power of 2'/'power of 10' tests fail, I assume because they make assumptions about float representation. |
And btw, I'm +10 for at least parts of this being merged ASAP, e.g. MP_OBJ_TO_PTR/OBJ_FROM_PTR part. And I thought that this complete patch would be good enough test of MP_OBJ_TO_PTR/OBJ_FROM_PTR, but it apparently won't, as pointers are unaffected by this implementation. So, would be nice to have ability to test them, e.g. by offsetting values back and forth. (But that's a separate feature, which shouldn't block merge of MP_OBJ_TO_PTR/OBJ_FROM_PTR commit itself). |
Yes, there are a few that need fixing, but it can be done later.
Yes, I think it's good to merge all of it now, since it doesn't break anything anymore (with OBJ_RERP_A).
That's not possible to do in a simple way because pointers pointing to ROM can't be linked with an offset (but MP_ROM_PTR is there exactly so you can play with different ways of storing ROM data vs RAM data). |
Merged! See b8cfb0d for last commit.
Yes. I think a 64-bit nan boxing build should be part of Travis. I would like it to be stmhal built with a 64-bit boxing option, but for that we need to get software double precision working (shouldn't be too hard) and then double precision math functions (a lot more work). |
I finally grasped why. Well, then MP_OBJ_FROM_PTR should be (for test we discuss) a macro/inline function which passes-thru address belonging to .text, and offsetting anything else. |
This is now ready for review and merging. It's pretty much the same as #1593, but now I split the conceptual changes into different commits. There are basically 4 types of changes:
It's probably best to look at the individual commits, rather than the whole thing at once.
The last outstanding thing: I think it would be much easier to understand the code if the macros are renamed: MP_OBJ_CAST becomes MP_OBJ_TO_PTR, and MP_OBJ_UNCAST becomes MP_OBJ_FROM_PTR. Unless there are better ideas.