|
66 | 66 | ) |
67 | 67 | ) |
68 | 68 | ) |
| 69 | + |
| 70 | +;; Import a struct in a global. |
| 71 | +(module |
| 72 | + ;; OPEND: (type $A (struct (field i32))) |
| 73 | + ;; CLOSE: (type $A (struct (field i32))) |
| 74 | + (type $A (struct (field i32))) |
| 75 | + |
| 76 | + ;; OPEND: (type $1 (func (result i32))) |
| 77 | + |
| 78 | + ;; OPEND: (import "primary" "global" (global $import (ref null $A))) |
| 79 | + ;; CLOSE: (type $1 (func (result i32))) |
| 80 | + |
| 81 | + ;; CLOSE: (import "primary" "global" (global $import (ref null $A))) |
| 82 | + (import "primary" "global" (global $import (ref null $A))) |
| 83 | + |
| 84 | + ;; OPEND: (func $read (type $1) (result i32) |
| 85 | + ;; OPEND-NEXT: (struct.get $A 0 |
| 86 | + ;; OPEND-NEXT: (global.get $import) |
| 87 | + ;; OPEND-NEXT: ) |
| 88 | + ;; OPEND-NEXT: ) |
| 89 | + ;; CLOSE: (func $read (type $1) (result i32) |
| 90 | + ;; CLOSE-NEXT: (unreachable) |
| 91 | + ;; CLOSE-NEXT: ) |
| 92 | + (func $read (result i32) |
| 93 | + ;; In closed world, we can assume no work happens on this struct outside, so |
| 94 | + ;; it can only be null. In open world, we can do nothing here. |
| 95 | + (struct.get $A 0 |
| 96 | + (global.get $import) |
| 97 | + ) |
| 98 | + ) |
| 99 | +) |
| 100 | + |
| 101 | +;; Import an array. |
| 102 | +(module |
| 103 | + ;; OPEND: (type $A (array (mut i32))) |
| 104 | + ;; CLOSE: (type $A (array (mut i32))) |
| 105 | + (type $A (array (mut i32))) |
| 106 | + |
| 107 | + ;; OPEND: (type $1 (func (result i32))) |
| 108 | + |
| 109 | + ;; OPEND: (import "primary" "global" (global $import (ref null $A))) |
| 110 | + ;; CLOSE: (type $1 (func (result i32))) |
| 111 | + |
| 112 | + ;; CLOSE: (import "primary" "global" (global $import (ref null $A))) |
| 113 | + (import "primary" "global" (global $import (ref null $A))) |
| 114 | + |
| 115 | + ;; OPEND: (func $read (type $1) (result i32) |
| 116 | + ;; OPEND-NEXT: (array.get $A |
| 117 | + ;; OPEND-NEXT: (global.get $import) |
| 118 | + ;; OPEND-NEXT: (i32.const 0) |
| 119 | + ;; OPEND-NEXT: ) |
| 120 | + ;; OPEND-NEXT: ) |
| 121 | + ;; CLOSE: (func $read (type $1) (result i32) |
| 122 | + ;; CLOSE-NEXT: (unreachable) |
| 123 | + ;; CLOSE-NEXT: ) |
| 124 | + (func $read (result i32) |
| 125 | + ;; We do not optimize in open world. |
| 126 | + (array.get $A |
| 127 | + (global.get $import) |
| 128 | + (i32.const 0) |
| 129 | + ) |
| 130 | + ) |
| 131 | +) |
| 132 | + |
| 133 | +;; Import a struct with a descriptor. |
| 134 | +(module |
| 135 | + (rec |
| 136 | + ;; OPEND: (rec |
| 137 | + ;; OPEND-NEXT: (type $A (sub (descriptor $A.desc (struct)))) |
| 138 | + ;; CLOSE: (rec |
| 139 | + ;; CLOSE-NEXT: (type $A (sub (descriptor $A.desc (struct)))) |
| 140 | + (type $A (sub (descriptor $A.desc (struct)))) |
| 141 | + ;; OPEND: (type $A.desc (sub (describes $A (struct)))) |
| 142 | + ;; CLOSE: (type $A.desc (sub (describes $A (struct)))) |
| 143 | + (type $A.desc (sub (describes $A (struct)))) |
| 144 | + ) |
| 145 | + |
| 146 | + ;; OPEND: (type $2 (func (result anyref))) |
| 147 | + |
| 148 | + ;; OPEND: (import "primary" "global" (global $import (ref null $A))) |
| 149 | + ;; CLOSE: (type $2 (func (result anyref))) |
| 150 | + |
| 151 | + ;; CLOSE: (import "primary" "global" (global $import (ref null $A))) |
| 152 | + (import "primary" "global" (global $import (ref null $A))) |
| 153 | + |
| 154 | + ;; OPEND: (func $read (type $2) (result anyref) |
| 155 | + ;; OPEND-NEXT: (ref.get_desc $A |
| 156 | + ;; OPEND-NEXT: (global.get $import) |
| 157 | + ;; OPEND-NEXT: ) |
| 158 | + ;; OPEND-NEXT: ) |
| 159 | + ;; CLOSE: (func $read (type $2) (result anyref) |
| 160 | + ;; CLOSE-NEXT: (unreachable) |
| 161 | + ;; CLOSE-NEXT: ) |
| 162 | + (func $read (result anyref) |
| 163 | + ;; We do not optimize in open world. |
| 164 | + (ref.get_desc $A |
| 165 | + (global.get $import) |
| 166 | + ) |
| 167 | + ) |
| 168 | +) |
| 169 | + |
0 commit comments