mirror of
https://github.com/pezkuwichain/wasm-instrument.git
synced 2026-06-13 21:01:07 +00:00
handle debug info (#16)
This commit is contained in:
+4
-1
@@ -1,3 +1,4 @@
|
||||
use parity_wasm::elements::Module;
|
||||
use std::{
|
||||
fs,
|
||||
io::{self, Read, Write},
|
||||
@@ -101,8 +102,10 @@ mod gas {
|
||||
run_diff_test("gas", concat!(stringify!($name), ".wat"), |input| {
|
||||
let rules = instrument::gas_metering::ConstantCostRules::default();
|
||||
|
||||
let module =
|
||||
let module: Module =
|
||||
elements::deserialize_buffer(input).expect("Failed to deserialize");
|
||||
let module = module.parse_names().expect("Failed to parse names");
|
||||
|
||||
let instrumented = instrument::gas_metering::inject(module, &rules, "env")
|
||||
.expect("Failed to instrument with gas metering");
|
||||
elements::serialize(instrumented).expect("Failed to serialize")
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
(module
|
||||
(type (;0;) (func (result i32)))
|
||||
(type (;1;) (func (param i32)))
|
||||
(import "env" "gas" (func $fibonacci_with_break (type 1)))
|
||||
(func (;1;) (type 0) (result i32)
|
||||
(import "env" "gas" (func (;0;) (type 1)))
|
||||
(func $fibonacci_with_break (;1;) (type 0) (result i32)
|
||||
(local i32 i32)
|
||||
i32.const 13
|
||||
call $fibonacci_with_break
|
||||
call 0
|
||||
block ;; label = @1
|
||||
i32.const 0
|
||||
local.set 0
|
||||
@@ -19,7 +19,7 @@
|
||||
i32.const 1
|
||||
br_if 0 (;@1;)
|
||||
i32.const 5
|
||||
call $fibonacci_with_break
|
||||
call 0
|
||||
local.get 0
|
||||
local.get 1
|
||||
local.tee 0
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
(module
|
||||
(type (;0;) (func (param i32 i32) (result i32)))
|
||||
(type (;1;) (func (param i32)))
|
||||
(import "env" "gas" (func $add_locals (type 1)))
|
||||
(func $add (type 0) (param $x i32) (param $y i32) (result i32)
|
||||
(import "env" "gas" (func (;0;) (type 1)))
|
||||
(func $add_locals (;1;) (type 0) (param $x i32) (param $y i32) (result i32)
|
||||
(local i32)
|
||||
i32.const 5
|
||||
call $add_locals
|
||||
call 0
|
||||
local.get $x
|
||||
local.get $y
|
||||
call 2
|
||||
call $add
|
||||
local.set 2
|
||||
local.get 2
|
||||
)
|
||||
(func (;2;) (type 0) (param i32 i32) (result i32)
|
||||
(func $add (;2;) (type 0) (param i32 i32) (result i32)
|
||||
i32.const 3
|
||||
call $add_locals
|
||||
call 0
|
||||
local.get 0
|
||||
local.get 1
|
||||
i32.add
|
||||
|
||||
@@ -2,12 +2,12 @@
|
||||
(type (;0;) (func (param i32 i32)))
|
||||
(type (;1;) (func))
|
||||
(type (;2;) (func (param i32)))
|
||||
(import "env" "ext_return" (func $ext_return (type 0)))
|
||||
(import "env" "ext_return" (func $ext_return (;0;) (type 0)))
|
||||
(import "env" "memory" (memory (;0;) 1 1))
|
||||
(import "env" "gas" (func $start (type 2)))
|
||||
(func (;2;) (type 1)
|
||||
(import "env" "gas" (func (;1;) (type 2)))
|
||||
(func $start (;2;) (type 1)
|
||||
i32.const 4
|
||||
call $start
|
||||
call 1
|
||||
i32.const 8
|
||||
i32.const 4
|
||||
call $ext_return
|
||||
@@ -15,6 +15,6 @@
|
||||
)
|
||||
(func (;3;) (type 1))
|
||||
(export "call" (func 3))
|
||||
(start 2)
|
||||
(start $start)
|
||||
(data (;0;) (i32.const 8) "\01\02\03\04")
|
||||
)
|
||||
@@ -2,8 +2,8 @@
|
||||
(type (;0;) (func))
|
||||
(type (;1;) (func (param i32 i32) (result i32)))
|
||||
(type (;2;) (func (param i32)))
|
||||
(import "env" "foo" (func $foo (type 0)))
|
||||
(func $i32.add (type 1) (param i32 i32) (result i32)
|
||||
(import "env" "foo" (func $foo (;0;) (type 0)))
|
||||
(func $i32.add (;1;) (type 1) (param i32 i32) (result i32)
|
||||
local.get 0
|
||||
local.get 1
|
||||
i32.add
|
||||
@@ -53,7 +53,7 @@
|
||||
i32.sub
|
||||
global.set 1
|
||||
)
|
||||
(global $counter (mut i32) i32.const 1)
|
||||
(global $counter (;0;) (mut i32) i32.const 1)
|
||||
(global (;1;) (mut i32) i32.const 0)
|
||||
(export "i32.add" (func 3))
|
||||
)
|
||||
@@ -1,8 +1,8 @@
|
||||
(module
|
||||
(type (;0;) (func))
|
||||
(type (;1;) (func (param i32 i32) (result i32)))
|
||||
(import "env" "foo" (func $foo (type 0)))
|
||||
(import "env" "boo" (func $boo (type 0)))
|
||||
(import "env" "foo" (func $foo (;0;) (type 0)))
|
||||
(import "env" "boo" (func $boo (;1;) (type 0)))
|
||||
(func (;2;) (type 1) (param i32 i32) (result i32)
|
||||
call $foo
|
||||
call $boo
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
(module
|
||||
(type (;0;) (func))
|
||||
(func $one-group-many-locals (type 0)
|
||||
(func $one-group-many-locals (;0;) (type 0)
|
||||
(local i64 i64 i32)
|
||||
)
|
||||
(func $main (type 0)
|
||||
(func $main (;1;) (type 0)
|
||||
global.get 0
|
||||
i32.const 5
|
||||
i32.add
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
(module
|
||||
(type (;0;) (func (param i32 i32)))
|
||||
(type (;1;) (func))
|
||||
(import "env" "ext_return" (func $ext_return (type 0)))
|
||||
(import "env" "ext_return" (func $ext_return (;0;) (type 0)))
|
||||
(import "env" "memory" (memory (;0;) 1 1))
|
||||
(func $start (type 1)
|
||||
(func $start (;1;) (type 1)
|
||||
(local i32)
|
||||
)
|
||||
(func (;2;) (type 1))
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
(type (;0;) (func))
|
||||
(type (;1;) (func (param i32)))
|
||||
(type (;2;) (func (param i32 i32) (result i32)))
|
||||
(import "env" "foo" (func $foo (type 0)))
|
||||
(import "env" "foo" (func $foo (;0;) (type 0)))
|
||||
(func (;1;) (type 1) (param i32)
|
||||
local.get 0
|
||||
i32.const 0
|
||||
@@ -23,7 +23,7 @@
|
||||
global.set 0
|
||||
drop
|
||||
)
|
||||
(func $i32.add (type 2) (param i32 i32) (result i32)
|
||||
(func $i32.add (;2;) (type 2) (param i32 i32) (result i32)
|
||||
local.get 0
|
||||
local.get 1
|
||||
i32.add
|
||||
|
||||
Reference in New Issue
Block a user