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

Specialize table access operations for short string keys #100

Closed
dibyendumajumdar opened this issue Aug 23, 2016 · 3 comments
Closed

Specialize table access operations for short string keys #100

dibyendumajumdar opened this issue Aug 23, 2016 · 3 comments

Comments

@dibyendumajumdar
Copy link
Owner

This is a common usage in Lua - and we already specialize when the variable is known to be table type (declared as a table) and the key is a short string. But even when the variable is not known to be a table type, if we know that the key is a short string then we could generate a more optimized version of the table get / set operation.

dibyendumajumdar pushed a commit that referenced this issue Sep 23, 2016
dibyendumajumdar pushed a commit that referenced this issue Sep 23, 2016
dibyendumajumdar pushed a commit that referenced this issue Sep 23, 2016
dibyendumajumdar pushed a commit that referenced this issue Sep 23, 2016
dibyendumajumdar pushed a commit that referenced this issue Sep 23, 2016
dibyendumajumdar pushed a commit that referenced this issue Sep 23, 2016
@dibyendumajumdar
Copy link
Owner Author

dibyendumajumdar commented Sep 24, 2016

Introduced new bytecodes GETTABLE_SK, SELF_SK and SETTABLE_SK that are emitted when we do not know that the variable is a table - but the key is known to be a short string constant. This covers the many uses of tables. Implementation wise only the interpreter has been enhanced for GETTABLE_SK right now (release 0.17) - work in JIT is still pending. These bytes code default to the standard bytecodes in JIT. Also had to put a workaround in listcode() to emit old opcode names to avoid tests failing.

dibyendumajumdar pushed a commit that referenced this issue Sep 25, 2016
dibyendumajumdar pushed a commit that referenced this issue Sep 25, 2016
@dibyendumajumdar
Copy link
Owner Author

A related optimisation is to encode the table subtypes in the same way as number, function and string subtypes are defined as 1-2 bit variant flags. I think this will improve performance as currently another field in the structure is inspected to determine whether the type is array type.

dibyendumajumdar pushed a commit that referenced this issue Sep 28, 2016
dibyendumajumdar pushed a commit that referenced this issue Sep 28, 2016
… in the lua value similar to how integer and number values are handled
dibyendumajumdar pushed a commit that referenced this issue Oct 6, 2016
…en operand of OP_SELF is known to be a short string
dibyendumajumdar pushed a commit that referenced this issue Oct 7, 2016
dibyendumajumdar pushed a commit that referenced this issue Oct 7, 2016
dibyendumajumdar pushed a commit that referenced this issue Oct 7, 2016
@dibyendumajumdar
Copy link
Owner Author

Fixed in 0.18 - more work can be done but will be tracked separately

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

1 participant