Since version 0.9.0, I've encountered an issue with circular references when compiling JavaScript code. #1116
Unanswered
mengbai123
asked this question in
Q&A
Replies: 1 comment 2 replies
-
I suppose my first question would be: does it work without your modifications to qjsc? Maybe your changes or your loader has a bug that worked by accident with the bytecode in 0.8.0 but stopped working with the newer bytecode format. |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Since version 0.9.0, I've encountered issues with errors related to circular references after compiling JavaScript code.
My program supports running JavaScript code after it's compiled into binary files. I modified the output_object_code function in qjsc.c to sequentially output the length and content of each compiled file into a single file. When running the script code, it parses this binary file and repeatedly executes the process of "reading the length -> loading the code" until all the code has been loaded (using js_std_eval_binary to run).
For a long time, this program was able to execute the code correctly, regardless of whether the JavaScript code was compiled or not.
However, starting from version 0.9.0, it has stopped working properly. I've been making efforts to upgrade the version, but I've run into some problems. It's likely that circular references between different JavaScript files after compilation are causing the loading to fail.
The above code could execute correctly both in the JavaScript source code form and after compilation in version 0.8.0.
However, on the latest version of QuickJS, the source code can run normally, but it fails to execute after compilation, with an error message saying "could not load module filename 'c'".
I suspect the problem might be related to circular loading. In the above code, b.js references the constant C from c.js, and c.js references the test2 function from b.js.
But why does it work fine when running the source code and also worked fine in the previous version?
Can someone answer my questions?
Beta Was this translation helpful? Give feedback.
All reactions