Skip to content

Refactor stringlike indexing primitives#2905

Merged
dvulakh merged 8 commits intomainfrom
dvulakh.prepare-for-unboxed-indexing-primitives
Aug 12, 2024
Merged

Refactor stringlike indexing primitives#2905
dvulakh merged 8 commits intomainfrom
dvulakh.prepare-for-unboxed-indexing-primitives

Conversation

@dvulakh
Copy link
Copy Markdown
Contributor

@dvulakh dvulakh commented Aug 8, 2024

Refactor the logic for translating the get/set primitives for bigstring, string, and bytes in preparation for new versions of these primitives with unboxed indices and unboxed return types (#2906). As part of the refactor, string-like loads and stores now share bounds-checking logic with arrays.

This PR does not add any new primitives. For existing primitives, I rely on existing tests.

I add a small test ocaml/testsuite/tests/prim-bigstring/non_existent_primitives.ml to show that the as-yet unoccupied spaces in the (container type x index kind x data width) cartesian product continue to fail with sensible compiler errors.

dvulakh added 3 commits August 7, 2024 16:42
to make it easier to add primitives for unboxed access without
duplicating as much code

Signed-off-by: David Vulakh <dvulakh@janestreet.com>
don't close over [mode] when constructing the [indexing_primitives]
map, and hoist the computation out of [lookup_primitive]

(previously we were recomputing the cartesian product each time we
entered [lookup_primitive])

Signed-off-by: David Vulakh <dvulakh@janestreet.com>
Signed-off-by: David Vulakh <dvulakh@janestreet.com>
@mshinwell
Copy link
Copy Markdown
Collaborator

Looks fine in outline, @TheNumbat please review in detail.

dvulakh added 3 commits August 8, 2024 12:07
Signed-off-by: David Vulakh <dvulakh@janestreet.com>
Signed-off-by: David Vulakh <dvulakh@janestreet.com>
Signed-off-by: David Vulakh <dvulakh@janestreet.com>
@mshinwell mshinwell added the flambda2 Prerequisite for, or part of, flambda2 label Aug 8, 2024
@dvulakh dvulakh requested a review from TheNumbat August 8, 2024 16:19
Signed-off-by: David Vulakh <dvulakh@janestreet.com>
* change type of [bound_kind] in [bound]
* move some type constraints to arguments
* return old comment about bounds checks
* move [is_substring] to [misc]

Signed-off-by: David Vulakh <dvulakh@janestreet.com>
@TheNumbat
Copy link
Copy Markdown
Member

Looks good to merge once CI passes

@dvulakh dvulakh merged commit 2d9548b into main Aug 12, 2024
@dvulakh dvulakh deleted the dvulakh.prepare-for-unboxed-indexing-primitives branch August 12, 2024 21:13
ITO444 pushed a commit to ITO444/flambda-backend that referenced this pull request Aug 13, 2024
* refactor string-like access primitives

to make it easier to add primitives for unboxed access without
duplicating as much code

Signed-off-by: David Vulakh <dvulakh@janestreet.com>

* hoist out [indexing_primitives]

don't close over [mode] when constructing the [indexing_primitives]
map, and hoist the computation out of [lookup_primitive]

(previously we were recomputing the cartesian product each time we
entered [lookup_primitive])

Signed-off-by: David Vulakh <dvulakh@janestreet.com>

* make fmt

Signed-off-by: David Vulakh <dvulakh@janestreet.com>

* label [index] and [bound] in [check_bound]

Signed-off-by: David Vulakh <dvulakh@janestreet.com>

* move annotation in [actual_max_length_for_string]

Signed-off-by: David Vulakh <dvulakh@janestreet.com>

* move annotation in [string_like_load]

Signed-off-by: David Vulakh <dvulakh@janestreet.com>

* replace cartesian product helper with let operator

Signed-off-by: David Vulakh <dvulakh@janestreet.com>

* review changes

- change type of [bound_kind] in [bound]
- move some type constraints to arguments
- return old comment about bounds checks
- move [is_substring] to [misc]

Signed-off-by: David Vulakh <dvulakh@janestreet.com>

---------

Signed-off-by: David Vulakh <dvulakh@janestreet.com>
lukemaurer pushed a commit to lukemaurer/flambda-backend that referenced this pull request Oct 23, 2024
* refactor string-like access primitives

to make it easier to add primitives for unboxed access without
duplicating as much code

Signed-off-by: David Vulakh <dvulakh@janestreet.com>

* hoist out [indexing_primitives]

don't close over [mode] when constructing the [indexing_primitives]
map, and hoist the computation out of [lookup_primitive]

(previously we were recomputing the cartesian product each time we
entered [lookup_primitive])

Signed-off-by: David Vulakh <dvulakh@janestreet.com>

* make fmt

Signed-off-by: David Vulakh <dvulakh@janestreet.com>

* label [index] and [bound] in [check_bound]

Signed-off-by: David Vulakh <dvulakh@janestreet.com>

* move annotation in [actual_max_length_for_string]

Signed-off-by: David Vulakh <dvulakh@janestreet.com>

* move annotation in [string_like_load]

Signed-off-by: David Vulakh <dvulakh@janestreet.com>

* replace cartesian product helper with let operator

Signed-off-by: David Vulakh <dvulakh@janestreet.com>

* review changes

- change type of [bound_kind] in [bound]
- move some type constraints to arguments
- return old comment about bounds checks
- move [is_substring] to [misc]

Signed-off-by: David Vulakh <dvulakh@janestreet.com>

---------

Signed-off-by: David Vulakh <dvulakh@janestreet.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

flambda2 Prerequisite for, or part of, flambda2

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants