-
Notifications
You must be signed in to change notification settings - Fork 1
feat: add macro LUA_USE_LIBC_JUMP_PSX #3
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
base: main
Are you sure you want to change the base?
Conversation
@nicolasnoble If you are interested I can make some customization macros, like LUA_USE_PSN00BSDK_PSX (something I solved with cmake, but I can do with macros), and LUA_USE_FLOAT32 (for those interested in floatpoint via software using the GCC mips compiler) |
Several thoughts here:
|
I believe that the fact that there is another setjmp table may end up conflicting with existing code.
I want to use the third-party solution for
if The |
I did not understand your point. how could this turn the project harder to maintain? |
So, in the absolute, setjmp/longjmp is totally independent and local. You can absolutely have two different implementations side-by-side with different registers mapping, as long as they get used in a properly balanced fashion, which is why I'm confused about how this is a problem to begin with. There are no global tables, no global state, it's just a single local holder of data which, in the case of Lua, stays on the stack temporarily for the duration of a protected call, and no interaction should happen with anything else outside of this scope. If you had to modify this to make something work, it means there's a deeper problem somewhere else is what I'm getting at, and doing this change feels like a bandaid to hide a real issue underneath. |
Whenever you're introducing new targets into a projects, it means the test matrix augments. Supporting 1, 2, 5, 23 different combinations of build variants means doing all these tests too. No external dependencies means no heavy test matrix, and no special setup to reproduce problems. It also means if a problem arises, if the code is 100% contained and has little to no external interactions, it should be reproducible regardless of the rest of the environment that problem appears on. |
I had severe memory problems both in the game and the emulator itself crashing using the self-contained version setjmp, when ended up using a third-party SDK its works, the solution seems a little different to me, after the change had no more problems. If you want to take a look, I'm starting on the PS1 when it comes to homebrew, my experience is with other consoles, I'm interested in this lib to port my multi-platform engine. setjmp:
sw $ra, 0x00($a0)
sw $sp, 0x04($a0)
sw $fp, 0x08($a0)
sw $s0, 0x0c($a0)
sw $s1, 0x10($a0)
sw $s2, 0x14($a0)
sw $s3, 0x18($a0)
sw $s4, 0x1c($a0)
sw $s5, 0x20($a0)
sw $s6, 0x24($a0)
sw $s7, 0x28($a0)
sw $gp, 0x2c($a0)
jr $ra
li $v0, 0 longjmp:
lw $ra, 0x00($a0)
lw $sp, 0x04($a0)
lw $fp, 0x08($a0)
lw $s0, 0x0c($a0)
lw $s1, 0x10($a0)
lw $s2, 0x14($a0)
lw $s3, 0x18($a0)
lw $s4, 0x1c($a0)
lw $s5, 0x20($a0)
lw $s6, 0x24($a0)
lw $s7, 0x28($a0)
lw $gp, 0x2c($a0)
jr $ra
move $v0, $a1 |
If you're having memory issues while using a third party library, I would first consider the possibility that the library's memory allocator has an issue. I've been using this psxlua project on several kilobytes, complex Lua files without issues. In fact, I have luac running on the psx directly, able to compile bytecode out from large Lua files. Having a corrupted setjmp context might be an indication a loose pointer got used. Maybe start from the beginning, use the official psyq libraries, with its known to be working memory allocator, and verify the behavior there is correct or not, in order to try and narrow further the troubleshooting. |
I'm not very interested in using the original SDK, as it is for Windows, and I would have to use Wine, currently my development environment only needs |
That is not correct. The libraries have been converted to modern gcc, and can be used on any modern operating system. See https://github.com/ABelliqueux/nolibgs_hello_worlds with some examples, https://github.com/Ay91169/PSGame, or other similar projects and documentation.
I highly suspect the problem is elsewhere, honestly, and that you've only displaced it. |
The other question I have is how did you narrow it down to setjmp / longjmp exactly? What was your troubleshooting process? |
I was doing eliminations and testing different combinations of Lua and C code, I tested different allocators, among other things that the port modifies, in the end I got good results using I started changing the setjmp syscall. If you want to see the project I'm working on, you just need to have cmake so the dependencies are managed locally. |
this adjustment makes it easier for those using PSn00bSDK, or some libc implementation for
longjmp
andsetjmp
#2