World: r3wp
[rebcode] Rebcode discussion
older newer | first last |
Rebolek 28-Oct-2005 [989x5] | (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 [1010x3] | yes. |
I hope that means a branch with three target. | |
( 2 target and next comand ) | |
BrianH 29-Oct-2005 [1013] | That would be faster if rebcode was implemented in x86 assembler, but how about other platforms? How would you make this faster if the engine is pargrammed in straight C? |
Volker 29-Oct-2005 [1014] | For now we have an interpreter. For straight c, it would not slow down at least. And with assembler a braw would be as fast as a brab, so we would not need it. althought if c shall be an option, brab matches to switch. |
BrianH 29-Oct-2005 [1015x2] | How would you do it, like this? cmp.i: ["Sets a variable to -1,0,1 if two values are <,=,>" word! word! | integer! word! | integer!] cmp.d: ["Sets a variable to -1,0,1 if two values are <,=,>" word! word! | decimal! word! | decimal!] |
; And then use it like this: cmp.i t a b brab [leq lgt] t ; Less than label leq ; Equal label lgt ; Greater than | |
Volker 29-Oct-2005 [1017x2] | No, i thought about a branch with 3 targets. misunderstanding, not cmp then. |
sub left-elem right-elem bra3 to-lesser to-higher left-elem ; here they are same | |
BrianH 29-Oct-2005 [1019] | Well, brab has three targets in the example above: 0, 1 and default. |
Volker 29-Oct-2005 [1020x2] | yes, but bra3 has -infinite..-1, 0, 1..infinite |
which is supported by cpu-flagwords. | |
BrianH 29-Oct-2005 [1022x2] | Then you are thinking like this? cmp.i: ["Do one of three blocks based on if two values are <,=,>" word! | integer! word! | integer! block! block! block!] cmp.d: ["Do one of three blocks based on if two values are <,=,>" word! | decimal! word! | decimal! block! block! block!] |
; And then use it like this: cmp.i a b [ ; Less than ] [ ; Equal ] [ ; Greater than ] | |
Volker 29-Oct-2005 [1024] | something like this. But imho it does to much. and it should work with gotos, is it possible to jump out of a blick? |
BrianH 29-Oct-2005 [1025] | No. That is why I prefer my first suggestion. |
Volker 29-Oct-2005 [1026x2] | that would be slower. |
the typical thing is that you really subtract (or compare) and follow that by two conditional branches. no lookup like with brab needed. | |
BrianH 29-Oct-2005 [1028] | Not much slower, really. If you specify a literal branch target block, both my suggestions would be translated to the same machine code by a JIT. |
Volker 29-Oct-2005 [1029x4] | next s1 next s2 seti char s1 sub char s2 bra3 to-equal to-higher ; we are lesser here label to-eqaul next s1 next s2 ; check length.. bra loop label to-higher ; we are higher here |
It was you who claimed a little extra add is to slow. | |
The jit has to realize that your compare results in -1, 0, 1, that you add 1, and then that you brab. Possible, but needs more insights. | |
which bloats jit. | |
BrianH 29-Oct-2005 [1033] | That would require a 3-valued comparison flag to be set inside the interpreter. Right now there is only a true/false flag. |
Volker 29-Oct-2005 [1034] | No, the bra3 takes a variable with the result of a 'sub. with jit that is a very small peephole, easy to detect. |
BrianH 29-Oct-2005 [1035x2] | A JIT would know that a cmp would only set t to -1, 0 or 1, and then know what to translate a following brab on it to. |
Your example bra3 there didn't act that way - the result of a sub isn't referenced. Do you want to fix your example? | |
Volker 29-Oct-2005 [1037x2] | You cant do a brab on a -1. |
So you have to track three statements. And to give always that order or the jit needs to look even deeper. | |
older newer | first last |