[Oberon] Why is RSC string data word-aligned?
Jörg
joerg.straube at iaeth.ch
Sun Jan 31 10:11:46 CET 2021
I thought Colby does agree that strings have to be word-aligned a) IN MEMORY, because of 4 times faster string assignment (s := “Hi there“;) and 4 times faster string parameter passing to procedures. (Out.String(“Hi there“);) see ORG.CopyString.
Word-alignment is not needed for string comparison (IF s = „“Hi there“ THEN) see ORG.StringRelation.
I understood he wondered why the strings are word-aligned b) IN RSC FILES too because the loader could do it while reading.
Colby, do I summarize your request correctly?
If so, let me explain what would have to be done to make strings NOT word-aligned in rsc files.
First, lets remember that a module has a compile time TC and later on the load time TL.
It’s not enough to have the word-alignment at TL only. As the compiler generates code for fast string assignments, the compiler needs to know the word-aligned offset of a string at TC already. Therefore, the variable „strx“ keeping track of the string offset in ORG is always word-aligned (see ORG.MakeStringItem)
Principally, Colby is right, we could now decide to break the rule of word-alignment between TC and TL. That can be done as follows:
- the compiler optimizes the file IO (and hence the file size but not necessarily the CPU cycles) at TC by writing the string buffer without consecutive 0X.
- the loader could re-word-align the string buffer at TL.
Could be done but I doubt 1) that the code is easier to read, 2) the file IO gain is noticeable 3) it‘s worth the effort.
br Jörg
> Am 31.01.2021 um 08:44 schrieb Paul Reed <paulreed at paddedcell.com>:
>
> Hi Colby,
>
>> ... So again: in
>> concrete terms, where does the efficiency for [string] word alignment come in?
>
> String assignment (as has been pointed out). The code generated by ORG.CopyString moves string data around by words, filling the full 32-bits of a register buffer with string data on each loop iteration. This may happen many times over and over again as code is running, once a module is loaded into memory.
>
> The unaligned data in a .rsc file is, I agree, unfortunate, as it could have been aligned relatively easily and then data could have been copied into memory a word at a time. But module loading only happens once, and there's lots of other stuff to do too, so as you say it was likely deemed not worth it.
>
> HTH,
> Paul
> --
> Oberon at lists.inf.ethz.ch mailing list for ETH Oberon and related systems
> https://lists.inf.ethz.ch/mailman/listinfo/oberon
More information about the Oberon
mailing list