diff options
Diffstat (limited to 'test/binaryen.js')
-rw-r--r-- | test/binaryen.js/expressions.js | 42 | ||||
-rw-r--r-- | test/binaryen.js/expressions.js.txt | 28 | ||||
-rw-r--r-- | test/binaryen.js/kitchen-sink.js | 29 | ||||
-rw-r--r-- | test/binaryen.js/kitchen-sink.js.txt | 4 | ||||
-rw-r--r-- | test/binaryen.js/memory-info.js.txt | 4 | ||||
-rw-r--r-- | test/binaryen.js/sideffects.js | 1 |
6 files changed, 60 insertions, 48 deletions
diff --git a/test/binaryen.js/expressions.js b/test/binaryen.js/expressions.js index 40d4194fd..71846f3c6 100644 --- a/test/binaryen.js/expressions.js +++ b/test/binaryen.js/expressions.js @@ -476,7 +476,7 @@ console.log("# GlobalSet"); console.log("# MemorySize"); (function testMemorySize() { const module = new binaryen.Module(); - + module.setMemory(1, 1, null); var type = binaryen.i32; const theMemorySize = binaryen.MemorySize(module.memory.size()); assert(theMemorySize instanceof binaryen.MemorySize); @@ -492,7 +492,7 @@ console.log("# MemorySize"); assert( theMemorySize.toText() == - "(memory.size)\n" + "(memory.size $0)\n" ); module.dispose(); @@ -501,6 +501,7 @@ console.log("# MemorySize"); console.log("# MemoryGrow"); (function testMemoryGrow() { const module = new binaryen.Module(); + module.setMemory(1, 1, null); var type = binaryen.i32; var delta = module.i32.const(1); @@ -521,7 +522,7 @@ console.log("# MemoryGrow"); assert( theMemoryGrow.toText() == - "(memory.grow\n (i32.const 2)\n)\n" + "(memory.grow $0\n (i32.const 2)\n)\n" ); module.dispose(); @@ -530,6 +531,7 @@ console.log("# MemoryGrow"); console.log("# Load"); (function testLoad() { const module = new binaryen.Module(); + module.setMemory(1, 1, null); var offset = 16; var align = 2; @@ -566,7 +568,7 @@ console.log("# Load"); assert( theLoad.toText() == - "(i64.atomic.load offset=32 align=4\n (i32.const 128)\n)\n" + "(i64.atomic.load $0 offset=32 align=4\n (i32.const 128)\n)\n" ); module.dispose(); @@ -575,6 +577,7 @@ console.log("# Load"); console.log("# Store"); (function testStore() { const module = new binaryen.Module(); + module.setMemory(1, 1, null); var offset = 16; var align = 2; @@ -615,7 +618,7 @@ console.log("# Store"); assert( theStore.toText() == - "(i64.atomic.store offset=32 align=4\n (i32.const 128)\n (i32.const 2)\n)\n" + "(i64.atomic.store $0 offset=32 align=4\n (i32.const 128)\n (i32.const 2)\n)\n" ); module.dispose(); @@ -822,6 +825,7 @@ console.log("# Return"); console.log("# AtomicRMW"); (function testAtomicRMW() { const module = new binaryen.Module(); + module.setMemory(1, 1, null); var op = binaryen.Operations.AtomicRMWAdd; var offset = 8; @@ -855,7 +859,7 @@ console.log("# AtomicRMW"); assert( theAtomicRMW.toText() == - "(i64.atomic.rmw16.sub_u offset=16\n (i32.const 4)\n (i64.const 5)\n)\n" + "(i64.atomic.rmw16.sub_u $0 offset=16\n (i32.const 4)\n (i64.const 5)\n)\n" ); module.dispose(); @@ -864,6 +868,7 @@ console.log("# AtomicRMW"); console.log("# AtomicCmpxchg"); (function testAtomicCmpxchg() { const module = new binaryen.Module(); + module.setMemory(1, 1, null); var offset = 8; var ptr = module.i32.const(2); @@ -897,7 +902,7 @@ console.log("# AtomicCmpxchg"); assert( theAtomicCmpxchg.toText() == - "(i64.atomic.rmw16.cmpxchg_u offset=16\n (i32.const 5)\n (i64.const 6)\n (i64.const 7)\n)\n" + "(i64.atomic.rmw16.cmpxchg_u $0 offset=16\n (i32.const 5)\n (i64.const 6)\n (i64.const 7)\n)\n" ); module.dispose(); @@ -906,6 +911,7 @@ console.log("# AtomicCmpxchg"); console.log("# AtomicWait"); (function testAtomicWait() { const module = new binaryen.Module(); + module.setMemory(1, 1, null); var ptr = module.i32.const(2); var expected = module.i32.const(3); @@ -935,7 +941,7 @@ console.log("# AtomicWait"); assert( theAtomicWait.toText() == - "(memory.atomic.wait64\n (i32.const 5)\n (i32.const 6)\n (i64.const 7)\n)\n" + "(memory.atomic.wait64 $0\n (i32.const 5)\n (i32.const 6)\n (i64.const 7)\n)\n" ); module.dispose(); @@ -944,6 +950,7 @@ console.log("# AtomicWait"); console.log("# AtomicNotify"); (function testAtomicNotify() { const module = new binaryen.Module(); + module.setMemory(1, 1, null); var ptr = module.i32.const(1); var notifyCount = module.i32.const(2); @@ -966,7 +973,7 @@ console.log("# AtomicNotify"); assert( theAtomicNotify.toText() == - "(memory.atomic.notify\n (i32.const 3)\n (i32.const 4)\n)\n" + "(memory.atomic.notify $0\n (i32.const 3)\n (i32.const 4)\n)\n" ); module.dispose(); @@ -1172,6 +1179,7 @@ console.log("# SIMDShift"); console.log("# SIMDLoad"); (function testSIMDLoad() { const module = new binaryen.Module(); + module.setMemory(1, 1, null); var op = binaryen.Operations.Load8x8SVec128; var offset = 16; @@ -1201,7 +1209,7 @@ console.log("# SIMDLoad"); assert( theSIMDLoad.toText() == - "(v128.load8_splat offset=32 align=4\n (i32.const 2)\n)\n" + "(v128.load8_splat $0 offset=32 align=4\n (i32.const 2)\n)\n" ); module.dispose(); @@ -1210,6 +1218,7 @@ console.log("# SIMDLoad"); console.log("# SIMDLoadStoreLane"); (function testSIMDLoadStoreLane() { const module = new binaryen.Module(); + module.setMemory(1, 1, null); var op = binaryen.Operations.Load8LaneVec128; var offset = 16; @@ -1249,7 +1258,7 @@ console.log("# SIMDLoadStoreLane"); assert( theSIMDLoadStoreLane.toText() == - "(v128.load16_lane offset=32 2\n (i32.const 2)\n (v128.const i32x4 0x01010101 0x01010101 0x01010101 0x01010101)\n)\n" + "(v128.load16_lane $0 offset=32 2\n (i32.const 2)\n (v128.const i32x4 0x01010101 0x01010101 0x01010101 0x01010101)\n)\n" ); theSIMDLoadStoreLane.op = op = binaryen.Operations.Store16LaneVec128; @@ -1263,7 +1272,7 @@ console.log("# SIMDLoadStoreLane"); assert( theSIMDLoadStoreLane.toText() == - "(v128.store16_lane offset=32 2\n (i32.const 2)\n (v128.const i32x4 0x01010101 0x01010101 0x01010101 0x01010101)\n)\n" + "(v128.store16_lane $0 offset=32 2\n (i32.const 2)\n (v128.const i32x4 0x01010101 0x01010101 0x01010101 0x01010101)\n)\n" ); module.dispose(); @@ -1272,6 +1281,7 @@ console.log("# SIMDLoadStoreLane"); console.log("# MemoryInit"); (function testMemoryInit() { const module = new binaryen.Module(); + module.setMemory(1, 1, null); var segment = 1; var dest = module.i32.const(2); @@ -1302,7 +1312,7 @@ console.log("# MemoryInit"); assert( theMemoryInit.toText() == - "(memory.init 5\n (i32.const 6)\n (i32.const 7)\n (i32.const 8)\n)\n" + "(memory.init $0 5\n (i32.const 6)\n (i32.const 7)\n (i32.const 8)\n)\n" ); module.dispose(); @@ -1338,6 +1348,7 @@ console.log("# DataDrop"); console.log("# MemoryCopy"); (function testMemoryCopy() { const module = new binaryen.Module(); + module.setMemory(1, 1, null); var dest = module.i32.const(1); var source = module.i32.const(2); @@ -1364,7 +1375,7 @@ console.log("# MemoryCopy"); assert( theMemoryCopy.toText() == - "(memory.copy\n (i32.const 4)\n (i32.const 5)\n (i32.const 6)\n)\n" + "(memory.copy $0 $0\n (i32.const 4)\n (i32.const 5)\n (i32.const 6)\n)\n" ); module.dispose(); @@ -1373,6 +1384,7 @@ console.log("# MemoryCopy"); console.log("# MemoryFill"); (function testMemoryFill() { const module = new binaryen.Module(); + module.setMemory(1, 1, null); var dest = module.i32.const(1); var value = module.i32.const(2); @@ -1399,7 +1411,7 @@ console.log("# MemoryFill"); assert( theMemoryFill.toText() == - "(memory.fill\n (i32.const 4)\n (i32.const 5)\n (i32.const 6)\n)\n" + "(memory.fill $0\n (i32.const 4)\n (i32.const 5)\n (i32.const 6)\n)\n" ); module.dispose(); diff --git a/test/binaryen.js/expressions.js.txt b/test/binaryen.js/expressions.js.txt index b9107f5c1..fbf69888a 100644 --- a/test/binaryen.js/expressions.js.txt +++ b/test/binaryen.js/expressions.js.txt @@ -65,20 +65,20 @@ ) # MemorySize -(memory.size) +(memory.size $0) # MemoryGrow -(memory.grow +(memory.grow $0 (i32.const 2) ) # Load -(i64.atomic.load offset=32 align=4 +(i64.atomic.load $0 offset=32 align=4 (i32.const 128) ) # Store -(i64.atomic.store offset=32 align=4 +(i64.atomic.store $0 offset=32 align=4 (i32.const 128) (i32.const 2) ) @@ -115,27 +115,27 @@ ) # AtomicRMW -(i64.atomic.rmw16.sub_u offset=16 +(i64.atomic.rmw16.sub_u $0 offset=16 (i32.const 4) (i64.const 5) ) # AtomicCmpxchg -(i64.atomic.rmw16.cmpxchg_u offset=16 +(i64.atomic.rmw16.cmpxchg_u $0 offset=16 (i32.const 5) (i64.const 6) (i64.const 7) ) # AtomicWait -(memory.atomic.wait64 +(memory.atomic.wait64 $0 (i32.const 5) (i32.const 6) (i64.const 7) ) # AtomicNotify -(memory.atomic.notify +(memory.atomic.notify $0 (i32.const 3) (i32.const 4) ) @@ -175,23 +175,23 @@ ) # SIMDLoad -(v128.load8_splat offset=32 align=4 +(v128.load8_splat $0 offset=32 align=4 (i32.const 2) ) # SIMDLoadStoreLane -(v128.load16_lane offset=32 2 +(v128.load16_lane $0 offset=32 2 (i32.const 2) (v128.const i32x4 0x01010101 0x01010101 0x01010101 0x01010101) ) -(v128.store16_lane offset=32 2 +(v128.store16_lane $0 offset=32 2 (i32.const 2) (v128.const i32x4 0x01010101 0x01010101 0x01010101 0x01010101) ) # MemoryInit -(memory.init 5 +(memory.init $0 5 (i32.const 6) (i32.const 7) (i32.const 8) @@ -201,14 +201,14 @@ (data.drop 2) # MemoryCopy -(memory.copy +(memory.copy $0 $0 (i32.const 4) (i32.const 5) (i32.const 6) ) # MemoryFill -(memory.fill +(memory.fill $0 (i32.const 4) (i32.const 5) (i32.const 6) diff --git a/test/binaryen.js/kitchen-sink.js b/test/binaryen.js/kitchen-sink.js index 59f398da9..95c2568e6 100644 --- a/test/binaryen.js/kitchen-sink.js +++ b/test/binaryen.js/kitchen-sink.js @@ -178,6 +178,19 @@ function test_core() { // Module creation module = new binaryen.Module(); + // Memory + module.setMemory(1, 256, "mem", [ + { + passive: false, + offset: module.i32.const(10), + data: "hello, world".split('').map(function(x) { return x.charCodeAt(0) }) + }, + { + passive: true, + offset: null, + data: "I am passive".split('').map(function(x) { return x.charCodeAt(0) }) + } + ], true); // Create a tag var tag = module.addTag("a-tag", binaryen.i32, binaryen.none); @@ -723,21 +736,6 @@ function test_core() { assert(module.getNumTables() === 1); assert(module.getNumElementSegments() === 1); - // Memory. One per module - - module.setMemory(1, 256, "mem", [ - { - passive: false, - offset: module.i32.const(10), - data: "hello, world".split('').map(function(x) { return x.charCodeAt(0) }) - }, - { - passive: true, - offset: null, - data: "I am passive".split('').map(function(x) { return x.charCodeAt(0) }) - } - ], true); - // Start function. One per module var starter = module.addFunction("starter", binaryen.none, binaryen.none, [], module.nop()); module.setStart(starter); @@ -1141,6 +1139,7 @@ function test_for_each() { function test_expression_info() { module = new binaryen.Module(); + module.setMemory(1, 1, null); // Issue #2392 console.log("getExpressionInfo(memory.grow)=" + JSON.stringify(binaryen.getExpressionInfo(module.memory.grow(1)))); diff --git a/test/binaryen.js/kitchen-sink.js.txt b/test/binaryen.js/kitchen-sink.js.txt index 2a5a05fe8..1be13aefe 100644 --- a/test/binaryen.js/kitchen-sink.js.txt +++ b/test/binaryen.js/kitchen-sink.js.txt @@ -130,10 +130,10 @@ getExpressionInfo(tuple[3])={"id":14,"type":5,"value":3.7} (table $t0 1 funcref) (elem $e0 (i32.const 0) "$kitchen()sinker") (tag $a-tag (param i32)) + (export "mem" (memory $0)) (export "kitchen_sinker" (func "$kitchen()sinker")) (export "a-global-exp" (global $a-global)) (export "a-tag-exp" (tag $a-tag)) - (export "mem" (memory $0)) (start $starter) (func "$kitchen()sinker" (param $0 i32) (param $1 i64) (param $2 f32) (param $3 f64) (result i32) (local $4 i32) @@ -2234,10 +2234,10 @@ getExpressionInfo(tuple[3])={"id":14,"type":5,"value":3.7} (table $t0 1 funcref) (elem $e0 (i32.const 0) "$kitchen()sinker") (tag $a-tag (param i32)) + (export "mem" (memory $0)) (export "kitchen_sinker" (func "$kitchen()sinker")) (export "a-global-exp" (global $a-global)) (export "a-tag-exp" (tag $a-tag)) - (export "mem" (memory $0)) (start $starter) (func "$kitchen()sinker" (param $0 i32) (param $1 i64) (param $2 f32) (param $3 f64) (result i32) (local $4 i32) diff --git a/test/binaryen.js/memory-info.js.txt b/test/binaryen.js/memory-info.js.txt index 39d1290ae..ba04d7442 100644 --- a/test/binaryen.js/memory-info.js.txt +++ b/test/binaryen.js/memory-info.js.txt @@ -3,7 +3,7 @@ true {"module":"","base":"","initial":1,"shared":false,"max":64} true {"module":"","base":"","initial":1,"shared":true,"max":64} -false +true {"module":"env","base":"memory","initial":0,"shared":false,"max":65536} -false +true {"module":"env","base":"memory","initial":0,"shared":true,"max":65536} diff --git a/test/binaryen.js/sideffects.js b/test/binaryen.js/sideffects.js index e3187041d..be5414aed 100644 --- a/test/binaryen.js/sideffects.js +++ b/test/binaryen.js/sideffects.js @@ -17,6 +17,7 @@ console.log("SideEffects.TrapsNeverHappen=" + binaryen.SideEffects.TrapsNeverHap console.log("SideEffects.Any=" + binaryen.SideEffects.Any); var module = new binaryen.Module(); +module.setMemory(1, 1, null); assert( binaryen.getSideEffects( module.i32.const(1), |