porffor 0.50.3 → 0.50.4
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/compiler/builtins.js +3 -2
- package/compiler/codegen.js +6 -26
- package/package.json +1 -1
- package/runner/index.js +1 -1
package/compiler/builtins.js
CHANGED
@@ -925,13 +925,14 @@ export const BuiltinFuncs = function() {
|
|
925
925
|
[ Opcodes.i32_sub ],
|
926
926
|
[ Opcodes.else ],
|
927
927
|
// else, currentPtr += bytesToAllocate
|
928
|
+
[ Opcodes.global_get, 0 ],
|
929
|
+
|
928
930
|
[ Opcodes.global_get, 0 ],
|
929
931
|
[ Opcodes.local_get, 0 ],
|
930
932
|
[ Opcodes.i32_add ],
|
931
933
|
[ Opcodes.global_set, 0 ],
|
932
934
|
|
933
|
-
// return currentPtr
|
934
|
-
[ Opcodes.global_get, 0 ],
|
935
|
+
// return currentPtr before +=
|
935
936
|
[ Opcodes.end ]
|
936
937
|
]
|
937
938
|
};
|
package/compiler/codegen.js
CHANGED
@@ -9,7 +9,7 @@ import * as Rhemyn from '../rhemyn/compile.js';
|
|
9
9
|
import parse from './parse.js';
|
10
10
|
import { log } from './log.js';
|
11
11
|
import './prefs.js';
|
12
|
-
import { allocPage
|
12
|
+
import { allocPage, allocStr } from './allocator.js';
|
13
13
|
|
14
14
|
let globals = {};
|
15
15
|
let tags = [];
|
@@ -1135,7 +1135,7 @@ const generateBinaryExp = (scope, decl, _global, _name) => {
|
|
1135
1135
|
|
1136
1136
|
const asmFuncToAsm = (scope, func) => {
|
1137
1137
|
return func(scope, {
|
1138
|
-
Valtype, Opcodes, TYPES, TYPE_NAMES, typeSwitch, makeString,
|
1138
|
+
Valtype, Opcodes, TYPES, TYPE_NAMES, typeSwitch, makeString, internalThrow,
|
1139
1139
|
getNodeType, generate, generateIdent,
|
1140
1140
|
builtin: (n, offset = false) => {
|
1141
1141
|
let idx = funcIndex[n] ?? importedFuncs[n];
|
@@ -1212,7 +1212,8 @@ const asmFuncToAsm = (scope, func) => {
|
|
1212
1212
|
i32ify: wasm => {
|
1213
1213
|
wasm.push(Opcodes.i32_to_u);
|
1214
1214
|
return wasm;
|
1215
|
-
}
|
1215
|
+
},
|
1216
|
+
allocPage: (scope, name) => allocPage({ scope, pages }, name)
|
1216
1217
|
});
|
1217
1218
|
};
|
1218
1219
|
|
@@ -1282,7 +1283,7 @@ const asmFunc = (name, { wasm, params = [], typedParams = false, locals: localTy
|
|
1282
1283
|
for (const inst of wasm) {
|
1283
1284
|
if (inst.at(-1) === 'read func lut') {
|
1284
1285
|
inst.splice(2, 99);
|
1285
|
-
inst.push(...unsignedLEB128(allocPage({}, 'func lut')));
|
1286
|
+
inst.push(...unsignedLEB128(allocPage({ scope: func, pages }, 'func lut')));
|
1286
1287
|
}
|
1287
1288
|
}
|
1288
1289
|
|
@@ -5046,27 +5047,6 @@ const generateMeta = (scope, decl) => {
|
|
5046
5047
|
};
|
5047
5048
|
|
5048
5049
|
let pages = new Map();
|
5049
|
-
const allocPage = (scope, name) => _allocPage({ scope, pages }, name);
|
5050
|
-
|
5051
|
-
const itemTypeToValtype = {
|
5052
|
-
i32: 'i32',
|
5053
|
-
i64: 'i64',
|
5054
|
-
f64: 'f64',
|
5055
|
-
|
5056
|
-
i8: 'i32',
|
5057
|
-
i16: 'i32'
|
5058
|
-
};
|
5059
|
-
|
5060
|
-
const StoreOps = {
|
5061
|
-
i32: Opcodes.i32_store,
|
5062
|
-
i64: Opcodes.i64_store,
|
5063
|
-
f64: Opcodes.f64_store,
|
5064
|
-
|
5065
|
-
// expects i32 input!
|
5066
|
-
i8: Opcodes.i32_store8,
|
5067
|
-
i16: Opcodes.i32_store16,
|
5068
|
-
};
|
5069
|
-
|
5070
5050
|
let data = [];
|
5071
5051
|
|
5072
5052
|
const compileBytes = (val, itemType) => {
|
@@ -5221,7 +5201,7 @@ const generateArray = (scope, decl, global = false, name = '$undeclared', static
|
|
5221
5201
|
if (staticAlloc) {
|
5222
5202
|
const uniqueName = name === '$undeclared' ? name + uniqId() : name;
|
5223
5203
|
|
5224
|
-
const ptr = allocPage(scope, uniqueName);
|
5204
|
+
const ptr = allocPage({ scope, pages }, uniqueName);
|
5225
5205
|
pointer = number(ptr, Valtype.i32)[0];
|
5226
5206
|
|
5227
5207
|
scope.arrays ??= new Map();
|
package/package.json
CHANGED