You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
3. Run the `.wasm` files using a minimal JS runtime
123
+
- Example: `node wasm.js <.wasm file>`
124
+
- Example: `node wasm.js binary_tree.wasm`
125
+
126
+
The `demo_wasm.sh` script is a useful utility to compile and run files with the WASM backend with a single command (provide the path to the input source file as an argument).
127
+
- To run the same example as above, run `./demo_wasm.sh tests/runtime/binary_tree.py`
128
+
129
+
### WASM Backend - Supported Features:
116
130
- int, bool, string, list
117
131
- most operators
118
132
- assignment
119
133
- control flow
120
134
- stdlib: print, len, and assert
121
135
- globals
122
136
123
-
Unsupported/TODO:
137
+
### WASM Backend - Unsupported Features:
124
138
- class/object
125
139
- nonlocal (partial)
126
-
- stdlib: input
140
+
- stdlib: input (node.js does not have synchronous I/O out of the box so this is difficult)
127
141
128
-
Memory format:
142
+
### WASM Backend - Memory Format, Safety, and Management:
129
143
130
144
- strings (utf-8) - first 4 bytes for length, followed by 1 byte for each character
131
145
- lists - first 4 bytes for length, followed by 8 bytes for each element
132
146
- ints - i64
133
-
- pointers (objects, strings, lists) - i32
134
-
- None - 0 (i32)
135
-
136
-
Strings and lists are stored in the heap, aligned to 8 bytes. Note that memory does not get freed/garbage collected, so memory will run out for long-running programs. This is especially a problem with string iteration and string/list concatenation, since indexing a string in Chocopy requires a new string to be allocated.
147
+
- pointers (objects, strings, lists) - i32, where `None` is 0
137
148
138
-
To provide memory safety, string/list indexing have bounds checking and list operations have a null-check, which crashes the program with a generic "unreachable" instruction.
149
+
Strings, lists, objects, and refs holding nonlocals are stored in the heap, aligned to 8 bytes. Right now, memory does not get freed/garbage collected once it is allocated. To provide memory safety, string/list indexing have bounds checking and list operations have a null-check, which crashes the program with a generic "unreachable" instruction.
0 commit comments