Tech Off Post

Single Post Permalink

View Thread: IL to C++ compiler - Need advice on implementing context switching
  • User profile image


    Thanks for the info about the GC. I'm using a "virtual" stack that only contains ref types so I don't have the problem with objects being incorrectly flagged due to matching int values, etc.

    As far as the vtables are concerned, I believe the vtables themselves are "static" in the sense that there is just one vtable for each type. So even if you create 100 instances of the same type, they all have a hidden pointer that point to the exact same vtable. Hence if you move the class around in memory, it won't matter since it will still point to the same vtable.

    From Wikipedia: "Typically, the compiler creates a separate vtable for each class. When an object is created, a pointer to this vtable, called the virtual table pointer, vpointer or VPTR, is added as a hidden member of this object"