Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.arch > #29292 > unrolled thread
| Started by | jim.brakefield@ieee.org |
|---|---|
| First post | 2015-08-21 20:11 -0700 |
| Last post | 2015-08-27 20:00 -0700 |
| Articles | 20 on this page of 138 — 30 participants |
Back to article view | Back to comp.arch
Four significant reasons for a 12X word size jim.brakefield@ieee.org - 2015-08-21 20:11 -0700
Re: Four significant reasons for a 12X word size MitchAlsup <MitchAlsup@aol.com> - 2015-08-22 10:18 -0700
Re: Four significant reasons for a 12X word size Quadibloc <jsavard@ecn.ab.ca> - 2015-08-22 12:16 -0700
Re: Four significant reasons for a 12X word size Ivan Godard <ivan@millcomputing.com> - 2015-08-22 12:49 -0700
Re: Four significant reasons for a 12X word size jim.brakefield@ieee.org - 2015-09-01 12:34 -0700
Re: Four significant reasons for a 12X word size Ivan Godard <ivan@millcomputing.com> - 2015-09-01 12:59 -0700
Re: Four significant reasons for a 12X word size jim.brakefield@ieee.org - 2015-09-01 13:29 -0700
Re: Four significant reasons for a 12X word size Ivan Godard <ivan@millcomputing.com> - 2015-09-01 15:36 -0700
Re: Four significant reasons for a 12X word size jim.brakefield@ieee.org - 2015-09-01 17:07 -0700
Re: Four significant reasons for a 12X word size Ivan Godard <ivan@millcomputing.com> - 2015-09-01 18:12 -0700
Re: Four significant reasons for a 12X word size Quadibloc <jsavard@ecn.ab.ca> - 2015-09-01 20:39 -0700
Re: Four significant reasons for a 12X word size Ivan Godard <ivan@millcomputing.com> - 2015-09-01 21:30 -0700
Permute registers (was: Four significant reasons for a 12X word size) Stefan Monnier <monnier@iro.umontreal.ca> - 2015-09-04 15:36 -0400
Re: Permute registers (was: Four significant reasons for a 12X word size) jim.brakefield@ieee.org - 2015-09-04 13:18 -0700
Re: Permute registers Ivan Godard <ivan@millcomputing.com> - 2015-09-04 13:41 -0700
Re: Permute registers Ivan Godard <ivan@millcomputing.com> - 2015-09-04 13:27 -0700
Re: Four significant reasons for a 12X word size Ivan Godard <ivan@millcomputing.com> - 2015-09-01 18:15 -0700
A good Mill intro (external) Ivan Godard <ivan@millcomputing.com> - 2015-09-01 18:43 -0700
Re: Four significant reasons for a 12X word size Quadibloc <jsavard@ecn.ab.ca> - 2015-09-01 20:52 -0700
Re: Four significant reasons for a 12X word size Bruce Hoult <bruce.hoult@gmail.com> - 2015-09-02 04:03 -0700
Re: Four significant reasons for a 12X word size Quadibloc <jsavard@ecn.ab.ca> - 2015-09-02 05:59 -0700
Re: Four significant reasons for a 12X word size Quadibloc <jsavard@ecn.ab.ca> - 2015-09-02 06:11 -0700
Re: Four significant reasons for a 12X word size Bruce Hoult <bruce.hoult@gmail.com> - 2015-09-02 07:15 -0700
Re: Four significant reasons for a 12X word size Chris Gray <cg@GraySage.COM> - 2015-09-02 10:42 -0600
Re: Four significant reasons for a 12X word size Anssi Saari <as@sci.fi> - 2015-09-03 11:32 +0300
Re: Four significant reasons for a 12X word size Quadibloc <jsavard@ecn.ab.ca> - 2015-09-02 10:03 -0700
Re: Four significant reasons for a 12X word size Bruce Hoult <bruce.hoult@gmail.com> - 2015-09-02 11:54 -0700
Re: Four significant reasons for a 12X word size Chris Gray <cg@GraySage.COM> - 2015-09-03 11:00 -0600
Re: Four significant reasons for a 12X word size Bruce Hoult <bruce.hoult@gmail.com> - 2015-09-03 10:11 -0700
Re: Four significant reasons for a 12X word size Jan Coombs <Jan-54 <jenfhaomndgfwutc@murmic.plus.com>> - 2015-09-04 09:35 +0100
Re: Four significant reasons for a 12X word size jim.brakefield@ieee.org - 2015-08-22 12:51 -0700
Re: Four significant reasons for a 12X word size Quadibloc <jsavard@ecn.ab.ca> - 2015-08-22 13:11 -0700
Re: Four significant reasons for a 12X word size BGB <cr88192@hotmail.com> - 2015-08-23 11:14 -0500
Re: Four significant reasons for a 12X word size jim.brakefield@ieee.org - 2015-08-23 11:13 -0700
Re: Four significant reasons for a 12X word size BGB <cr88192@hotmail.com> - 2015-08-23 14:33 -0500
Re: Four significant reasons for a 12X word size thomas.entner99@gmail.com - 2015-08-23 16:23 -0700
Re: Four significant reasons for a 12X word size Quadibloc <jsavard@ecn.ab.ca> - 2015-08-23 17:43 -0700
Re: Four significant reasons for a 12X word size thomas.entner99@gmail.com - 2015-08-23 18:00 -0700
Re: Four significant reasons for a 12X word size jim.brakefield@ieee.org - 2015-08-23 19:14 -0700
Re: Four significant reasons for a 12X word size BGB <cr88192@hotmail.com> - 2015-08-23 20:00 -0500
Re: Four significant reasons for a 12X word size Bruce Hoult <bruce.hoult@gmail.com> - 2015-08-24 04:59 -0700
Re: Four significant reasons for a 12X word size Terje Mathisen <terje.mathisen@tmsw.no> - 2015-08-24 18:45 +0200
Re: Four significant reasons for a 12X word size nmm@needham.csi.cam.ac.uk (Nick Maclaren) - 2015-08-24 19:09 +0100
Re: Four significant reasons for a 12X word size jim.brakefield@ieee.org - 2015-08-24 13:31 -0700
Re: Four significant reasons for a 12X word size Quadibloc <jsavard@ecn.ab.ca> - 2015-08-24 14:09 -0700
Re: Four significant reasons for a 12X word size jgd@cix.co.uk (John Dallman) - 2015-08-24 22:26 +0100
Re: Four significant reasons for a 12X word size anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2015-08-25 10:29 +0000
Re: Four significant reasons for a 12X word size Quadibloc <jsavard@ecn.ab.ca> - 2015-08-24 16:22 -0700
Re: Four significant reasons for a 12X word size MitchAlsup <MitchAlsup@aol.com> - 2015-08-24 16:58 -0700
Re: Four significant reasons for a 12X word size Quadibloc <jsavard@ecn.ab.ca> - 2015-08-24 18:48 -0700
Re: Four significant reasons for a 12X word size anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2015-08-25 09:04 +0000
Re: Four significant reasons for a 12X word size BGB <cr88192@hotmail.com> - 2015-08-25 09:32 -0500
Re: Four significant reasons for a 12X word size Bruce Hoult <bruce.hoult@gmail.com> - 2015-08-25 10:30 -0700
Re: Four significant reasons for a 12X word size Terje Mathisen <terje.mathisen@tmsw.no> - 2015-08-25 21:27 +0200
Re: Four significant reasons for a 12X word size Bruce Hoult <bruce.hoult@gmail.com> - 2015-08-25 13:51 -0700
Re: Four significant reasons for a 12X word size Terje Mathisen <terje.mathisen@tmsw.no> - 2015-08-26 08:31 +0200
Re: Four significant reasons for a 12X word size MitchAlsup <MitchAlsup@aol.com> - 2015-08-25 16:56 -0700
Re: Four significant reasons for a 12X word size Ivan Godard <ivan@millcomputing.com> - 2015-08-25 17:36 -0700
Re: Four significant reasons for a 12X word size BGB <cr88192@hotmail.com> - 2015-08-25 20:10 -0500
Re: Four significant reasons for a 12X word size Bruce Hoult <bruce.hoult@gmail.com> - 2015-08-26 02:41 -0700
Re: Four significant reasons for a 12X word size BGB <cr88192@hotmail.com> - 2015-08-26 09:28 -0500
Re: Four significant reasons for a 12X word size Waldek Hebisch <hebisch@antispam.uni.wroc.pl> - 2015-08-27 00:53 +0000
Re: Four significant reasons for a 12X word size jgk@panix.com (Joe keane) - 2015-08-25 18:30 +0000
Re: Four significant reasons for a 12X word size Terje Mathisen <terje.mathisen@tmsw.no> - 2015-08-25 21:31 +0200
Re: Four significant reasons for a 12X word size BGB <cr88192@hotmail.com> - 2015-08-25 20:40 -0500
Re: Four significant reasons for a 12X word size anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2015-08-26 09:24 +0000
Re: Four significant reasons for a 12X word size BGB <cr88192@hotmail.com> - 2015-08-26 08:09 -0500
Re: Four significant reasons for a 12X word size anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2015-08-26 14:35 +0000
Re: Four significant reasons for a 12X word size BGB <cr88192@hotmail.com> - 2015-08-26 10:29 -0500
Re: Four significant reasons for a 12X word size anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2015-08-26 16:17 +0000
Re: Four significant reasons for a 12X word size BGB <cr88192@hotmail.com> - 2015-08-26 17:42 -0500
Re: Four significant reasons for a 12X word size anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2015-08-27 13:51 +0000
Re: Four significant reasons for a 12X word size BGB <cr88192@hotmail.com> - 2015-08-27 10:50 -0500
Re: Four significant reasons for a 12X word size Michael S <already5chosen@yahoo.com> - 2015-08-28 04:44 -0700
Re: Four significant reasons for a 12X word size BGB <cr88192@hotmail.com> - 2015-08-28 08:22 -0500
Re: Four significant reasons for a 12X word size Terje Mathisen <terje.mathisen@tmsw.no> - 2015-08-26 22:32 +0200
Re: Four significant reasons for a 12X word size BGB <cr88192@hotmail.com> - 2015-08-26 18:25 -0500
Re: Four significant reasons for a 12X word size anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2015-08-26 09:15 +0000
Re: Four significant reasons for a 12X word size Quadibloc <jsavard@ecn.ab.ca> - 2015-08-26 06:28 -0700
Re: Four significant reasons for a 12X word size anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2015-08-26 13:54 +0000
Re: Four significant reasons for a 12X word size BGB <cr88192@hotmail.com> - 2015-08-26 09:53 -0500
Re: Four significant reasons for a 12X word size Stefan Monnier <monnier@iro.umontreal.ca> - 2015-08-28 11:22 -0400
Re: Four significant reasons for a 12X word size BGB <cr88192@hotmail.com> - 2015-08-28 16:09 -0500
Re: Four significant reasons for a 12X word size Terje Mathisen <terje.mathisen@tmsw.no> - 2015-08-29 14:54 +0200
character encoding (was: Four significant reasons for a 12X word size) anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2015-08-29 14:05 +0000
Re: character encoding Terje Mathisen <terje.mathisen@tmsw.no> - 2015-08-29 19:10 +0200
Re: character encoding nmm@needham.csi.cam.ac.uk (Nick Maclaren) - 2015-08-29 18:25 +0100
Re: character encoding Terje Mathisen <terje.mathisen@tmsw.no> - 2015-08-29 21:03 +0200
Re: character encoding Ivan Godard <ivan@millcomputing.com> - 2015-08-29 10:32 -0700
Re: character encoding nmm@needham.csi.cam.ac.uk (Nick Maclaren) - 2015-08-29 18:37 +0100
Re: character encoding Ivan Godard <ivan@millcomputing.com> - 2015-08-29 10:53 -0700
Re: character encoding nmm@needham.csi.cam.ac.uk (Nick Maclaren) - 2015-08-29 19:12 +0100
Re: character encoding anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2015-08-29 17:35 +0000
Re: character encoding Ivan Godard <ivan@millcomputing.com> - 2015-08-29 10:44 -0700
Re: character encoding anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2015-08-29 17:55 +0000
Re: character encoding anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2015-08-31 11:23 +0000
Re: character encoding Terje Mathisen <terje.mathisen@tmsw.no> - 2015-08-31 14:18 +0200
Re: character encoding Terje Mathisen <terje.mathisen@tmsw.no> - 2015-08-29 21:20 +0200
Re: character encoding Terje Mathisen <terje.mathisen@tmsw.no> - 2015-08-29 21:11 +0200
Re: Four significant reasons for a 12X word size BGB <cr88192@hotmail.com> - 2015-08-29 12:19 -0500
Re: Four significant reasons for a 12X word size Quadibloc <jsavard@ecn.ab.ca> - 2015-08-29 07:41 -0700
Re: Four significant reasons for a 12X word size Terje Mathisen <terje.mathisen@tmsw.no> - 2015-08-29 19:12 +0200
Re: Four significant reasons for a 12X word size nmm@needham.csi.cam.ac.uk (Nick Maclaren) - 2015-08-29 18:23 +0100
Re: Four significant reasons for a 12X word size BGB <cr88192@hotmail.com> - 2015-08-29 17:17 -0500
Re: Four significant reasons for a 12X word size George Neuner <gneuner2@comcast.net> - 2015-08-29 14:57 -0400
Re: Four significant reasons for a 12X word size jim.brakefield@ieee.org - 2015-08-29 12:40 -0700
Re: Four significant reasons for a 12X word size Terje Mathisen <terje.mathisen@tmsw.no> - 2015-08-30 00:05 +0200
Re: Four significant reasons for a 12X word size EricP <ThatWouldBeTelling@thevillage.com> - 2015-08-24 13:16 -0400
Re: Four significant reasons for a 12X word size EricP <ThatWouldBeTelling@thevillage.com> - 2015-08-24 13:29 -0400
Re: Four significant reasons for a 12X word size mrs@kithrup.com (Mike Stump) - 2015-08-24 21:32 +0000
Re: Four significant reasons for a 12X word size Terje Mathisen <terje.mathisen@tmsw.no> - 2015-08-25 08:49 +0200
Re: Four significant reasons for a 12X word size mrs@kithrup.com (Mike Stump) - 2015-08-25 22:43 +0000
Re: Four significant reasons for a 12X word size EricP <ThatWouldBeTelling@thevillage.com> - 2015-08-25 21:55 -0400
Re: Four significant reasons for a 12X word size paul wallich <pw@panix.com> - 2015-08-25 22:12 -0400
Re: Four significant reasons for a 12X word size EricP <ThatWouldBeTelling@thevillage.com> - 2015-08-26 13:54 -0400
Re: Four significant reasons for a 12X word size Stephen Fuld <SFuld@alumni.cmu.edu.invalid> - 2015-08-26 11:47 -0700
Re: Four significant reasons for a 12X word size mac <acolvin@efunct.com> - 2015-08-27 16:15 +0000
Re: Four significant reasons for a 12X word size Stephen Fuld <SFuld@alumni.cmu.edu.invalid> - 2015-08-27 10:44 -0700
Re: Four significant reasons for a 12X word size rpw3@rpw3.org (Rob Warnock) - 2015-08-28 06:09 +0000
Re: Four significant reasons for a 12X word size EricP <ThatWouldBeTelling@thevillage.com> - 2015-08-28 12:23 -0400
Re: Four significant reasons for a 12X word size Terje Mathisen <terje.mathisen@tmsw.no> - 2015-08-26 08:37 +0200
Re: Four significant reasons for a 12X word size mrs@kithrup.com (Mike Stump) - 2015-08-26 22:54 +0000
Re: Four significant reasons for a 12X word size Terje Mathisen <terje.mathisen@tmsw.no> - 2015-08-27 07:48 +0200
Re: Four significant reasons for a 12X word size mrs@kithrup.com (Mike Stump) - 2015-08-27 16:30 +0000
Re: Four significant reasons for a 12X word size jim.brakefield@ieee.org - 2015-08-23 19:09 -0700
Re: Four significant reasons for a 12X word size Megol <golem960@gmail.com> - 2015-08-24 04:32 -0700
Re: Four significant reasons for a 12X word size R Kym Horsell <kym@kymhorsell.com> - 2015-08-24 11:37 +0000
Re: Four significant reasons for a 12X word size Quadibloc <jsavard@ecn.ab.ca> - 2015-08-22 12:56 -0700
Re: Four significant reasons for a 12X word size Quadibloc <jsavard@ecn.ab.ca> - 2015-08-22 13:10 -0700
Re: Four significant reasons for a 12X word size Quadibloc <jsavard@ecn.ab.ca> - 2015-08-22 17:17 -0700
Re: Four significant reasons for a 12X word size jim.brakefield@ieee.org - 2015-08-22 19:59 -0700
Re: Four significant reasons for a 12X word size jim.brakefield@ieee.org - 2015-09-01 12:47 -0700
Re: Four significant reasons for a 12X word size jim.brakefield@ieee.org - 2015-08-22 20:10 -0700
Re: Four significant reasons for a 12X word size Robert Wessel <robertwessel2@yahoo.com> - 2015-08-23 21:41 -0500
Re: Four significant reasons for a 12X word size BGB <cr88192@hotmail.com> - 2015-08-24 10:53 -0500
Re: Four significant reasons for a 12X word size Robert Miles <robertmilesxyz@gmail.com> - 2015-08-26 17:39 -0700
Re: Four significant reasons for a 12X word size Terje Mathisen <terje.mathisen@tmsw.no> - 2015-08-27 07:52 +0200
Re: Four significant reasons for a 12X word size spamkiller539@gmail.com - 2015-08-27 20:00 -0700
Page 4 of 7 — ← Prev page 1 2 3 [4] 5 6 7 Next page →
| From | BGB <cr88192@hotmail.com> |
|---|---|
| Date | 2015-08-26 09:28 -0500 |
| Message-ID | <mrkion$c4b$1@news.albasani.net> |
| In reply to | #29409 |
On 8/26/2015 4:41 AM, Bruce Hoult wrote: > On Wednesday, August 26, 2015 at 4:20:06 AM UTC+3, BGB wrote: >> On 8/25/2015 12:30 PM, Bruce Hoult wrote: >>> On Tuesday, August 25, 2015 at 5:37:05 PM UTC+3, BGB wrote: >>>> On 8/25/2015 4:04 AM, Anton Ertl wrote: >>>>> MitchAlsup <MitchAlsup@aol.com> writes: >>>>>> On Monday, August 24, 2015 at 11:45:28 AM UTC-5, Terje Mathisen wrote: >>>>>>> >>>>>>> Power of two have won, deal with it. >>>>>> >>>>>> This is correct in terms of data widths and address widths. >>>>>> This is incorrect if and when data-tagging comes back into style. >>>>> >>>>> Data tagging has been used for a long time in various programming >>>>> language implementations. It works nicely with power-of-two word >>>>> sizes; moreover, on 64-bit architectures (with byte addressing, but >>>>> that's all of them), we can have 8 different tag values without >>>>> reducing the addressible memory. >>>>> >>>> >>>> the cost of LSB tagging is, however, that any such pointers can no >>>> longer be byte-aligned, which is an issue for things like tagged >>>> pointers into arrays or pointing at string characters. >>>> >>>> granted, yes, MSB tagging reduces the size of the address space, but >>>> this isn't really an issue on current 64-bit targets. granted, it isn't >>>> really a good option for 32-bit targets much outside of microcontroller >>>> development at this point. >>>> >>>> which is better likely depends on the use-case. >>>> >>>> for object-pointers and LSB tagging, you can actually get by using >>>> 4-bits as a tag if all objects are 16-byte aligned. >>> >>> Perhaps folk here aren't aware that both MSB and LSB tagging are a bit passé now. The current hotness for 64 bit machines is "NaN encoding". >>> >>> The problem is that (for a 64 bit machine) either MSB or LSB tagging prevents one of the tagged types from being a double precision float. This seems like a shame. >>> >>> So, it has become common to take advantage of the fact that although the IEEE standard provides for 2^53 - 1 NaN values (all zeroes means infinity), all common hardware and libraries only use one of them. >>> >>> That means you can hide some extra tag bits inside the significand along with a boolean or a character or a pointer that while not the full 64 bits is bigger than any current or near term address space. Or an integer that, while again not a full 64 bits, is quite significantly bigger than 32 bits (52 bits is possible). >>> >> >> NaN tagging is only really "good" if the vast majority of you datums are >> floating point numbers. if integer and pointer data are the primary >> types (and the language keeps integer and floating point numbers as >> distinct types), NaN tagging isn't nearly such a great solution anymore. >> >> I have an MSB tagging scheme that basically passes through a large part >> of the double space at full precision, as well as having plenty of space >> for pointers, and a 62-bit fixnum type. > > Steal the top bit from the exponent? > > I guess 1e150 or so ought to be enough for most purposes. > it passes though doubles whose top 4 bits are 3/4 or B/C, with the rest of the space getting 4 LSB bits trimmed off. so, effectively, this trims 2 bits off the exponent. the 3/4 and B/C space is however still larger than 32-bit floats, and the vast majority of doubles fall in this range, so it isn't a huge loss. the tag space was mostly laid out as: 0, pointer (positive, 1) 1/2, fixnum (positive) 3/4, flonum (positive) 5/6/7, some more specialized types 8, flonum2 (double>>4) 9/A, more stuff B/C, flonum (negative) D/E, fixnum (negative) F, pointer (negative, 1) 1: in one VM using this basic scheme, 0 and F were both 60 bit pointer spaces (for their respective signs). in a newer VM, 0 is 48 bits and F is 60 bits, with sign extension being used on 64-bit targets. I may swap these around, and use 0 as the straight 60-bit pass-through pointer type though. the reason for adding a type-tag to the pointer was that this VM moved away from using the pointed-to memory-object to encode its type. the newer VM also added explicit "C-style" pointers to the tagged-reference system (mostly so pointers could be cast to variant and remember their type and preserve semantics). the older VM uses boxing for 'long' values outside the fixnum range, but it is possible for the embedded/RT version, that variant-long will be 62-bit modular by default (vs 64 bits for long/ulong). possible could be to pass 2/3/4/5 and A/B/C/D, but this leaves less bits for fixnums and other things (probably only a 61 bit fixnum). though, possible a case could be made for doing things like: 0, pointer 1/2/3, tagged stuff 4/5/6/7, 62-bit fixnum 8/9/A/B, 62-bit flonum (double>>2) C/D/E, tagged stuff F, pointer which have the advantage of slightly simpler encode/decode logic than the scheme I had used (at the cost of losing the ability to do full precision double over part of the range). ex: decoding flonum: i=((s64)(t<<2))>>2; vs: i=((s64)t)-(0x1000000000000000LL^(((s64)t)>>63)); and encoding (mod-62): t=(i&0x3FFFFFFFFFFFFFFFLL)|0x4000000000000000LL; vs: t=((i<<2)>>2)+(0x1000000000000000LL^(i>>63)); but, the scheme was funky mostly because I had tried to fit things around double.
[toc] | [prev] | [next] | [standalone]
| From | Waldek Hebisch <hebisch@antispam.uni.wroc.pl> |
|---|---|
| Date | 2015-08-27 00:53 +0000 |
| Message-ID | <mrln2r$676$1@z-news.wcss.wroc.pl> |
| In reply to | #29360 |
Bruce Hoult <bruce.hoult@gmail.com> wrote:
>
> Perhaps folk here aren't aware that both MSB and LSB tagging are a bit pass? now. The current hotness for 64 bit machines is "NaN encoding".
>
> The problem is that (for a 64 bit machine) either MSB or LSB tagging prevents one of the tagged types from being a double precision float. This seems like a shame.
>
> So, it has become common to take advantage of the fact that although the IEEE standard provides for 2^53 - 1 NaN values (all zeroes means infinity), all common hardware and libraries only use one of them.
>
> That means you can hide some extra tag bits inside the significand along with a boolean or a character or a pointer that while not the full 64 bits is bigger than any current or near term address space. Or an integer that, while again not a full 64 bits, is quite significantly bigger than 32 bits (52 bits is possible).
In may programs most data are integers. And when I have floats
most of them is in arrays which contain only floating point
data so they can use untagged representation. So for me
allowing doubles withing tagging scheme is not a big deal.
Loosing 12 bits of integers would be painful -- actually
one of advanteges of integers over doubles is that I have
more significant bits (62 + sign compared to 53 + sign).
In my problems to comfortably handle n items I need integers
of order n^4, less comfortable but reasonably I can do with
n^3, below n^2 algortithm may fail and while above n^2
should work it leads to various inefficiences and/or
complicated coding. For 2^32 items I would prefer 128-bit
integer arithmetic. With 63 bits I can reasonably handle
about 2^20 items. Lower number of bits either leads to
unconfortably small upper bound on size of problem
which are guaranteed to work or to ugly coding.
--
Waldek Hebisch
hebisch@math.uni.wroc.pl
[toc] | [prev] | [next] | [standalone]
| From | jgk@panix.com (Joe keane) |
|---|---|
| Date | 2015-08-25 18:30 +0000 |
| Message-ID | <mric7k$3gm$1@reader1.panix.com> |
| In reply to | #29325 |
In article <mrfhn2$skf$1@speranza.aioe.org>, Terje Mathisen <terje.mathisen@tmsw.no> wrote: >Power of two have won, deal with it. The next step is to set CHAR_BIT to be 16.
[toc] | [prev] | [next] | [standalone]
| From | Terje Mathisen <terje.mathisen@tmsw.no> |
|---|---|
| Date | 2015-08-25 21:31 +0200 |
| Message-ID | <mrifqk$tto$2@speranza.aioe.org> |
| In reply to | #29370 |
jgk@panix.com (Joe keane) wrote: > In article <mrfhn2$skf$1@speranza.aioe.org>, > Terje Mathisen <terje.mathisen@tmsw.no> wrote: >> Power of two have won, deal with it. > > The next step is to set CHAR_BIT to be 16. > Nope, utf8 has won this battle. Terje -- - <Terje.Mathisen at tmsw.no> "almost all programming can be viewed as an exercise in caching"
[toc] | [prev] | [next] | [standalone]
| From | BGB <cr88192@hotmail.com> |
|---|---|
| Date | 2015-08-25 20:40 -0500 |
| Message-ID | <mrj5nq$brr$1@news.albasani.net> |
| In reply to | #29377 |
On 8/25/2015 2:31 PM, Terje Mathisen wrote: > jgk@panix.com (Joe keane) wrote: >> In article <mrfhn2$skf$1@speranza.aioe.org>, >> Terje Mathisen <terje.mathisen@tmsw.no> wrote: >>> Power of two have won, deal with it. >> >> The next step is to set CHAR_BIT to be 16. >> > Nope, utf8 has won this battle. > for C, yes, agreed... we still need bytes, and C lacks any good alternate way to define bytes besides using 'char'. for an HLL, it may make sense to have a wider 'char' type (such as an 'int' with special semantics), which is split off from 'byte'/'sbyte'/'ubyte' (as 8 bit integer types) and 'char8'/'char16', however with narrower underlying storage for string types. byte[256] arrb; //256 bytes char8[256] arrc8; //256 bytes char16[256] arrc16; //512 bytes char[256] arrc; //512 or 1024 bytes string str="Foo String\n"; //implicitly stored as ASCII chars arrc8[0]=str[0]; //'F' arrc16[0]=str[0]; //'F' arrc[0]=str[0]; //'F' maybe: string ss=str; char[] st=arrc; //copy string characters while(*ss) *st++=*ss++; *st++='\0'; //new string from characters. string s1=new string(arrc); actually, this same language has other funkiness: int/uint: always 32 bits long/ulong: always 64 bits nint/unint: typically 32-bits, possibly later may be 16 bits. nlong/unlong: may be 32 or 64 bits. 'nint' may be 16 bits on targets where a 16-bit integer type is preferable to a 32-bit type. otherwise 'int' and 'nint' are equivalent.
[toc] | [prev] | [next] | [standalone]
| From | anton@mips.complang.tuwien.ac.at (Anton Ertl) |
|---|---|
| Date | 2015-08-26 09:24 +0000 |
| Message-ID | <2015Aug26.112434@mips.complang.tuwien.ac.at> |
| In reply to | #29400 |
BGB <cr88192@hotmail.com> writes: >for an HLL, it may make sense to have a wider 'char' type (such as an >'int' with special semantics), which is split off from >'byte'/'sbyte'/'ubyte' (as 8 bit integer types) and 'char8'/'char16', >however with narrower underlying storage for string types. We have that in Forth-2012; if you use the UTF-8 encoding, strings in memory are encoded as UTF-8, but you can then, e.g., fetch a code point onto the stack (with XC@+), or you can fetch individual bytes with C@, or you can copy whole strings or substrings in memory with MOVE. The number of times I have used XC@+ is approximately 0 (and that's even though I originated this word), because I don't program anagram generators that often and there are few other uses for that kind of stuff; moreover, an anagram generator that assumes that a code point corresponds to a character as the user sees it would not work properly for composite characters, so dealing with individual code points is not even really useful for that. Makes me wonder what possessed the Python people to use fixed-width encodings for strings. - anton -- M. Anton Ertl Some things have to be seen to be believed anton@mips.complang.tuwien.ac.at Most things have to be believed to be seen http://www.complang.tuwien.ac.at/anton/home.html
[toc] | [prev] | [next] | [standalone]
| From | BGB <cr88192@hotmail.com> |
|---|---|
| Date | 2015-08-26 08:09 -0500 |
| Message-ID | <mrke3r$3df$1@news.albasani.net> |
| In reply to | #29408 |
On 8/26/2015 4:24 AM, Anton Ertl wrote: > BGB <cr88192@hotmail.com> writes: >> for an HLL, it may make sense to have a wider 'char' type (such as an >> 'int' with special semantics), which is split off from >> 'byte'/'sbyte'/'ubyte' (as 8 bit integer types) and 'char8'/'char16', >> however with narrower underlying storage for string types. > > We have that in Forth-2012; if you use the UTF-8 encoding, strings in > memory are encoded as UTF-8, but you can then, e.g., fetch a code > point onto the stack (with XC@+), or you can fetch individual bytes > with C@, or you can copy whole strings or substrings in memory with > MOVE. The number of times I have used XC@+ is approximately 0 (and > that's even though I originated this word), because I don't program > anagram generators that often and there are few other uses for that > kind of stuff; moreover, an anagram generator that assumes that a code > point corresponds to a character as the user sees it would not work > properly for composite characters, so dealing with individual code > points is not even really useful for that. > with the downside that is... using Forth... but, yeah, my script language did this, namely using mostly UTF-8 strings with a wider logical 'char' type. a variant I had started development on mostly for embedded, switches over mostly to CP-1252 or UTF-16 (on a per-string basis), mostly for sake of making typical string operations more predictable. > Makes me wonder what possessed the Python people to use fixed-width > encodings for strings. > no idea there.
[toc] | [prev] | [next] | [standalone]
| From | anton@mips.complang.tuwien.ac.at (Anton Ertl) |
|---|---|
| Date | 2015-08-26 14:35 +0000 |
| Message-ID | <2015Aug26.163548@mips.complang.tuwien.ac.at> |
| In reply to | #29418 |
BGB <cr88192@hotmail.com> writes: >On 8/26/2015 4:24 AM, Anton Ertl wrote: >> BGB <cr88192@hotmail.com> writes: >>> for an HLL, it may make sense to have a wider 'char' type (such as an >>> 'int' with special semantics), which is split off from >>> 'byte'/'sbyte'/'ubyte' (as 8 bit integer types) and 'char8'/'char16', >>> however with narrower underlying storage for string types. >> >> We have that in Forth-2012; if you use the UTF-8 encoding, strings in >> memory are encoded as UTF-8, but you can then, e.g., fetch a code >> point onto the stack (with XC@+), or you can fetch individual bytes >> with C@, or you can copy whole strings or substrings in memory with >> MOVE. The number of times I have used XC@+ is approximately 0 (and >> that's even though I originated this word), because I don't program >> anagram generators that often and there are few other uses for that >> kind of stuff; moreover, an anagram generator that assumes that a code >> point corresponds to a character as the user sees it would not work >> properly for composite characters, so dealing with individual code >> points is not even really useful for that. >> > >with the downside that is... using Forth... It's an upside, but anyway, my point was that this codepoint type is not as useful as I once thought. >a variant I had started development on mostly for embedded, switches >over mostly to CP-1252 or UTF-16 (on a per-string basis), mostly for >sake of making typical string operations more predictable. This sounds like the Python way (except Python uses fixed-width 8-bit, 16-bit, or 32-bit encodings on a per-string basis). What are the "typical string operations" that this makes more predictable? - anton -- M. Anton Ertl Some things have to be seen to be believed anton@mips.complang.tuwien.ac.at Most things have to be believed to be seen http://www.complang.tuwien.ac.at/anton/home.html
[toc] | [prev] | [next] | [standalone]
| From | BGB <cr88192@hotmail.com> |
|---|---|
| Date | 2015-08-26 10:29 -0500 |
| Message-ID | <mrkma5$iim$1@news.albasani.net> |
| In reply to | #29428 |
On 8/26/2015 9:35 AM, Anton Ertl wrote: > BGB <cr88192@hotmail.com> writes: >> On 8/26/2015 4:24 AM, Anton Ertl wrote: >>> BGB <cr88192@hotmail.com> writes: >>>> for an HLL, it may make sense to have a wider 'char' type (such as an >>>> 'int' with special semantics), which is split off from >>>> 'byte'/'sbyte'/'ubyte' (as 8 bit integer types) and 'char8'/'char16', >>>> however with narrower underlying storage for string types. >>> >>> We have that in Forth-2012; if you use the UTF-8 encoding, strings in >>> memory are encoded as UTF-8, but you can then, e.g., fetch a code >>> point onto the stack (with XC@+), or you can fetch individual bytes >>> with C@, or you can copy whole strings or substrings in memory with >>> MOVE. The number of times I have used XC@+ is approximately 0 (and >>> that's even though I originated this word), because I don't program >>> anagram generators that often and there are few other uses for that >>> kind of stuff; moreover, an anagram generator that assumes that a code >>> point corresponds to a character as the user sees it would not work >>> properly for composite characters, so dealing with individual code >>> points is not even really useful for that. >>> >> >> with the downside that is... using Forth... > > It's an upside, but anyway, my point was that this codepoint type is > not as useful as I once thought. > ok. not everyone is really a fan of Forth though... >> a variant I had started development on mostly for embedded, switches >> over mostly to CP-1252 or UTF-16 (on a per-string basis), mostly for >> sake of making typical string operations more predictable. > > This sounds like the Python way (except Python uses fixed-width 8-bit, > 16-bit, or 32-bit encodings on a per-string basis). What are the > "typical string operations" that this makes more predictable? > mine generally uses 8 or 16, where typically it will follow Java like convention of using explicit surrogate pairs for wider characters in UTF-16 strings. the main things that are faster and more predictable is code based on randomly accessing string characters, ex: "str[idx]". if you are faking UTF-16, with CP-1252 all accesses are still O(1), whereas to do this with UTF-8 requires O(n), since it is necessary to walk the string to the particular character index (unpredictable at best, and terribly slow if dealing with longer strings) walking a string with '*s++' is similarly effected, but not as drastically, because this operation will take a different path and thus a different number of clock-cycles depending on which character is present, so a more predictable cost (internal type checks) is preferable to a less predictable cost (needing to walk different paths to decode the character). though, the VM doesn't require strict / cycle exact timing, but more you want a reasonably sane worse-case (say, this sequence of instructions will finish within 200 clock-cycles). if you have an operation which could either take 5-10 cycles, or potentially several hundred or several thousand cycles, depending on unpredictable external factors, this is not good... for similar/related reasons, this particular VM does not use a GC, but instead a combination of explicit lifetimes (via semantics), lifetime inference, and explicit memory management (good old 'delete'...). unlike C#, the language also makes a defined difference between array declarations: char[256] arr; //array only has a scope-local lifetime char[] arr=new char[256]; //array has dynamic lifetime note that character-width and assignment is not an issue, as strings are implicitly read-only in the language (mutable strings requires using character arrays).
[toc] | [prev] | [next] | [standalone]
| From | anton@mips.complang.tuwien.ac.at (Anton Ertl) |
|---|---|
| Date | 2015-08-26 16:17 +0000 |
| Message-ID | <2015Aug26.181708@mips.complang.tuwien.ac.at> |
| In reply to | #29431 |
BGB <cr88192@hotmail.com> writes: >On 8/26/2015 9:35 AM, Anton Ertl wrote: >> BGB <cr88192@hotmail.com> writes: >>> a variant I had started development on mostly for embedded, switches >>> over mostly to CP-1252 or UTF-16 (on a per-string basis), mostly for >>> sake of making typical string operations more predictable. >> >> This sounds like the Python way (except Python uses fixed-width 8-bit, >> 16-bit, or 32-bit encodings on a per-string basis). What are the >> "typical string operations" that this makes more predictable? >> > >mine generally uses 8 or 16, where typically it will follow Java like >convention of using explicit surrogate pairs for wider characters in >UTF-16 strings. > > >the main things that are faster and more predictable is code based on >randomly accessing string characters, ex: "str[idx]". > >if you are faking UTF-16, with CP-1252 all accesses are still O(1), >whereas to do this with UTF-8 requires O(n), since it is necessary to >walk the string to the particular character index (unpredictable at >best, and terribly slow if dealing with longer strings) It's the same (i.e., O(n)) with UTF-16, because an Unicode code point can occupy 16 bits or 32 bits in UTF-16 encoding. And if you really want to access characters, not code points, you have to deal with composite characters, and then this is an O(n) operation even in the "fixed width". Anyway, in my experience this is not a typical string operation. Sure, when building typical string operations such as concatenation or parsing in a language like C or Pascal, you have a lots of str[idx] in there, and that might make you think that it is a common operation, but you can actually build most typical string operations without accessing individual code points. Indeed, if you use the original byte-oriented code with Unicode data, it often just works: string concatenation does not need to know where the boundaries between code points are to do its work, nor does strstr(). It may be a good idea to replace strchr(s,'c') with strstr(s,"c"), but most of the time even that is not necessary, because strchr() is used for looking for delimiters that happen to be in the ASCII range. - anton -- M. Anton Ertl Some things have to be seen to be believed anton@mips.complang.tuwien.ac.at Most things have to be believed to be seen http://www.complang.tuwien.ac.at/anton/home.html
[toc] | [prev] | [next] | [standalone]
| From | BGB <cr88192@hotmail.com> |
|---|---|
| Date | 2015-08-26 17:42 -0500 |
| Message-ID | <mrlflg$14o$1@news.albasani.net> |
| In reply to | #29434 |
On 8/26/2015 11:17 AM, Anton Ertl wrote:
> BGB <cr88192@hotmail.com> writes:
>> On 8/26/2015 9:35 AM, Anton Ertl wrote:
>>> BGB <cr88192@hotmail.com> writes:
>>>> a variant I had started development on mostly for embedded, switches
>>>> over mostly to CP-1252 or UTF-16 (on a per-string basis), mostly for
>>>> sake of making typical string operations more predictable.
>>>
>>> This sounds like the Python way (except Python uses fixed-width 8-bit,
>>> 16-bit, or 32-bit encodings on a per-string basis). What are the
>>> "typical string operations" that this makes more predictable?
>>>
>>
>> mine generally uses 8 or 16, where typically it will follow Java like
>> convention of using explicit surrogate pairs for wider characters in
>> UTF-16 strings.
>>
>>
>> the main things that are faster and more predictable is code based on
>> randomly accessing string characters, ex: "str[idx]".
>>
>> if you are faking UTF-16, with CP-1252 all accesses are still O(1),
>> whereas to do this with UTF-8 requires O(n), since it is necessary to
>> walk the string to the particular character index (unpredictable at
>> best, and terribly slow if dealing with longer strings)
>
> It's the same (i.e., O(n)) with UTF-16, because an Unicode code point
> can occupy 16 bits or 32 bits in UTF-16 encoding. And if you really
> want to access characters, not code points, you have to deal with
> composite characters, and then this is an O(n) operation even in the
> "fixed width".
>
though, with UTF-16, there isn't expectation that you see the complete
character, but rather one of the surrogate-pair characters.
though, one could argue that the same applies to UTF-8 if accessed in
terms of bytes (you can have O(1) per-byte access), but either way.
so, all that is required of random character access is that we can make
the string look like an array of 16-bit codepoints, regardless of
whether it is 8 or 16-bits in memory, and preferably with an O(1) random
access.
> Anyway, in my experience this is not a typical string operation.
> Sure, when building typical string operations such as concatenation or
> parsing in a language like C or Pascal, you have a lots of str[idx] in
> there, and that might make you think that it is a common operation,
> but you can actually build most typical string operations without
> accessing individual code points.
>
the basic model used by the language will be mostly C-like (the handling
of arrays falls between that of Java and C, and 'string' is essentially
semantically a special type of array in the language).
just the parent language follows after JS/AS, Java, and C# in the sense
of using UTF-16/UCS-2 as the canonical character set (rather than either
ASCII or UTF-32 / UCS-4).
when using UTF-8, it is actually a variant known as M-UTF-8, which
encodes non-BMP characters as multiple codepoints (UTF-8 encoded forms
of the surrogate pairs). similarly, there are separate encodings for NUL
as a character, ans NUL as a string terminator.
for example, a 0 byte will terminate a string, but C0-80 would encode a NUL.
however, CP-1252 strings will not allow embedded NULs.
if you compose a string with non-BMP characters, generally they will
decay into surrogate pairs when the char[] array is converted to a 'string'.
in the parent language, array-like "string objects" existed (not going
to try to explain, as they were a little convoluted). essentially, it
involved the use of pointers to objects holding pointers and type and
bounds information (and/or a pointer into an array's data area with
reverse lookups used to do type and bounds checks).
in the current VM, essentially they are type-tagged pointers. on 32-bit
targets, the bounds for small arrays/strings will be encoded directly in
the pointer, whereas for 64-bit targets (and larger arrays), the type
and bounds-check info may be escape-coded via an index into a table.
ex, array/string/variant-pointer index operation:
is raw/unbounded tagged pointer?
(32-bit) 9TTT-0000-PPPP-PPPP
(64-bit) 9TTT-PPPP-PPPP-PPPP
PPPP=pointed-to memory address
do operation relative to pointed-to-address.
TTT=000-0FF: Primitive Pointer Type
TTT=100-FFF: Type-Table Index
operation: '*(T *)P' or '((T *)P)[idx]'
is bounded pointer? (32-bit targets)
9TTT-IIII-PPPP-PPPP
PPPP=pointed-to memory address
is encoded directly in pointer? (TTT=000-0FF)
do operation based on coded bounds (IIII=L3.E4F9, size=F<<E).
use type/bounds from escape-coded table index (TTT=100-FFF)
IIII gives some additional type-index bits
low bits encode relative offset from array base.
operation: '*(T *)P' or '((T *)P)[idx]'
assume array object:
use pointer-values, types, and bound from array-object.
(32-bits) 0TTT-0000-PPPP-PPPP
(64-bits) 0TTT-PPPP-PPPP-PPPP
TTT=indicates type of array/string.
PPPP=Pointer to Array-Header Object
pointer may encode base-relative index:
(32-bits) 77II-IIII-PPPP-PPPP
(64-bits) 76II-IIPP-PPPP-PPPP
(64-bits) 77II-PPPP-PPPP-PPPP
II=Offset Base Index
PPPP=Pointer to Array-Header Object
operation: '(((ArrayHeader *)P)->data)[II+Index]'
yes, overly complicated, but generally some extra complexity trying to
ram stuff into the pointers tends to cost less than needing to deal with
additional heap allocated memory objects.
> Indeed, if you use the original byte-oriented code with Unicode data,
> it often just works: string concatenation does not need to know where
> the boundaries between code points are to do its work, nor does
> strstr(). It may be a good idea to replace strchr(s,'c') with
> strstr(s,"c"), but most of the time even that is not necessary,
> because strchr() is used for looking for delimiters that happen to be
> in the ASCII range.
>
yes, this works, but is not how this language deals with its native strings.
it is possible to have a '*char8' type that would be essentially a C
style string...
[toc] | [prev] | [next] | [standalone]
| From | anton@mips.complang.tuwien.ac.at (Anton Ertl) |
|---|---|
| Date | 2015-08-27 13:51 +0000 |
| Message-ID | <2015Aug27.155138@mips.complang.tuwien.ac.at> |
| In reply to | #29451 |
BGB <cr88192@hotmail.com> writes: >On 8/26/2015 11:17 AM, Anton Ertl wrote: >> BGB <cr88192@hotmail.com> writes: >>> On 8/26/2015 9:35 AM, Anton Ertl wrote: >>>> BGB <cr88192@hotmail.com> writes: >>>>> a variant I had started development on mostly for embedded, switches >>>>> over mostly to CP-1252 or UTF-16 (on a per-string basis), mostly for >>>>> sake of making typical string operations more predictable. >>>> >>>> This sounds like the Python way (except Python uses fixed-width 8-bit, >>>> 16-bit, or 32-bit encodings on a per-string basis). What are the >>>> "typical string operations" that this makes more predictable? >>>> >>> >>> mine generally uses 8 or 16, where typically it will follow Java like >>> convention of using explicit surrogate pairs for wider characters in >>> UTF-16 strings. >>> >>> >>> the main things that are faster and more predictable is code based on >>> randomly accessing string characters, ex: "str[idx]". >>> >>> if you are faking UTF-16, with CP-1252 all accesses are still O(1), >>> whereas to do this with UTF-8 requires O(n), since it is necessary to >>> walk the string to the particular character index (unpredictable at >>> best, and terribly slow if dealing with longer strings) >> >> It's the same (i.e., O(n)) with UTF-16, because an Unicode code point >> can occupy 16 bits or 32 bits in UTF-16 encoding. And if you really >> want to access characters, not code points, you have to deal with >> composite characters, and then this is an O(n) operation even in the >> "fixed width". >> > >though, with UTF-16, there isn't expectation that you see the complete >character, but rather one of the surrogate-pair characters. > >though, one could argue that the same applies to UTF-8 if accessed in >terms of bytes (you can have O(1) per-byte access), but either way. Exactly. >so, all that is required of random character access is that we can make >the string look like an array of 16-bit codepoints, regardless of >whether it is 8 or 16-bits in memory, and preferably with an O(1) random >access. Not sure what you mean with "16-bit codepoints". Unicode code points don't fit into 16 bits. Anyway, with ASCII we had the property that each byte represents a character; the fixed-width encodings (UTF-32 these days) try to preserve that property, but replaces "byte" with something larger, and "character" with code point (composite characters are composed of multiple code points). But that's not an important property in most code. >the basic model used by the language will be mostly C-like (the handling >of arrays falls between that of Java and C, and 'string' is essentially >semantically a special type of array in the language). > > >just the parent language follows after JS/AS, Java, and C# in the sense >of using UTF-16/UCS-2 as the canonical character set (rather than either >ASCII or UTF-32 / UCS-4). Java can be excused for choosing UTF-16 because of its date of design. C# inherited this nonsense from both Java and Windows NT (which is also excused because of its date of design). What's your excuse? - anton -- M. Anton Ertl Some things have to be seen to be believed anton@mips.complang.tuwien.ac.at Most things have to be believed to be seen http://www.complang.tuwien.ac.at/anton/home.html
[toc] | [prev] | [next] | [standalone]
| From | BGB <cr88192@hotmail.com> |
|---|---|
| Date | 2015-08-27 10:50 -0500 |
| Message-ID | <mrnbsm$ktq$1@news.albasani.net> |
| In reply to | #29470 |
On 8/27/2015 8:51 AM, Anton Ertl wrote: > BGB <cr88192@hotmail.com> writes: >> On 8/26/2015 11:17 AM, Anton Ertl wrote: >>> BGB <cr88192@hotmail.com> writes: >>>> On 8/26/2015 9:35 AM, Anton Ertl wrote: >>>>> BGB <cr88192@hotmail.com> writes: >>>>>> a variant I had started development on mostly for embedded, switches >>>>>> over mostly to CP-1252 or UTF-16 (on a per-string basis), mostly for >>>>>> sake of making typical string operations more predictable. >>>>> >>>>> This sounds like the Python way (except Python uses fixed-width 8-bit, >>>>> 16-bit, or 32-bit encodings on a per-string basis). What are the >>>>> "typical string operations" that this makes more predictable? >>>>> >>>> >>>> mine generally uses 8 or 16, where typically it will follow Java like >>>> convention of using explicit surrogate pairs for wider characters in >>>> UTF-16 strings. >>>> >>>> >>>> the main things that are faster and more predictable is code based on >>>> randomly accessing string characters, ex: "str[idx]". >>>> >>>> if you are faking UTF-16, with CP-1252 all accesses are still O(1), >>>> whereas to do this with UTF-8 requires O(n), since it is necessary to >>>> walk the string to the particular character index (unpredictable at >>>> best, and terribly slow if dealing with longer strings) >>> >>> It's the same (i.e., O(n)) with UTF-16, because an Unicode code point >>> can occupy 16 bits or 32 bits in UTF-16 encoding. And if you really >>> want to access characters, not code points, you have to deal with >>> composite characters, and then this is an O(n) operation even in the >>> "fixed width". >>> >> >> though, with UTF-16, there isn't expectation that you see the complete >> character, but rather one of the surrogate-pair characters. >> >> though, one could argue that the same applies to UTF-8 if accessed in >> terms of bytes (you can have O(1) per-byte access), but either way. > > Exactly. > >> so, all that is required of random character access is that we can make >> the string look like an array of 16-bit codepoints, regardless of >> whether it is 8 or 16-bits in memory, and preferably with an O(1) random >> access. > > Not sure what you mean with "16-bit codepoints". Unicode code points > don't fit into 16 bits. > UTF-16 / UCS-2 / BMP. > Anyway, with ASCII we had the property that each byte represents a > character; the fixed-width encodings (UTF-32 these days) try to > preserve that property, but replaces "byte" with something larger, and > "character" with code point (composite characters are composed of > multiple code points). But that's not an important property in most > code. > yeah. this VM uses 16-bits for the canonical character, but internally uses 32-bits in some cases, though mostly this is because: the bytecode ISA doesn't strongly distinguish 16 and 32-bit data, and 16-bit is implicitly promoted to 32-bits; it allows easier handling of special cases, like a '-1' non-character, and allows characters outside the BMP to temporarily exist (you can have them in 'char' or 'char[]', just not generally in 'string'...). >> the basic model used by the language will be mostly C-like (the handling >> of arrays falls between that of Java and C, and 'string' is essentially >> semantically a special type of array in the language). >> >> >> just the parent language follows after JS/AS, Java, and C# in the sense >> of using UTF-16/UCS-2 as the canonical character set (rather than either >> ASCII or UTF-32 / UCS-4). > > Java can be excused for choosing UTF-16 because of its date of design. > C# inherited this nonsense from both Java and Windows NT (which is > also excused because of its date of design). What's your excuse? > because it follows off of its predecessors (JavaScript, Java, C#, and ActionScript) and follows the same basic conventions as them. one of these conventions is the use of UTF-16 as the canonical character set (as opposed to either ASCII or UCS-4 / UTF-32). changing away from this doesn't seem particularly worthwhile. it also isn't really a "new" language, mostly just a reimplementation of a language I have been using since around 2004, mostly to address the issue of the parent being far too heavyweight to really be viable on embedded targets, and too unpredictable to really be useful for real-time. however, it was not a goal of this effort to introduce any significant changes to the semantics, but rather merely to improve reliability, performance, and try to reduce its code and memory footprint. though, I will set limits, like it is more something suitable for ARM9 or higher-end Cortex-M chips, but probably not something for MSP430 or similar... or such...
[toc] | [prev] | [next] | [standalone]
| From | Michael S <already5chosen@yahoo.com> |
|---|---|
| Date | 2015-08-28 04:44 -0700 |
| Message-ID | <d93c78aa-0431-4dec-a3ea-19e5f975ef52@googlegroups.com> |
| In reply to | #29470 |
On Thursday, August 27, 2015 at 5:11:32 PM UTC+3, Anton Ertl wrote: > > C# inherited this nonsense from both Java and Windows NT (which is > also excused because of its date of design). > I find it funny that C# defines string type as a sequence of UTF-16 code units, but at the same time recommends UTF-8 as a preferred encoding for C# sources.
[toc] | [prev] | [next] | [standalone]
| From | BGB <cr88192@hotmail.com> |
|---|---|
| Date | 2015-08-28 08:22 -0500 |
| Message-ID | <mrpnji$3vb$1@news.albasani.net> |
| In reply to | #29517 |
On 8/28/2015 6:44 AM, Michael S wrote: > On Thursday, August 27, 2015 at 5:11:32 PM UTC+3, Anton Ertl wrote: >> >> C# inherited this nonsense from both Java and Windows NT (which is >> also excused because of its date of design). >> > > I find it funny that C# defines string type as a sequence of UTF-16 code units, but at the same time recommends UTF-8 as a preferred encoding for C# sources. > yes. UTF-8 is generally good for text-storage, and UTF-16 often makes sense for strings (if wide characters are common). UTF-32 is less common, and is harder to justify because on-average it waste lots of memory vs UTF-8 or UTF-16. in my case, it was noted that UTF-8 will probably remain as the common external format for text used with my stuff, just with a mix of CP-1252 and maybe 437, mixed with UTF-16, for strings. the logical string would either way appear to the HLL as a collection of UTF-16 codepoints, even in cases where in-memory it is ASCII. so, CP-1252 generally has the advantage of being sufficient for most Western European text, and also does ASCII. CP-437 mostly has ASCII and a lot of block-drawing characters, so is better for things like textual UIs. the same VM is also used for C, which uses raw signed-byte pointers for accessing strings, and unsigned short for accessing wide-strings.
[toc] | [prev] | [next] | [standalone]
| From | Terje Mathisen <terje.mathisen@tmsw.no> |
|---|---|
| Date | 2015-08-26 22:32 +0200 |
| Message-ID | <mrl7pk$cfg$1@speranza.aioe.org> |
| In reply to | #29431 |
BGB wrote:
> the main things that are faster and more predictable is code based on
> randomly accessing string characters, ex: "str[idx]".
>
> if you are faking UTF-16, with CP-1252 all accesses are still O(1),
> whereas to do this with UTF-8 requires O(n), since it is necessary to
> walk the string to the particular character index (unpredictable at
> best, and terribly slow if dealing with longer strings)
This is only if idx is random, right?
I.e. if idx follows a typical stride-1 pattern, then it is the same as
your next example:
>
> walking a string with '*s++' is similarly effected, but not as
> drastically, because this operation will take a different path and thus
> a different number of clock-cycles depending on which character is
> present, so a more predictable cost (internal type checks) is preferable
> to a less predictable cost (needing to walk different paths to decode
> the character).
This operation isn't really that hard to make close to constant speed
since utf-8 encodes the total length of all single and multi-byte
characters in the top 6 bits of the first byte:
first_byte = *s;
len = utf8len[first_byte >> 2];
// The code above could use an intrinsic/hw instruction to scan
// from the top for the first zero bit, avoiding that 64-byte lookup table.
s += len;
// Branchless construction of the code point:
b1 = first_byte & first_mask[len];
b2 = s[1] & 63;
b3 = s[2] & 63;
b4 = s[3] & 63;
b5 = s[4] & 63;
b6 = s[5] & 63;
trailing_data = b6 | (b5 << 6) | (b4 << 12) | (b3 << 18) | (b2 << 24);
trailing_bits = (len-1)*6;
code_point = (b1 << trailing_bits) |
(trailing_data >> (30-trailing_bits));
If we limit ourselves to 16 or 21-bit chars then we can speed up all
characters below this limit but with the cost of a test & branch to
handle longer/wider characters.
Terje
--
- <Terje.Mathisen at tmsw.no>
"almost all programming can be viewed as an exercise in caching"
[toc] | [prev] | [next] | [standalone]
| From | BGB <cr88192@hotmail.com> |
|---|---|
| Date | 2015-08-26 18:25 -0500 |
| Message-ID | <mrli6l$4vo$1@news.albasani.net> |
| In reply to | #29443 |
On 8/26/2015 3:32 PM, Terje Mathisen wrote: > BGB wrote: >> the main things that are faster and more predictable is code based on >> randomly accessing string characters, ex: "str[idx]". >> >> if you are faking UTF-16, with CP-1252 all accesses are still O(1), >> whereas to do this with UTF-8 requires O(n), since it is necessary to >> walk the string to the particular character index (unpredictable at >> best, and terribly slow if dealing with longer strings) > > This is only if idx is random, right? > > I.e. if idx follows a typical stride-1 pattern, then it is the same as > your next example: only if the compiler/VM recognizes that it is advancing sequentially. the VM isn't really that smart as of yet. >> >> walking a string with '*s++' is similarly effected, but not as >> drastically, because this operation will take a different path and thus >> a different number of clock-cycles depending on which character is >> present, so a more predictable cost (internal type checks) is preferable >> to a less predictable cost (needing to walk different paths to decode >> the character). > > This operation isn't really that hard to make close to constant speed > since utf-8 encodes the total length of all single and multi-byte > characters in the top 6 bits of the first byte: > > first_byte = *s; > len = utf8len[first_byte >> 2]; > // The code above could use an intrinsic/hw instruction to scan > // from the top for the first zero bit, avoiding that 64-byte lookup table. > > s += len; > > // Branchless construction of the code point: > b1 = first_byte & first_mask[len]; > b2 = s[1] & 63; > b3 = s[2] & 63; > b4 = s[3] & 63; > b5 = s[4] & 63; > b6 = s[5] & 63; > > trailing_data = b6 | (b5 << 6) | (b4 << 12) | (b3 << 18) | (b2 << 24); > trailing_bits = (len-1)*6; > > code_point = (b1 << trailing_bits) | > (trailing_data >> (30-trailing_bits)); > > > If we limit ourselves to 16 or 21-bit chars then we can speed up all > characters below this limit but with the cost of a test & branch to > handle longer/wider characters. > possible. UTF-8 is still used for some things, just not as the default 'string' type. symbols and keywords are still stored as UTF-8, as well as serialized text data is still generally stored as UTF-8 (except where the compiler has used CP-1252 or CP-437 or similar). M-UTF-8 generally doesn't allow characters outside the 16-bit range, at the cost that UTF-8 codepoints encoding surrogate pairs are less space-efficient than encoding the codepoints directly. but, yeah, branchless decoding could help in some cases.
[toc] | [prev] | [next] | [standalone]
| From | anton@mips.complang.tuwien.ac.at (Anton Ertl) |
|---|---|
| Date | 2015-08-26 09:15 +0000 |
| Message-ID | <2015Aug26.111527@mips.complang.tuwien.ac.at> |
| In reply to | #29370 |
jgk@panix.com (Joe keane) writes: >In article <mrfhn2$skf$1@speranza.aioe.org>, >Terje Mathisen <terje.mathisen@tmsw.no> wrote: >>Power of two have won, deal with it. > >The next step is to set CHAR_BIT to be 16. The next step in what? CHAR_BIT=16 makes no sense. Among variable-width character encodings, UTF-8 is superior to UTF-16. And 16 bits are not sufficient for fixed-width character encoding (but fixed-width encodings have less benefits over variable-width encodings than many people imagine, especially for Unicode). - anton -- M. Anton Ertl Some things have to be seen to be believed anton@mips.complang.tuwien.ac.at Most things have to be believed to be seen http://www.complang.tuwien.ac.at/anton/home.html
[toc] | [prev] | [next] | [standalone]
| From | Quadibloc <jsavard@ecn.ab.ca> |
|---|---|
| Date | 2015-08-26 06:28 -0700 |
| Message-ID | <bee436a1-a32c-4139-853a-2263ebdbce0d@googlegroups.com> |
| In reply to | #29407 |
On Wednesday, August 26, 2015 at 3:19:09 AM UTC-6, Anton Ertl wrote: > Among > variable-width character encodings, UTF-8 is superior to UTF-16. That depends which characters you're using. With UTF-8, only 7-bit ASCII fits in 8 bits; then, a limited group of characters fits in 16 bits. With UTF-16, all the original Unicode characters are 16 bits, only the more exotic characters take up more space. John Savard
[toc] | [prev] | [next] | [standalone]
| From | anton@mips.complang.tuwien.ac.at (Anton Ertl) |
|---|---|
| Date | 2015-08-26 13:54 +0000 |
| Message-ID | <2015Aug26.155431@mips.complang.tuwien.ac.at> |
| In reply to | #29420 |
Quadibloc <jsavard@ecn.ab.ca> writes: >On Wednesday, August 26, 2015 at 3:19:09 AM UTC-6, Anton Ertl wrote: >> Among >> variable-width character encodings, UTF-8 is superior to UTF-16. > >That depends which characters you're using. Independent of the characters I am using. >With UTF-8, only 7-bit ASCII fits in 8 bits; then, a limited group of characters fits in 16 bits. With UTF-16, all the original Unicode characters are 16 bits, only the more exotic characters take up more space. Oh, that argument. It's not just about size, but if we look at size, there is enough ASCII in many files (e.g., web pages) containing Chinese characters to make UTF-8 a win for such files, too. But the main reason is that UTF-8 works fine with most of the code written for ASCII, requiring changes only in a few places. Note that both the PRC and Taiwan settled for ASCII-compatible variable-width multiple-of-8 encodings rather than something like UTF-16, so UTF-16 really has no home base. If UCS-2 had not been designed into some interfaces in the early 1990s when UCS-2 looked like the future, it would have died out by now, and UTF-16 is just a variable-width encoding catering for these interfaces just as UTF-8 is for the classical byte-based interfaces. - anton -- M. Anton Ertl Some things have to be seen to be believed anton@mips.complang.tuwien.ac.at Most things have to be believed to be seen http://www.complang.tuwien.ac.at/anton/home.html
[toc] | [prev] | [next] | [standalone]
Page 4 of 7 — ← Prev page 1 2 3 [4] 5 6 7 Next page →
Back to top | Article view | comp.arch
csiph-web