forked from gap-system/gap
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
kernel: change coding of integers, strings, eager floats
When coding GAP function bodies, we now have an (optional) plist in the function body of (immutable) values. Instead of storing the raw data for an integer or string within the respective expression, we instead store the integer resp. string in that values plist, and retrieve it from there when printing or evaluation such expressions (for strings, evaluation returns a shallow copy of the stored string constant, to preserve semantics). For eager floats, the values plist is used instead of `EAGER_FLOAT_LITERAL_CACHE`, which is removed by this patch (thus resolving part of issue gap-system#1993). These changes have several advantages: * we avoid a possible GC crash when compiling (large) string expressions * a function like `f := x -> 12345678901234567890` used to return a new integer object with each call; now it always returns the same integer, i.e., `IsIdenticalObj(f(1), f(2));` now returns true * floats benefit from avoiding use of a global "cache" which never is emptied (thus these eager float literals now are garbage collected if the function referencing them is garbage collected) * the cache simplifies future optimizations: e.g. we could convert expressions like `-2^100` by evaluating them and storing the result in the values list; we could also store permutations precomputed, that is, replace a `T_PERM_EXPR` and the `T_PERM_CYCLE` expressions nested in it by a single "constant expression" that references the immutable permutation described by these expressions (at least in the case these expressions were explicitly defined, i.e., `(1,2)` would work but not `(i,j)`
- Loading branch information
Showing
4 changed files
with
61 additions
and
75 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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