Repository navigation
Architecture pass fixes: cppia - #478
Open
dimensionscape wants to merge 3 commits into
Open
dimensionscape wants to merge 3 commits into
dimensionscape wants to merge 3 commits into
Conversation
Compared with the same code built as C++, which both now match:
JIT:
- Array<Dynamic> and Array<Any> compound assignment stored the right
hand side alone, and ++, --, insert and toString had no JIT code at
all, so they did nothing ("Unknown ArrayBuiltinAny"). They call
helpers sharing the interpreter's arithmetic, which catch, and the
jitted code checks after each.
- A Bool pushed, unshifted or set into an Array<Any> was stored as an
Int. It goes in boxed.
- Bitwise compound operators on an Array<Null<Int>> did nothing: the
bitwise cases fell through to the element's type for lack of a break.
- An Int array's element read out of range as a String was "null", not
"0". It reads the element type's zero.
- ++d[i] on a Dynamic used as a statement decremented: the test was
crement==coPostInc || crement==coPostInc.
Interpreter:
- A typed indexOf or lastIndexOf used as a Float returned 0 without
running.
- join and toString used as a statement, and iterator and
keyValueIterator, were skipped, receiver and element toString calls
with them.
Test: CppiaArrayEngines, twelve lines, each wrong in one engine before
and right in both now, interpreted and under the JIT on Windows x64.
Fixes #468
SECURITY.md promises a load error for a malformed .cppia file, but these crashed the host, interpreted, under the JIT, or both: - MAIN in a module with no types: ScriptCallable::link read the type of its return, 0, from an empty table. Return type ids are checked. - An unknown script enum constructor left a null value that was dereferenced, and a call with the wrong number of arguments wrote past the enum value under the JIT. Both fail to link. - Two classes with one type id: the second overwrote the first's and wrote outside the vtable made for it. It fails to load. - A string constant id, and the text format's file id, were read unchecked, and the string table grew to them: by 100000000 entries, 1.4 GB, for a file id, and the JIT's addresses of its strings were left dangling. They are checked as other string ids are. - An enum parameter index past the value read past it. A script enum's constructors bound it at link, and otherwise the interpreter and the JIT check the value's own parameter count. - break or continue outside a loop made sljit assert under the JIT, ending the process. The function fails to compile instead, checked on the pass that emits code, since the measuring pass has no labels. - A super constructor call to a script class other than the super class ran that constructor on an instance laid out for this one. It fails to link, after the check for a class with no constructor. CppiaMalformedConstructors' control, such a call from a static main, is refused now too. Test: CppiaMalformedLoads, ten such files, loaded and run interpreted and with the JIT compiling as it loads. Before, the host crashed on the first; now each fails to load or runs safely. The cppia suite and the 60 Cppia regression tests pass, interpreted and under the JIT, on Windows x64. Fixes #467
adoptInstances compared only field names, storage types and offsets, and docs/CppiaModuleRelease.md said methods could differ in any way. But a call's vtable slot is fixed when its code links, so old code still running, which the docs say finishes normally, called a moved instance by the old slots: with a method added first, foo.b() ran the new a(), and foo.a() reached x(), whose Int was read as a String, crashing the interpreter and giving the JIT a String of garbage. And a moved class's field could hold an instance of a class that stayed, since its layout changed, which new code then read with the new layout, past the object. Now: - methods, their super classes' included, must have the same names in the same slots, and so must the script interfaces the class implements; - fields compare their type names, so a retyped field within one storage type, Array<Int> to Array<Float>, keeps its instances, as the docs said it did; - a class with a field that can hold an instance of a class that stays stays too, to a fixed point. The report says which rule kept a class, and the docs describe the rule. Test: CppiaAdoptLayouts, the two cases, interpreted and under the JIT. Before, the first crashed the interpreter and the second read past the object; now neither class moves and old code keeps its own results. CppiaAdoptInstances, whose classes change only method bodies, still moves them, on Windows x64. Fixes #464
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The cppia fixes from the architecture pass in #154. Each commit has a regression test that fails without its fix and passes with it on Windows x64.
Array<Dynamic>compound assignment stored the right hand side alone, its++,insertandtoStringdid nothing, Bools in anArray<Any>became Ints, bitwise compound assignment onArray<Null<Int>>did nothing, an out of range Int read as a String was "null", and++d[i]on a Dynamic as a statement decremented. Interpreted,indexOfused as a Float gave 0 andjoinortoStringas a statement did not run. Both engines now match the same code built as C++. Test: CppiaArrayEngines.adoptInstancesmoved instances whose methods changed slots, so old code still running called the wrong method or crashed, and moved classes whose fields could hold instances that stayed. Methods and script interface slots must match now, field types compare by name, and a class stays with the classes its fields hold. docs/CppiaModuleRelease.md describes the rule. Test: CppiaAdoptLayouts.Also run locally: the cppia suite interpreted and with the JIT, and the Cppia regression tests.
Fixes #464
Fixes #467
Fixes #468