@@ -6,14 +6,15 @@ use cache::Cache;
6
6
use vm:: Environment ;
7
7
8
8
pub use error:: Error ;
9
- use parity_wasm:: builder;
10
- use parity_wasm:: elements:: { self , External , MemoryType , Module } ;
11
9
pub use std:: ptr:: NonNull ;
12
10
use std:: sync:: Arc ;
11
+ use wasm_instrument:: parity_wasm:: builder;
12
+ use wasm_instrument:: parity_wasm:: elements:: { self , External , MemoryType , Module } ;
13
13
use wasmer:: Universal ;
14
14
use wasmer_middlewares:: metering:: { get_remaining_points, MeteringPoints } ;
15
15
16
- use pwasm_utils:: { self } ;
16
+ // use pwasm_utils::{self};
17
+ use wasm_instrument:: { self } ;
17
18
18
19
use wasmer:: Singlepass ;
19
20
@@ -75,7 +76,9 @@ fn inject_memory(module: Module) -> Result<Module, Error> {
75
76
}
76
77
77
78
fn inject_stack_height ( module : Module ) -> Result < Module , Error > {
78
- pwasm_utils:: stack_height:: inject_limiter ( module, MAX_STACK_HEIGHT )
79
+ // pwasm_utils::stack_height::inject_limiter(module, MAX_STACK_HEIGHT)
80
+ // .map_err(|_| Error::StackHeightInjectionError)
81
+ wasm_instrument:: inject_stack_limiter ( module, MAX_STACK_HEIGHT )
79
82
. map_err ( |_| Error :: StackHeightInjectionError )
80
83
}
81
84
@@ -327,10 +330,10 @@ mod test {
327
330
328
331
use super :: * ;
329
332
use assert_matches:: assert_matches;
330
- use parity_wasm:: elements;
331
333
use std:: io:: { Read , Write } ;
332
334
use std:: process:: Command ;
333
335
use tempfile:: NamedTempFile ;
336
+ use wasm_instrument:: parity_wasm:: elements;
334
337
335
338
pub struct MockEnv { }
336
339
@@ -405,7 +408,7 @@ mod test {
405
408
fn test_compile ( ) {
406
409
let wasm = wat2wasm (
407
410
r#"(module
408
- (type (func (param i64 i64 i32 i64) (result i64)))
411
+ (type (func (param i64 i64 i64 i64) (result i64)))
409
412
(import "env" "ask_external_data" (func (type 0)))
410
413
(func
411
414
(local $idx i32)
@@ -428,7 +431,7 @@ mod test {
428
431
let code = compile ( & wasm) . unwrap ( ) ;
429
432
let expected = wat2wasm (
430
433
r#"(module
431
- (type (;0;) (func (param i64 i64 i32 i64) (result i64)))
434
+ (type (;0;) (func (param i64 i64 i64 i64) (result i64)))
432
435
(type (;1;) (func))
433
436
(import "env" "ask_external_data" (func (;0;) (type 0)))
434
437
(func (;1;) (type 1)
@@ -450,7 +453,7 @@ mod test {
450
453
(func (;2;) (type 1))
451
454
(func (;3;) (type 1)
452
455
global.get 0
453
- i32.const 3
456
+ i32.const 5
454
457
i32.add
455
458
global.set 0
456
459
global.get 0
@@ -461,7 +464,7 @@ mod test {
461
464
end
462
465
call 1
463
466
global.get 0
464
- i32.const 3
467
+ i32.const 5
465
468
i32.sub
466
469
global.set 0)
467
470
(memory (;0;) 17 512)
@@ -489,7 +492,7 @@ mod test {
489
492
)
490
493
)
491
494
(func (;"execute": Resolves with result "beeb";)
492
- )
495
+ )
493
496
(memory 17)
494
497
(data (i32.const 1048576) "beeb") (;str = "beeb";)
495
498
(export "prepare" (func 0))
@@ -628,7 +631,7 @@ mod test {
628
631
(func (;1;) (type 0))
629
632
(func (;2;) (type 0)
630
633
global.get 0
631
- i32.const 3
634
+ i32.const 5
632
635
i32.add
633
636
global.set 0
634
637
global.get 0
@@ -639,13 +642,29 @@ mod test {
639
642
end
640
643
call 0
641
644
global.get 0
642
- i32.const 3
645
+ i32.const 5
646
+ i32.sub
647
+ global.set 0)
648
+ (func (;3;) (type 0)
649
+ global.get 0
650
+ i32.const 2
651
+ i32.add
652
+ global.set 0
653
+ global.get 0
654
+ i32.const 16384
655
+ i32.gt_u
656
+ if ;; label = @1
657
+ unreachable
658
+ end
659
+ call 1
660
+ global.get 0
661
+ i32.const 2
643
662
i32.sub
644
663
global.set 0)
645
664
(memory (;0;) 17)
646
665
(global (;0;) (mut i32) (i32.const 0))
647
666
(export "prepare" (func 2))
648
- (export "execute" (func 1 ))
667
+ (export "execute" (func 3 ))
649
668
(data (;0;) (i32.const 1048576) "beeb"))"# ,
650
669
) ;
651
670
assert_eq ! ( wasm, expected) ;
0 commit comments