A method and computer system that implements polymorphic inline caches having
locking
slots. Each time the polymorphic method is called having a new object type, a new
slot in the polymorphic inline cache is created. By comparing the object types
of new methods with object type values already in the cache, it can readily be
determined if a new slot has to be created to accommodate a new object type. Preferably,
if two threads wish to access the polymorphic inline cache at the same time, the
second thread will wait until the first thread accesses and creates and/or uses
its slot because it is likely that the second thread will call the method of the
same type. Altematively, the second thread may access and create and/or use another
slot of the polymorphic inline cache because the first slot is locked to all objects
other than its type.