Skip to content

Commit 0304832

Browse files
sstricklCommit Queue
authored and
Commit Queue
committed
[vm] Check hash-based caches in the DRT_InstanceOf runtime entry.
We added a hash-based cache check in DRT_TypeCheck until the SubtypeNTestCache stubs handle hash-based caches to avoid doing the full runtime check when unnecessary, but did not do so for DRT_InstanceOf. This fixes that until an upcoming CL that adds support for hash-based caches in the SubtypeNTestCacheStubs lands. TEST=Manual inspection of profiles before and after change. Not adding an automated test as this change is a temporary bandaid similar to the tested path in DRT_TypeCheck that will be removed soon. Change-Id: I905a0fc6f501c68d66ae1ee848631c40cad04af2 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/310882 Reviewed-by: Martin Kustermann <[email protected]> Commit-Queue: Tess Strickland <[email protected]>
1 parent 97a09b9 commit 0304832

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

runtime/vm/runtime_entry.cc

+16
Original file line numberDiff line numberDiff line change
@@ -1068,6 +1068,22 @@ DEFINE_RUNTIME_ENTRY(Instanceof, 5) {
10681068
ASSERT(type.IsFinalized());
10691069
ASSERT(!type.IsDynamicType()); // No need to check assignment.
10701070
ASSERT(!cache.IsNull());
1071+
// Handle cases where currently the SubtypeNTestCache stubs return a false
1072+
// negative and the information is already in the cache.
1073+
//
1074+
// TODO(sstrickl): Remove this check and the associated helper function when
1075+
// the SubtypeNTestCache stubs have been updated to handle hash-based caches.
1076+
if (cache.IsHash()) {
1077+
const auto& result = Bool::Handle(
1078+
zone, ResultForExistingTypeTestCacheEntry(
1079+
zone, thread, instance, type, instantiator_type_arguments,
1080+
function_type_arguments, cache));
1081+
if (!result.IsNull()) {
1082+
// Early exit because an entry already exists in the cache.
1083+
arguments.SetReturn(result);
1084+
return;
1085+
}
1086+
}
10711087
const Bool& result = Bool::Get(instance.IsInstanceOf(
10721088
type, instantiator_type_arguments, function_type_arguments));
10731089
if (FLAG_trace_type_checks) {

0 commit comments

Comments
 (0)