File tree Expand file tree Collapse file tree 2 files changed +61
-0
lines changed
packages/vm/src/wasm_backend Expand file tree Collapse file tree 2 files changed +61
-0
lines changed Original file line number Diff line number Diff line change @@ -20,4 +20,17 @@ mod tests {
2020 let engine = make_compiling_engine ( None ) ;
2121 assert ! ( compile( & engine, FLOATY ) . is_ok( ) ) ;
2222 }
23+
24+ #[ test]
25+ fn reference_types_dont_panic ( ) {
26+ const WASM : & str = r#"(module
27+ (type $t0 (func (param funcref externref)))
28+ (import "" "" (func $hello (type $t0)))
29+ )"# ;
30+
31+ let wasm = wat:: parse_str ( WASM ) . unwrap ( ) ;
32+ let engine = make_compiling_engine ( None ) ;
33+ let error = compile ( & engine, & wasm) . unwrap_err ( ) ;
34+ assert ! ( error. to_string( ) . contains( "FuncRef" ) ) ;
35+ }
2336}
Original file line number Diff line number Diff line change @@ -448,4 +448,52 @@ mod tests {
448448 . to_string( )
449449 . contains( "Bulk memory operation" ) ) ;
450450 }
451+
452+ #[ test]
453+ fn bulk_table_operations_not_supported ( ) {
454+ // these operations can take a long time with big tables
455+ let deterministic = Arc :: new ( Gatekeeper :: default ( ) ) ;
456+ let mut compiler = make_compiler_config ( ) ;
457+ compiler. push_middleware ( deterministic) ;
458+ let store = Store :: new ( compiler) ;
459+
460+ let wasm = wat:: parse_str (
461+ r#"
462+ (module
463+ (table 2 funcref)
464+ (func (export "test") (param $i i32) (result i32)
465+ ;; grow table to size of $i
466+ ref.null func
467+ local.get $i
468+ table.grow 0))
469+ "# ,
470+ )
471+ . unwrap ( ) ;
472+
473+ let result = Module :: new ( & store, wasm) ;
474+ assert ! ( result
475+ . unwrap_err( )
476+ . to_string( )
477+ . contains( "Reference type operation" ) ) ;
478+
479+ let wasm = wat:: parse_str (
480+ r#"
481+ (module
482+ (table 1000000000 funcref)
483+ (func (export "test") (param $i i32)
484+ ;; fill with nulls
485+ i32.const 0
486+ ref.null func
487+ i32.const 1000000000
488+ table.fill 0))
489+ "# ,
490+ )
491+ . unwrap ( ) ;
492+
493+ let result = Module :: new ( & store, wasm) ;
494+ assert ! ( result
495+ . unwrap_err( )
496+ . to_string( )
497+ . contains( "Reference type operation" ) ) ;
498+ }
451499}
You can’t perform that action at this time.
0 commit comments