Skip to content

Commit 1e4721d

Browse files
committed
[ConstraintSystem] Move tracking of solver depth/states into SolverState.
Instead of doing this when scopes are created and destroyed, do this when scopes are registered and rolled back on the SolverState. NFC.
1 parent f689af1 commit 1e4721d

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

lib/Sema/CSSolver.cpp

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// This source file is part of the Swift.org open source project
44
//
5-
// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
5+
// Copyright (c) 2014 - 2018 Apple Inc. and the Swift project authors
66
// Licensed under Apache License v2.0 with Runtime Library Exception
77
//
88
// See https://swift.org/LICENSE.txt for license information
@@ -472,8 +472,6 @@ ConstraintSystem::SolverState::~SolverState() {
472472
ConstraintSystem::SolverScope::SolverScope(ConstraintSystem &cs)
473473
: cs(cs), CGScope(cs.CG)
474474
{
475-
++cs.solverState->depth;
476-
477475
resolvedOverloadSets = cs.resolvedOverloadSets;
478476
numTypeVariables = cs.TypeVariables.size();
479477
numSavedBindings = cs.solverState->savedBindings.size();
@@ -488,13 +486,9 @@ ConstraintSystem::SolverScope::SolverScope(ConstraintSystem &cs)
488486

489487
cs.solverState->registerScope(this);
490488
assert(!cs.failedConstraint && "Unexpected failed constraint!");
491-
492-
++cs.solverState->NumStatesExplored;
493489
}
494490

495491
ConstraintSystem::SolverScope::~SolverScope() {
496-
--cs.solverState->depth;
497-
498492
// Erase the end of various lists.
499493
cs.resolvedOverloadSets = resolvedOverloadSets;
500494
truncate(cs.TypeVariables, numTypeVariables);

lib/Sema/ConstraintSystem.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// This source file is part of the Swift.org open source project
44
//
5-
// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
5+
// Copyright (c) 2014 - 2018 Apple Inc. and the Swift project authors
66
// Licensed under Apache License v2.0 with Runtime Library Exception
77
//
88
// See https://swift.org/LICENSE.txt for license information
@@ -1150,6 +1150,9 @@ class ConstraintSystem {
11501150
///
11511151
/// \param scope The scope to associate with current solver state.
11521152
void registerScope(SolverScope *scope) {
1153+
++depth;
1154+
++NumStatesExplored;
1155+
11531156
CS.incrementScopeCounter();
11541157
auto scopeInfo =
11551158
std::make_tuple(scope, retiredConstraints.begin(),
@@ -1212,6 +1215,8 @@ class ConstraintSystem {
12121215
///
12131216
/// \param scope The solver scope to rollback.
12141217
void rollback(SolverScope *scope) {
1218+
--depth;
1219+
12151220
SolverScope *savedScope;
12161221
// The position of last retired constraint before given scope.
12171222
ConstraintList::iterator lastRetiredPos;

0 commit comments

Comments
 (0)