porffor 0.18.9 → 0.18.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/.editorconfig ADDED
@@ -0,0 +1,12 @@
1
+ # EditorConfig is awesome: https://EditorConfig.org
2
+
3
+ # top-most EditorConfig file
4
+ root = true
5
+
6
+ [*]
7
+ indent_style = space
8
+ indent_size = 2
9
+ end_of_line = lf
10
+ charset = utf-8
11
+ trim_trailing_whitespace = true
12
+ insert_final_newline = false
@@ -1140,5 +1140,50 @@ export const BuiltinFuncs = function() {
1140
1140
  ]
1141
1141
  };
1142
1142
 
1143
+ this.__Porffor_allocateBytes = {
1144
+ params: [ Valtype.i32 ],
1145
+ locals: [],
1146
+ globals: [ Valtype.i32, Valtype.i32 ],
1147
+ globalNames: [ 'currentPtr', 'bytesWritten' ],
1148
+ globalInits: [ 0, pageSize ], // init to pageSize so we always allocate on first call
1149
+ returns: [ Valtype.i32 ],
1150
+ returnType: TYPES.number,
1151
+ wasm: [
1152
+ // bytesWritten += bytesToAllocate
1153
+ [ Opcodes.local_get, 0 ],
1154
+ [ Opcodes.global_get, 1 ],
1155
+ [ Opcodes.i32_add ],
1156
+ [ Opcodes.global_set, 1 ],
1157
+
1158
+ // if bytesWritten >= pageSize:
1159
+ [ Opcodes.global_get, 1 ],
1160
+ ...number(pageSize, Valtype.i32),
1161
+ [ Opcodes.i32_ge_s ],
1162
+ [ Opcodes.if, Valtype.i32 ],
1163
+ // bytesWritten = 0
1164
+ [ Opcodes.local_get, 0 ],
1165
+ [ Opcodes.global_set, 1 ],
1166
+
1167
+ // grow memory by 1 page
1168
+ ...number(1, Valtype.i32),
1169
+ [ Opcodes.memory_grow, 0x00 ],
1170
+
1171
+ // currentPtr = old page count * pageSize
1172
+ ...number(pageSize, Valtype.i32),
1173
+ [ Opcodes.i32_mul ],
1174
+ [ Opcodes.global_set, 0 ],
1175
+ [ Opcodes.else ],
1176
+ // else, currentPtr += bytesToAllocate
1177
+ [ Opcodes.global_get, 0 ],
1178
+ [ Opcodes.local_get, 0 ],
1179
+ [ Opcodes.i32_add ],
1180
+ [ Opcodes.global_set, 0 ]
1181
+ [ Opcodes.end ],
1182
+
1183
+ // return currentPtr
1184
+ [ Opcodes.global_get, 0 ]
1185
+ ]
1186
+ };
1187
+
1143
1188
  GeneratedBuiltins.BuiltinFuncs.call(this);
1144
1189
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "porffor",
3
3
  "description": "a basic experimental wip aot optimizing js -> wasm engine/compiler/runtime in js",
4
- "version": "0.18.9+336c1baba",
4
+ "version": "0.18.11+3744bea72",
5
5
  "author": "CanadaHonk",
6
6
  "license": "MIT",
7
7
  "scripts": {},
package/runner/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  import fs from 'node:fs';
3
- globalThis.version = '0.18.9+336c1baba';
3
+ globalThis.version = '0.18.11+3744bea72';
4
4
 
5
5
  // deno compat
6
6
  if (typeof process === 'undefined' && typeof Deno !== 'undefined') {