Download

How blueprints work?

I want to know how blueprint is converted to machine code.

Blueprints are never compiled to machine language. Like most scripting engines such as Python, Lua, Javascript etc… the actual execution of the script happens within a runtime VM - there are exceptions, of course. For performance reasons, sometimes the scripts are compiled into an intermediate format, called bytecode, but those are not really machine code and are platform independent. No actual CPU can understand these bytecodes and execute them. The script’s runtime - such as V8 engine for javascript, python runtime etc… - can understand this bytecode and it is this runtime engine that runs the actual machine code on the physical processor.

For example, imagine I wrote a new scripting language called foobar, and it has the following bytecode syntax to add two numbers

VAR X:  ADD A,B

Now this is not going to be understood by any physical processor. But the foobar runtime knows what this means, and it will emit the platform specific machine code instructions to get it done.

So the runtime could generate something like this (not real assembly instructions, just a pseudocode).

MOV RAX, [A]
MOV RCX, [B]
ADD RAX, RCX
MOV [X], RAX

Please remember that the runtime does not ‘compile’ the bytecode into it’s machine code equivalent. For example in the above case, the runtime will end up executing a lot more machine code than what I have shown, because it needs to run code to allocate memory, garbage collection, referencing etc…

Now unreal does give us the option to convert a blueprint to equivalent C++ code which is then compiled along with any other C++ code. In this case, the logic within the Blueprint is compiled to actual machine code by the C++ compiler.

2 Likes

However, blueprint nativized code will be retired with release of Unreal 5.
Too many bugs.

Thanks