mirror of
https://github.com/opelly27/Stockfish.git
synced 2026-05-20 13:17:44 +00:00
Store Eval::Info in Search::Stack
Instead of a pointer. This should fix the issue of remaining with a stale pointer when for instance calling IID, but also null search verification, singular search and razoring where we call search with the same ss pointer. In this case ss->ei is overwritten in the search() call and upon returning remains stale. This patch could have a performance hit because Eval::Info is big (176 bytes) and during splitting we copy 4 ss entries. On the good side, this patch is a clean solution. Proposed by Gary. No functional change.
This commit is contained in:
+4
-7
@@ -489,7 +489,6 @@ namespace {
|
|||||||
|
|
||||||
Move movesSearched[64];
|
Move movesSearched[64];
|
||||||
StateInfo st;
|
StateInfo st;
|
||||||
Eval::Info ei;
|
|
||||||
const TTEntry *tte;
|
const TTEntry *tte;
|
||||||
SplitPoint* splitPoint;
|
SplitPoint* splitPoint;
|
||||||
Key posKey;
|
Key posKey;
|
||||||
@@ -524,7 +523,6 @@ namespace {
|
|||||||
bestValue = -VALUE_INFINITE;
|
bestValue = -VALUE_INFINITE;
|
||||||
ss->currentMove = threatMove = (ss+1)->excludedMove = bestMove = MOVE_NONE;
|
ss->currentMove = threatMove = (ss+1)->excludedMove = bestMove = MOVE_NONE;
|
||||||
ss->ply = (ss-1)->ply + 1;
|
ss->ply = (ss-1)->ply + 1;
|
||||||
ss->ei = &ei;
|
|
||||||
(ss+1)->skipNullMove = false; (ss+1)->reduction = DEPTH_ZERO;
|
(ss+1)->skipNullMove = false; (ss+1)->reduction = DEPTH_ZERO;
|
||||||
(ss+2)->killers[0] = (ss+2)->killers[1] = MOVE_NONE;
|
(ss+2)->killers[0] = (ss+2)->killers[1] = MOVE_NONE;
|
||||||
|
|
||||||
@@ -594,7 +592,7 @@ namespace {
|
|||||||
// Never assume anything on values stored in TT
|
// Never assume anything on values stored in TT
|
||||||
if ( (ss->staticEval = eval = tte->eval_value()) == VALUE_NONE
|
if ( (ss->staticEval = eval = tte->eval_value()) == VALUE_NONE
|
||||||
||(ss->evalMargin = tte->eval_margin()) == VALUE_NONE)
|
||(ss->evalMargin = tte->eval_margin()) == VALUE_NONE)
|
||||||
eval = ss->staticEval = evaluate(pos, ss->evalMargin, &ei);
|
eval = ss->staticEval = evaluate(pos, ss->evalMargin, &ss->ei);
|
||||||
|
|
||||||
// Can ttValue be used as a better position evaluation?
|
// Can ttValue be used as a better position evaluation?
|
||||||
if (ttValue != VALUE_NONE)
|
if (ttValue != VALUE_NONE)
|
||||||
@@ -604,7 +602,7 @@ namespace {
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
eval = ss->staticEval = evaluate(pos, ss->evalMargin, &ei);
|
eval = ss->staticEval = evaluate(pos, ss->evalMargin, &ss->ei);
|
||||||
TT.store(posKey, VALUE_NONE, BOUND_NONE, DEPTH_NONE, MOVE_NONE,
|
TT.store(posKey, VALUE_NONE, BOUND_NONE, DEPTH_NONE, MOVE_NONE,
|
||||||
ss->staticEval, ss->evalMargin);
|
ss->staticEval, ss->evalMargin);
|
||||||
}
|
}
|
||||||
@@ -1121,7 +1119,6 @@ split_point_start: // At split points actual search starts from here
|
|||||||
assert(depth <= DEPTH_ZERO);
|
assert(depth <= DEPTH_ZERO);
|
||||||
|
|
||||||
StateInfo st;
|
StateInfo st;
|
||||||
Eval::Info ei;
|
|
||||||
const TTEntry* tte;
|
const TTEntry* tte;
|
||||||
Key posKey;
|
Key posKey;
|
||||||
Move ttMove, move, bestMove;
|
Move ttMove, move, bestMove;
|
||||||
@@ -1178,10 +1175,10 @@ split_point_start: // At split points actual search starts from here
|
|||||||
// Never assume anything on values stored in TT
|
// Never assume anything on values stored in TT
|
||||||
if ( (ss->staticEval = bestValue = tte->eval_value()) == VALUE_NONE
|
if ( (ss->staticEval = bestValue = tte->eval_value()) == VALUE_NONE
|
||||||
||(ss->evalMargin = tte->eval_margin()) == VALUE_NONE)
|
||(ss->evalMargin = tte->eval_margin()) == VALUE_NONE)
|
||||||
ss->staticEval = bestValue = evaluate(pos, ss->evalMargin, &ei);
|
ss->staticEval = bestValue = evaluate(pos, ss->evalMargin, &ss->ei);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
ss->staticEval = bestValue = evaluate(pos, ss->evalMargin, &ei);
|
ss->staticEval = bestValue = evaluate(pos, ss->evalMargin, &ss->ei);
|
||||||
|
|
||||||
// Stand pat. Return immediately if static value is at least beta
|
// Stand pat. Return immediately if static value is at least beta
|
||||||
if (bestValue >= beta)
|
if (bestValue >= beta)
|
||||||
|
|||||||
+1
-1
@@ -49,7 +49,7 @@ struct Stack {
|
|||||||
Value evalMargin;
|
Value evalMargin;
|
||||||
int skipNullMove;
|
int skipNullMove;
|
||||||
int futilityMoveCount;
|
int futilityMoveCount;
|
||||||
Eval::Info* ei;
|
Eval::Info ei;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user