| Index: runtime/vm/dart_api_impl.cc | 
| diff --git a/runtime/vm/dart_api_impl.cc b/runtime/vm/dart_api_impl.cc | 
| index 4bc1125f23058b732b486cee122f850f03dd89db..33ed0638759e34ba384a91dc60a14b15aee78be3 100644 | 
| --- a/runtime/vm/dart_api_impl.cc | 
| +++ b/runtime/vm/dart_api_impl.cc | 
| @@ -1500,8 +1500,11 @@ Dart_CreateSnapshot(uint8_t** vm_snapshot_data_buffer, | 
|  | 
| #if defined(DEBUG) | 
| I->heap()->CollectAllGarbage(); | 
| -  CheckFunctionTypesVisitor check_canonical(T); | 
| -  I->heap()->IterateObjects(&check_canonical); | 
| +  { | 
| +    HeapIterationScope iteration(T); | 
| +    CheckFunctionTypesVisitor check_canonical(T); | 
| +    iteration.IterateObjects(&check_canonical); | 
| +  } | 
| #endif  // #if defined(DEBUG) | 
|  | 
| Symbols::Compact(I); | 
| @@ -1535,8 +1538,11 @@ Dart_CreateScriptSnapshot(uint8_t** script_snapshot_buffer, | 
|  | 
| #if defined(DEBUG) | 
| I->heap()->CollectAllGarbage(); | 
| -  CheckFunctionTypesVisitor check_canonical(T); | 
| -  I->heap()->IterateObjects(&check_canonical); | 
| +  { | 
| +    HeapIterationScope iteration(T); | 
| +    CheckFunctionTypesVisitor check_canonical(T); | 
| +    iteration.IterateObjects(&check_canonical); | 
| +  } | 
| #endif  // #if defined(DEBUG) | 
|  | 
| ScriptSnapshotWriter writer(script_snapshot_buffer, ApiReallocate); | 
|  |