summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/wasm/spec/start.wast
blob: 513f7b9babfdd71d5c012ec0194f169d1026e94e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
(assert_invalid
  (module (func) (start 1))
  "unknown function"
)
(assert_invalid
  (module
    (func $main (result i32) (return (i32.const 0)))
    (start $main)
  )
  "start function"
)
(assert_invalid
  (module
    (func $main (param $a i32))
    (start $main)
  )
  "start function"
)
(module
  (memory (data "A"))
  (func $inc
    (i32.store8
      (i32.const 0)
      (i32.add
        (i32.load8_u (i32.const 0))
        (i32.const 1)
      )
    )
  )
  (func $get (result i32)
    (return (i32.load8_u (i32.const 0)))
  )
  (func $main
    (call $inc)
    (call $inc)
    (call $inc)
  )

  (start $main)
  (export "inc" (func $inc))
  (export "get" (func $get))
)
(assert_return (invoke "get") (i32.const 68))
(invoke "inc")
(assert_return (invoke "get") (i32.const 69))
(invoke "inc")
(assert_return (invoke "get") (i32.const 70))

(module
  (memory (data "A"))
  (func $inc
    (i32.store8
      (i32.const 0)
      (i32.add
        (i32.load8_u (i32.const 0))
        (i32.const 1)
      )
    )
  )
  (func $get (result i32)
    (return (i32.load8_u (i32.const 0)))
  )
  (func $main
    (call $inc)
    (call $inc)
    (call $inc)
  )
  (start 2)
  (export "inc" (func $inc))
  (export "get" (func $get))
)
(assert_return (invoke "get") (i32.const 68))
(invoke "inc")
(assert_return (invoke "get") (i32.const 69))
(invoke "inc")
(assert_return (invoke "get") (i32.const 70))

(module
  (func $print_i32 (import "spectest" "print") (param i32))
  (func $main (call $print_i32 (i32.const 1)))
  (start 1)
)

(module
  (func $print_i32 (import "spectest" "print") (param i32))
  (func $main (call $print_i32 (i32.const 2)))
  (start $main)
)

(assert_trap
  (module (func $main (unreachable)) (start $main))
  "unreachable"
)