-
Notifications
You must be signed in to change notification settings - Fork 69
Open
Labels
Description
We currently have to assume every method call to be polymorphic (i.e. resolved at run time rather than compile time) because ST lacks a dedicated keyword similar to C++ to flag only certain methods as virtual. This makes the implementation somewhat inefficient compared to statically resolved function calls in the IR.
For performance optimization there are a few points to note:
- C++ has some vtable specific IR syntax (see https://godbolt.org/z/9KKMY1Mfc,
@vtable for ...). At the time of coming up with our polymorphism implementation we were aware of that syntax but couldn't find any documentation. Perhaps we should give it another try if it means LLVM can use it to optimize virtual method calls. - We could introduce a
finalkeyword to classes and function blocks, making them not extendable and as a result allowing us to "devirtualize" the method calls. Alternatively make them final by default and introduce another keyword to make them extendable, though that would break compatibility for codesys. - As noted in here feat: Polymorphism (Classes and Function Blocks) #1493 (review), for static analysis Static Class Hierarchy Analysis might be interesting.
Reactions are currently unavailable