Questions about Luau bytecode

Hello! In the past few weeks I’ve become obsessed with the internals of VMs and what they do to work. Since it’s not very clear to me, I think this is a valid place to put my questions:

  1. Is the source of the Luau compiler open source?
  2. If so, how can I compile some source code to get vanilla Luau bytecode?
  3. This one’s mainly related to VM obfuscation: I see VM obfuscators have these long strings (of what I think is encrypted bytecode that it interprets), either made out of hexadecimal or strings that look like this, “\103\132\47\108”, and I think this is just some ASCII code that strings can change into plain text. Am I correct about this, or am I missing something?
  4. How would I decompile Luau bytecode back into source code?
  5. I’ve heard of the word “opcodes” and I know that it means an operation code, where the CPU can perform a certain operation. Is there a documentation/reference for Luau opcodes, or is it the same as vanilla Lua 5.1.4? I’ve heard Luau does optimizations when compiling to bytecode, I’m just confused here.

If this didn’t make any sense, or these questions are just bad, that’s fine. I’m not very good at writing organized posts. Thanks!

3 Likes

No.

(Doesn’t apply; you can’t.)

Yeah, you can escape an ASCII code in a string and it’ll be converted to its respective character. Useful for non-printable stuff you can’t put in the editor like \0.

There’s no official way to do this as far as I’m aware; exploiters have developed custom solutions but I wouldn’t exactly consider that a go-to solution.

Opcodes are codes that refer to operators (like addition and subtraction and stuff). It should just be the same as vanilla since it’s based on your processor more than a specific language. I’m not really an expert on what Lua does with that, though, so I could be wrong. Someone else who knows more on the topic might want to interject.

6 Likes

Thanks for the response! Do you know if roblox takes the source code, compiles it to bytecode, and interprets it? Or is it more complicated/have extra steps? Like, can you just throw some source code into the bytecode serializer and just expect it to work?

3 Likes

I believe they use a JIT (Just-in-time) bytecode compiler.

No, they don’t. Luau was built off of Lua 5.1, and while luau has become significantly faster, it doesn’t have JIT.

7 Likes

You’re pretty late to this topic. They don’t use a JIT compiler in the sense that all bytecode is compiled prior to or at game start. The client receives only compiled bytecode.

Lua is almost always JIT compiled.
smh I thought JIT meant that it was compiled as the first step when you execute it.

2 Likes