aboutsummaryrefslogtreecommitdiff
path: root/tests/unit/libexpr/value
diff options
context:
space:
mode:
authoreldritch horrors <pennae@lix.systems>2024-01-29 06:19:23 +0100
committereldritch horrors <pennae@lix.systems>2024-03-18 16:12:46 +0100
commit86a1121d16f7eeb594955e39ff4e6fcd69f1b8c5 (patch)
tree4309fa2dd8699b05a57ba733c2e38b045f899c01 /tests/unit/libexpr/value
parentc39150e6bb4dd04bc60f1d9c13b7bc89d55948a8 (diff)
use byte indexed locations for PosIdx
we now keep not a table of all positions, but a table of all origins and their sizes. position indices are now direct pointers into the virtual concatenation of all parsed contents. this slightly reduces memory usage and time spent in the parser, at the cost of not being able to report positions if the total input size exceeds 4GiB. this limit is not unique to nix though, rustc and clang also limit their input to 4GiB (although at least clang refuses to process inputs that are larger, we will not). this new 4GiB limit probably will not cause any problems for quite a while, all of nixpkgs together is less than 100MiB in size and already needs over 700MiB of memory and multiple seconds just to parse. 4GiB worth of input will easily take multiple minutes and over 30GiB of memory without even evaluating anything. if problems *do* arise we can probably recover the old table-based system by adding some tracking to Pos::Origin (or increasing the size of PosIdx outright), but for time being this looks like more complexity than it's worth. since we now need to read the entire input again to determine the line/column of a position we'll make unsafeGetAttrPos slightly lazy: mostly the set it returns is only used to determine the file of origin of an attribute, not its exact location. the thunks do not add measurable runtime overhead. notably this change is necessary to allow changing the parser since apparently nothing supports nix's very idiosyncratic line ending choice of "anything goes", making it very hard to calculate line/column positions in the parser (while byte offsets are very easy). (cherry picked from commit 5d9fdab3de0ee17c71369ad05806b9ea06dfceda) Change-Id: Ie0b2430cb120c09097afa8c0101884d94f4bbf34
Diffstat (limited to 'tests/unit/libexpr/value')
-rw-r--r--tests/unit/libexpr/value/print.cc8
1 files changed, 4 insertions, 4 deletions
diff --git a/tests/unit/libexpr/value/print.cc b/tests/unit/libexpr/value/print.cc
index aabf156c2..d2d699a64 100644
--- a/tests/unit/libexpr/value/print.cc
+++ b/tests/unit/libexpr/value/print.cc
@@ -110,8 +110,8 @@ TEST_F(ValuePrintingTests, vLambda)
.up = nullptr,
.values = { }
};
- PosTable::Origin origin((std::monostate()));
- auto posIdx = state.positions.add(origin, 1, 1);
+ PosTable::Origin origin = state.positions.addOrigin(std::monostate(), 1);
+ auto posIdx = state.positions.add(origin, 0);
auto body = ExprInt(0);
auto formals = Formals {};
@@ -558,8 +558,8 @@ TEST_F(ValuePrintingTests, ansiColorsLambda)
.up = nullptr,
.values = { }
};
- PosTable::Origin origin((std::monostate()));
- auto posIdx = state.positions.add(origin, 1, 1);
+ PosTable::Origin origin = state.positions.addOrigin(std::monostate(), 1);
+ auto posIdx = state.positions.add(origin, 0);
auto body = ExprInt(0);
auto formals = Formals {};