Commit 230ce7f
authored
Canonicalize types earlier in validation (#1299)
* Canonicalize types earlier in validation
This commit refactors the internals of validation to centralize
canonicalization in one location. This means that stages such as
operator validation no longer need to perform canonicalization.
Additionally types are always stored in their canonical forms.
The refactoring here is done when a `RecGroup` is inserted into a
`TypeList`. The rec-group-local offsets are used to intern the group but
when actually adding to a `TypeList` all rec-group-local offsets are
updated to an ID-based form. This is then plumbed in many other
locations as well by changing many `t: ValType` validators to `t: &mut
ValType` to internally canonicalize.
This is originally motivated by trying to update Wasmtime to the latest
`wasmparser` but many APIs which previously returned `&FuncType` for
example returned `FuncType` instead due to the
canonicalization-on-the-fly. This change means that the old
`&FuncType`-style APIs can return because types are always canonicalized
at-rest.
This change additionally changes the behavior of one test. It was
previously considered valid and is now considered valid. I've confirmed
that `wasm-opt` considers the test invalid, so I've updated the test to
`assert_invalid` instead.
* Fix test compile
* Remove unused arguments
* Review comments1 parent acee342 commit 230ce7f
File tree
14 files changed
+429
-585
lines changed- crates/wasmparser
- src
- readers/core
- validator
- core
- tests
- local/gc
- snapshots/local/gc
14 files changed
+429
-585
lines changedSome generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
16 | | - | |
17 | 16 | | |
18 | 17 | | |
19 | 18 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
16 | | - | |
17 | | - | |
18 | 16 | | |
19 | 17 | | |
20 | 18 | | |
21 | 19 | | |
22 | 20 | | |
23 | 21 | | |
| 22 | + | |
| 23 | + | |
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| |||
384 | 384 | | |
385 | 385 | | |
386 | 386 | | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
387 | 401 | | |
388 | 402 | | |
389 | 403 | | |
| |||
416 | 430 | | |
417 | 431 | | |
418 | 432 | | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
419 | 462 | | |
420 | 463 | | |
421 | 464 | | |
| |||
562 | 605 | | |
563 | 606 | | |
564 | 607 | | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
565 | 621 | | |
566 | 622 | | |
567 | 623 | | |
| |||
640 | 696 | | |
641 | 697 | | |
642 | 698 | | |
| 699 | + | |
| 700 | + | |
| 701 | + | |
| 702 | + | |
| 703 | + | |
| 704 | + | |
| 705 | + | |
| 706 | + | |
| 707 | + | |
| 708 | + | |
| 709 | + | |
| 710 | + | |
| 711 | + | |
| 712 | + | |
| 713 | + | |
| 714 | + | |
| 715 | + | |
643 | 716 | | |
644 | 717 | | |
645 | 718 | | |
| |||
0 commit comments