From 72c52ea7d4eb61b95cf8a5164947cb760fe42e9c Mon Sep 17 00:00:00 2001 From: Thomas Lively <7121787+tlively@users.noreply.github.com> Date: Fri, 19 Jul 2019 16:24:37 -0700 Subject: Remove bulk memory instructions refering to active segments (#2235) This prevents those instructions from becoming invalid due to memory packing optimizations and is also a code size win. Fixes #2227. --- test/passes/memory-packing.txt | 20 ------------ test/passes/memory-packing.wast | 20 ------------ test/passes/memory-packing_all-features.txt | 47 ++++++++++++++++++++++++++++ test/passes/memory-packing_all-features.wast | 39 +++++++++++++++++++++++ 4 files changed, 86 insertions(+), 40 deletions(-) delete mode 100644 test/passes/memory-packing.txt delete mode 100644 test/passes/memory-packing.wast create mode 100644 test/passes/memory-packing_all-features.txt create mode 100644 test/passes/memory-packing_all-features.wast (limited to 'test') diff --git a/test/passes/memory-packing.txt b/test/passes/memory-packing.txt deleted file mode 100644 index 9805375f1..000000000 --- a/test/passes/memory-packing.txt +++ /dev/null @@ -1,20 +0,0 @@ -(module - (import "env" "memory" (memory $0 2048 2048)) - (data (global.get $memoryBase) "waka this cannot be optimized\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00we don\'t know where it will go") - (data (i32.const 1024) "waka this CAN be optimized") - (data (i32.const 1107) "we DO know where it will go") - (data (i32.const 2057) "zeros before") - (data (i32.const 3000) "zeros after") - (data (i32.const 4000) "zeros\00in\00the\00middle") - (data (i32.const 4035) "nice skip here") - (data (i32.const 4066) "another\00but no") - (import "env" "memoryBase" (global $memoryBase i32)) -) -(module - (import "env" "memory" (memory $0 2048 2048)) - (import "env" "memoryBase" (global $memoryBase i32)) -) -(module - (import "env" "memory" (memory $0 2048 2048)) - (import "env" "memoryBase" (global $memoryBase i32)) -) diff --git a/test/passes/memory-packing.wast b/test/passes/memory-packing.wast deleted file mode 100644 index 6cdd453d1..000000000 --- a/test/passes/memory-packing.wast +++ /dev/null @@ -1,20 +0,0 @@ -(module - (import "env" "memory" (memory $0 2048 2048)) - (import "env" "memoryBase" (global $memoryBase i32)) - (data (global.get $memoryBase) "waka this cannot be optimized\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00we don't know where it will go") - (data (i32.const 1024) "waka this CAN be optimized\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00we DO know where it will go") - (data (i32.const 2000) "\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00zeros before") - (data (i32.const 3000) "zeros after\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00") - (data (i32.const 4000) "zeros\00in\00the\00middle\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00nice skip here\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00another\00but no") -) -(module - (import "env" "memory" (memory $0 2048 2048)) - (import "env" "memoryBase" (global $memoryBase i32)) - ;; nothing -) -(module - (import "env" "memory" (memory $0 2048 2048)) - (import "env" "memoryBase" (global $memoryBase i32)) - (data (i32.const 4066) "") ;; empty -) - diff --git a/test/passes/memory-packing_all-features.txt b/test/passes/memory-packing_all-features.txt new file mode 100644 index 000000000..bf04ae91b --- /dev/null +++ b/test/passes/memory-packing_all-features.txt @@ -0,0 +1,47 @@ +(module + (import "env" "memory" (memory $0 2048 2048)) + (data (global.get $memoryBase) "waka this cannot be optimized\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00we don\'t know where it will go") + (data (i32.const 1024) "waka this CAN be optimized") + (data (i32.const 1107) "we DO know where it will go") + (data (i32.const 2057) "zeros before") + (data (i32.const 3000) "zeros after") + (data (i32.const 4000) "zeros\00in\00the\00middle") + (data (i32.const 4035) "nice skip here") + (data (i32.const 4066) "another\00but no") + (import "env" "memoryBase" (global $memoryBase i32)) +) +(module + (import "env" "memory" (memory $0 2048 2048)) + (import "env" "memoryBase" (global $memoryBase i32)) +) +(module + (import "env" "memory" (memory $0 2048 2048)) + (import "env" "memoryBase" (global $memoryBase i32)) +) +(module + (type $FUNCSIG$v (func)) + (memory $0 1 1) + (func $foo (; 0 ;) (type $FUNCSIG$v) + (block + (drop + (i32.const 0) + ) + (drop + (i32.const 0) + ) + (drop + (i32.const 0) + ) + (unreachable) + ) + (unreachable) + ) + (func $bar (; 1 ;) (type $FUNCSIG$v) + (drop + (loop $loop-in (result i32) + (unreachable) + (i32.const 42) + ) + ) + ) +) diff --git a/test/passes/memory-packing_all-features.wast b/test/passes/memory-packing_all-features.wast new file mode 100644 index 000000000..e43bd0314 --- /dev/null +++ b/test/passes/memory-packing_all-features.wast @@ -0,0 +1,39 @@ +(module + (import "env" "memory" (memory $0 2048 2048)) + (import "env" "memoryBase" (global $memoryBase i32)) + (data (global.get $memoryBase) "waka this cannot be optimized\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00we don't know where it will go") + (data (i32.const 1024) "waka this CAN be optimized\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00we DO know where it will go") + (data (i32.const 2000) "\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00zeros before") + (data (i32.const 3000) "zeros after\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00") + (data (i32.const 4000) "zeros\00in\00the\00middle\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00nice skip here\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00another\00but no") +) +(module + (import "env" "memory" (memory $0 2048 2048)) + (import "env" "memoryBase" (global $memoryBase i32)) + ;; nothing +) +(module + (import "env" "memory" (memory $0 2048 2048)) + (import "env" "memoryBase" (global $memoryBase i32)) + (data (i32.const 4066) "") ;; empty +) +(module + (memory $0 1 1) + (data (i32.const 0) "") + (func $foo + (memory.init 0 + (i32.const 0) + (i32.const 0) + (i32.const 0) + ) + (data.drop 0) + ) + (func $bar + (drop + (loop (result i32) + (data.drop 0) + (i32.const 42) + ) + ) + ) +) -- cgit v1.2.3