-
Notifications
You must be signed in to change notification settings - Fork 98
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
AST-33: Codegen for Word8/16/32 operations #216
Conversation
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.
So, this means that 0xAB : Word8
is stored as 0xAB000000 : i32
, right?
This does not fly yet: The (current) specification for Vanilla
is that it is a pointer if the last bit is 0, and a scalar otherwise. So it would have to be 0xAB000001 : i32
. You can probably trigger a bug this way if you send a message with your new data types.
(In fact, please do extend test/run-dfinity/data-params.as
as you implement new data types).
The two solutions are:
- Add the tag bit there (and complicate some of the operations), or
- Swap the convention: Pointers are tagged and scalars are not. Andreas originally envisioned this, by representing a pointer to location
x
asx-1
. We’d have to adjust where we call the system API (data.externalize
);Load
andStore
can use the offset to fix that.
If you think we should do the latter, then that should happen on a separate branch first, and well tested, I think. Maybe let’s chat on Slack about it.
to make life easier for arithmetic on Word8/Word16 (#216) (This is with GC disabled.)
|
we have a polymorpic expander now!
of type-driven templating
@nomeata I'd like to make Is there an example for such a thing? You wrote some |
this is not semantics changing, but may reduce the recursion depth
no need to sanitise when we know that the bit is clear
24a55ce Revert "another attempt to go green" dc5e8bc Revert "try go green"
@nomeata I think this is ready for review now. The last bullet point (bounds check on |
into new module UnboxedSmallWord
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.
Ups, forgot to submit this comment.
fix serialisation of Tagged.SmallWord this was a carry-over from before the pointer tagging was changed
instead of memcpy_words_skewed this version is probably more efficient (less calls) ``` asm i32.const 1 call $alloc_words tee_local $x' i32.const 11 i32.store offset=1 get_local $x' get_local $x i32.load offset=5 i32.store offset=5 get_local $x' ```
@nomeata I was going to suggest to have helpers for alloc+store_tag, etc. Will use the |
the resulting code is ``` asm i32.const 2 call $alloc_words tee_local $heap_object i32.const 11 i32.store offset=1 get_local $heap_object get_local $x i32.load offset=5 i32.store offset=5 get_local $heap_object ```
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.
Thanks, good job!
## Changelog for candid: Branch: master Commits: [dfinity/candid@68135b51...8cb12349](dfinity/candid@68135b5...8cb1234) * [`cb117b7b`](dfinity/candid@cb117b7) JS binding for BigInt ([dfinity/candid#215](http://r.duckduckgo.com/l/?uddg=https://github.com/dfinity/candid/issues/215)) * [`8cb12349`](dfinity/candid@8cb1234) release ([dfinity/candid#216](http://r.duckduckgo.com/l/?uddg=https://github.com/dfinity/candid/issues/216))
## Changelog for candid: Branch: master Commits: [dfinity/candid@68135b51...8cb12349](dfinity/candid@68135b5...8cb1234) * [`cb117b7b`](dfinity/candid@cb117b7) JS binding for BigInt ([dfinity/candid#215](http://r.duckduckgo.com/l/?uddg=https://github.com/dfinity/candid/issues/215)) * [`8cb12349`](dfinity/candid@8cb1234) release ([dfinity/candid#216](http://r.duckduckgo.com/l/?uddg=https://github.com/dfinity/candid/issues/216))
## Changelog for ic-hs: Branch: master Commits: [dfinity/ic-hs@e727feca...a5f89cf5](dfinity/ic-hs@e727fec...a5f89cf) * [`99efc33f`](dfinity/ic-hs@99efc33) sync node height before making an update call in compliance tests ([dfinity/ic-hs#213](https://togithub.com/dfinity/ic-hs/issues/213)) * [`4bdf6c35`](dfinity/ic-hs@4bdf6c3) sync node height before getStateCert ([dfinity/ic-hs#214](https://togithub.com/dfinity/ic-hs/issues/214)) * [`f718f74d`](dfinity/ic-hs@f718f74) retry on http status of 429 ([dfinity/ic-hs#215](https://togithub.com/dfinity/ic-hs/issues/215)) * [`a5f89cf5`](dfinity/ic-hs@a5f89cf) add note that DFINITY stopped contributing ([dfinity/ic-hs#216](https://togithub.com/dfinity/ic-hs/issues/216))
## Changelog for ic-hs: Branch: master Commits: [dfinity/ic-hs@e727feca...a5f89cf5](dfinity/ic-hs@e727fec...a5f89cf) * [`99efc33f`](dfinity/ic-hs@99efc33) sync node height before making an update call in compliance tests ([dfinity/ic-hs#213](https://togithub.com/dfinity/ic-hs/issues/213)) * [`4bdf6c35`](dfinity/ic-hs@4bdf6c3) sync node height before getStateCert ([dfinity/ic-hs#214](https://togithub.com/dfinity/ic-hs/issues/214)) * [`f718f74d`](dfinity/ic-hs@f718f74) retry on http status of 429 ([dfinity/ic-hs#215](https://togithub.com/dfinity/ic-hs/issues/215)) * [`a5f89cf5`](dfinity/ic-hs@a5f89cf) add note that DFINITY stopped contributing ([dfinity/ic-hs#216](https://togithub.com/dfinity/ic-hs/issues/216))
## Changelog for ic-hs: Branch: master Commits: [dfinity/ic-hs@e727feca...a5f89cf5](dfinity/ic-hs@e727fec...a5f89cf) * [`99efc33f`](dfinity/ic-hs@99efc33) sync node height before making an update call in compliance tests ([dfinity/ic-hs#213](https://togithub.com/dfinity/ic-hs/issues/213)) * [`4bdf6c35`](dfinity/ic-hs@4bdf6c3) sync node height before getStateCert ([dfinity/ic-hs#214](https://togithub.com/dfinity/ic-hs/issues/214)) * [`f718f74d`](dfinity/ic-hs@f718f74) retry on http status of 429 ([dfinity/ic-hs#215](https://togithub.com/dfinity/ic-hs/issues/215)) * [`a5f89cf5`](dfinity/ic-hs@a5f89cf) add note that DFINITY stopped contributing ([dfinity/ic-hs#216](https://togithub.com/dfinity/ic-hs/issues/216))
## Changelog for ic-hs: Branch: master Commits: [dfinity/ic-hs@e727feca...a5f89cf5](dfinity/ic-hs@e727fec...a5f89cf) * [`99efc33f`](dfinity/ic-hs@99efc33) sync node height before making an update call in compliance tests ([dfinity/ic-hs#213](https://togithub.com/dfinity/ic-hs/issues/213)) * [`4bdf6c35`](dfinity/ic-hs@4bdf6c3) sync node height before getStateCert ([dfinity/ic-hs#214](https://togithub.com/dfinity/ic-hs/issues/214)) * [`f718f74d`](dfinity/ic-hs@f718f74) retry on http status of 429 ([dfinity/ic-hs#215](https://togithub.com/dfinity/ic-hs/issues/215)) * [`a5f89cf5`](dfinity/ic-hs@a5f89cf) add note that DFINITY stopped contributing ([dfinity/ic-hs#216](https://togithub.com/dfinity/ic-hs/issues/216))
Stories:
Word32
specific)Probably nothing interesting for
Word32
. OTOH,Word8
andWord16
are kept in an MSB-aligned format withVanilla
SR
. Carrying operations (add, sub, mul) are correctly working by discarding the ripple. Most logical ops are also not infectious, i.e. won't introduce nonzero bits in the lower part. Thus, the frequent operations come for free.Similarly
Char
can be represented 8-bit-left-shifted asVanilla
.This is the theory, and now also practice, as the tests pass :-)
I managed to keep the generating code mostly uniform, due to the additional bookkeeping being in helpers, that
nop
when nothing is to ne done.I have also (kind-of) implemented a C++-like type based templating mechanism, see
name_of_type
.Word32
(clz
,ctz
,popcnt
)Word8/16
(clz
,ctz
,popcnt
) ---> done in AST-33: Support popcnt/clz/ctz/shrs for Word8/Word16 #238Word32
:shrs
Word8/16
:shrs
(also: revisit implementation, see comment below, AST-33: Word64 and operations #235) ---> done in AST-33: Support popcnt/clz/ctz/shrs for Word8/Word16 #238Word8/16/32/64
:btst
(AST-33: bit-testing of words #239)module UnboxedSmallWord
, probably)charToWord32
andword32ToChar
(**)
word32ToChar
(interpreter and compiler)