Implements v128.const and adds support for vector value type. (#556)
This commit implements the v128.const, i32x4.add and i64x2.add in interpreter mode and this adds support for the vector value types in the locals and globals. Notably, the vector type values can be passed and returned by exported functions as well as host functions via two-uint64 encodings as described in #484 (comment). Note: implementation of these instructions on JIT will be done in subsequent PR. part of #484 Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
This commit is contained in:
@@ -732,7 +732,7 @@ func TestModule_validateExports(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestModule_buildGlobalInstances(t *testing.T) {
|
||||
func TestModule_buildGlobals(t *testing.T) {
|
||||
m := Module{GlobalSection: []*Global{
|
||||
{
|
||||
Type: &GlobalType{Mutable: true, ValType: ValueTypeF64},
|
||||
@@ -744,17 +744,27 @@ func TestModule_buildGlobalInstances(t *testing.T) {
|
||||
Init: &ConstantExpression{Opcode: OpcodeI32Const,
|
||||
Data: leb128.EncodeInt32(math.MaxInt32)},
|
||||
},
|
||||
{
|
||||
Type: &GlobalType{Mutable: false, ValType: ValueTypeV128},
|
||||
Init: &ConstantExpression{Opcode: OpcodeVecV128Const,
|
||||
Data: []byte{
|
||||
1, 0, 0, 0, 0, 0, 0, 0,
|
||||
2, 0, 0, 0, 0, 0, 0, 0,
|
||||
},
|
||||
},
|
||||
},
|
||||
}}
|
||||
|
||||
globals := m.buildGlobals(nil)
|
||||
expectedGlobals := []*GlobalInstance{
|
||||
{Type: &GlobalType{ValType: ValueTypeF64, Mutable: true}, Val: api.EncodeF64(math.MaxFloat64)},
|
||||
{Type: &GlobalType{ValType: ValueTypeI32, Mutable: false}, Val: math.MaxInt32},
|
||||
{Type: &GlobalType{ValType: ValueTypeV128, Mutable: false}, Val: 0x1, ValHi: 0x2},
|
||||
}
|
||||
require.Equal(t, expectedGlobals, globals)
|
||||
}
|
||||
|
||||
func TestModule_buildFunctionInstances(t *testing.T) {
|
||||
func TestModule_buildFunctions(t *testing.T) {
|
||||
nopCode := &Code{nil, []byte{OpcodeEnd}}
|
||||
m := Module{
|
||||
TypeSection: []*FunctionType{{}},
|
||||
|
||||
Reference in New Issue
Block a user