Function attributes
Control protection, inlining and fastcalls for individual Luau functions.
Function attributes change how a function is compiled. Place SVM_ATTRIBUTES after the function signature, on the same line:
local function addOne(value) SVM_ATTRIBUTES("INLINE")
return value + 1
end
return addOne(41)The compiler removes this directive; it does not require a runtime global.
These attributes are described in the Secure Luau 0.1.18 reference. Compatibility with the hosted compiler's final version and configuration has not been verified. The examples below have not been run through that service.
NO_PROTECT
local function nativeAdd(left, right) SVM_ATTRIBUTES("NO_PROTECT")
return left + right
endNO_PROTECT keeps the function as ordinary Luau bytecode. Secure VM lowering and protection passes do not run on it. Use it for code that needs direct Luau VM execution or behavior that Secure Luau does not support. Protected and unprotected functions can call each other.
The tradeoff is loss of protection: the function's instructions, strings and constants remain in ordinary Luau bytecode. Do not use this attribute for sensitive code.
INLINE
local function add(left, right) SVM_ATTRIBUTES("INLINE")
return left + right
end
return add(40, 2)INLINE copies a local closure into each direct call site and removes the closure and call. Later protection passes process that code as part of the caller. This can reduce call overhead for small, frequently called helpers; repeated call sites can increase bytecode size.
Restrictions:
- The target must be a local closure, not the root function, and must have at least one direct call site.
- The closure cannot escape through a return, capture, argument or stored value.
- Captured values and variadic parameters are not supported.
- A nested closure must also be a valid
INLINEtarget so the compiler can remove it first. - Specialized loop instructions, including numeric and generic
forloops, are not supported. - The caller must be protected.
Inlining is required when marked. The compiler reports an error if it cannot preserve the function's behavior or if expansion is too large.
NO_FASTCALL
local function readMethod() SVM_ATTRIBUTES("NO_FASTCALL")
return getnamecallmethod()
endNO_FASTCALL disables Secure Luau fastcalls inside the marked function. It does not affect callers or nested functions. The current fastcall targets are getnamecallmethod and setnamecallmethod.
Fastcalls invoke a host handler directly from the secure VM. They avoid global lookup and call frames and ignore hooks. Disabling them adds lookup and call-frame overhead when ordinary calls are used.
This attribute does not disable ENVCALL. Ordinary global lookup also requires built-in environment calls to be disabled and the path not to be registered as a custom environment call. Those are compiler configuration requirements; the dashboard does not expose controls for them. Do not assume the attribute alone makes every call observe replacements or hooks.
General rules
- Attribute names are case-sensitive string literals.
- Use one attribute per function. The current attributes cannot be combined or repeated.
- Unknown attributes cause a compile error.
- An attribute applies only to its containing function; nested functions do not inherit it.
- A directive after executable code is removed but is not applied.
- Use optimization level
0or1. Luau O2 and@nativeare unsupported because they can remove the function boundaries used by attributes.
The current language reference also treats a direct standalone SVM_ATTRIBUTES(...) call as a directive even when a local, parameter or captured upvalue has the same name. This name-resolution detail must be checked against the compiler version you use; it is not documented in the 0.1.18 reference.
See compiler macros for conditional compilation.