Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CData allocation recording #672

Closed
sergos opened this issue Mar 18, 2021 · 1 comment
Closed

CData allocation recording #672

sergos opened this issue Mar 18, 2021 · 1 comment

Comments

@sergos
Copy link

sergos commented Mar 18, 2021

ffinew.lua.txt

Trace recording is aborted due to NYI for the case of a struct with aggregate allocation.
Ironically, it works for the array of the same structs - see the test in attach.

The VLA/VLS machinery was added in f1f7e40 on the v2.1 branch, closing NYI for array of aggregates around line 1013
I believe it could be also applied for the case of struct with aggregates at line 1042 since it handles zero init, failing with initializers list anyways.

The test attached shows the following 500x uplift with initial state

$ ./luajit ../../test/ffinew.lua 
Median time for struct allocation: 0.021003 sec
Median time for array allocation: 4.6000000000213e-05 sec

turned into

$ ./luajit ../../test/ffinew.lua 
Median time for struct allocation: 4.8e-05 sec
Median time for array allocation: 4.8000000000001e-05 sec

with

--- a/src/lj_crecord.c
+++ b/src/lj_crecord.c
@@ -1039,7 +1039,7 @@ static void crec_alloc(jit_State *J, RecordFFData *rd, CTypeID id)
          dc = ctype_rawchild(cts, df);  /* Field type. */
          if (!(ctype_isnum(dc->info) || ctype_isptr(dc->info) ||
                ctype_isenum(dc->info)))
-           lj_trace_err(J, LJ_TRERR_NYICONV);  /* NYI: init aggregates. */
+            goto special;
          if (J->base[i]) {
            sp = J->base[i];
            sval = &rd->argv[i];
@MikePall
Copy link
Member

The fix is not that simple, since some stores may already have been emitted.

I've added a proper workaround that helps the zero-fill struct-of-NYI case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants