@amxts/core 0.2.3 → 0.3.0
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/README.md +5 -5
- package/README.ru.md +5 -5
- package/as/amxts.d.ts +13 -3
- package/as/entities.ts +571 -501
- package/as/events.ts +3323 -557
- package/as/facade.ts +3079 -718
- package/as/fetch.ts +2 -2
- package/as/fs.ts +352 -59
- package/as/hlds.ts +121 -120
- package/as/hooks.ts +10585 -5177
- package/as/lib/check.ts +3 -2
- package/as/natives.ts +856 -1272
- package/as/promise.ts +37 -27
- package/as/vector.ts +94 -14
- package/includes/order.txt +17 -19
- package/node_modules/assemblyscript/std/assembly/index.d.ts +1 -1
- package/package.json +9 -6
- package/runtime/deps/assemblyscript/dist/asc.js +136 -42
- package/runtime/deps/assemblyscript/dist/assemblyscript.js +141 -141
- package/runtime/licenses/README.md +9 -7
- package/runtime/licenses/ReGameDLL-LICENSE +21 -0
- package/runtime/licenses/ReHLDS-LICENSE +21 -0
- package/runtime/licenses/zlib-LICENSE +22 -0
- package/runtime/natives.txt +618 -523
- package/runtime/patches/README.md +87 -1
- package/runtime/patches/assemblyscript-0.28.20-amxts.patch +4838 -416
- package/runtime/patches/wamr-2.4.5-amxts.patch +417 -5
- package/scripts/auto-imports.ts +1 -1
- package/scripts/build-identity.ts +102 -65
- package/scripts/build-wasm.ts +17 -13
- package/scripts/check.ts +4 -1
- package/scripts/client-messages.ts +73 -1
- package/scripts/compile-cache.ts +11 -8
- package/scripts/compile-pool.ts +6 -3
- package/scripts/compile-worker.ts +23 -23
- package/scripts/compile.ts +142 -19
- package/scripts/docs/as/amxts.ts +10 -4
- package/scripts/docs/as/facade.ts +1779 -275
- package/scripts/docs/as/fetch.ts +2 -2
- package/scripts/docs/as/fs.ts +190 -6
- package/scripts/docs/as/vector.ts +81 -0
- package/scripts/docs/entities.ts +12 -0
- package/scripts/docs/events.ts +49 -13
- package/scripts/docs/game.ts +6 -0
- package/scripts/docs/messages.ts +10 -1
- package/scripts/hlds-events.ts +11 -11
- package/scripts/includes.ts +3 -4
- package/scripts/leaf-natives.ts +84 -0
- package/scripts/player-fields.ts +1 -1
- package/scripts/plugin-natives.ts +1 -1
- package/scripts/prebuilt.ts +42 -11
- package/scripts/project.ts +63 -4
- package/scripts/reapi-events.ts +9 -9
- package/scripts/server-env.ts +145 -0
- package/scripts/shared-modules.ts +23 -7
- package/scripts/system.ts +1 -1
- package/scripts/tracked-fs.ts +11 -2
- package/scripts/typed-commands.ts +153 -15
- package/scripts/upgrade-calls.ts +225 -0
- package/scripts/upgrade-names.ts +1 -4
- package/scripts/upgrade.ts +47 -34
- package/src/cli-api.mjs +3 -2
- package/src/system.mjs +21 -11
- package/src/testing/compile.ts +31 -8
- package/src/testing/coroutines.ts +0 -10
- package/src/testing/memory.ts +89 -2
- package/src/testing/natives.ts +67 -30
- package/src/testing/server.ts +1094 -155
- package/src/testing/tables.ts +23 -6
- package/src/typecheck.mjs +110 -0
- package/runtime/licenses/Bun-LICENSE.md +0 -84
|
@@ -30,7 +30,74 @@ unions of string literals, closures, optional properties and `undefined`,
|
|
|
30
30
|
`?.`, `??`, destructuring, `Record` and index signatures with `in`, `delete`,
|
|
31
31
|
`Object.keys` and `for...in`, `try`/`catch`/`finally`, typed `JSON`, text joined
|
|
32
32
|
with a number by `+`, `async`/`await`, overloads, object types in place,
|
|
33
|
-
return types read off the body
|
|
33
|
+
return types read off the body (a returned literal is the interface of its
|
|
34
|
+
file), `flatMap`, a `sort` comparator whose number orders by its sign
|
|
35
|
+
(`(a, b) => a - b` on fractions), a handler typed `Context & Player` that takes either,
|
|
36
|
+
`Date` in the server's time zone.
|
|
37
|
+
|
|
38
|
+
It also tunes the runtime (`std/assembly/rt/`) for a plugin, which makes
|
|
39
|
+
many small objects over a small live heap: a small block freed (up to 124
|
|
40
|
+
bytes) goes on a list of its size, and the next allocation of that size
|
|
41
|
+
takes it without TLSF's search, split or merge; and the incremental collector
|
|
42
|
+
starts a cycle only once the heap has doubled and grown 1 MB more
|
|
43
|
+
(`ASC_GC_IDLEGAP`), not 1 KB, since a cycle visits every root and every
|
|
44
|
+
live object. `ASC_GC_STRESS` steps the collector on every allocation, for
|
|
45
|
+
the tests of what the shadow stack keeps.
|
|
46
|
+
|
|
47
|
+
And it makes a plugin's many small calls cheaper:
|
|
48
|
+
|
|
49
|
+
- a function that can reach no collection - no allocation, no import (a
|
|
50
|
+
native may call back into the plugin) other than one marked `@leaf`, no
|
|
51
|
+
call through a function value - keeps no shadow-stack frame, and a call
|
|
52
|
+
to it no slots for its arguments; in one that can, a local gets a slot
|
|
53
|
+
only if it holds a value across such a call (`src/passes/shadowstack.ts`) -
|
|
54
|
+
a template's parts are read again after its join, which takes them from
|
|
55
|
+
a static array the collector never visits;
|
|
56
|
+
- the check for an error on its way to a catch after a call is kept only
|
|
57
|
+
where the callee may throw, which is known once the whole program is
|
|
58
|
+
compiled;
|
|
59
|
+
- a variable a closure captured is read and written in place, not through
|
|
60
|
+
a call.
|
|
61
|
+
|
|
62
|
+
And it allocates less:
|
|
63
|
+
|
|
64
|
+
- an array subclass can keep its elements in its own object (`new
|
|
65
|
+
Array(length, true)` leaves it without a buffer for the subclass to point
|
|
66
|
+
at room of its own, as `Vector` does): one allocation, its own buffer
|
|
67
|
+
until it grows past that room;
|
|
68
|
+
- an object that never leaves the function that makes it - its fields read
|
|
69
|
+
and written there, its address given only to an import that keeps none or
|
|
70
|
+
to a function that keeps none of it - is made in that function's part of
|
|
71
|
+
the shadow stack, with the header of a static object the collector never
|
|
72
|
+
frees (`src/passes/stackobjects.ts`, run by the build on the optimized
|
|
73
|
+
module, `makeStackObjects`). Which parameters a function keeps is worked
|
|
74
|
+
out for the whole program first: stored into the heap or a global,
|
|
75
|
+
returned, captured, given on to a function or an import that keeps it.
|
|
76
|
+
An object literal is made where it is written, not by a call, and an
|
|
77
|
+
array literal is one allocation, its elements in its own object, so
|
|
78
|
+
`player.showHud(text, { color: [255, 40, 40] })` allocates nothing; an
|
|
79
|
+
object stored into another made in the same frame stays there with it.
|
|
80
|
+
The collector reads the references in such an object when it reads the
|
|
81
|
+
stack, so a store into one needs no barrier; a function an async
|
|
82
|
+
function's coroutine may park in is left alone;
|
|
83
|
+
- null stored into a reference field is a plain store, without the
|
|
84
|
+
collector's barrier, and a field that starts at zero is not written again
|
|
85
|
+
in a constructor: the incremental runtime's allocation is zeroed;
|
|
86
|
+
- a constructor inlined as a super call does not check again whether
|
|
87
|
+
`this` was allocated.
|
|
88
|
+
|
|
89
|
+
And it keeps a whole number in an integer: a `number` local that can only
|
|
90
|
+
ever hold a whole number within i32 - a loop's counter, an index, a
|
|
91
|
+
remainder, a product or a sum of such - gets an i32 local in its place, and
|
|
92
|
+
the arithmetic and the comparisons over it are i32's
|
|
93
|
+
(`src/passes/wholenumbers.ts`, run by the build on the optimized module,
|
|
94
|
+
`keepWholeNumbers`). It is proven by an interval analysis of each function
|
|
95
|
+
with a loop, where a value is a whole number within a range - never NaN, an
|
|
96
|
+
infinity or -0 - or anything; a loop is solved to a fixpoint, and a
|
|
97
|
+
comparison narrows the locals it compares in the branch it guards, `x * x <=
|
|
98
|
+
n` included. What is not proven stays an f64: `7 / 2` is 3.5, a sum past
|
|
99
|
+
2^31 is exact, `-6 % 3` is -0. The check a `%` makes that its numbers are
|
|
100
|
+
whole is seen to hold there, and only i32's remainder is left.
|
|
34
101
|
|
|
35
102
|
After changing `src/` or `std/` in `runtime/deps/assemblyscript`, rebuild it
|
|
36
103
|
and write the patch back from there:
|
|
@@ -50,9 +117,28 @@ version`.
|
|
|
50
117
|
native as a direct call;
|
|
51
118
|
- the warning about a signature that disagrees with its import, which WAMR
|
|
52
119
|
compiles out of its own compiler;
|
|
120
|
+
- on i386, a double made a 64-bit integer with saturation (`i64.trunc_sat_f64_s`,
|
|
121
|
+
what every number made a cell becomes) through SSE2 when it fits in 32 bits,
|
|
122
|
+
and through the x87 only when it does not;
|
|
123
|
+
- on i386 with SSE2, a double made a 32-bit integer with saturation
|
|
124
|
+
(`i32.trunc_sat_f64_s`, what a `%` checks its numbers are whole with) as
|
|
125
|
+
`cvttsd2si` itself: only its answer for NaN and a number out of range,
|
|
126
|
+
`0x80000000`, takes the branch that saturates, not three branches around
|
|
127
|
+
every conversion;
|
|
53
128
|
- the i386 symbols the loader did not resolve, which LLVM spells with one
|
|
54
129
|
underscore: the float and vector constant pools (`_real@...`, `_xmm@...`)
|
|
55
130
|
and, on Windows, the 64-bit division helpers (`_alldiv`, `_aullrem`, ...);
|
|
131
|
+
- `wasm_runtime_take_trap_frames`: the frames a trap left, for the module to
|
|
132
|
+
print its own way rather than WAMR printing them to stdout;
|
|
133
|
+
- `wasm_runtime_memory_view`: where the plugin's memory is and its size, in
|
|
134
|
+
one call, for a native's thunk that reads and writes it;
|
|
135
|
+
- a direct call (`wasm_runtime_direct_entry`, `_begin`, `_end`): the machine
|
|
136
|
+
code of an AOT function, which the module calls itself with the C types of
|
|
137
|
+
its parameters - what `wasm_runtime_call_wasm` does on every call, less
|
|
138
|
+
what it asks of a function it has not seen; the frame and the trap are
|
|
139
|
+
handled as that call handles them. `_begin` is written into the module's
|
|
140
|
+
call by the link-time optimisation of either compiler (`__forceinline`,
|
|
141
|
+
`always_inline`);
|
|
56
142
|
- two build fixes for building `wamrc` against a prebuilt LLVM: a stub
|
|
57
143
|
`LibXml2::LibXml2` target, and repointing `LLVMDebugInfoPDB`, whose
|
|
58
144
|
exported target carries the DIA SDK path of the machine that built the
|