Skip to content

FAILURE validate error using v128 #1566

@rckprtr

Description

@rckprtr

Im trying to use v128 to encode any Integer and Float value using LEB128

I have the algorithm working for integers and now trying to use v128 to support floats but Im getting the below error.

[wasm-validator error in function assembly/lib/utils/LEB128/EncodeLEB128v128<i64>] v128 != i32: binary child types must be equal, on 
[v128] (v128.and
 [v128] (local.get $0)
 [i32] (i32.const 127)
)
[wasm-validator error in function assembly/lib/utils/LEB128/EncodeLEB128v128<i64>] i32 != v128: v128 op, on 
[v128] (v128.and
 [v128] (local.get $0)
 [i32] (i32.const 127)
)
[wasm-validator error in function assembly/lib/utils/LEB128/EncodeLEB128v128<i64>] local.set's value type must be correct, on 
[none] (local.set $7
 [v128] (v128.and
  [v128] (local.get $0)
  [i32] (i32.const 127)
 )
)
[wasm-validator error in function assembly/lib/utils/LEB128/EncodeLEB128v128<i64>] v128 != i32: binary child types must be equal, on 
[v128] (i8x16.eq
 [v128] (local.get $0)
 [i32] (i32.const 0)
)
[wasm-validator error in function assembly/lib/utils/LEB128/EncodeLEB128v128<i64>] i32 != v128: v128 op, on 
[v128] (i8x16.eq
 [v128] (local.get $0)
 [i32] (i32.const 0)
)
[wasm-validator error in function assembly/lib/utils/LEB128/EncodeLEB128v128<i64>] v128 != i32: binary child types must be equal, on 
[v128] (i8x16.eq
 [v128] (local.get $0)
 [i32] (i32.const -1)
)
[wasm-validator error in function assembly/lib/utils/LEB128/EncodeLEB128v128<i64>] i32 != v128: v128 op, on 
[v128] (i8x16.eq
 [v128] (local.get $0)
 [i32] (i32.const -1)
)
[wasm-validator error in function assembly/counter/CounterActor#echo] call param types must match, on 
[i32] (call $assembly/lib/utils/LEB128/EncodeLEB128v128<i64>
 [i32] (i32.const 10000)
)
(on argument 0)

My code below. I used a generic for shr assuming I would use it like this:

var results = EncodeLEB128v128<f64>(<v128>(1234.5678));

function EncodeLEB128v128<T>(value: v128): PipeBuffer {

    let bytes: u8 = 0;
    let more: bool = true;
    let signBitSet: bool = true;

    var pipe = new PipeBuffer();

    
    while (more) {
        let chunk:u8 = <u8>v128.and(value,<v128>(0x7f));
        value = v128.shr<T>(value, 7);

        signBitSet = (chunk & 0x40) != 0; 
        more = !((value == <v128>0 && !signBitSet) || (value == <v128>-1 && signBitSet));
        if (more) { chunk |= 0x80; }

        pipe.write([chunk]);
        bytes += 1;
    };

    return pipe;
}

Ive been trying to find examples of using v128, if anyone has any it may help.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions