Commit 0581c58
committed
wasm: fix function-value calls for fn consts, expression callees, and eval order
Address the three review comments on #27532:
- fn consts (`const cb = add1; cb(1)`): push_fn_value did `scope.find(node.name)`,
but a fn const lives in the global scope under its qualified name (node.const_name),
so the lexical lookup missed and aborted with 'cannot resolve function value'.
Resolve is_fn_a_const callees through node.const_name instead.
- expression callees that return a function (`make_cb()(1)`): the checker leaves
is_fn_var false here, with an empty name and a fn-typed left_type, so detection
fell through to call('') and panicked. Detect name=='' with a fn-typed left_type
as a function value and dispatch via call_indirect.
- evaluation order (`make_box().op(next())`): the callee was evaluated after the
argument loop, reversing V's left-to-right order for callees with side effects.
Evaluate the callee's table index into a temp local before the args and reload
it on top for call_indirect.
Extend tests/fn_value.vv with all three scenarios (covering struct returns too).1 parent 38398a2 commit 0581c58
3 files changed
Lines changed: 78 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
809 | 809 | | |
810 | 810 | | |
811 | 811 | | |
812 | | - | |
| 812 | + | |
813 | 813 | | |
| 814 | + | |
| 815 | + | |
| 816 | + | |
| 817 | + | |
| 818 | + | |
| 819 | + | |
| 820 | + | |
| 821 | + | |
| 822 | + | |
| 823 | + | |
| 824 | + | |
| 825 | + | |
| 826 | + | |
814 | 827 | | |
815 | | - | |
| 828 | + | |
816 | 829 | | |
817 | 830 | | |
818 | 831 | | |
| |||
830 | 843 | | |
831 | 844 | | |
832 | 845 | | |
833 | | - | |
834 | | - | |
| 846 | + | |
| 847 | + | |
| 848 | + | |
| 849 | + | |
835 | 850 | | |
836 | 851 | | |
837 | 852 | | |
| |||
844 | 859 | | |
845 | 860 | | |
846 | 861 | | |
| 862 | + | |
| 863 | + | |
| 864 | + | |
| 865 | + | |
| 866 | + | |
847 | 867 | | |
848 | 868 | | |
849 | 869 | | |
| |||
902 | 922 | | |
903 | 923 | | |
904 | 924 | | |
| 925 | + | |
| 926 | + | |
| 927 | + | |
| 928 | + | |
| 929 | + | |
| 930 | + | |
| 931 | + | |
| 932 | + | |
| 933 | + | |
| 934 | + | |
| 935 | + | |
| 936 | + | |
| 937 | + | |
| 938 | + | |
| 939 | + | |
905 | 940 | | |
906 | 941 | | |
907 | 942 | | |
| |||
935 | 970 | | |
936 | 971 | | |
937 | 972 | | |
938 | | - | |
939 | | - | |
940 | | - | |
| 973 | + | |
| 974 | + | |
941 | 975 | | |
942 | | - | |
| 976 | + | |
943 | 977 | | |
944 | 978 | | |
945 | 979 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
17 | 39 | | |
18 | 40 | | |
19 | 41 | | |
| |||
39 | 61 | | |
40 | 62 | | |
41 | 63 | | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
42 | 73 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
0 commit comments