[quote=244610:@Kevin Gale]At one time the RB compiler / linked was quite good at stripping unused stuff. For example, it would strip dynamic string constants that weren’t referenced in code and would also strip external plugins if the code that called them was not referenced.
When we migrated some projects to Xojo I was shocked to find out how dumb it had become. I vaguely remember a conversation where Norman thought that the introduction of Introspection may have changed things.[/quote]
The stripping code in the linker has not changed in the last five years. It uses a simple but effective algorithm where there are a fixed set of roots, like the app object, and the linker traverses all reachable nodes* and marks them live. Only live nodes make it into the final executable.
Introspection is a double-edged sword, which allows runtime flexibility at the cost of hindering optimization. The introspection metadata references all of the methods, properties, and the types involved. This precludes optimizations like stripping out “unused” properties and methods because the compiler cannot prove at compile time they are actually unused.
Unfortunately the introspection module isn’t the only thing relying on the metadata. At the moment it’s also used for:
- The plugin SDK’s REALLoadObjectMethod, REALSetPropValue, and REALGetPropValue functions.
- XojoScript uses it to know what gets exposed to the script via the context object.
- The runtime itself uses it to glue together C++ code to Xojo objects.
Now, back to the question of resources. The compiler does not currently associate resources with functions, so it has no way of knowing if it’s still required. It’s hardly an intractable problem, just a lower priority one.
- A node is any linkable item like a method, property, or introspection metadata.