r3wp [groups: 83 posts: 189283]
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

World: r3wp

[rebcode] Rebcode discussion

Volker
28-Oct-2005
[962x2]
You have to get the table-base from somewhere and add that.
So even a 0-base may need to add or subtract something.
BrianH
28-Oct-2005
[964]
If the table-base is a pointer to the table (as it is here) any rebasing 
would require math. The question is whether you want to do that math 
every time, or just when you need to.
Volker
28-Oct-2005
[965]
You need to do it every time you switch. Its not 0-based, its always 
table-based.
BrianH
28-Oct-2005
[966]
0-based doesn't need to add or subtract anything if n is already 
0-based, like it would be for modulus calculations.
Volker
28-Oct-2005
[967]
You have to add that 0 to the table-base. table-base may be known 
by pc and slightly faster to access if not dynamic, ubt i doubt the 
difference is big.
BrianH
28-Oct-2005
[968x3]
The table is a block. The block reference has a position. That position 
is the base. All these indexes are relative to that. If you specify 
0-based or 1-based, that 0 or 1 can be hardcoded (faster in the interpreter) 
or can be replaced with 0-based or 1-based machine instructions (faster 
if you JIT, as both types are common, and other bases require rebasing 
to 0 or 1 first).
x86 has instructions that directly correspond to pick/poke and pickz/pokez, 
but other bases require some math (or segmenting).
This isn't like change or copy - branches are supposed to be fast.
Volker
28-Oct-2005
[971x2]
The block reference has a position.

 Yes. And i can base on that at compiletime. if i use 1, i decrement 
 that position at compiletime. when i add, its as good as 0-based. 
 if i know at compiletime the offset is something else, i can adjust 
 too.
BTW if you jit, never think branches are fast..
Gabriele
28-Oct-2005
[973x2]
New REBCODE release: www.rebol.net/builds/031/rebcode15.zip
note: rewrite engine is disabled.
BrianH
28-Oct-2005
[975]
First impression:
- Yay! setw/getw, rotl/rotr, bswap, change = change/part, brab 

- I hadn't thought of those, but cool: ext8/ext16, break now breakt/breakf, 
making rebcode* now a field in system/internal

- Questions: Haven't done the grand renaming yet? Rewrite getting 
rewritten? Does brab work yet (it crashed for me)?
Gabriele
28-Oct-2005
[976]
renaming will be next, then a public beta will be released. brab 
should work, but i haven't tested it, and not sure if anyone tested 
it yet...
BrianH
28-Oct-2005
[977x4]
Crashes with literal integer indexes into the label block. Does work 
with index assigned to a word - apparently 0-based right now.
; This works

do rebcode [x [integer!]] [brab [a b] x return -1 label a return 
0 label b return 1] 0
; This crashes

do rebcode [] [brab [a b] 0 return -1 label a return 0 label b return 
1]
Also, as far as I can tell, indirect label blocks just don't work, 
and for indirect offset blocks the position of the block is ignored 
and the index is counted relative to the head of the block, not the 
current position. If these two cases stand as is, there will be no 
reason to support indirect offset block addressing at all. The current 
reasons to support indirect branch target blocks are to have the 
label words used to make offset calculations at runtime (effectively 
making the branch target an absolute offset), or to play with the 
branch block position for obscure reasons. Relative branch targets 
are only valid from one location, so there is no point to putting 
them into a runtime value like a block referenced through a word 
when they can only be used once.
(Pardon the awkward phrasing - it's a complicated topic and I don't 
have time to rephrase. Be back later)
Gabriele
28-Oct-2005
[981]
indirect labels: no, labels can only be looked up by the assembler. 
there's no way to look them up at runtime.
BrianH
28-Oct-2005
[982x4]
Then there is almost no point to referring to the label block indirectly. 
You could theoretically swap indirect offset blocks at runtime as 
part of a state machine, but you would have to calculate offsets 
manually, and couldn't use rewrite rules then because the offsets 
would likely change in unpredictable ways.
Since indirect offset blocks would be harder to JIT, why bother to 
support them at all? Only indirect label blocks would be really useful.
(Sorry to answer my own question) A state machine could be implemented 
as a brab with an indirect offset block at the head of a loop - that's 
a good use I guess. With an indirect label block (or absolute offsets) 
you could do the machine without the loop, just branches at the end 
of each state, but if you had to do runtime searching for the labels 
that wouldn't be faster.
So, no threaded interpreters. Oh well.
Rebolek
28-Oct-2005
[986x8]
I was trying how fast is apply in new version but I'm not able to 
chceck it. I've got small test, I store precise time in a variable, 
run test, subtract precise time from stored time. But with new rebcode, 
second time is returned BEFORE rebocde is finished. Looks like if 
rebcode rust as independent task or thread (?).
Following test takes cca. 30secs on my computer, but REBOL says otherwise:
>> probe xt: now/time/precise muls probe xt - probe now/time/precise
23:10:45.859
23:10:46.015
-0:00:00.156
(forgot test function)
>> muls: rebcode [a][loop 1000000000 [mul a 2] return a]
Whe is the time printed before 'muls function is finished?
hm sorry, my fault :)
I forgot argument, better go to bad, good night :))
Henrik
29-Oct-2005
[994]
http://www.rebol.com/docs/rebcode.html<--- docs are up
BrianH
29-Oct-2005
[995x2]
New rebcode-enabled versions up: Core 2.6.51, View 1.3.51

Fixes since test 15 (as far as I can tell so far): The BRAB crash 
has been fixed in syntax - now the index can only be passed in a 
word, literal indexes have been disallowed (and were a little silly 
anyway, as they could be replaced by BRA or BRAW).
The great rename hasn't been done yet and BRAB is currently 0-based.
Ladislav
29-Oct-2005
[997]
the poll seems to be a little "unpopular", only two voters and one 
of them is me
BrianH
29-Oct-2005
[998x2]
The other is me.
Volker was making some comments earlier about BRAB, but apparently 
didn't vote. I think he was in favor of the third choice, BRAB/BRABZ, 
or perhaps passing the base as a parameter. I prefer that third choice, 
but 0-based is my fallback.
Volker
29-Oct-2005
[1000]
Missed the voting.
BrianH
29-Oct-2005
[1001]
It's still there, so vote!
Volker
29-Oct-2005
[1002]
I am not sure what i would need. With state-machines and such its 
no problem anyway, as i can choose the keys adjusted to brab's needs.
BrianH
29-Oct-2005
[1003]
When loop unrolling by modulus, you need 0-based.
Volker
29-Oct-2005
[1004x2]
Teaming up with rebol 1 would be better, but then a little add is 
no problem too. And 0 would be slightly faster, as the cpu does a 
0-bounds-check automatic.
So i give a weak pro to 0-based.
BrianH
29-Oct-2005
[1006]
As long as it's documented, it should be fine.
Volker
29-Oct-2005
[1007]
But how about a three-state if too? lesser/equal/higher 0? Could 
speed up binary search and such?
BrianH
29-Oct-2005
[1008x2]
(That reminds me: I need to finish reading the docs)
You mean a general CMP?
Volker
29-Oct-2005
[1010x2]
yes.
I hope that means a branch with three target.