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

Implement checks to verify if we exceeded the max constant for a given index size. #13

Closed
2 tasks done
NotJustAnna opened this issue Nov 14, 2021 · 0 comments
Closed
2 tasks done
Labels
bug Something isn't working component:compiler This issue is related to the Compiler and/or Bytecode. enhancement New feature or request
Milestone

Comments

@NotJustAnna
Copy link
Owner

NotJustAnna commented Nov 14, 2021

Throughout the bytecode, integers of multiple sizes (12 bits, 16 bits and 24 bits) are used to index values on constant pools. However, the compiler does not care if a given constant is over the index's size in bits, and invalid bytecode will be generated in this case.

Notable cases:

  • InvokeLocalInsn/InvokeMemberInsn uses a 16-bits integer #nameConst to index the string pool, whereas the rest of the code uses 24-bits integers.

  • PushExceptionHandlingInsn/PushLoopHandlingInsn uses a pair of 12-bits integer (don't judge, size constraints) to index two labels, whereas JumpInsn uses a 24-bit integer.

  • Implement checks to verify if a given compilation exceeds either the absolute maximum constant size.

    • In reality, this only matters for the case when we do NOT want to immediately execute the compiled code, so generating the error at serialization time should be okay.
  • Reduce the integer used in constant pools/function definitions size to 24-bit integers.

@NotJustAnna NotJustAnna added this to the Version 1.0 milestone Nov 14, 2021
@NotJustAnna NotJustAnna added bug Something isn't working component:compiler This issue is related to the Compiler and/or Bytecode. enhancement New feature or request labels Nov 14, 2021
NotJustAnna pushed a commit that referenced this issue Nov 15, 2021
…/PushDecimal. Closes #12, resolves some tasks of #13.
NotJustAnna added a commit that referenced this issue Jul 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working component:compiler This issue is related to the Compiler and/or Bytecode. enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant