Next: , Previous: Method-Based Discriminating Functions, Up: Discriminating Functions


3.3 Accessor Discriminating Functions

Accessor Discriminating Functions are used when the effective method of all calls is an access to a slot, either reading, writing or checking boundness1; for this path to apply, there must be no non-standard methods on SB-MOP:SLOT-VALUE-USING-CLASS and its siblings. The first state is SB-PCL::ONE-CLASS, entered when one class of instance has been accessed; the discriminating function here closes over the wrapper of the class and the slot index, and accesses the slot of the instance directly.

If a direct instance of another class is passed to the generic function for slot access, then another accessor discriminating function is created: if the index of the slot in the slots vector of each instance is the same, then a SB-PCL::TWO-CLASS function is created, closing over the two class wrappers and the index and performing the simple dispatch. If the slot indexes are not the same, then we go to the SB-PCL::N-N state.

For slot accesses for more than two classes with the same index, we move to the SB-PCL::ONE-INDEX state which maintains a cache of wrappers for which the slot index is the same. If at any point the slot index for an instance is not the same, the state moves to SB-PCL::N-N, which maintains a cache of wrappers and their associated indexes; if at any point an effective method which is not a simple slot access is encountered, then the discriminating function moves into the SB-PCL::CHECKING, SB-PCL::CACHING or SB-PCL::DISPATCH states.


Footnotes

[1] Although there is ordinarily no way for a user to define a boundp method, some automatically generated generic functions have them.