Skip to content

Bytecode ​

Bytecode codec, disassembler, verifier, opcode tables, and instruction helpers for Luau v3–v14 bytecode.

Types ​

BytecodeDecoder type ​

luau
type BytecodeDecoder = ((number) -> number) | { decode: (self: any, code: { number }) -> () }

ProtoModule type ​

luau
type ProtoModule = {
	version: number,
	typesversion: number,
	strings: { string },
	protos: { Proto },
	mainid: number,
	userdataTypes: { string }?,
}

In-memory decoded bytecode module produced by Bytecode.deserialize and Compiler.compileProto.

Properties ​

disassemble Re-export ​

luau
Bytecode.disassemble

Disassembles binary Luau bytecode or a ProtoModule into human-readable listings, throwing on corrupt input.

deserialize Re-export ​

luau
Bytecode.deserialize

Decodes binary Luau bytecode (v3–v14 and v100) into an immutable ProtoModule.

serialize Re-export ​

luau
Bytecode.serialize

Encodes a ProtoModule back into binary Luau bytecode with an optional opcode encoder.

decodeLineInfo Re-export ​

luau
Bytecode.decodeLineInfo

Unpacks delta-encoded line numbers and per-proto baseline offsets for a Proto.

encodeError Re-export ​

luau
Bytecode.encodeError

Formats a compiler or parser error message as a status-zero binary bytecode payload.

decodeError Re-export ​

luau
Bytecode.decodeError

Extracts the error message from a status-zero bytecode payload, or nil for valid bytecode.

getStringHash Re-export ​

luau
Bytecode.getStringHash

Computes the Luau bytecode string hash for an identifier or string constant.

getImportId Re-export ​

luau
Bytecode.getImportId

Packs 1 to 3 string constant indices into a 32-bit LOP_GETIMPORT identifier.

decomposeImportId Re-export ​

luau
Bytecode.decomposeImportId

Unpacks a 32-bit LOP_GETIMPORT identifier into (count, id0, id1, id2).

insnOp Re-export ​

luau
Bytecode.insnOp

Extracts the opcode byte (0..255) from a 32-bit bytecode instruction word.

insnA Re-export ​

luau
Bytecode.insnA

Extracts operand A (8-bit unsigned) from a 32-bit bytecode instruction word.

insnB Re-export ​

luau
Bytecode.insnB

Extracts operand B (8-bit unsigned) from a 32-bit bytecode instruction word.

insnC Re-export ​

luau
Bytecode.insnC

Extracts operand C (8-bit unsigned) from a 32-bit bytecode instruction word.

insnD Re-export ​

luau
Bytecode.insnD

Extracts signed 16-bit operand D from a 32-bit bytecode instruction word.

insnE Re-export ​

luau
Bytecode.insnE

Extracts signed 24-bit operand E from a 32-bit bytecode instruction word.

Opcodes Re-export ​

luau
Bytecode.Opcodes

Map of upstream LOP_* instruction names to numeric opcodes.

opcodeNames Re-export ​

luau
Bytecode.opcodeNames

Reverse lookup table from numeric opcode to instruction name.

opLengths Re-export ​

luau
Bytecode.opLengths

Instruction word length (1 or 2) keyed by numeric opcode.

Builtins Re-export ​

luau
Bytecode.Builtins

Map of upstream LBF_* fastcall builtin names to numeric IDs.

builtinNames Re-export ​

luau
Bytecode.builtinNames

Reverse lookup table from numeric builtin ID to function name.

Tags Re-export ​

luau
Bytecode.Tags

Bytecode format version limits and constant/type tag constants (LBC_*).

Types Re-export ​

luau
Bytecode.Types

Encoded bytecode type tags (LBC_TYPE_*).

Captures Re-export ​

luau
Bytecode.Captures

Upvalue capture mode tags (LCT_*).

ProtoFlags Re-export ​

luau
Bytecode.ProtoFlags

Function prototype flag bitmasks (LPF_*).

FeedbackTypes Re-export ​

luau
Bytecode.FeedbackTypes

Inline feedback entry type tags (LFT_*).

DumpFlags Re-export ​

luau
Bytecode.DumpFlags

Bitmask flags controlling disassemble and compiler dump output.

Functions ​

verify ​

luau
Bytecode.verify(input: string | buffer | ProtoModule, decoder: BytecodeDecoder?): (boolean, string?)

Validates binary bytecode or a ProtoModule statically without instantiating a closure.