2018-03-17 14:33:39 +01:00
|
|
|
# For dynamic calls (ie method calls where the method can not be determined at compile time)
|
|
|
|
# we resolve the method at runtime, and then cache it. Aaron has shown that over 99%
|
|
|
|
# of call sites are type stable, so one cache entry at the moment
|
|
|
|
#
|
2018-07-07 08:11:09 +02:00
|
|
|
# A cache entry stores the type of the object and the CallableMethod that is to be called
|
2018-03-17 14:33:39 +01:00
|
|
|
# This is used in DynamicCall, see there
|
|
|
|
#
|
|
|
|
module Parfait
|
|
|
|
class CacheEntry < Object
|
2018-07-16 18:00:04 +02:00
|
|
|
|
2019-09-09 23:18:20 +02:00
|
|
|
attr_reader :cached_type, :cached_method
|
2018-07-16 18:00:04 +02:00
|
|
|
|
2018-03-17 14:33:39 +01:00
|
|
|
def initialize(type , method)
|
2019-09-09 23:18:20 +02:00
|
|
|
super()
|
2019-09-09 19:26:54 +02:00
|
|
|
@cached_type = type
|
|
|
|
@cached_method = method
|
2018-03-17 14:33:39 +01:00
|
|
|
end
|
2018-07-16 18:00:04 +02:00
|
|
|
|
2018-04-17 19:26:15 +02:00
|
|
|
def to_s
|
2019-09-09 19:26:54 +02:00
|
|
|
"CacheEntry" + "#{@cached_method&.name}"
|
2018-04-17 19:26:15 +02:00
|
|
|
end
|
2018-03-17 14:33:39 +01:00
|
|
|
end
|
|
|
|
end
|